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