1 #ifndef TGCALLS_VIDEO_CAPTURE_INTERFACE_H 2 #define TGCALLS_VIDEO_CAPTURE_INTERFACE_H 3 4 #include <string> 5 #include <memory> 6 #include <functional> 7 8 namespace rtc { 9 template <typename VideoFrameT> 10 class VideoSinkInterface; 11 } // namespace rtc 12 13 namespace webrtc { 14 class VideoFrame; 15 } // namespace webrtc 16 17 namespace tgcalls { 18 19 class PlatformContext; 20 class Threads; 21 22 enum class VideoState { 23 Inactive, 24 Paused, 25 Active, 26 }; 27 28 29 class VideoCaptureInterface { 30 protected: 31 VideoCaptureInterface() = default; 32 33 public: 34 static std::unique_ptr<VideoCaptureInterface> Create( 35 std::shared_ptr<Threads> threads, 36 std::string deviceId = std::string(), 37 bool isScreenCapture = false, 38 std::shared_ptr<PlatformContext> platformContext = nullptr); 39 40 virtual ~VideoCaptureInterface(); 41 42 virtual void switchToDevice(std::string deviceId, bool isScreenCapture) = 0; 43 virtual void setState(VideoState state) = 0; 44 virtual void setPreferredAspectRatio(float aspectRatio) = 0; 45 virtual void setOutput(std::shared_ptr<rtc::VideoSinkInterface<webrtc::VideoFrame>> sink) = 0; setOnFatalError(std::function<void ()> error)46 virtual void setOnFatalError(std::function<void()> error) { 47 // TODO: make this function pure virtual when everybody implements it. 48 } setOnPause(std::function<void (bool)> pause)49 virtual void setOnPause(std::function<void(bool)> pause) { 50 // TODO: make this function pure virtual when everybody implements it. 51 } setOnIsActiveUpdated(std::function<void (bool)> onIsActiveUpdated)52 virtual void setOnIsActiveUpdated(std::function<void(bool)> onIsActiveUpdated) { 53 // TODO: make this function pure virtual when everybody implements it. 54 } withNativeImplementation(std::function<void (void *)> completion)55 virtual void withNativeImplementation(std::function<void(void *)> completion) { 56 completion(nullptr); 57 } 58 }; 59 60 } // namespace tgcalls 61 62 #endif 63