| 6 | #include "api/video_track_source_proxy.h" |
| 7 |
| 8 | namespace tgcalls { |
| 9 | namespace { |
| 10 |
| 11 | static VideoCameraCapturer *GetCapturer( |
| 12 | const rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> nativeSource) { |
| 13 | const auto proxy = static_cast<webrtc::VideoTrackSourceProxy*>(nativeSource.get()); |
| 14 | const auto internal = static_cast<VideoCapturerTrackSource*>(proxy->internal()); |
| 15 | return internal->capturer(); |
| 16 | } |
| 17 |
| 18 | } // namespace |
| 19 |
| 20 | VideoCapturerInterfaceImpl::VideoCapturerInterfaceImpl( |
| 21 | rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> source, |
| 22 | bool useFrontCamera, |
| 23 | std::function<void(VideoState)> stateUpdated) |
| 24 | : _source(source) |
| 25 | , _stateUpdated(stateUpdated) { |
| 26 | } |
| 27 |
| 28 | VideoCapturerInterfaceImpl::~VideoCapturerInterfaceImpl() { |
| 29 | } |
| 30 |
| 31 | void VideoCapturerInterfaceImpl::setState(VideoState state) { |
| 32 | GetCapturer(_source)->setState(state); |
| 33 | if (_stateUpdated) { |
| 34 | _stateUpdated(state); |
| 35 | } |
| 36 | } |
| 37 |
| 38 | void VideoCapturerInterfaceImpl::setPreferredCaptureAspectRatio(float aspectRatio) { |
| 39 | GetCapturer(_source)->setPreferredCaptureAspectRatio(aspectRatio); |
| 40 | } |
| 41 |
| 42 | void VideoCapturerInterfaceImpl::setUncroppedOutput(std::shared_ptr<rtc::VideoSinkInterface<webrtc::VideoFrame>> sink) { |
| 43 | if (_uncroppedSink != nullptr) { |
| 44 | _source->RemoveSink(_uncroppedSink.get()); |
| 45 | } |
| 46 | _uncroppedSink = sink; |
| 47 | if (_uncroppedSink != nullptr) { |
| 48 | _source->AddOrUpdateSink(_uncroppedSink.get(), rtc::VideoSinkWants()); |
| 49 | } |
| 50 | } |
| 51 |
| 52 | } // namespace tgcalls |
| 53 |