From 9d148597cb4b8a0dea5f34ce47e76e77e65952f6 Mon Sep 17 00:00:00 2001 From: Mikhail Filimonov Date: Thu, 2 Jan 2025 08:26:57 +0400 Subject: [PATCH] macos related changes --- .../Sources/GroupCallContext.swift | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/submodules/TelegramVoip/Sources/GroupCallContext.swift b/submodules/TelegramVoip/Sources/GroupCallContext.swift index 1c2e36f36f..58e91897e0 100644 --- a/submodules/TelegramVoip/Sources/GroupCallContext.swift +++ b/submodules/TelegramVoip/Sources/GroupCallContext.swift @@ -986,6 +986,55 @@ public final class OngoingGroupCallContext { func switchAudioOutput(_ deviceId: String) { self.context.switchAudioOutput(deviceId) } + + func makeIncomingVideoView(endpointId: String, requestClone: Bool, completion: @escaping (OngoingCallContextPresentationCallVideoView?, OngoingCallContextPresentationCallVideoView?) -> Void) { + self.context.makeIncomingVideoView(withEndpointId: endpointId, requestClone: requestClone, completion: { mainView, cloneView in + if let mainView = mainView { + #if os(macOS) + let mainVideoView = OngoingCallContextPresentationCallVideoView( + view: mainView, + setOnFirstFrameReceived: { [weak mainView] f in + mainView?.setOnFirstFrameReceived(f) + }, + getOrientation: { [weak mainView] in + if let mainView = mainView { + return OngoingCallVideoOrientation(mainView.orientation) + } else { + return .rotation0 + } + }, + getAspect: { [weak mainView] in + if let mainView = mainView { + return mainView.aspect + } else { + return 0.0 + } + }, + setOnOrientationUpdated: { [weak mainView] f in + mainView?.setOnOrientationUpdated { value, aspect in + f?(OngoingCallVideoOrientation(value), aspect) + } + }, setVideoContentMode: { [weak mainView] mode in + mainView?.setVideoContentMode(mode) + }, + setOnIsMirroredUpdated: { [weak mainView] f in + 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) + } + ) + completion(mainVideoView, nil) + #endif + } else { + completion(nil, nil) + } + }) + } + func video(endpointId: String) -> Signal { let queue = self.queue