#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 VideoCaptureInterfaceObject { public: VideoCaptureInterfaceObject(std::string deviceId, std::shared_ptr platformContext); ~VideoCaptureInterfaceObject(); void switchToDevice(std::string deviceId); void setState(VideoState state); void setPreferredAspectRatio(float aspectRatio); void setOutput(std::shared_ptr> sink); void setStateUpdated(std::function stateUpdated); webrtc::VideoTrackSourceInterface *source(); 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; VideoState _state = VideoState::Active; float _preferredAspectRatio = 0.0f; bool _shouldBeAdaptedToReceiverAspectRate = true; }; class VideoCaptureInterfaceImpl : public VideoCaptureInterface { public: VideoCaptureInterfaceImpl(std::string deviceId, std::shared_ptr platformContext); virtual ~VideoCaptureInterfaceImpl(); void switchToDevice(std::string deviceId) override; void setState(VideoState state) override; void setPreferredAspectRatio(float aspectRatio) override; void setOutput(std::shared_ptr> sink) override; std::shared_ptr getPlatformContext() override; ThreadLocalObject *object(); private: ThreadLocalObject _impl; std::shared_ptr _platformContext; }; } // namespace tgcalls #endif