diff --git a/submodules/TelegramVoip/Sources/GroupCallContext.swift b/submodules/TelegramVoip/Sources/GroupCallContext.swift index 3ef9ad3ccd..980ed3ab3b 100644 --- a/submodules/TelegramVoip/Sources/GroupCallContext.swift +++ b/submodules/TelegramVoip/Sources/GroupCallContext.swift @@ -601,44 +601,15 @@ public final class OngoingGroupCallContext { mainView?.setOnIsMirroredUpdated { value in f?(value) } + }, + setIsPaused: { [weak mainView] paused in + mainView?.setIsPaused(paused) + }, + renderToSize: { [weak mainView] size, animated in + mainView?.render(to: size, animated: animated) } ) - var cloneVideoView: OngoingCallContextPresentationCallVideoView? - if let cloneView = cloneView { - cloneVideoView = OngoingCallContextPresentationCallVideoView( - view: cloneView, - setOnFirstFrameReceived: { [weak cloneView] f in - cloneView?.setOnFirstFrameReceived(f) - }, - getOrientation: { [weak cloneView] in - if let cloneView = cloneView { - return OngoingCallVideoOrientation(cloneView.orientation) - } else { - return .rotation0 - } - }, - getAspect: { [weak cloneView] in - if let cloneView = cloneView { - return cloneView.aspect - } else { - return 0.0 - } - }, - setOnOrientationUpdated: { [weak cloneView] f in - cloneView?.setOnOrientationUpdated { value, aspect in - f?(OngoingCallVideoOrientation(value), aspect) - } - }, setVideoContentMode: { [weak cloneView] mode in - cloneView?.setVideoContentMode(mode) - }, - setOnIsMirroredUpdated: { [weak cloneView] f in - cloneView?.setOnIsMirroredUpdated { value in - f?(value) - } - } - ) - } - completion(mainVideoView, cloneVideoView) + completion(mainVideoView, nil) #endif } else { completion(nil, nil) diff --git a/submodules/TgVoipWebrtc/PublicHeaders/TgVoipWebrtc/OngoingCallThreadLocalContext.h b/submodules/TgVoipWebrtc/PublicHeaders/TgVoipWebrtc/OngoingCallThreadLocalContext.h index 5358bf382e..c83010f703 100644 --- a/submodules/TgVoipWebrtc/PublicHeaders/TgVoipWebrtc/OngoingCallThreadLocalContext.h +++ b/submodules/TgVoipWebrtc/PublicHeaders/TgVoipWebrtc/OngoingCallThreadLocalContext.h @@ -105,6 +105,8 @@ typedef NS_ENUM(int32_t, OngoingCallDataSavingWebrtc) { #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) - (void)setVideoContentMode:(CALayerContentsGravity _Nonnull )mode; - (void)setForceMirrored:(bool)forceMirrored; +- (void)setIsPaused:(bool)paused; +- (void)renderToSize:(NSSize)size animated: (bool)animated; #endif @end diff --git a/submodules/TgVoipWebrtc/Sources/OngoingCallThreadLocalContext.mm b/submodules/TgVoipWebrtc/Sources/OngoingCallThreadLocalContext.mm index 53d02b469b..33eb99070e 100644 --- a/submodules/TgVoipWebrtc/Sources/OngoingCallThreadLocalContext.mm +++ b/submodules/TgVoipWebrtc/Sources/OngoingCallThreadLocalContext.mm @@ -50,26 +50,8 @@ @end -@interface IsProcessingCustomSampleBufferFlag : NSObject - -@property (nonatomic) bool value; - -@end - -@implementation IsProcessingCustomSampleBufferFlag - -- (instancetype)init { - self = [super init]; - if (self != nil) { - } - return self; -} - -@end - @interface OngoingCallThreadLocalContextVideoCapturer () { std::shared_ptr _interface; - IsProcessingCustomSampleBufferFlag *_isProcessingCustomSampleBuffer; } @end @@ -235,7 +217,6 @@ self = [super init]; if (self != nil) { _interface = interface; - _isProcessingCustomSampleBuffer = [[IsProcessingCustomSampleBufferFlag alloc] init]; _croppingBuffer = std::make_shared>(); } return self; @@ -273,6 +254,20 @@ tgcalls::VideoCaptureInterfaceObject *GetVideoCaptureAssumingSameThread(tgcalls: } #if TARGET_OS_IOS +- (void)submitSampleBuffer:(CMSampleBufferRef _Nonnull)sampleBuffer { + if (!sampleBuffer) { + return; + } + tgcalls::StaticThreads::getThreads()->getMediaThread()->PostTask(RTC_FROM_HERE, [interface = _interface, sampleBuffer = CFRetain(sampleBuffer)]() { + auto capture = GetVideoCaptureAssumingSameThread(interface.get()); + auto source = capture->source(); + if (source) { + [CustomExternalCapturer passSampleBuffer:(CMSampleBufferRef)sampleBuffer toSource:source]; + } + CFRelease(sampleBuffer); + }); +} + - (void)submitPixelBuffer:(CVPixelBufferRef _Nonnull)pixelBuffer rotation:(OngoingCallVideoOrientationWebrtc)rotation { if (!pixelBuffer) { return; @@ -294,19 +289,13 @@ tgcalls::VideoCaptureInterfaceObject *GetVideoCaptureAssumingSameThread(tgcalls: break; } - if (_isProcessingCustomSampleBuffer.value) { - return; - } - _isProcessingCustomSampleBuffer.value = true; - - tgcalls::StaticThreads::getThreads()->getMediaThread()->PostTask(RTC_FROM_HERE, [interface = _interface, pixelBuffer = CFRetain(pixelBuffer), croppingBuffer = _croppingBuffer, videoRotation = videoRotation, isProcessingCustomSampleBuffer = _isProcessingCustomSampleBuffer]() { + tgcalls::StaticThreads::getThreads()->getMediaThread()->PostTask(RTC_FROM_HERE, [interface = _interface, pixelBuffer = CFRetain(pixelBuffer), croppingBuffer = _croppingBuffer, videoRotation = videoRotation]() { auto capture = GetVideoCaptureAssumingSameThread(interface.get()); auto source = capture->source(); if (source) { [CustomExternalCapturer passPixelBuffer:(CVPixelBufferRef)pixelBuffer rotation:videoRotation toSource:source croppingBuffer:*croppingBuffer]; } CFRelease(pixelBuffer); - isProcessingCustomSampleBuffer.value = false; }); } @@ -1121,9 +1110,10 @@ private: } std::vector videoCodecPreferences; +// videoCodecPreferences.push_back(tgcalls::VideoCodecName::H264); + //videoCodecPreferences.push_back(tgcalls::VideoCodecName::VP9);/ int minOutgoingVideoBitrateKbit = 500; - bool disableOutgoingAudioProcessing = false; tgcalls::GroupConfig config; config.need_log = false; @@ -1195,7 +1185,6 @@ private: return std::make_shared(task); }, .outgoingAudioBitrateKbit = outgoingAudioBitrateKbit, - .disableOutgoingAudioProcessing = disableOutgoingAudioProcessing, .videoContentType = _videoContentType, .videoCodecPreferences = videoCodecPreferences, .initialEnableNoiseSuppression = enableNoiseSuppression, @@ -1477,15 +1466,6 @@ private: } } -- (void)addExternalAudioData:(NSData * _Nonnull)data { - if (_instance) { - std::vector samples; - samples.resize(data.length); - [data getBytes:samples.data() length:data.length]; - _instance->addExternalAudioSamples(std::move(samples)); - } -} - @end @implementation OngoingGroupCallMediaChannelDescription