video_capture.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. #ifndef MODULES_VIDEO_CAPTURE_VIDEO_CAPTURE_H_
  11. #define MODULES_VIDEO_CAPTURE_VIDEO_CAPTURE_H_
  12. #include "api/video/video_rotation.h"
  13. #include "api/video/video_sink_interface.h"
  14. #include "modules/include/module.h"
  15. #include "modules/video_capture/video_capture_defines.h"
  16. namespace webrtc {
  17. class VideoCaptureModule : public rtc::RefCountInterface {
  18. public:
  19. // Interface for receiving information about available camera devices.
  20. class DeviceInfo {
  21. public:
  22. virtual uint32_t NumberOfDevices() = 0;
  23. // Returns the available capture devices.
  24. // deviceNumber - Index of capture device.
  25. // deviceNameUTF8 - Friendly name of the capture device.
  26. // deviceUniqueIdUTF8 - Unique name of the capture device if it exist.
  27. // Otherwise same as deviceNameUTF8.
  28. // productUniqueIdUTF8 - Unique product id if it exist.
  29. // Null terminated otherwise.
  30. virtual int32_t GetDeviceName(uint32_t deviceNumber,
  31. char* deviceNameUTF8,
  32. uint32_t deviceNameLength,
  33. char* deviceUniqueIdUTF8,
  34. uint32_t deviceUniqueIdUTF8Length,
  35. char* productUniqueIdUTF8 = 0,
  36. uint32_t productUniqueIdUTF8Length = 0) = 0;
  37. // Returns the number of capabilities this device.
  38. virtual int32_t NumberOfCapabilities(const char* deviceUniqueIdUTF8) = 0;
  39. // Gets the capabilities of the named device.
  40. virtual int32_t GetCapability(const char* deviceUniqueIdUTF8,
  41. const uint32_t deviceCapabilityNumber,
  42. VideoCaptureCapability& capability) = 0;
  43. // Gets clockwise angle the captured frames should be rotated in order
  44. // to be displayed correctly on a normally rotated display.
  45. virtual int32_t GetOrientation(const char* deviceUniqueIdUTF8,
  46. VideoRotation& orientation) = 0;
  47. // Gets the capability that best matches the requested width, height and
  48. // frame rate.
  49. // Returns the deviceCapabilityNumber on success.
  50. virtual int32_t GetBestMatchedCapability(
  51. const char* deviceUniqueIdUTF8,
  52. const VideoCaptureCapability& requested,
  53. VideoCaptureCapability& resulting) = 0;
  54. // Display OS /capture device specific settings dialog
  55. virtual int32_t DisplayCaptureSettingsDialogBox(
  56. const char* deviceUniqueIdUTF8,
  57. const char* dialogTitleUTF8,
  58. void* parentWindow,
  59. uint32_t positionX,
  60. uint32_t positionY) = 0;
  61. virtual ~DeviceInfo() {}
  62. };
  63. // Register capture data callback
  64. virtual void RegisterCaptureDataCallback(
  65. rtc::VideoSinkInterface<VideoFrame>* dataCallback) = 0;
  66. // Remove capture data callback
  67. virtual void DeRegisterCaptureDataCallback() = 0;
  68. // Start capture device
  69. virtual int32_t StartCapture(const VideoCaptureCapability& capability) = 0;
  70. virtual int32_t StopCapture() = 0;
  71. // Returns the name of the device used by this module.
  72. virtual const char* CurrentDeviceName() const = 0;
  73. // Returns true if the capture device is running
  74. virtual bool CaptureStarted() = 0;
  75. // Gets the current configuration.
  76. virtual int32_t CaptureSettings(VideoCaptureCapability& settings) = 0;
  77. // Set the rotation of the captured frames.
  78. // If the rotation is set to the same as returned by
  79. // DeviceInfo::GetOrientation the captured frames are
  80. // displayed correctly if rendered.
  81. virtual int32_t SetCaptureRotation(VideoRotation rotation) = 0;
  82. // Tells the capture module whether to apply the pending rotation. By default,
  83. // the rotation is applied and the generated frame is up right. When set to
  84. // false, generated frames will carry the rotation information from
  85. // SetCaptureRotation. Return value indicates whether this operation succeeds.
  86. virtual bool SetApplyRotation(bool enable) = 0;
  87. // Return whether the rotation is applied or left pending.
  88. virtual bool GetApplyRotation() = 0;
  89. protected:
  90. ~VideoCaptureModule() override {}
  91. };
  92. } // namespace webrtc
  93. #endif // MODULES_VIDEO_CAPTURE_VIDEO_CAPTURE_H_