Add UMA stats for camera capture pixel format on windows

Bug: none
Change-Id: I8f492243b154b842c77c8303f52cb1900214e85e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3041419
Commit-Queue: Ilya Nikolaevskiy <ilnik@chromium.org>
Reviewed-by: Dale Curtis <dalecurtis@chromium.org>
Reviewed-by: Evan Liu <evliu@google.com>
Cr-Commit-Position: refs/heads/master@{#904246}
diff --git a/media/capture/video/win/video_capture_device_mf_win.cc b/media/capture/video/win/video_capture_device_mf_win.cc
index 26cf18b..6449299 100644
--- a/media/capture/video/win/video_capture_device_mf_win.cc
+++ b/media/capture/video/win/video_capture_device_mf_win.cc
@@ -1123,6 +1123,19 @@
       std::make_unique<CapabilityWin>(best_match_video_capability);
 
   is_started_ = true;
+
+  base::UmaHistogramEnumeration(
+      "Media.VideoCapture.Win.Device.InternalPixelFormat",
+      best_match_video_capability.source_pixel_format,
+      media::VideoPixelFormat::PIXEL_FORMAT_MAX);
+  base::UmaHistogramEnumeration(
+      "Media.VideoCapture.Win.Device.CapturePixelFormat",
+      best_match_video_capability.supported_format.pixel_format,
+      media::VideoPixelFormat::PIXEL_FORMAT_MAX);
+  base::UmaHistogramEnumeration(
+      "Media.VideoCapture.Win.Device.RequestedPixelFormat",
+      params.requested_format.pixel_format,
+      media::VideoPixelFormat::PIXEL_FORMAT_MAX);
 }
 
 void VideoCaptureDeviceMFWin::StopAndDeAllocate() {
diff --git a/media/capture/video/win/video_capture_device_win.cc b/media/capture/video/win/video_capture_device_win.cc
index b6269ef..f15d263f 100644
--- a/media/capture/video/win/video_capture_device_win.cc
+++ b/media/capture/video/win/video_capture_device_win.cc
@@ -13,6 +13,7 @@
 #include <utility>
 
 #include "base/feature_list.h"
+#include "base/metrics/histogram_functions.h"
 #include "base/strings/sys_string_conversions.h"
 #include "base/win/scoped_co_mem.h"
 #include "base/win/scoped_variant.h"
@@ -522,6 +523,17 @@
     return;
   }
 
+  base::UmaHistogramEnumeration(
+      "Media.VideoCapture.Win.Device.InternalPixelFormat",
+      capture_format_.pixel_format, media::VideoPixelFormat::PIXEL_FORMAT_MAX);
+  base::UmaHistogramEnumeration(
+      "Media.VideoCapture.Win.Device.CapturePixelFormat",
+      capture_format_.pixel_format, media::VideoPixelFormat::PIXEL_FORMAT_MAX);
+  base::UmaHistogramEnumeration(
+      "Media.VideoCapture.Win.Device.RequestedPixelFormat",
+      params.requested_format.pixel_format,
+      media::VideoPixelFormat::PIXEL_FORMAT_MAX);
+
   client_->OnStarted();
   state_ = kCapturing;
 }
diff --git a/tools/metrics/histograms/histograms_xml/media/histograms.xml b/tools/metrics/histograms/histograms_xml/media/histograms.xml
index a576f40..b2ecc1e8 100644
--- a/tools/metrics/histograms/histograms_xml/media/histograms.xml
+++ b/tools/metrics/histograms/histograms_xml/media/histograms.xml
@@ -4448,6 +4448,36 @@
   </summary>
 </histogram>
 
+<histogram name="Media.VideoCapture.Win.Device.CapturePixelFormat"
+    enum="VideoPixelFormatUnion" expires_after="2022-02-28">
+  <owner>ilnik@google.com</owner>
+  <owner>video-cmi-mpp@google.com</owner>
+  <summary>
+    Counts the pixel formats produced by the VideoCaptureDevice on Windows. This
+    is recorded when the camera is opened.
+  </summary>
+</histogram>
+
+<histogram name="Media.VideoCapture.Win.Device.InternalPixelFormat"
+    enum="VideoPixelFormatUnion" expires_after="2022-02-28">
+  <owner>ilnik@google.com</owner>
+  <owner>video-cmi-mpp@google.com</owner>
+  <summary>
+    Counts the pixel formats used internaly by Windows VideoCaptureEngine. This
+    is recorded when the camera is opened.
+  </summary>
+</histogram>
+
+<histogram name="Media.VideoCapture.Win.Device.RequestedPixelFormat"
+    enum="VideoPixelFormatUnion" expires_after="2022-02-28">
+  <owner>ilnik@google.com</owner>
+  <owner>video-cmi-mpp@google.com</owner>
+  <summary>
+    Counts the pixel formats requested by the consumer on Windows. This is
+    recorded when the camera is opened.
+  </summary>
+</histogram>
+
 <histogram name="Media.VideoCapture.Win.ErrorEvent" enum="Hresult"
     expires_after="2022-06-17">
   <owner>toprice@chromium.org</owner>