#include "DarwinInterface.h" #include "VideoCapturerInterfaceImpl.h" #include "sdk/objc/native/src/objc_video_track_source.h" #include "media/base/media_constants.h" #include "TGRTCDefaultVideoEncoderFactory.h" #include "TGRTCDefaultVideoDecoderFactory.h" #include "sdk/objc/native/api/video_encoder_factory.h" #include "sdk/objc/native/api/video_decoder_factory.h" #include "api/video_track_source_proxy.h" #ifdef WEBRTC_IOS #include "sdk/objc/components/audio/RTCAudioSession.h" #endif // WEBRTC_IOS #import namespace tgcalls { void DarwinInterface::configurePlatformAudio() { #ifdef WEBRTC_IOS [RTCAudioSession sharedInstance].useManualAudio = true; [[RTCAudioSession sharedInstance] audioSessionDidActivate:[AVAudioSession sharedInstance]]; [RTCAudioSession sharedInstance].isAudioEnabled = true; #endif } float DarwinInterface::getDisplayAspectRatio() { return 0.0f; } std::unique_ptr DarwinInterface::makeVideoEncoderFactory() { return webrtc::ObjCToNativeVideoEncoderFactory([[TGRTCDefaultVideoEncoderFactory alloc] init]); } std::unique_ptr DarwinInterface::makeVideoDecoderFactory() { return webrtc::ObjCToNativeVideoDecoderFactory([[TGRTCDefaultVideoDecoderFactory alloc] init]); } bool DarwinInterface::supportsEncoding(const std::string &codecName) { if (codecName == cricket::kH265CodecName) { #ifdef WEBRTC_IOS if (@available(iOS 11.0, *)) { return [[AVAssetExportSession allExportPresets] containsObject:AVAssetExportPresetHEVCHighestQuality]; } #elif defined WEBRTC_MAC // WEBRTC_IOS if (@available(macOS 10.13, *)) { return [[AVAssetExportSession allExportPresets] containsObject:AVAssetExportPresetHEVCHighestQuality]; } #endif // WEBRTC_IOS || WEBRTC_MAC } else if (codecName == cricket::kH264CodecName) { return true; } else if (codecName == cricket::kVp8CodecName) { return true; } else if (codecName == cricket::kVp9CodecName) { #ifndef WEBRTC_IOS return true; #else return false; #endif } return false; } rtc::scoped_refptr DarwinInterface::makeVideoSource(rtc::Thread *signalingThread, rtc::Thread *workerThread) { rtc::scoped_refptr objCVideoTrackSource(new rtc::RefCountedObject()); return webrtc::VideoTrackSourceProxy::Create(signalingThread, workerThread, objCVideoTrackSource); } std::unique_ptr DarwinInterface::makeVideoCapturer(rtc::scoped_refptr source, bool useFrontCamera, std::function stateUpdated, std::shared_ptr platformContext) { return std::make_unique(source, useFrontCamera, stateUpdated); } std::unique_ptr CreatePlatformInterface() { return std::make_unique(); } } // namespace tgcalls