andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 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 | /* |
| 12 | * video_capture_quick_time_info.h |
| 13 | * |
| 14 | */ |
| 15 | |
| 16 | #ifndef WEBRTC_MODULES_VIDEO_CAPTURE_MAIN_SOURCE_MAC_QUICKTIME_VIDEO_CAPTURE_QUICK_TIME_INFO_H_ |
| 17 | #define WEBRTC_MODULES_VIDEO_CAPTURE_MAIN_SOURCE_MAC_QUICKTIME_VIDEO_CAPTURE_QUICK_TIME_INFO_H_ |
| 18 | |
| 19 | #include <QuickTime/QuickTime.h> |
| 20 | |
| 21 | #include "../../video_capture_impl.h" |
| 22 | #include "../../device_info_impl.h" |
| 23 | #include "list_wrapper.h" |
| 24 | #include "map_wrapper.h" |
| 25 | |
| 26 | class VideoRenderCallback; |
| 27 | |
| 28 | namespace webrtc |
| 29 | { |
| 30 | class CriticalSectionWrapper; |
| 31 | class EventWrapper; |
| 32 | class ThreadWrapper; |
| 33 | class Trace; |
| 34 | |
| 35 | class VideoCaptureMacQuickTimeInfo: public DeviceInfoImpl |
| 36 | { |
| 37 | public: |
| 38 | |
| 39 | static DeviceInfo* Create(const WebRtc_Word32 id); |
| 40 | static void Destroy(DeviceInfo* deviceInfo); |
| 41 | |
| 42 | VideoCaptureMacQuickTimeInfo(const WebRtc_Word32 id); |
| 43 | virtual ~VideoCaptureMacQuickTimeInfo(); |
| 44 | |
| 45 | WebRtc_Word32 Init(); |
| 46 | |
| 47 | virtual WebRtc_UWord32 NumberOfDevices(); |
| 48 | |
| 49 | /* |
| 50 | * Returns the available capture devices. |
| 51 | * deviceNumber -[in] index of capture device |
| 52 | * deviceNameUTF8 - friendly name of the capture device |
| 53 | * deviceUniqueIdUTF8 - unique name of the capture device if it exist. |
| 54 | * Otherwise same as deviceNameUTF8 |
| 55 | * productUniqueIdUTF8 - unique product id if it exist. Null terminated |
| 56 | * otherwise. |
| 57 | */ |
| 58 | virtual WebRtc_Word32 GetDeviceName( |
| 59 | WebRtc_UWord32 deviceNumber, char* deviceNameUTF8, |
| 60 | WebRtc_UWord32 deviceNameLength, char* deviceUniqueIdUTF8, |
| 61 | WebRtc_UWord32 deviceUniqueIdUTF8Length, |
| 62 | char* productUniqueIdUTF8 = 0, |
| 63 | WebRtc_UWord32 productUniqueIdUTF8Length = 0); |
| 64 | |
| 65 | |
| 66 | // ************** The remaining public functions are not supported on Mac |
| 67 | |
| 68 | /* |
| 69 | * Returns the number of capabilities for this device |
| 70 | */ |
| 71 | virtual WebRtc_Word32 NumberOfCapabilities(const char* deviceUniqueIdUTF8); |
| 72 | |
| 73 | /* |
| 74 | * Gets the capabilities of the named device |
| 75 | */ |
| 76 | virtual WebRtc_Word32 GetCapability( |
| 77 | const char* deviceUniqueIdUTF8, |
| 78 | const WebRtc_UWord32 deviceCapabilityNumber, |
| 79 | VideoCaptureCapability& capability); |
| 80 | |
| 81 | /* |
| 82 | * Gets the capability that best matches the requested width, height and frame rate. |
| 83 | * Returns the deviceCapabilityNumber on success. |
| 84 | */ |
| 85 | virtual WebRtc_Word32 GetBestMatchedCapability( |
| 86 | const char* deviceUniqueIdUTF8, |
| 87 | const VideoCaptureCapability& requested, |
| 88 | VideoCaptureCapability& resulting); |
| 89 | |
| 90 | /* |
| 91 | * Display OS /capture device specific settings dialog |
| 92 | */ |
| 93 | virtual WebRtc_Word32 DisplayCaptureSettingsDialogBox( |
| 94 | const char* deviceUniqueIdUTF8, |
| 95 | const char* dialogTitleUTF8, void* parentWindow, |
| 96 | WebRtc_UWord32 positionX, WebRtc_UWord32 positionY); |
| 97 | |
| 98 | protected: |
| 99 | virtual WebRtc_Word32 CreateCapabilityMap( |
| 100 | const char* deviceUniqueIdUTF8); |
| 101 | |
| 102 | private: |
| 103 | |
| 104 | struct VideoCaptureMacName |
| 105 | { |
| 106 | VideoCaptureMacName(); |
| 107 | |
| 108 | enum |
| 109 | { |
| 110 | kVideoCaptureMacNameMaxSize = 64 |
| 111 | }; |
| 112 | char _name[kVideoCaptureMacNameMaxSize]; |
| 113 | CFIndex _size; |
| 114 | }; |
| 115 | |
| 116 | enum |
| 117 | { |
| 118 | kVideoCaptureMacDeviceListTimeout = 5000 |
| 119 | }; // Timeout value [ms] if we want to create a new device list or not |
| 120 | enum |
| 121 | { |
| 122 | kYuy2_1280_1024_length = 2621440 |
| 123 | }; // Temporary constant allowing this size from built-in iSight webcams. |
| 124 | |
| 125 | private: |
| 126 | // private methods |
| 127 | |
| 128 | int GetCaptureDevices(WebRtc_UWord32 deviceNumber, |
| 129 | char* deviceNameUTF8, |
| 130 | WebRtc_UWord32 deviceNameUTF8Length, |
| 131 | char* deviceUniqueIdUTF8, |
| 132 | WebRtc_UWord32 deviceUniqueIdUTF8Length, |
| 133 | char* productUniqueIdUTF8, |
| 134 | WebRtc_UWord32 productUniqueIdUTF8Length, |
| 135 | int& numberOfDevices); |
| 136 | |
| 137 | static CFIndex PascalStringToCString(const unsigned char* pascalString, |
| 138 | char* cString, CFIndex bufferSize); |
| 139 | |
| 140 | private: |
| 141 | // member vars |
| 142 | WebRtc_Word32 _id; |
| 143 | bool _terminated; |
| 144 | CriticalSectionWrapper* _grabberCritsect; |
| 145 | webrtc::Trace* _trace; |
| 146 | webrtc::ThreadWrapper* _grabberUpdateThread; |
| 147 | webrtc::EventWrapper* _grabberUpdateEvent; |
| 148 | SeqGrabComponent _captureGrabber; |
| 149 | Component _captureDevice; |
| 150 | char _captureDeviceDisplayName[64]; |
| 151 | bool _captureIsInitialized; |
| 152 | GWorldPtr _gWorld; |
| 153 | SGChannel _captureChannel; |
| 154 | ImageSequence _captureSequence; |
| 155 | bool _sgPrepared; |
| 156 | bool _sgStarted; |
| 157 | int _codecWidth; |
| 158 | int _codecHeight; |
| 159 | int _trueCaptureWidth; |
| 160 | int _trueCaptureHeight; |
| 161 | ListWrapper _captureDeviceList; |
| 162 | WebRtc_Word64 _captureDeviceListTime; |
| 163 | ListWrapper _captureCapabilityList; |
| 164 | }; |
| 165 | } // namespace webrtc |
| 166 | #endif // WEBRTC_MODULES_VIDEO_CAPTURE_MAIN_SOURCE_MAC_QUICKTIME_VIDEO_CAPTURE_QUICK_TIME_INFO_H_ |