blob: 8d2a8f55147af28b600422596f0781cfca7cf17b [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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_VIDEO_CAPTURE_VIDEO_CAPTURE_H_
12#define MODULES_VIDEO_CAPTURE_VIDEO_CAPTURE_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020014#include "api/video/video_rotation.h"
Niels Möllerc6ce9c52018-05-11 11:15:30 +020015#include "api/video/video_sink_interface.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020016#include "modules/include/module.h"
17#include "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
Yves Gerey665174f2018-06-19 15:03:05 +020021class 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.
Yves Gerey665174f2018-06-19 15:03:05 +020035 virtual int32_t GetDeviceName(uint32_t deviceNumber,
36 char* deviceNameUTF8,
37 uint32_t deviceNameLength,
38 char* deviceUniqueIdUTF8,
39 uint32_t deviceUniqueIdUTF8Length,
40 char* productUniqueIdUTF8 = 0,
41 uint32_t productUniqueIdUTF8Length = 0) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000042
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000043 // Returns the number of capabilities this device.
Yves Gerey665174f2018-06-19 15:03:05 +020044 virtual int32_t NumberOfCapabilities(const char* deviceUniqueIdUTF8) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000045
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000046 // Gets the capabilities of the named device.
Yves Gerey665174f2018-06-19 15:03:05 +020047 virtual int32_t GetCapability(const char* deviceUniqueIdUTF8,
48 const uint32_t deviceCapabilityNumber,
49 VideoCaptureCapability& capability) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000050
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000051 // Gets clockwise angle the captured frames should be rotated in order
52 // to be displayed correctly on a normally rotated display.
guoweis@webrtc.org5a7dc392015-02-13 14:31:26 +000053 virtual int32_t GetOrientation(const char* deviceUniqueIdUTF8,
54 VideoRotation& orientation) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000055
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000056 // Gets the capability that best matches the requested width, height and
57 // frame rate.
58 // Returns the deviceCapabilityNumber on success.
pbos@webrtc.orgdfc5bb92013-04-10 08:23:13 +000059 virtual int32_t GetBestMatchedCapability(
leozwang@webrtc.org1745e932012-03-01 16:30:40 +000060 const char* deviceUniqueIdUTF8,
mallinath@webrtc.org12984f02012-02-16 18:18:21 +000061 const VideoCaptureCapability& requested,
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000062 VideoCaptureCapability& resulting) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000063
Yves Gerey665174f2018-06-19 15:03:05 +020064 // Display OS /capture device specific settings dialog
pbos@webrtc.orgdfc5bb92013-04-10 08:23:13 +000065 virtual int32_t DisplayCaptureSettingsDialogBox(
leozwang@webrtc.org1745e932012-03-01 16:30:40 +000066 const char* deviceUniqueIdUTF8,
67 const char* dialogTitleUTF8,
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000068 void* parentWindow,
pbos@webrtc.orgdfc5bb92013-04-10 08:23:13 +000069 uint32_t positionX,
70 uint32_t positionY) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000071
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000072 virtual ~DeviceInfo() {}
73 };
niklase@google.com470e71d2011-07-07 08:21:25 +000074
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000075 // Register capture data callback
mallinath@webrtc.org7433a082014-01-29 00:56:02 +000076 virtual void RegisterCaptureDataCallback(
Yves Gerey665174f2018-06-19 15:03:05 +020077 rtc::VideoSinkInterface<VideoFrame>* dataCallback) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000078
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000079 // Remove capture data callback
mallinath@webrtc.org7433a082014-01-29 00:56:02 +000080 virtual void DeRegisterCaptureDataCallback() = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000081
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000082 // Start capture device
Yves Gerey665174f2018-06-19 15:03:05 +020083 virtual int32_t StartCapture(const VideoCaptureCapability& capability) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000084
pbos@webrtc.orgdfc5bb92013-04-10 08:23:13 +000085 virtual int32_t StopCapture() = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000086
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000087 // Returns the name of the device used by this module.
leozwang@webrtc.org1745e932012-03-01 16:30:40 +000088 virtual const char* CurrentDeviceName() const = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000089
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000090 // Returns true if the capture device is running
91 virtual bool CaptureStarted() = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000092
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000093 // Gets the current configuration.
pbos@webrtc.orgdfc5bb92013-04-10 08:23:13 +000094 virtual int32_t CaptureSettings(VideoCaptureCapability& settings) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000095
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +000096 // Set the rotation of the captured frames.
97 // If the rotation is set to the same as returned by
98 // DeviceInfo::GetOrientation the captured frames are
99 // displayed correctly if rendered.
guoweis@webrtc.org5a7dc392015-02-13 14:31:26 +0000100 virtual int32_t SetCaptureRotation(VideoRotation rotation) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000101
guoweis@webrtc.org1226e922015-02-11 18:37:54 +0000102 // Tells the capture module whether to apply the pending rotation. By default,
103 // the rotation is applied and the generated frame is up right. When set to
104 // false, generated frames will carry the rotation information from
105 // SetCaptureRotation. Return value indicates whether this operation succeeds.
106 virtual bool SetApplyRotation(bool enable) = 0;
107
108 // Return whether the rotation is applied or left pending.
109 virtual bool GetApplyRotation() = 0;
110
Yves Gerey665174f2018-06-19 15:03:05 +0200111 protected:
Nico Weber22f99252019-02-20 10:13:16 -0500112 ~VideoCaptureModule() override {}
niklase@google.com470e71d2011-07-07 08:21:25 +0000113};
perkj@webrtc.org0cc68dc2011-09-12 08:53:36 +0000114
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +0000115} // namespace webrtc
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200116#endif // MODULES_VIDEO_CAPTURE_VIDEO_CAPTURE_H_