blob: 884953b5e169b0fda628f1ab4e34b6a84847cc80 [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
Henrik Kjellander5dda80a2015-11-12 12:46:09 +010011#ifndef WEBRTC_MODULES_VIDEO_CAPTURE_VIDEO_CAPTURE_H_
12#define WEBRTC_MODULES_VIDEO_CAPTURE_VIDEO_CAPTURE_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
nisseaf916892017-01-10 07:44:26 -080014#include "webrtc/api/video/video_rotation.h"
nisseb29b9c82016-12-12 00:22:56 -080015#include "webrtc/media/base/videosinkinterface.h"
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010016#include "webrtc/modules/include/module.h"
Henrik Kjellander5dda80a2015-11-12 12:46:09 +010017#include "webrtc/modules/video_capture/video_capture_defines.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000018
19namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000020
nisseb29b9c82016-12-12 00:22:56 -080021class VideoCaptureModule: public rtc::RefCountInterface {
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000022 public:
23 // Interface for receiving information about available camera devices.
24 class DeviceInfo {
25 public:
pbos@webrtc.orgdfc5bb92013-04-10 08:23:13 +000026 virtual uint32_t NumberOfDevices() = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000027
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000028 // Returns the available capture devices.
29 // deviceNumber - Index of capture device.
30 // deviceNameUTF8 - Friendly name of the capture device.
31 // deviceUniqueIdUTF8 - Unique name of the capture device if it exist.
32 // Otherwise same as deviceNameUTF8.
33 // productUniqueIdUTF8 - Unique product id if it exist.
34 // Null terminated otherwise.
pbos@webrtc.orgdfc5bb92013-04-10 08:23:13 +000035 virtual int32_t GetDeviceName(
36 uint32_t deviceNumber,
leozwang@webrtc.org1745e932012-03-01 16:30:40 +000037 char* deviceNameUTF8,
pbos@webrtc.orgdfc5bb92013-04-10 08:23:13 +000038 uint32_t deviceNameLength,
leozwang@webrtc.org1745e932012-03-01 16:30:40 +000039 char* deviceUniqueIdUTF8,
pbos@webrtc.orgdfc5bb92013-04-10 08:23:13 +000040 uint32_t deviceUniqueIdUTF8Length,
leozwang@webrtc.org1745e932012-03-01 16:30:40 +000041 char* productUniqueIdUTF8 = 0,
pbos@webrtc.orgdfc5bb92013-04-10 08:23:13 +000042 uint32_t productUniqueIdUTF8Length = 0) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000043
niklase@google.com470e71d2011-07-07 08:21:25 +000044
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000045 // Returns the number of capabilities this device.
pbos@webrtc.orgdfc5bb92013-04-10 08:23:13 +000046 virtual int32_t NumberOfCapabilities(
leozwang@webrtc.org1745e932012-03-01 16:30:40 +000047 const char* deviceUniqueIdUTF8) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000048
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000049 // Gets the capabilities of the named device.
pbos@webrtc.orgdfc5bb92013-04-10 08:23:13 +000050 virtual int32_t GetCapability(
leozwang@webrtc.org1745e932012-03-01 16:30:40 +000051 const char* deviceUniqueIdUTF8,
pbos@webrtc.orgdfc5bb92013-04-10 08:23:13 +000052 const uint32_t deviceCapabilityNumber,
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000053 VideoCaptureCapability& capability) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000054
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000055 // Gets clockwise angle the captured frames should be rotated in order
56 // to be displayed correctly on a normally rotated display.
guoweis@webrtc.org5a7dc392015-02-13 14:31:26 +000057 virtual int32_t GetOrientation(const char* deviceUniqueIdUTF8,
58 VideoRotation& orientation) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000059
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000060 // Gets the capability that best matches the requested width, height and
61 // frame rate.
62 // Returns the deviceCapabilityNumber on success.
pbos@webrtc.orgdfc5bb92013-04-10 08:23:13 +000063 virtual int32_t GetBestMatchedCapability(
leozwang@webrtc.org1745e932012-03-01 16:30:40 +000064 const char* deviceUniqueIdUTF8,
mallinath@webrtc.org12984f02012-02-16 18:18:21 +000065 const VideoCaptureCapability& requested,
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000066 VideoCaptureCapability& resulting) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000067
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000068 // Display OS /capture device specific settings dialog
pbos@webrtc.orgdfc5bb92013-04-10 08:23:13 +000069 virtual int32_t DisplayCaptureSettingsDialogBox(
leozwang@webrtc.org1745e932012-03-01 16:30:40 +000070 const char* deviceUniqueIdUTF8,
71 const char* dialogTitleUTF8,
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000072 void* parentWindow,
pbos@webrtc.orgdfc5bb92013-04-10 08:23:13 +000073 uint32_t positionX,
74 uint32_t positionY) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000075
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000076 virtual ~DeviceInfo() {}
77 };
niklase@google.com470e71d2011-07-07 08:21:25 +000078
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000079 // Register capture data callback
mallinath@webrtc.org7433a082014-01-29 00:56:02 +000080 virtual void RegisterCaptureDataCallback(
nisseb29b9c82016-12-12 00:22:56 -080081 rtc::VideoSinkInterface<VideoFrame> *dataCallback) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000082
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000083 // Remove capture data callback
mallinath@webrtc.org7433a082014-01-29 00:56:02 +000084 virtual void DeRegisterCaptureDataCallback() = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000085
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000086 // Start capture device
pbos@webrtc.orgdfc5bb92013-04-10 08:23:13 +000087 virtual int32_t StartCapture(
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000088 const VideoCaptureCapability& capability) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000089
pbos@webrtc.orgdfc5bb92013-04-10 08:23:13 +000090 virtual int32_t StopCapture() = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000091
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000092 // Returns the name of the device used by this module.
leozwang@webrtc.org1745e932012-03-01 16:30:40 +000093 virtual const char* CurrentDeviceName() const = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000094
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000095 // Returns true if the capture device is running
96 virtual bool CaptureStarted() = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000097
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000098 // Gets the current configuration.
pbos@webrtc.orgdfc5bb92013-04-10 08:23:13 +000099 virtual int32_t CaptureSettings(VideoCaptureCapability& settings) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000100
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +0000101 // Set the rotation of the captured frames.
102 // If the rotation is set to the same as returned by
103 // DeviceInfo::GetOrientation the captured frames are
104 // displayed correctly if rendered.
guoweis@webrtc.org5a7dc392015-02-13 14:31:26 +0000105 virtual int32_t SetCaptureRotation(VideoRotation rotation) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000106
guoweis@webrtc.org1226e922015-02-11 18:37:54 +0000107 // Tells the capture module whether to apply the pending rotation. By default,
108 // the rotation is applied and the generated frame is up right. When set to
109 // false, generated frames will carry the rotation information from
110 // SetCaptureRotation. Return value indicates whether this operation succeeds.
111 virtual bool SetApplyRotation(bool enable) = 0;
112
113 // Return whether the rotation is applied or left pending.
114 virtual bool GetApplyRotation() = 0;
115
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +0000116protected:
117 virtual ~VideoCaptureModule() {};
niklase@google.com470e71d2011-07-07 08:21:25 +0000118};
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +0000119
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +0000120} // namespace webrtc
Henrik Kjellander5dda80a2015-11-12 12:46:09 +0100121#endif // WEBRTC_MODULES_VIDEO_CAPTURE_VIDEO_CAPTURE_H_