blob: 736a539fc1fe6eac5dc63cea1793cba73804332c [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
mallinath@webrtc.org12984f02012-02-16 18:18:21 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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.org94caca72012-10-30 21:58:00 +000011#ifndef WEBRTC_MODULES_VIDEO_CAPTURE_INCLUDE_VIDEO_CAPTURE_H_
12#define WEBRTC_MODULES_VIDEO_CAPTURE_INCLUDE_VIDEO_CAPTURE_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
andrew@webrtc.org94caca72012-10-30 21:58:00 +000014#include "webrtc/modules/interface/module.h"
15#include "webrtc/modules/video_capture/include/video_capture_defines.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000016
17namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000018
leozwang@webrtc.org77609632012-07-13 22:00:43 +000019#if defined(WEBRTC_ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD)
20WebRtc_Word32 SetCaptureAndroidVM(void* javaVM, void* javaContext);
21#endif
22
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000023class 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;
niklase@google.com470e71d2011-07-07 08:21:25 +000029
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000030 // 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,
leozwang@webrtc.org1745e932012-03-01 16:30:40 +000039 char* deviceNameUTF8,
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000040 WebRtc_UWord32 deviceNameLength,
leozwang@webrtc.org1745e932012-03-01 16:30:40 +000041 char* deviceUniqueIdUTF8,
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000042 WebRtc_UWord32 deviceUniqueIdUTF8Length,
leozwang@webrtc.org1745e932012-03-01 16:30:40 +000043 char* productUniqueIdUTF8 = 0,
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000044 WebRtc_UWord32 productUniqueIdUTF8Length = 0) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000045
niklase@google.com470e71d2011-07-07 08:21:25 +000046
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000047 // Returns the number of capabilities this device.
48 virtual WebRtc_Word32 NumberOfCapabilities(
leozwang@webrtc.org1745e932012-03-01 16:30:40 +000049 const char* deviceUniqueIdUTF8) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000050
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000051 // Gets the capabilities of the named device.
52 virtual WebRtc_Word32 GetCapability(
leozwang@webrtc.org1745e932012-03-01 16:30:40 +000053 const char* deviceUniqueIdUTF8,
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000054 const WebRtc_UWord32 deviceCapabilityNumber,
55 VideoCaptureCapability& capability) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000056
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000057 // 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(
leozwang@webrtc.org1745e932012-03-01 16:30:40 +000060 const char* deviceUniqueIdUTF8,
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000061 VideoCaptureRotation& orientation) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000062
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000063 // 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(
leozwang@webrtc.org1745e932012-03-01 16:30:40 +000067 const char* deviceUniqueIdUTF8,
mallinath@webrtc.org12984f02012-02-16 18:18:21 +000068 const VideoCaptureCapability& requested,
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000069 VideoCaptureCapability& resulting) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000070
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000071 // Display OS /capture device specific settings dialog
72 virtual WebRtc_Word32 DisplayCaptureSettingsDialogBox(
leozwang@webrtc.org1745e932012-03-01 16:30:40 +000073 const char* deviceUniqueIdUTF8,
74 const char* dialogTitleUTF8,
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000075 void* parentWindow,
76 WebRtc_UWord32 positionX,
77 WebRtc_UWord32 positionY) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000078
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000079 virtual ~DeviceInfo() {}
80 };
niklase@google.com470e71d2011-07-07 08:21:25 +000081
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000082 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;
stefan@webrtc.orga4a88f92011-12-02 08:34:05 +000091 // Inform the encoder about the packet loss and the round-trip time.
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000092 // - packetLoss : Fraction lost
93 // (loss rate in percent = 100 * packetLoss / 255).
stefan@webrtc.orga4a88f92011-12-02 08:34:05 +000094 // - rtt : Round-trip time in milliseconds.
95 virtual WebRtc_Word32 SetChannelParameters(WebRtc_UWord32 packetLoss,
96 int rtt) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000097
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000098 // Encode the next frame as key frame.
99 virtual WebRtc_Word32 EncodeFrameType(const FrameType type) = 0;
100 protected:
101 virtual ~VideoCaptureEncodeInterface() {
102 }
103 };
niklase@google.com470e71d2011-07-07 08:21:25 +0000104
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +0000105 // Register capture data callback
106 virtual WebRtc_Word32 RegisterCaptureDataCallback(
107 VideoCaptureDataCallback& dataCallback) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000108
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +0000109 // Remove capture data callback
110 virtual WebRtc_Word32 DeRegisterCaptureDataCallback() = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000111
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +0000112 // Register capture callback.
113 virtual WebRtc_Word32 RegisterCaptureCallback(
114 VideoCaptureFeedBack& callBack) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000115
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +0000116 // Remove capture callback.
117 virtual WebRtc_Word32 DeRegisterCaptureCallback() = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000118
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +0000119 // Start capture device
120 virtual WebRtc_Word32 StartCapture(
121 const VideoCaptureCapability& capability) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000122
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +0000123 virtual WebRtc_Word32 StopCapture() = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000124
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +0000125 // Returns the name of the device used by this module.
leozwang@webrtc.org1745e932012-03-01 16:30:40 +0000126 virtual const char* CurrentDeviceName() const = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000127
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +0000128 // Returns true if the capture device is running
129 virtual bool CaptureStarted() = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000130
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +0000131 // Gets the current configuration.
132 virtual WebRtc_Word32 CaptureSettings(VideoCaptureCapability& settings) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000133
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +0000134 virtual WebRtc_Word32 SetCaptureDelay(WebRtc_Word32 delayMS) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000135
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +0000136 // Returns the current CaptureDelay. Only valid when the camera is running.
137 virtual WebRtc_Word32 CaptureDelay() = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000138
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +0000139 // 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;
niklase@google.com470e71d2011-07-07 08:21:25 +0000144
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +0000145 // 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;
niklase@google.com470e71d2011-07-07 08:21:25 +0000149
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +0000150 virtual WebRtc_Word32 EnableFrameRateCallback(const bool enable) = 0;
151 virtual WebRtc_Word32 EnableNoPictureAlarm(const bool enable) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000152
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +0000153protected:
154 virtual ~VideoCaptureModule() {};
niklase@google.com470e71d2011-07-07 08:21:25 +0000155};
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +0000156
157} // namespace webrtc
andrew@webrtc.org94caca72012-10-30 21:58:00 +0000158#endif // WEBRTC_MODULES_VIDEO_CAPTURE_INCLUDE_VIDEO_CAPTURE_H_