• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
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 
11 #ifndef MODULES_VIDEO_CAPTURE_VIDEO_CAPTURE_H_
12 #define MODULES_VIDEO_CAPTURE_VIDEO_CAPTURE_H_
13 
14 #include "api/video/video_rotation.h"
15 #include "api/video/video_sink_interface.h"
16 #include "modules/include/module.h"
17 #include "modules/video_capture/video_capture_defines.h"
18 
19 namespace webrtc {
20 
21 class VideoCaptureModule : public rtc::RefCountInterface {
22  public:
23   // Interface for receiving information about available camera devices.
24   class DeviceInfo {
25    public:
26     virtual uint32_t NumberOfDevices() = 0;
27 
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.
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;
42 
43     // Returns the number of capabilities this device.
44     virtual int32_t NumberOfCapabilities(const char* deviceUniqueIdUTF8) = 0;
45 
46     // Gets the capabilities of the named device.
47     virtual int32_t GetCapability(const char* deviceUniqueIdUTF8,
48                                   const uint32_t deviceCapabilityNumber,
49                                   VideoCaptureCapability& capability) = 0;
50 
51     // Gets clockwise angle the captured frames should be rotated in order
52     // to be displayed correctly on a normally rotated display.
53     virtual int32_t GetOrientation(const char* deviceUniqueIdUTF8,
54                                    VideoRotation& orientation) = 0;
55 
56     // Gets the capability that best matches the requested width, height and
57     // frame rate.
58     // Returns the deviceCapabilityNumber on success.
59     virtual int32_t GetBestMatchedCapability(
60         const char* deviceUniqueIdUTF8,
61         const VideoCaptureCapability& requested,
62         VideoCaptureCapability& resulting) = 0;
63 
64     // Display OS /capture device specific settings dialog
65     virtual int32_t DisplayCaptureSettingsDialogBox(
66         const char* deviceUniqueIdUTF8,
67         const char* dialogTitleUTF8,
68         void* parentWindow,
69         uint32_t positionX,
70         uint32_t positionY) = 0;
71 
~DeviceInfo()72     virtual ~DeviceInfo() {}
73   };
74 
75   //   Register capture data callback
76   virtual void RegisterCaptureDataCallback(
77       rtc::VideoSinkInterface<VideoFrame>* dataCallback) = 0;
78 
79   //  Remove capture data callback
80   virtual void DeRegisterCaptureDataCallback() = 0;
81 
82   // Start capture device
83   virtual int32_t StartCapture(const VideoCaptureCapability& capability) = 0;
84 
85   virtual int32_t StopCapture() = 0;
86 
87   // Returns the name of the device used by this module.
88   virtual const char* CurrentDeviceName() const = 0;
89 
90   // Returns true if the capture device is running
91   virtual bool CaptureStarted() = 0;
92 
93   // Gets the current configuration.
94   virtual int32_t CaptureSettings(VideoCaptureCapability& settings) = 0;
95 
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.
100   virtual int32_t SetCaptureRotation(VideoRotation rotation) = 0;
101 
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 
111  protected:
~VideoCaptureModule()112   ~VideoCaptureModule() override {}
113 };
114 
115 }  // namespace webrtc
116 #endif  // MODULES_VIDEO_CAPTURE_VIDEO_CAPTURE_H_
117