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 | |
Henrik Kjellander | 5dda80a | 2015-11-12 12:46:09 +0100 | [diff] [blame] | 11 | #ifndef WEBRTC_MODULES_VIDEO_CAPTURE_VIDEO_CAPTURE_H_ |
| 12 | #define WEBRTC_MODULES_VIDEO_CAPTURE_VIDEO_CAPTURE_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 13 | |
nisse | af91689 | 2017-01-10 07:44:26 -0800 | [diff] [blame] | 14 | #include "webrtc/api/video/video_rotation.h" |
nisse | b29b9c8 | 2016-12-12 00:22:56 -0800 | [diff] [blame] | 15 | #include "webrtc/media/base/videosinkinterface.h" |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 16 | #include "webrtc/modules/include/module.h" |
Henrik Kjellander | 5dda80a | 2015-11-12 12:46:09 +0100 | [diff] [blame] | 17 | #include "webrtc/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 | |
nisse | b29b9c8 | 2016-12-12 00:22:56 -0800 | [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. |
pbos@webrtc.org | dfc5bb9 | 2013-04-10 08:23:13 +0000 | [diff] [blame] | 35 | virtual int32_t GetDeviceName( |
| 36 | uint32_t deviceNumber, |
leozwang@webrtc.org | 1745e93 | 2012-03-01 16:30:40 +0000 | [diff] [blame] | 37 | char* deviceNameUTF8, |
pbos@webrtc.org | dfc5bb9 | 2013-04-10 08:23:13 +0000 | [diff] [blame] | 38 | uint32_t deviceNameLength, |
leozwang@webrtc.org | 1745e93 | 2012-03-01 16:30:40 +0000 | [diff] [blame] | 39 | char* deviceUniqueIdUTF8, |
pbos@webrtc.org | dfc5bb9 | 2013-04-10 08:23:13 +0000 | [diff] [blame] | 40 | uint32_t deviceUniqueIdUTF8Length, |
leozwang@webrtc.org | 1745e93 | 2012-03-01 16:30:40 +0000 | [diff] [blame] | 41 | char* productUniqueIdUTF8 = 0, |
pbos@webrtc.org | dfc5bb9 | 2013-04-10 08:23:13 +0000 | [diff] [blame] | 42 | uint32_t productUniqueIdUTF8Length = 0) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 43 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 44 | |
perkj@webrtc.org | 0cc68dc | 2011-09-12 08:53:36 +0000 | [diff] [blame] | 45 | // Returns the number of capabilities this device. |
pbos@webrtc.org | dfc5bb9 | 2013-04-10 08:23:13 +0000 | [diff] [blame] | 46 | virtual int32_t NumberOfCapabilities( |
leozwang@webrtc.org | 1745e93 | 2012-03-01 16:30:40 +0000 | [diff] [blame] | 47 | const char* deviceUniqueIdUTF8) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 48 | |
perkj@webrtc.org | 0cc68dc | 2011-09-12 08:53:36 +0000 | [diff] [blame] | 49 | // Gets the capabilities of the named device. |
pbos@webrtc.org | dfc5bb9 | 2013-04-10 08:23:13 +0000 | [diff] [blame] | 50 | virtual int32_t GetCapability( |
leozwang@webrtc.org | 1745e93 | 2012-03-01 16:30:40 +0000 | [diff] [blame] | 51 | const char* deviceUniqueIdUTF8, |
pbos@webrtc.org | dfc5bb9 | 2013-04-10 08:23:13 +0000 | [diff] [blame] | 52 | const uint32_t deviceCapabilityNumber, |
perkj@webrtc.org | 0cc68dc | 2011-09-12 08:53:36 +0000 | [diff] [blame] | 53 | VideoCaptureCapability& capability) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 54 | |
perkj@webrtc.org | 0cc68dc | 2011-09-12 08:53:36 +0000 | [diff] [blame] | 55 | // Gets clockwise angle the captured frames should be rotated in order |
| 56 | // to be displayed correctly on a normally rotated display. |
guoweis@webrtc.org | 5a7dc39 | 2015-02-13 14:31:26 +0000 | [diff] [blame] | 57 | virtual int32_t GetOrientation(const char* deviceUniqueIdUTF8, |
| 58 | VideoRotation& orientation) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 59 | |
perkj@webrtc.org | 0cc68dc | 2011-09-12 08:53:36 +0000 | [diff] [blame] | 60 | // Gets the capability that best matches the requested width, height and |
| 61 | // frame rate. |
| 62 | // Returns the deviceCapabilityNumber on success. |
pbos@webrtc.org | dfc5bb9 | 2013-04-10 08:23:13 +0000 | [diff] [blame] | 63 | virtual int32_t GetBestMatchedCapability( |
leozwang@webrtc.org | 1745e93 | 2012-03-01 16:30:40 +0000 | [diff] [blame] | 64 | const char* deviceUniqueIdUTF8, |
mallinath@webrtc.org | 12984f0 | 2012-02-16 18:18:21 +0000 | [diff] [blame] | 65 | const VideoCaptureCapability& requested, |
perkj@webrtc.org | 0cc68dc | 2011-09-12 08:53:36 +0000 | [diff] [blame] | 66 | VideoCaptureCapability& resulting) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 67 | |
perkj@webrtc.org | 0cc68dc | 2011-09-12 08:53:36 +0000 | [diff] [blame] | 68 | // Display OS /capture device specific settings dialog |
pbos@webrtc.org | dfc5bb9 | 2013-04-10 08:23:13 +0000 | [diff] [blame] | 69 | virtual int32_t DisplayCaptureSettingsDialogBox( |
leozwang@webrtc.org | 1745e93 | 2012-03-01 16:30:40 +0000 | [diff] [blame] | 70 | const char* deviceUniqueIdUTF8, |
| 71 | const char* dialogTitleUTF8, |
perkj@webrtc.org | 0cc68dc | 2011-09-12 08:53:36 +0000 | [diff] [blame] | 72 | void* parentWindow, |
pbos@webrtc.org | dfc5bb9 | 2013-04-10 08:23:13 +0000 | [diff] [blame] | 73 | uint32_t positionX, |
| 74 | uint32_t positionY) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 75 | |
perkj@webrtc.org | 0cc68dc | 2011-09-12 08:53:36 +0000 | [diff] [blame] | 76 | virtual ~DeviceInfo() {} |
| 77 | }; |
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 | // Register capture data callback |
mallinath@webrtc.org | 7433a08 | 2014-01-29 00:56:02 +0000 | [diff] [blame] | 80 | virtual void RegisterCaptureDataCallback( |
nisse | b29b9c8 | 2016-12-12 00:22:56 -0800 | [diff] [blame] | 81 | rtc::VideoSinkInterface<VideoFrame> *dataCallback) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 82 | |
perkj@webrtc.org | 0cc68dc | 2011-09-12 08:53:36 +0000 | [diff] [blame] | 83 | // Remove capture data callback |
mallinath@webrtc.org | 7433a08 | 2014-01-29 00:56:02 +0000 | [diff] [blame] | 84 | virtual void DeRegisterCaptureDataCallback() = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 85 | |
perkj@webrtc.org | 0cc68dc | 2011-09-12 08:53:36 +0000 | [diff] [blame] | 86 | // Start capture device |
pbos@webrtc.org | dfc5bb9 | 2013-04-10 08:23:13 +0000 | [diff] [blame] | 87 | virtual int32_t StartCapture( |
perkj@webrtc.org | 0cc68dc | 2011-09-12 08:53:36 +0000 | [diff] [blame] | 88 | const VideoCaptureCapability& capability) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 89 | |
pbos@webrtc.org | dfc5bb9 | 2013-04-10 08:23:13 +0000 | [diff] [blame] | 90 | virtual int32_t StopCapture() = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 91 | |
perkj@webrtc.org | 0cc68dc | 2011-09-12 08:53:36 +0000 | [diff] [blame] | 92 | // Returns the name of the device used by this module. |
leozwang@webrtc.org | 1745e93 | 2012-03-01 16:30:40 +0000 | [diff] [blame] | 93 | virtual const char* CurrentDeviceName() const = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 94 | |
perkj@webrtc.org | 0cc68dc | 2011-09-12 08:53:36 +0000 | [diff] [blame] | 95 | // Returns true if the capture device is running |
| 96 | virtual bool CaptureStarted() = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 97 | |
perkj@webrtc.org | 0cc68dc | 2011-09-12 08:53:36 +0000 | [diff] [blame] | 98 | // Gets the current configuration. |
pbos@webrtc.org | dfc5bb9 | 2013-04-10 08:23:13 +0000 | [diff] [blame] | 99 | virtual int32_t CaptureSettings(VideoCaptureCapability& settings) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 100 | |
perkj@webrtc.org | 0cc68dc | 2011-09-12 08:53:36 +0000 | [diff] [blame] | 101 | // 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.org | 5a7dc39 | 2015-02-13 14:31:26 +0000 | [diff] [blame] | 105 | virtual int32_t SetCaptureRotation(VideoRotation rotation) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 106 | |
guoweis@webrtc.org | 1226e92 | 2015-02-11 18:37:54 +0000 | [diff] [blame] | 107 | // 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.org | 0cc68dc | 2011-09-12 08:53:36 +0000 | [diff] [blame] | 116 | protected: |
| 117 | virtual ~VideoCaptureModule() {}; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 118 | }; |
perkj@webrtc.org | 0cc68dc | 2011-09-12 08:53:36 +0000 | [diff] [blame] | 119 | |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 120 | } // namespace webrtc |
Henrik Kjellander | 5dda80a | 2015-11-12 12:46:09 +0100 | [diff] [blame] | 121 | #endif // WEBRTC_MODULES_VIDEO_CAPTURE_VIDEO_CAPTURE_H_ |