| 5 |
| 6 | #include "api/video_codecs/builtin_video_encoder_factory.h" |
| 7 | #include "api/video_codecs/builtin_video_decoder_factory.h" |
| 8 | #include "pc/video_track_source_proxy.h" |
| 9 |
| 10 | #if TGCALLS_UWP_DESKTOP |
| 11 | #include "modules/video_coding/codecs/h264/win/h264_mf_factory.h" |
| 12 | #endif |
| 13 |
| 14 | namespace tgcalls { |
| 15 |
| 16 | std::unique_ptr<webrtc::VideoEncoderFactory> DesktopInterface::makeVideoEncoderFactory(bool preferHardwareEncoding, bool isScreencast) { |
| 17 | #if TGCALLS_UWP_DESKTOP |
| 18 | return std::make_unique<webrtc::H264MFEncoderFactory>(); |
| 19 | #else |
| 20 | return webrtc::CreateBuiltinVideoEncoderFactory(); |
| 21 | #endif |
| 22 | } |
| 23 |
| 24 | std::unique_ptr<webrtc::VideoDecoderFactory> DesktopInterface::makeVideoDecoderFactory() { |
| 25 | #if TGCALLS_UWP_DESKTOP |
| 26 | return std::make_unique<webrtc::H264MFDecoderFactory>(); |
| 27 | #else |
| 28 | return webrtc::CreateBuiltinVideoDecoderFactory(); |
| 29 | #endif |
| 30 | } |
| 31 |
| 32 | rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> DesktopInterface::makeVideoSource(rtc::Thread *signalingThread, rtc::Thread *workerThread) { |
| 33 | const auto videoTrackSource = rtc::scoped_refptr<VideoCapturerTrackSource>( |
| 34 | new rtc::RefCountedObject<VideoCapturerTrackSource>()); |
| 35 | return videoTrackSource |
| 36 | ? webrtc::VideoTrackSourceProxy::Create(signalingThread, workerThread, videoTrackSource) |
| 37 | : nullptr; |
| 38 | } |
| 39 |
| 40 | bool DesktopInterface::supportsEncoding(const std::string &codecName) { |
| 41 | return (codecName == cricket::kH264CodecName) |
| 42 | || (codecName == cricket::kVp8CodecName); |
| 43 | } |
| 44 |
| 45 | void DesktopInterface::adaptVideoSource(rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> videoSource, int width, int height, int fps) { |
| 46 | } |
| 47 |
| 48 | std::unique_ptr<VideoCapturerInterface> DesktopInterface::makeVideoCapturer(rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> source, std::string deviceId, std::function<void(VideoState)> stateUpdated, std::function<void(PlatformCaptureInfo)> captureInfoUpdated, std::shared_ptr<PlatformContext> platformContext, std::pair<int, int> &outResolution) { |
| 49 | return std::make_unique<VideoCapturerInterfaceImpl>(source, deviceId, stateUpdated, platformContext, outResolution); |
| 50 | } |
| 51 |
| 52 | std::unique_ptr<PlatformInterface> CreatePlatformInterface() { |
| 53 | return std::make_unique<DesktopInterface>(); |
| 54 | } |
| 55 |
| 56 | } // namespace tgcalls |
| 57 |