xref: /aosp_15_r20/external/webrtc/modules/video_capture/windows/device_info_ds.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
2  *  Copyright (c) 2012 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 #ifndef MODULES_VIDEO_CAPTURE_MAIN_SOURCE_WINDOWS_DEVICE_INFO_DS_H_
12 #define MODULES_VIDEO_CAPTURE_MAIN_SOURCE_WINDOWS_DEVICE_INFO_DS_H_
13 
14 #include <dshow.h>
15 
16 #include "modules/video_capture/device_info_impl.h"
17 #include "modules/video_capture/video_capture_impl.h"
18 
19 namespace webrtc {
20 namespace videocapturemodule {
21 struct VideoCaptureCapabilityWindows : public VideoCaptureCapability {
22   uint32_t directShowCapabilityIndex;
23   bool supportFrameRateControl;
VideoCaptureCapabilityWindowsVideoCaptureCapabilityWindows24   VideoCaptureCapabilityWindows() {
25     directShowCapabilityIndex = 0;
26     supportFrameRateControl = false;
27   }
28 };
29 
30 class DeviceInfoDS : public DeviceInfoImpl {
31  public:
32   // Factory function.
33   static DeviceInfoDS* Create();
34 
35   DeviceInfoDS();
36   ~DeviceInfoDS() override;
37 
38   int32_t Init() override;
39   uint32_t NumberOfDevices() override;
40 
41   /*
42    * Returns the available capture devices.
43    */
44   int32_t GetDeviceName(uint32_t deviceNumber,
45                         char* deviceNameUTF8,
46                         uint32_t deviceNameLength,
47                         char* deviceUniqueIdUTF8,
48                         uint32_t deviceUniqueIdUTF8Length,
49                         char* productUniqueIdUTF8,
50                         uint32_t productUniqueIdUTF8Length) override;
51 
52   /*
53    * Display OS /capture device specific settings dialog
54    */
55   int32_t DisplayCaptureSettingsDialogBox(const char* deviceUniqueIdUTF8,
56                                           const char* dialogTitleUTF8,
57                                           void* parentWindow,
58                                           uint32_t positionX,
59                                           uint32_t positionY) override;
60 
61   // Windows specific
62 
63   /* Gets a capture device filter
64    The user of this API is responsible for releasing the filter when it not
65    needed.
66    */
67   IBaseFilter* GetDeviceFilter(const char* deviceUniqueIdUTF8,
68                                char* productUniqueIdUTF8 = NULL,
69                                uint32_t productUniqueIdUTF8Length = 0);
70 
71   int32_t GetWindowsCapability(
72       int32_t capabilityIndex,
73       VideoCaptureCapabilityWindows& windowsCapability);
74 
75   static void GetProductId(const char* devicePath,
76                            char* productUniqueIdUTF8,
77                            uint32_t productUniqueIdUTF8Length);
78 
79  protected:
80   int32_t GetDeviceInfo(uint32_t deviceNumber,
81                         char* deviceNameUTF8,
82                         uint32_t deviceNameLength,
83                         char* deviceUniqueIdUTF8,
84                         uint32_t deviceUniqueIdUTF8Length,
85                         char* productUniqueIdUTF8,
86                         uint32_t productUniqueIdUTF8Length);
87 
88   int32_t CreateCapabilityMap(const char* deviceUniqueIdUTF8) override
89       RTC_EXCLUSIVE_LOCKS_REQUIRED(_apiLock);
90 
91  private:
92   ICreateDevEnum* _dsDevEnum;
93   IEnumMoniker* _dsMonikerDevEnum;
94   bool _CoUninitializeIsRequired;
95   std::vector<VideoCaptureCapabilityWindows> _captureCapabilitiesWindows;
96 };
97 }  // namespace videocapturemodule
98 }  // namespace webrtc
99 #endif  // MODULES_VIDEO_CAPTURE_MAIN_SOURCE_WINDOWS_DEVICE_INFO_DS_H_
100