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_VIDEO_CAPTURE_H_ 12 #define MODULES_VIDEO_CAPTURE_VIDEO_CAPTURE_H_ 13 14 #include "api/video/video_rotation.h" 15 #include "api/video/video_sink_interface.h" 16 #include "modules/video_capture/video_capture_defines.h" 17 18 namespace webrtc { 19 20 class VideoCaptureModule : public rtc::RefCountInterface { 21 public: 22 // Interface for receiving information about available camera devices. 23 class DeviceInfo { 24 public: 25 virtual uint32_t NumberOfDevices() = 0; 26 27 // Returns the available capture devices. 28 // deviceNumber - Index of capture device. 29 // deviceNameUTF8 - Friendly name of the capture device. 30 // deviceUniqueIdUTF8 - Unique name of the capture device if it exist. 31 // Otherwise same as deviceNameUTF8. 32 // productUniqueIdUTF8 - Unique product id if it exist. 33 // Null terminated otherwise. 34 virtual int32_t GetDeviceName(uint32_t deviceNumber, 35 char* deviceNameUTF8, 36 uint32_t deviceNameLength, 37 char* deviceUniqueIdUTF8, 38 uint32_t deviceUniqueIdUTF8Length, 39 char* productUniqueIdUTF8 = 0, 40 uint32_t productUniqueIdUTF8Length = 0) = 0; 41 42 // Returns the number of capabilities this device. 43 virtual int32_t NumberOfCapabilities(const char* deviceUniqueIdUTF8) = 0; 44 45 // Gets the capabilities of the named device. 46 virtual int32_t GetCapability(const char* deviceUniqueIdUTF8, 47 uint32_t deviceCapabilityNumber, 48 VideoCaptureCapability& capability) = 0; 49 50 // Gets clockwise angle the captured frames should be rotated in order 51 // to be displayed correctly on a normally rotated display. 52 virtual int32_t GetOrientation(const char* deviceUniqueIdUTF8, 53 VideoRotation& orientation) = 0; 54 55 // Gets the capability that best matches the requested width, height and 56 // frame rate. 57 // Returns the deviceCapabilityNumber on success. 58 virtual int32_t GetBestMatchedCapability( 59 const char* deviceUniqueIdUTF8, 60 const VideoCaptureCapability& requested, 61 VideoCaptureCapability& resulting) = 0; 62 63 // Display OS /capture device specific settings dialog 64 virtual int32_t DisplayCaptureSettingsDialogBox( 65 const char* deviceUniqueIdUTF8, 66 const char* dialogTitleUTF8, 67 void* parentWindow, 68 uint32_t positionX, 69 uint32_t positionY) = 0; 70 ~DeviceInfo()71 virtual ~DeviceInfo() {} 72 }; 73 74 // Register capture data callback 75 virtual void RegisterCaptureDataCallback( 76 rtc::VideoSinkInterface<VideoFrame>* dataCallback) = 0; 77 78 // Remove capture data callback 79 virtual void DeRegisterCaptureDataCallback() = 0; 80 81 // Start capture device 82 virtual int32_t StartCapture(const VideoCaptureCapability& capability) = 0; 83 84 virtual int32_t StopCapture() = 0; 85 86 // Returns the name of the device used by this module. 87 virtual const char* CurrentDeviceName() const = 0; 88 89 // Returns true if the capture device is running 90 virtual bool CaptureStarted() = 0; 91 92 // Gets the current configuration. 93 virtual int32_t CaptureSettings(VideoCaptureCapability& settings) = 0; 94 95 // Set the rotation of the captured frames. 96 // If the rotation is set to the same as returned by 97 // DeviceInfo::GetOrientation the captured frames are 98 // displayed correctly if rendered. 99 virtual int32_t SetCaptureRotation(VideoRotation rotation) = 0; 100 101 // Tells the capture module whether to apply the pending rotation. By default, 102 // the rotation is applied and the generated frame is up right. When set to 103 // false, generated frames will carry the rotation information from 104 // SetCaptureRotation. Return value indicates whether this operation succeeds. 105 virtual bool SetApplyRotation(bool enable) = 0; 106 107 // Return whether the rotation is applied or left pending. 108 virtual bool GetApplyRotation() = 0; 109 110 protected: ~VideoCaptureModule()111 ~VideoCaptureModule() override {} 112 }; 113 114 } // namespace webrtc 115 #endif // MODULES_VIDEO_CAPTURE_VIDEO_CAPTURE_H_ 116