diff --git a/submodules/TelegramVoip/Sources/GroupCallContext.swift b/submodules/TelegramVoip/Sources/GroupCallContext.swift index 1c2e36f36f..eec11fe27c 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 @@ -1226,6 +1275,12 @@ public final class OngoingGroupCallContext { impl.stop(account: account, reportCallId: reportCallId) } } + + public func makeIncomingVideoView(endpointId: String, requestClone: Bool, completion: @escaping (OngoingCallContextPresentationCallVideoView?, OngoingCallContextPresentationCallVideoView?) -> Void) { + self.impl.with { impl in + impl.makeIncomingVideoView(endpointId: endpointId, requestClone: requestClone, completion: completion) + } + } public func video(endpointId: String) -> Signal { return Signal { subscriber in