2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
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.
11 #ifndef WEBRTC_MODULES_VIDEO_CAPTURE_INCLUDE_VIDEO_CAPTURE_H_
12 #define WEBRTC_MODULES_VIDEO_CAPTURE_INCLUDE_VIDEO_CAPTURE_H_
14 #include "webrtc/modules/interface/module.h"
15 #include "webrtc/modules/video_capture/include/video_capture_defines.h"
23 #if defined(ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD)
24 int32_t SetCaptureAndroidVM(JavaVM* javaVM);
27 class VideoCaptureModule: public RefCountedModule {
29 // Interface for receiving information about available camera devices.
32 virtual uint32_t NumberOfDevices() = 0;
34 // Returns the available capture devices.
35 // deviceNumber - Index of capture device.
36 // deviceNameUTF8 - Friendly name of the capture device.
37 // deviceUniqueIdUTF8 - Unique name of the capture device if it exist.
38 // Otherwise same as deviceNameUTF8.
39 // productUniqueIdUTF8 - Unique product id if it exist.
40 // Null terminated otherwise.
41 virtual int32_t GetDeviceName(
42 uint32_t deviceNumber,
44 uint32_t deviceNameLength,
45 char* deviceUniqueIdUTF8,
46 uint32_t deviceUniqueIdUTF8Length,
47 char* productUniqueIdUTF8 = 0,
48 uint32_t productUniqueIdUTF8Length = 0) = 0;
51 // Returns the number of capabilities this device.
52 virtual int32_t NumberOfCapabilities(
53 const char* deviceUniqueIdUTF8) = 0;
55 // Gets the capabilities of the named device.
56 virtual int32_t GetCapability(
57 const char* deviceUniqueIdUTF8,
58 const uint32_t deviceCapabilityNumber,
59 VideoCaptureCapability& capability) = 0;
61 // Gets clockwise angle the captured frames should be rotated in order
62 // to be displayed correctly on a normally rotated display.
63 virtual int32_t GetOrientation(
64 const char* deviceUniqueIdUTF8,
65 VideoCaptureRotation& orientation) = 0;
67 // Gets the capability that best matches the requested width, height and
69 // Returns the deviceCapabilityNumber on success.
70 virtual int32_t GetBestMatchedCapability(
71 const char* deviceUniqueIdUTF8,
72 const VideoCaptureCapability& requested,
73 VideoCaptureCapability& resulting) = 0;
75 // Display OS /capture device specific settings dialog
76 virtual int32_t DisplayCaptureSettingsDialogBox(
77 const char* deviceUniqueIdUTF8,
78 const char* dialogTitleUTF8,
81 uint32_t positionY) = 0;
83 virtual ~DeviceInfo() {}
86 class VideoCaptureEncodeInterface {
88 virtual int32_t ConfigureEncoder(const VideoCodec& codec,
89 uint32_t maxPayloadSize) = 0;
90 // Inform the encoder about the new target bit rate.
91 // - newBitRate : New target bit rate in Kbit/s.
92 // - frameRate : The target frame rate.
93 virtual int32_t SetRates(int32_t newBitRate, int32_t frameRate) = 0;
94 // Inform the encoder about the packet loss and the round-trip time.
95 // - packetLoss : Fraction lost
96 // (loss rate in percent = 100 * packetLoss / 255).
97 // - rtt : Round-trip time in milliseconds.
98 virtual int32_t SetChannelParameters(uint32_t packetLoss, int rtt) = 0;
100 // Encode the next frame as key frame.
101 virtual int32_t EncodeFrameType(const FrameType type) = 0;
103 virtual ~VideoCaptureEncodeInterface() {
107 // Register capture data callback
108 virtual void RegisterCaptureDataCallback(
109 VideoCaptureDataCallback& dataCallback) = 0;
111 // Remove capture data callback
112 virtual void DeRegisterCaptureDataCallback() = 0;
114 // Register capture callback.
115 virtual void RegisterCaptureCallback(VideoCaptureFeedBack& callBack) = 0;
117 // Remove capture callback.
118 virtual void DeRegisterCaptureCallback() = 0;
120 // Start capture device
121 virtual int32_t StartCapture(
122 const VideoCaptureCapability& capability) = 0;
124 virtual int32_t StopCapture() = 0;
126 // Returns the name of the device used by this module.
127 virtual const char* CurrentDeviceName() const = 0;
129 // Returns true if the capture device is running
130 virtual bool CaptureStarted() = 0;
132 // Gets the current configuration.
133 virtual int32_t CaptureSettings(VideoCaptureCapability& settings) = 0;
135 virtual void SetCaptureDelay(int32_t delayMS) = 0;
137 // Returns the current CaptureDelay. Only valid when the camera is running.
138 virtual int32_t CaptureDelay() = 0;
140 // Set the rotation of the captured frames.
141 // If the rotation is set to the same as returned by
142 // DeviceInfo::GetOrientation the captured frames are
143 // displayed correctly if rendered.
144 virtual int32_t SetCaptureRotation(VideoCaptureRotation rotation) = 0;
146 // Gets a pointer to an encode interface if the capture device supports the
147 // requested type and size. NULL otherwise.
148 virtual VideoCaptureEncodeInterface* GetEncodeInterface(
149 const VideoCodec& codec) = 0;
151 virtual void EnableFrameRateCallback(const bool enable) = 0;
152 virtual void EnableNoPictureAlarm(const bool enable) = 0;
155 virtual ~VideoCaptureModule() {};
158 } // namespace webrtc
159 #endif // WEBRTC_MODULES_VIDEO_CAPTURE_INCLUDE_VIDEO_CAPTURE_H_