diff --git a/submodules/TelegramCore/Sources/MacOS/MacInternalUpdater.swift b/submodules/TelegramCore/Sources/MacOS/MacInternalUpdater.swift index ef88773a54..b0ae253b1a 100644 --- a/submodules/TelegramCore/Sources/MacOS/MacInternalUpdater.swift +++ b/submodules/TelegramCore/Sources/MacOS/MacInternalUpdater.swift @@ -40,7 +40,7 @@ public func requestUpdatesXml(account: Account, source: String) -> Signal() @@ -433,9 +435,10 @@ public final class OngoingGroupCallContext { init(queue: Queue, inputDeviceId: String, outputDeviceId: String, audioSessionActive: Signal, video: OngoingCallVideoCapturer?, requestMediaChannelDescriptions: @escaping (Set, @escaping ([MediaChannelDescription]) -> Void) -> Disposable, rejoinNeeded: @escaping () -> Void, outgoingAudioBitrateKbit: Int32?, videoContentType: VideoContentType, enableNoiseSuppression: Bool, disableAudioInput: Bool, preferX264: Bool, logPath: String) { self.queue = queue +#if os(iOS) self.audioDevice = nil let audioDevice = self.audioDevice - +#endif var networkStateUpdatedImpl: ((GroupCallNetworkState) -> Void)? var audioLevelsUpdatedImpl: (([NSNumber]) -> Void)? @@ -450,7 +453,7 @@ public final class OngoingGroupCallContext { } var getBroadcastPartsSource: (() -> BroadcastPartSource?)? - +#if os(iOS) self.context = GroupCallThreadLocalContext( queue: ContextQueueImpl(queue: queue), networkStateUpdated: { state in @@ -544,6 +547,101 @@ public final class OngoingGroupCallContext { logPath: logPath, audioDevice: audioDevice ) +#else + self.context = GroupCallThreadLocalContext( + queue: ContextQueueImpl(queue: queue), + networkStateUpdated: { state in + networkStateUpdatedImpl?(state) + }, + audioLevelsUpdated: { levels in + audioLevelsUpdatedImpl?(levels) + }, + inputDeviceId: inputDeviceId, + outputDeviceId: outputDeviceId, + videoCapturer: video?.impl, + requestMediaChannelDescriptions: { ssrcs, completion in + final class OngoingGroupCallMediaChannelDescriptionTaskImpl : NSObject, OngoingGroupCallMediaChannelDescriptionTask { + private let disposable: Disposable + + init(disposable: Disposable) { + self.disposable = disposable + } + + func cancel() { + self.disposable.dispose() + } + } + + let disposable = requestMediaChannelDescriptions(Set(ssrcs.map { $0.uint32Value }), { channels in + completion(channels.map { channel -> OngoingGroupCallMediaChannelDescription in + let mappedType: OngoingGroupCallMediaChannelType + switch channel.kind { + case .audio: + mappedType = .audio + case .video: + mappedType = .video + } + return OngoingGroupCallMediaChannelDescription( + type: mappedType, + audioSsrc: channel.audioSsrc, + videoDescription: channel.videoDescription + ) + }) + }) + + return OngoingGroupCallMediaChannelDescriptionTaskImpl(disposable: disposable) + }, + requestCurrentTime: { completion in + let disposable = MetaDisposable() + + queue.async { + disposable.set(getBroadcastPartsSource?()?.requestTime(completion: completion)) + } + + return OngoingGroupCallBroadcastPartTaskImpl(disposable: disposable) + }, + requestAudioBroadcastPart: { timestampMilliseconds, durationMilliseconds, completion in + let disposable = MetaDisposable() + + queue.async { + disposable.set(getBroadcastPartsSource?()?.requestPart(timestampMilliseconds: timestampMilliseconds, durationMilliseconds: durationMilliseconds, subject: .audio, completion: completion, rejoinNeeded: { + rejoinNeeded() + })) + } + + return OngoingGroupCallBroadcastPartTaskImpl(disposable: disposable) + }, + requestVideoBroadcastPart: { timestampMilliseconds, durationMilliseconds, channelId, quality, completion in + let disposable = MetaDisposable() + + queue.async { + let mappedQuality: OngoingGroupCallContext.VideoChannel.Quality + switch quality { + case .thumbnail: + mappedQuality = .thumbnail + case .medium: + mappedQuality = .medium + case .full: + mappedQuality = .full + @unknown default: + mappedQuality = .thumbnail + } + disposable.set(getBroadcastPartsSource?()?.requestPart(timestampMilliseconds: timestampMilliseconds, durationMilliseconds: durationMilliseconds, subject: .video(channelId: channelId, quality: mappedQuality), completion: completion, rejoinNeeded: { + rejoinNeeded() + })) + } + + return OngoingGroupCallBroadcastPartTaskImpl(disposable: disposable) + }, + outgoingAudioBitrateKbit: outgoingAudioBitrateKbit ?? 32, + videoContentType: _videoContentType, + enableNoiseSuppression: enableNoiseSuppression, + disableAudioInput: disableAudioInput, + preferX264: preferX264, + logPath: logPath + ) +#endif + let queue = self.queue