| #include "api/video/video_frame.h" |
| 6 | #include "api/video/video_source_interface.h" |
| 7 | #include "media/base/video_adapter.h" |
| 8 | #include "modules/video_capture/video_capture.h" |
| 9 |
| 10 | #include "VideoCaptureInterface.h" |
| 11 |
| 12 | #include <memory> |
| 13 | #include <vector> |
| 14 | #include <stddef.h> |
| 15 |
| 16 | namespace tgcalls { |
| 17 |
| 18 | class VideoCameraCapturer |
| 19 | : public rtc::VideoSinkInterface<webrtc::VideoFrame> { |
| 20 | public: |
| 21 | explicit VideoCameraCapturer( |
| 22 | std::shared_ptr<rtc::VideoSinkInterface<webrtc::VideoFrame>> sink); |
| 23 | ~VideoCameraCapturer(); |
| 24 |
| 25 | void setState(VideoState state); |
| 26 | void setDeviceId(std::string deviceId); |
| 27 | void setPreferredCaptureAspectRatio(float aspectRatio); |
| 28 | void setOnFatalError(std::function<void()> error); |
| 29 |
| 30 | std::pair<int, int> resolution() const; |
| 31 |
| 32 | void OnFrame(const webrtc::VideoFrame &frame) override; |
| 33 |
| 34 | private: |
| 35 | void create(); |
| 36 | bool create( |
| 37 | webrtc::VideoCaptureModule::DeviceInfo *info, |
| 38 | const std::string &deviceId); |
| 39 | void destroy(); |
| 40 | void failed(); |
| 41 |
| 42 | std::shared_ptr<rtc::VideoSinkInterface<webrtc::VideoFrame>> _sink; |
| 43 | rtc::scoped_refptr<webrtc::VideoCaptureModule> _module; |
| 44 | webrtc::VideoCaptureCapability _capability; |
| 45 |
| 46 | VideoState _state = VideoState::Inactive; |
| 47 | std::string _requestedDeviceId; |
| 48 | std::pair<int, int> _dimensions; |
| 49 | std::function<void()> _error; |
| 50 | float _aspectRatio = 0.; |
| 51 | bool _failed = false; |
| 52 |
| 53 | }; |
| 54 |
| 55 | } // namespace tgcalls |
| 56 |
| 57 | #endif |
| 58 |