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 | |
andrew@webrtc.org | 5f6856f | 2012-10-30 21:58:00 +0000 | [diff] [blame^] | 11 | #ifndef WEBRTC_MODULES_VIDEO_CAPTURE_INCLUDE_VIDEO_CAPTURE_H_ |
| 12 | #define WEBRTC_MODULES_VIDEO_CAPTURE_INCLUDE_VIDEO_CAPTURE_H_ |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 13 | |
andrew@webrtc.org | 5f6856f | 2012-10-30 21:58:00 +0000 | [diff] [blame^] | 14 | #include "webrtc/modules/interface/module.h" |
| 15 | #include "webrtc/modules/video_capture/include/video_capture_defines.h" |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 16 | |
| 17 | namespace webrtc { |
| 18 | |
| 19 | #if defined(WEBRTC_ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD) |
| 20 | WebRtc_Word32 SetCaptureAndroidVM(void* javaVM, void* javaContext); |
| 21 | #endif |
| 22 | |
| 23 | class VideoCaptureModule: public RefCountedModule { |
| 24 | public: |
| 25 | // Interface for receiving information about available camera devices. |
| 26 | class DeviceInfo { |
| 27 | public: |
| 28 | virtual WebRtc_UWord32 NumberOfDevices() = 0; |
| 29 | |
| 30 | // Returns the available capture devices. |
| 31 | // deviceNumber - Index of capture device. |
| 32 | // deviceNameUTF8 - Friendly name of the capture device. |
| 33 | // deviceUniqueIdUTF8 - Unique name of the capture device if it exist. |
| 34 | // Otherwise same as deviceNameUTF8. |
| 35 | // productUniqueIdUTF8 - Unique product id if it exist. |
| 36 | // Null terminated otherwise. |
| 37 | virtual WebRtc_Word32 GetDeviceName( |
| 38 | WebRtc_UWord32 deviceNumber, |
| 39 | char* deviceNameUTF8, |
| 40 | WebRtc_UWord32 deviceNameLength, |
| 41 | char* deviceUniqueIdUTF8, |
| 42 | WebRtc_UWord32 deviceUniqueIdUTF8Length, |
| 43 | char* productUniqueIdUTF8 = 0, |
| 44 | WebRtc_UWord32 productUniqueIdUTF8Length = 0) = 0; |
| 45 | |
| 46 | |
| 47 | // Returns the number of capabilities this device. |
| 48 | virtual WebRtc_Word32 NumberOfCapabilities( |
| 49 | const char* deviceUniqueIdUTF8) = 0; |
| 50 | |
| 51 | // Gets the capabilities of the named device. |
| 52 | virtual WebRtc_Word32 GetCapability( |
| 53 | const char* deviceUniqueIdUTF8, |
| 54 | const WebRtc_UWord32 deviceCapabilityNumber, |
| 55 | VideoCaptureCapability& capability) = 0; |
| 56 | |
| 57 | // Gets clockwise angle the captured frames should be rotated in order |
| 58 | // to be displayed correctly on a normally rotated display. |
| 59 | virtual WebRtc_Word32 GetOrientation( |
| 60 | const char* deviceUniqueIdUTF8, |
| 61 | VideoCaptureRotation& orientation) = 0; |
| 62 | |
| 63 | // Gets the capability that best matches the requested width, height and |
| 64 | // frame rate. |
| 65 | // Returns the deviceCapabilityNumber on success. |
| 66 | virtual WebRtc_Word32 GetBestMatchedCapability( |
| 67 | const char* deviceUniqueIdUTF8, |
| 68 | const VideoCaptureCapability& requested, |
| 69 | VideoCaptureCapability& resulting) = 0; |
| 70 | |
| 71 | // Display OS /capture device specific settings dialog |
| 72 | virtual WebRtc_Word32 DisplayCaptureSettingsDialogBox( |
| 73 | const char* deviceUniqueIdUTF8, |
| 74 | const char* dialogTitleUTF8, |
| 75 | void* parentWindow, |
| 76 | WebRtc_UWord32 positionX, |
| 77 | WebRtc_UWord32 positionY) = 0; |
| 78 | |
| 79 | virtual ~DeviceInfo() {} |
| 80 | }; |
| 81 | |
| 82 | class VideoCaptureEncodeInterface { |
| 83 | public: |
| 84 | virtual WebRtc_Word32 ConfigureEncoder(const VideoCodec& codec, |
| 85 | WebRtc_UWord32 maxPayloadSize) = 0; |
| 86 | // Inform the encoder about the new target bit rate. |
| 87 | // - newBitRate : New target bit rate in Kbit/s. |
| 88 | // - frameRate : The target frame rate. |
| 89 | virtual WebRtc_Word32 SetRates(WebRtc_Word32 newBitRate, |
| 90 | WebRtc_Word32 frameRate) = 0; |
| 91 | // Inform the encoder about the packet loss and the round-trip time. |
| 92 | // - packetLoss : Fraction lost |
| 93 | // (loss rate in percent = 100 * packetLoss / 255). |
| 94 | // - rtt : Round-trip time in milliseconds. |
| 95 | virtual WebRtc_Word32 SetChannelParameters(WebRtc_UWord32 packetLoss, |
| 96 | int rtt) = 0; |
| 97 | |
| 98 | // Encode the next frame as key frame. |
| 99 | virtual WebRtc_Word32 EncodeFrameType(const FrameType type) = 0; |
| 100 | protected: |
| 101 | virtual ~VideoCaptureEncodeInterface() { |
| 102 | } |
| 103 | }; |
| 104 | |
| 105 | // Register capture data callback |
| 106 | virtual WebRtc_Word32 RegisterCaptureDataCallback( |
| 107 | VideoCaptureDataCallback& dataCallback) = 0; |
| 108 | |
| 109 | // Remove capture data callback |
| 110 | virtual WebRtc_Word32 DeRegisterCaptureDataCallback() = 0; |
| 111 | |
| 112 | // Register capture callback. |
| 113 | virtual WebRtc_Word32 RegisterCaptureCallback( |
| 114 | VideoCaptureFeedBack& callBack) = 0; |
| 115 | |
| 116 | // Remove capture callback. |
| 117 | virtual WebRtc_Word32 DeRegisterCaptureCallback() = 0; |
| 118 | |
| 119 | // Start capture device |
| 120 | virtual WebRtc_Word32 StartCapture( |
| 121 | const VideoCaptureCapability& capability) = 0; |
| 122 | |
| 123 | virtual WebRtc_Word32 StopCapture() = 0; |
| 124 | |
| 125 | // Returns the name of the device used by this module. |
| 126 | virtual const char* CurrentDeviceName() const = 0; |
| 127 | |
| 128 | // Returns true if the capture device is running |
| 129 | virtual bool CaptureStarted() = 0; |
| 130 | |
| 131 | // Gets the current configuration. |
| 132 | virtual WebRtc_Word32 CaptureSettings(VideoCaptureCapability& settings) = 0; |
| 133 | |
| 134 | virtual WebRtc_Word32 SetCaptureDelay(WebRtc_Word32 delayMS) = 0; |
| 135 | |
| 136 | // Returns the current CaptureDelay. Only valid when the camera is running. |
| 137 | virtual WebRtc_Word32 CaptureDelay() = 0; |
| 138 | |
| 139 | // Set the rotation of the captured frames. |
| 140 | // If the rotation is set to the same as returned by |
| 141 | // DeviceInfo::GetOrientation the captured frames are |
| 142 | // displayed correctly if rendered. |
| 143 | virtual WebRtc_Word32 SetCaptureRotation(VideoCaptureRotation rotation) = 0; |
| 144 | |
| 145 | // Gets a pointer to an encode interface if the capture device supports the |
| 146 | // requested type and size. NULL otherwise. |
| 147 | virtual VideoCaptureEncodeInterface* GetEncodeInterface( |
| 148 | const VideoCodec& codec) = 0; |
| 149 | |
| 150 | virtual WebRtc_Word32 EnableFrameRateCallback(const bool enable) = 0; |
| 151 | virtual WebRtc_Word32 EnableNoPictureAlarm(const bool enable) = 0; |
| 152 | |
| 153 | protected: |
| 154 | virtual ~VideoCaptureModule() {}; |
| 155 | }; |
| 156 | |
| 157 | } // namespace webrtc |
andrew@webrtc.org | 5f6856f | 2012-10-30 21:58:00 +0000 | [diff] [blame^] | 158 | #endif // WEBRTC_MODULES_VIDEO_CAPTURE_INCLUDE_VIDEO_CAPTURE_H_ |