niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
mallinath@webrtc.org | 12984f0 | 2012-02-16 18:18:21 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef MODULES_VIDEO_CAPTURE_VIDEO_CAPTURE_H_ |
| 12 | #define MODULES_VIDEO_CAPTURE_VIDEO_CAPTURE_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 13 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 14 | #include "api/video/video_rotation.h" |
Niels Möller | c6ce9c5 | 2018-05-11 11:15:30 +0200 | [diff] [blame] | 15 | #include "api/video/video_sink_interface.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 16 | #include "modules/include/module.h" |
| 17 | #include "modules/video_capture/video_capture_defines.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 18 | |
| 19 | namespace webrtc { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 20 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 21 | class VideoCaptureModule : public rtc::RefCountInterface { |
perkj@webrtc.org | 0cc68dc | 2011-09-12 08:53:36 +0000 | [diff] [blame] | 22 | public: |
| 23 | // Interface for receiving information about available camera devices. |
| 24 | class DeviceInfo { |
| 25 | public: |
pbos@webrtc.org | dfc5bb9 | 2013-04-10 08:23:13 +0000 | [diff] [blame] | 26 | virtual uint32_t NumberOfDevices() = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 27 | |
perkj@webrtc.org | 0cc68dc | 2011-09-12 08:53:36 +0000 | [diff] [blame] | 28 | // 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 Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 35 | 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.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 42 | |
perkj@webrtc.org | 0cc68dc | 2011-09-12 08:53:36 +0000 | [diff] [blame] | 43 | // Returns the number of capabilities this device. |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 44 | virtual int32_t NumberOfCapabilities(const char* deviceUniqueIdUTF8) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 45 | |
perkj@webrtc.org | 0cc68dc | 2011-09-12 08:53:36 +0000 | [diff] [blame] | 46 | // Gets the capabilities of the named device. |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 47 | virtual int32_t GetCapability(const char* deviceUniqueIdUTF8, |
| 48 | const uint32_t deviceCapabilityNumber, |
| 49 | VideoCaptureCapability& capability) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 50 | |
perkj@webrtc.org | 0cc68dc | 2011-09-12 08:53:36 +0000 | [diff] [blame] | 51 | // Gets clockwise angle the captured frames should be rotated in order |
| 52 | // to be displayed correctly on a normally rotated display. |
guoweis@webrtc.org | 5a7dc39 | 2015-02-13 14:31:26 +0000 | [diff] [blame] | 53 | virtual int32_t GetOrientation(const char* deviceUniqueIdUTF8, |
| 54 | VideoRotation& orientation) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 55 | |
perkj@webrtc.org | 0cc68dc | 2011-09-12 08:53:36 +0000 | [diff] [blame] | 56 | // Gets the capability that best matches the requested width, height and |
| 57 | // frame rate. |
| 58 | // Returns the deviceCapabilityNumber on success. |
pbos@webrtc.org | dfc5bb9 | 2013-04-10 08:23:13 +0000 | [diff] [blame] | 59 | virtual int32_t GetBestMatchedCapability( |
leozwang@webrtc.org | 1745e93 | 2012-03-01 16:30:40 +0000 | [diff] [blame] | 60 | const char* deviceUniqueIdUTF8, |
mallinath@webrtc.org | 12984f0 | 2012-02-16 18:18:21 +0000 | [diff] [blame] | 61 | const VideoCaptureCapability& requested, |
perkj@webrtc.org | 0cc68dc | 2011-09-12 08:53:36 +0000 | [diff] [blame] | 62 | VideoCaptureCapability& resulting) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 63 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 64 | // Display OS /capture device specific settings dialog |
pbos@webrtc.org | dfc5bb9 | 2013-04-10 08:23:13 +0000 | [diff] [blame] | 65 | virtual int32_t DisplayCaptureSettingsDialogBox( |
leozwang@webrtc.org | 1745e93 | 2012-03-01 16:30:40 +0000 | [diff] [blame] | 66 | const char* deviceUniqueIdUTF8, |
| 67 | const char* dialogTitleUTF8, |
perkj@webrtc.org | 0cc68dc | 2011-09-12 08:53:36 +0000 | [diff] [blame] | 68 | void* parentWindow, |
pbos@webrtc.org | dfc5bb9 | 2013-04-10 08:23:13 +0000 | [diff] [blame] | 69 | uint32_t positionX, |
| 70 | uint32_t positionY) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 71 | |
perkj@webrtc.org | 0cc68dc | 2011-09-12 08:53:36 +0000 | [diff] [blame] | 72 | virtual ~DeviceInfo() {} |
| 73 | }; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 74 | |
perkj@webrtc.org | 0cc68dc | 2011-09-12 08:53:36 +0000 | [diff] [blame] | 75 | // Register capture data callback |
mallinath@webrtc.org | 7433a08 | 2014-01-29 00:56:02 +0000 | [diff] [blame] | 76 | virtual void RegisterCaptureDataCallback( |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 77 | rtc::VideoSinkInterface<VideoFrame>* dataCallback) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 78 | |
perkj@webrtc.org | 0cc68dc | 2011-09-12 08:53:36 +0000 | [diff] [blame] | 79 | // Remove capture data callback |
mallinath@webrtc.org | 7433a08 | 2014-01-29 00:56:02 +0000 | [diff] [blame] | 80 | virtual void DeRegisterCaptureDataCallback() = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 81 | |
perkj@webrtc.org | 0cc68dc | 2011-09-12 08:53:36 +0000 | [diff] [blame] | 82 | // Start capture device |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 83 | virtual int32_t StartCapture(const VideoCaptureCapability& capability) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 84 | |
pbos@webrtc.org | dfc5bb9 | 2013-04-10 08:23:13 +0000 | [diff] [blame] | 85 | virtual int32_t StopCapture() = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 86 | |
perkj@webrtc.org | 0cc68dc | 2011-09-12 08:53:36 +0000 | [diff] [blame] | 87 | // Returns the name of the device used by this module. |
leozwang@webrtc.org | 1745e93 | 2012-03-01 16:30:40 +0000 | [diff] [blame] | 88 | virtual const char* CurrentDeviceName() const = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 89 | |
perkj@webrtc.org | 0cc68dc | 2011-09-12 08:53:36 +0000 | [diff] [blame] | 90 | // Returns true if the capture device is running |
| 91 | virtual bool CaptureStarted() = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 92 | |
perkj@webrtc.org | 0cc68dc | 2011-09-12 08:53:36 +0000 | [diff] [blame] | 93 | // Gets the current configuration. |
pbos@webrtc.org | dfc5bb9 | 2013-04-10 08:23:13 +0000 | [diff] [blame] | 94 | virtual int32_t CaptureSettings(VideoCaptureCapability& settings) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 95 | |
perkj@webrtc.org | 0cc68dc | 2011-09-12 08:53:36 +0000 | [diff] [blame] | 96 | // 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.org | 5a7dc39 | 2015-02-13 14:31:26 +0000 | [diff] [blame] | 100 | virtual int32_t SetCaptureRotation(VideoRotation rotation) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 101 | |
guoweis@webrtc.org | 1226e92 | 2015-02-11 18:37:54 +0000 | [diff] [blame] | 102 | // 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 Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 111 | protected: |
Nico Weber | 22f9925 | 2019-02-20 10:13:16 -0500 | [diff] [blame^] | 112 | ~VideoCaptureModule() override {} |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 113 | }; |
perkj@webrtc.org | 0cc68dc | 2011-09-12 08:53:36 +0000 | [diff] [blame] | 114 | |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 115 | } // namespace webrtc |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 116 | #endif // MODULES_VIDEO_CAPTURE_VIDEO_CAPTURE_H_ |