xref: /aosp_15_r20/external/webrtc/modules/desktop_capture/desktop_capture_metrics_helper.cc (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
2  *  Copyright (c) 2021 The WebRTC project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #include "modules/desktop_capture/desktop_capture_metrics_helper.h"
12 
13 #include "modules/desktop_capture/desktop_capture_types.h"
14 #include "system_wrappers/include/metrics.h"
15 
16 namespace webrtc {
17 namespace {
18 // This enum is logged via UMA so entries should not be reordered or have their
19 // values changed. This should also be kept in sync with the values in the
20 // DesktopCapturerId namespace.
21 enum class SequentialDesktopCapturerId {
22   kUnknown = 0,
23   kWgcCapturerWin = 1,
24   kScreenCapturerWinMagnifier = 2,
25   kWindowCapturerWinGdi = 3,
26   kScreenCapturerWinGdi = 4,
27   kScreenCapturerWinDirectx = 5,
28   kMaxValue = kScreenCapturerWinDirectx
29 };
30 }  // namespace
31 
RecordCapturerImpl(uint32_t capturer_id)32 void RecordCapturerImpl(uint32_t capturer_id) {
33   SequentialDesktopCapturerId sequential_id;
34   switch (capturer_id) {
35     case DesktopCapturerId::kWgcCapturerWin:
36       sequential_id = SequentialDesktopCapturerId::kWgcCapturerWin;
37       break;
38     case DesktopCapturerId::kScreenCapturerWinMagnifier:
39       sequential_id = SequentialDesktopCapturerId::kScreenCapturerWinMagnifier;
40       break;
41     case DesktopCapturerId::kWindowCapturerWinGdi:
42       sequential_id = SequentialDesktopCapturerId::kWindowCapturerWinGdi;
43       break;
44     case DesktopCapturerId::kScreenCapturerWinGdi:
45       sequential_id = SequentialDesktopCapturerId::kScreenCapturerWinGdi;
46       break;
47     case DesktopCapturerId::kScreenCapturerWinDirectx:
48       sequential_id = SequentialDesktopCapturerId::kScreenCapturerWinDirectx;
49       break;
50     case DesktopCapturerId::kUnknown:
51     default:
52       sequential_id = SequentialDesktopCapturerId::kUnknown;
53   }
54   RTC_HISTOGRAM_ENUMERATION(
55       "WebRTC.DesktopCapture.Win.DesktopCapturerImpl",
56       static_cast<int>(sequential_id),
57       static_cast<int>(SequentialDesktopCapturerId::kMaxValue));
58 }
59 
60 }  // namespace webrtc
61