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