diff --git a/Telegram/BroadcastUpload/BroadcastUploadExtension.swift b/Telegram/BroadcastUpload/BroadcastUploadExtension.swift index b2ce0189c5..d1c0696c6a 100644 --- a/Telegram/BroadcastUpload/BroadcastUploadExtension.swift +++ b/Telegram/BroadcastUpload/BroadcastUploadExtension.swift @@ -138,7 +138,7 @@ private func rootPathForBasePath(_ appGroupPath: String) -> String { self.audioConverter = CustomAudioConverter(asbd: asbd) } if let audioConverter = self.audioConverter { - if let data = audioConverter.convert(sampleBuffer: sampleBuffer) { + if let data = audioConverter.convert(sampleBuffer: sampleBuffer), !data.isEmpty { self.screencastBufferClientContext?.writeAudioData(data: data) } } diff --git a/submodules/ShareController/Sources/ShareControllerNode.swift b/submodules/ShareController/Sources/ShareControllerNode.swift index 4678c1d123..0aa3efa75b 100644 --- a/submodules/ShareController/Sources/ShareControllerNode.swift +++ b/submodules/ShareController/Sources/ShareControllerNode.swift @@ -379,7 +379,7 @@ final class ShareControllerNode: ViewControllerTracingNode, UIScrollViewDelegate let animation = contentNode.layer.makeAnimation(from: 0.0 as NSNumber, to: 1.0 as NSNumber, keyPath: "opacity", timingFunction: CAMediaTimingFunctionName.easeInEaseOut.rawValue, duration: 0.35) animation.fillMode = .both if !fastOut { - animation.beginTime = CACurrentMediaTime() + 0.1 + animation.beginTime = contentNode.layer.convertTime(CACurrentMediaTime(), from: nil) + 0.1 } contentNode.layer.add(animation, forKey: "opacity") } diff --git a/submodules/TelegramApi/Sources/Api0.swift b/submodules/TelegramApi/Sources/Api0.swift index 57f1f4c9d9..7bafaa580b 100644 --- a/submodules/TelegramApi/Sources/Api0.swift +++ b/submodules/TelegramApi/Sources/Api0.swift @@ -584,7 +584,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-1160215659] = { return Api.InputMessage.parse_inputMessageReplyTo($0) } dict[-2037963464] = { return Api.InputMessage.parse_inputMessagePinned($0) } dict[-1392895362] = { return Api.InputMessage.parse_inputMessageCallbackQuery($0) } - dict[2028213859] = { return Api.GroupCallParticipantVideo.parse_groupCallParticipantVideo($0) } + dict[1735736008] = { return Api.GroupCallParticipantVideo.parse_groupCallParticipantVideo($0) } dict[-58224696] = { return Api.PhoneCallProtocol.parse_phoneCallProtocol($0) } dict[-1237848657] = { return Api.StatsDateRangeDays.parse_statsDateRangeDays($0) } dict[-275956116] = { return Api.messages.AffectedFoundMessages.parse_affectedFoundMessages($0) } diff --git a/submodules/TelegramApi/Sources/Api2.swift b/submodules/TelegramApi/Sources/Api2.swift index 597f5d0fe5..e17594636e 100644 --- a/submodules/TelegramApi/Sources/Api2.swift +++ b/submodules/TelegramApi/Sources/Api2.swift @@ -14978,13 +14978,13 @@ public extension Api { } public enum GroupCallParticipantVideo: TypeConstructorDescription { - case groupCallParticipantVideo(flags: Int32, endpoint: String, sourceGroups: [Api.GroupCallParticipantVideoSourceGroup]) + case groupCallParticipantVideo(flags: Int32, endpoint: String, sourceGroups: [Api.GroupCallParticipantVideoSourceGroup], audioSource: Int32?) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { - case .groupCallParticipantVideo(let flags, let endpoint, let sourceGroups): + case .groupCallParticipantVideo(let flags, let endpoint, let sourceGroups, let audioSource): if boxed { - buffer.appendInt32(2028213859) + buffer.appendInt32(1735736008) } serializeInt32(flags, buffer: buffer, boxed: false) serializeString(endpoint, buffer: buffer, boxed: false) @@ -14993,14 +14993,15 @@ public extension Api { for item in sourceGroups { item.serialize(buffer, true) } + if Int(flags) & Int(1 << 1) != 0 {serializeInt32(audioSource!, buffer: buffer, boxed: false)} break } } public func descriptionFields() -> (String, [(String, Any)]) { switch self { - case .groupCallParticipantVideo(let flags, let endpoint, let sourceGroups): - return ("groupCallParticipantVideo", [("flags", flags), ("endpoint", endpoint), ("sourceGroups", sourceGroups)]) + case .groupCallParticipantVideo(let flags, let endpoint, let sourceGroups, let audioSource): + return ("groupCallParticipantVideo", [("flags", flags), ("endpoint", endpoint), ("sourceGroups", sourceGroups), ("audioSource", audioSource)]) } } @@ -15013,11 +15014,14 @@ public extension Api { if let _ = reader.readInt32() { _3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.GroupCallParticipantVideoSourceGroup.self) } + var _4: Int32? + if Int(_1!) & Int(1 << 1) != 0 {_4 = reader.readInt32() } let _c1 = _1 != nil let _c2 = _2 != nil let _c3 = _3 != nil - if _c1 && _c2 && _c3 { - return Api.GroupCallParticipantVideo.groupCallParticipantVideo(flags: _1!, endpoint: _2!, sourceGroups: _3!) + let _c4 = (Int(_1!) & Int(1 << 1) == 0) || _4 != nil + if _c1 && _c2 && _c3 && _c4 { + return Api.GroupCallParticipantVideo.groupCallParticipantVideo(flags: _1!, endpoint: _2!, sourceGroups: _3!, audioSource: _4) } else { return nil diff --git a/submodules/TelegramCallsUI/Sources/PresentationGroupCall.swift b/submodules/TelegramCallsUI/Sources/PresentationGroupCall.swift index 2c362e1808..5d7cb5dc27 100644 --- a/submodules/TelegramCallsUI/Sources/PresentationGroupCall.swift +++ b/submodules/TelegramCallsUI/Sources/PresentationGroupCall.swift @@ -415,12 +415,8 @@ public final class PresentationGroupCallImpl: PresentationGroupCall { private var screencastBufferServerContext: IpcGroupCallBufferAppContext? private var screencastCapturer: OngoingCallVideoCapturer? - //private var screencastIpcContext: IpcGroupCallAppContext? - private var ssrcMapping: [UInt32: PeerId] = [:] - private var requestedSsrcs = Set() - private var summaryInfoState = Promise(nil) private var summaryParticipantsState = Promise(nil) @@ -887,7 +883,7 @@ public final class PresentationGroupCallImpl: PresentationGroupCall { guard let strongSelf = self else { return } - strongSelf.genericCallContext?.addExternalAudioData(data: data) + strongSelf.screencastCallContext?.addExternalAudioData(data: data) }) self.screencastStateDisposable = (screencastBufferServerContext.isActive |> distinctUntilChanged @@ -2050,6 +2046,18 @@ public final class PresentationGroupCallImpl: PresentationGroupCall { videoDescription: nil )) } + + if let screencastSsrc = participant.presentationDescription?.audioSsrc { + if remainingSsrcs.contains(screencastSsrc) { + remainingSsrcs.remove(screencastSsrc) + + result.append(OngoingGroupCallContext.MediaChannelDescription( + kind: .audio, + audioSsrc: screencastSsrc, + videoDescription: nil + )) + } + } } } diff --git a/submodules/TelegramCore/Sources/GroupCalls.swift b/submodules/TelegramCore/Sources/GroupCalls.swift index e377ac0181..2d4a92a44d 100644 --- a/submodules/TelegramCore/Sources/GroupCalls.swift +++ b/submodules/TelegramCore/Sources/GroupCalls.swift @@ -855,6 +855,7 @@ public final class GroupCallParticipantsContext { public var endpointId: String public var ssrcGroups: [SsrcGroup] + public var audioSsrc: UInt32? public var isPaused: Bool } @@ -1527,6 +1528,9 @@ public final class GroupCallParticipantsContext { if let ssrc = participant.ssrc { existingSsrcs.insert(ssrc) } + if let presentationDescription = participant.presentationDescription, let presentationAudioSsrc = presentationDescription.audioSsrc { + existingSsrcs.insert(presentationAudioSsrc) + } } for ssrc in ssrcs { @@ -2488,7 +2492,7 @@ extension GroupCallParticipantsContext.Participant { private extension GroupCallParticipantsContext.Participant.VideoDescription { init(_ apiVideo: Api.GroupCallParticipantVideo) { switch apiVideo { - case let .groupCallParticipantVideo(flags, endpoint, sourceGroups): + case let .groupCallParticipantVideo(flags, endpoint, sourceGroups, audioSource): var parsedSsrcGroups: [SsrcGroup] = [] for group in sourceGroups { switch group { @@ -2497,7 +2501,7 @@ private extension GroupCallParticipantsContext.Participant.VideoDescription { } } let isPaused = (flags & (1 << 0)) != 0 - self.init(endpointId: endpoint, ssrcGroups: parsedSsrcGroups, isPaused: isPaused) + self.init(endpointId: endpoint, ssrcGroups: parsedSsrcGroups, audioSsrc: audioSource.flatMap(UInt32.init(bitPattern:)), isPaused: isPaused) } } } diff --git a/submodules/TgVoipWebrtc/tgcalls b/submodules/TgVoipWebrtc/tgcalls index 76d781c09c..3cf1822a70 160000 --- a/submodules/TgVoipWebrtc/tgcalls +++ b/submodules/TgVoipWebrtc/tgcalls @@ -1 +1 @@ -Subproject commit 76d781c09cd4d827e417a56cc7bc39b0d2217e78 +Subproject commit 3cf1822a70e3b84f6a762755e5249b26e915d321