#ifndef TGCALLS_VIDEO_CAPTURE_INTERFACE_IMPL_H #define TGCALLS_VIDEO_CAPTURE_INTERFACE_IMPL_H #include "VideoCaptureInterface.h" #include #include "ThreadLocalObject.h" #include "api/media_stream_interface.h" #include "platform/PlatformInterface.h" namespace tgcalls { class VideoCapturerInterface; class Threads; class VideoCaptureInterfaceObject { public: VideoCaptureInterfaceObject(std::string deviceId, bool isScreenCapture, std::shared_ptr platformContext, Threads &threads); ~VideoCaptureInterfaceObject(); void switchToDevice(std::string deviceId, bool isScreenCapture); void withNativeImplementation(std::function completion); void setState(VideoState state); void setPreferredAspectRatio(float aspectRatio); void setOutput(std::shared_ptr> sink); void setStateUpdated(std::function stateUpdated); void setRotationUpdated(std::function rotationUpdated); void setOnFatalError(std::function error); void setOnPause(std::function pause); void setOnIsActiveUpdated(std::function onIsActiveUpdated); webrtc::VideoTrackSourceInterface *source(); int getRotation(); bool isScreenCapture(); private: void updateAspectRateAdaptation(); rtc::scoped_refptr _videoSource; std::shared_ptr> _currentUncroppedSink; std::shared_ptr _platformContext; std::pair _videoCapturerResolution; std::unique_ptr _videoCapturer; std::function _stateUpdated; std::function _onFatalError; std::function _onPause; std::function _onIsActiveUpdated; std::function _rotationUpdated; VideoState _state = VideoState::Active; float _preferredAspectRatio = 0.0f; bool _shouldBeAdaptedToReceiverAspectRate = true; bool _isScreenCapture = false; }; class VideoCaptureInterfaceImpl : public VideoCaptureInterface { public: VideoCaptureInterfaceImpl(std::string deviceId, bool isScreenCapture, std::shared_ptr platformContext, std::shared_ptr threads); virtual ~VideoCaptureInterfaceImpl(); void switchToDevice(std::string deviceId, bool isScreenCapture) override; void withNativeImplementation(std::function completion) override; void setState(VideoState state) override; void setPreferredAspectRatio(float aspectRatio) override; void setOutput(std::shared_ptr> sink) override; void setOnFatalError(std::function error) override; void setOnPause(std::function pause) override; void setOnIsActiveUpdated(std::function onIsActiveUpdated) override; std::shared_ptr getPlatformContext() override; ThreadLocalObject *object(); private: ThreadLocalObject _impl; std::shared_ptr _platformContext; }; } // namespace tgcalls #endif