mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 03:20:48 +00:00
Video streaming improvements
This commit is contained in:
parent
fd233a4657
commit
c3b36dda43
@ -687,7 +687,8 @@ public final class PresentationCallManagerImpl: PresentationCallManager {
|
||||
peerId: peerId,
|
||||
isChannel: isChannel,
|
||||
invite: nil,
|
||||
joinAsPeerId: nil
|
||||
joinAsPeerId: nil,
|
||||
isStream: false
|
||||
)
|
||||
strongSelf.updateCurrentGroupCall(call)
|
||||
strongSelf.currentGroupCallPromise.set(.single(call))
|
||||
@ -849,7 +850,8 @@ public final class PresentationCallManagerImpl: PresentationCallManager {
|
||||
peerId: peerId,
|
||||
isChannel: isChannel,
|
||||
invite: invite,
|
||||
joinAsPeerId: joinAsPeerId
|
||||
joinAsPeerId: joinAsPeerId,
|
||||
isStream: initialCall.isStream ?? false
|
||||
)
|
||||
strongSelf.updateCurrentGroupCall(call)
|
||||
strongSelf.currentGroupCallPromise.set(.single(call))
|
||||
|
@ -86,13 +86,14 @@ public final class AccountGroupCallContextImpl: AccountGroupCallContext {
|
||||
var disposable: Disposable?
|
||||
public var participantsContext: GroupCallParticipantsContext?
|
||||
|
||||
private let panelDataPromise = Promise<GroupCallPanelData>()
|
||||
public var panelData: Signal<GroupCallPanelData, NoError> {
|
||||
private let panelDataPromise = Promise<GroupCallPanelData?>()
|
||||
public var panelData: Signal<GroupCallPanelData?, NoError> {
|
||||
return self.panelDataPromise.get()
|
||||
}
|
||||
|
||||
public init(account: Account, engine: TelegramEngine, peerId: PeerId, isChannel: Bool, call: EngineGroupCallDescription) {
|
||||
self.panelDataPromise.set(.single(GroupCallPanelData(
|
||||
self.panelDataPromise.set(.single(nil))
|
||||
/*self.panelDataPromise.set(.single(GroupCallPanelData(
|
||||
peerId: peerId,
|
||||
isChannel: isChannel,
|
||||
info: GroupCallInfo(
|
||||
@ -114,7 +115,7 @@ public final class AccountGroupCallContextImpl: AccountGroupCallContext {
|
||||
participantCount: 0,
|
||||
activeSpeakers: Set(),
|
||||
groupCall: nil
|
||||
)))
|
||||
)))*/
|
||||
|
||||
let state = engine.calls.getGroupCallParticipants(callId: call.id, accessHash: call.accessHash, offset: "", ssrcs: [], limit: 100, sortAscending: nil)
|
||||
|> map(Optional.init)
|
||||
@ -161,7 +162,7 @@ public final class AccountGroupCallContextImpl: AccountGroupCallContext {
|
||||
return GroupCallPanelData(
|
||||
peerId: peerId,
|
||||
isChannel: isChannel,
|
||||
info: GroupCallInfo(id: call.id, accessHash: call.accessHash, participantCount: state.totalCount, streamDcId: nil, title: state.title, scheduleTimestamp: state.scheduleTimestamp, subscribedToScheduled: state.subscribedToScheduled, recordingStartTimestamp: nil, sortAscending: state.sortAscending, defaultParticipantsAreMuted: state.defaultParticipantsAreMuted, isVideoEnabled: state.isVideoEnabled, unmutedVideoLimit: state.unmutedVideoLimit, isStream: call.isStream),
|
||||
info: GroupCallInfo(id: call.id, accessHash: call.accessHash, participantCount: state.totalCount, streamDcId: nil, title: state.title, scheduleTimestamp: state.scheduleTimestamp, subscribedToScheduled: state.subscribedToScheduled, recordingStartTimestamp: nil, sortAscending: state.sortAscending, defaultParticipantsAreMuted: state.defaultParticipantsAreMuted, isVideoEnabled: state.isVideoEnabled, unmutedVideoLimit: state.unmutedVideoLimit, isStream: state.isStream),
|
||||
topParticipants: topParticipants,
|
||||
participantCount: state.totalCount,
|
||||
activeSpeakers: activeSpeakers,
|
||||
@ -637,7 +638,7 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
|
||||
private var screencastAudioDataDisposable: Disposable?
|
||||
private var screencastStateDisposable: Disposable?
|
||||
|
||||
public var isStream = false
|
||||
public let isStream: Bool
|
||||
|
||||
init(
|
||||
accountContext: AccountContext,
|
||||
@ -649,7 +650,8 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
|
||||
peerId: PeerId,
|
||||
isChannel: Bool,
|
||||
invite: String?,
|
||||
joinAsPeerId: PeerId?
|
||||
joinAsPeerId: PeerId?,
|
||||
isStream: Bool
|
||||
) {
|
||||
self.account = accountContext.account
|
||||
self.accountContext = accountContext
|
||||
@ -666,10 +668,6 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
|
||||
self.schedulePending = initialCall == nil
|
||||
self.isScheduled = initialCall == nil || initialCall?.scheduleTimestamp != nil
|
||||
|
||||
if let initialCall = initialCall {
|
||||
self.isStream = initialCall.isStream
|
||||
}
|
||||
|
||||
self.stateValue = PresentationGroupCallState.initialValue(myPeerId: self.joinAsPeerId, title: initialCall?.title, scheduleTimestamp: initialCall?.scheduleTimestamp, subscribedToScheduled: initialCall?.subscribedToScheduled ?? false)
|
||||
self.statePromise = ValuePromise(self.stateValue)
|
||||
|
||||
@ -678,6 +676,7 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
|
||||
self.isVideoEnabled = true
|
||||
self.hasVideo = false
|
||||
self.hasScreencast = false
|
||||
self.isStream = isStream
|
||||
|
||||
var didReceiveAudioOutputs = false
|
||||
|
||||
@ -1235,6 +1234,7 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
|
||||
totalCount: 0,
|
||||
isVideoEnabled: callInfo.isVideoEnabled,
|
||||
unmutedVideoLimit: callInfo.unmutedVideoLimit,
|
||||
isStream: callInfo.isStream,
|
||||
version: 0
|
||||
),
|
||||
previousServiceState: nil
|
||||
@ -3002,7 +3002,6 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
|
||||
|
||||
if let value = value {
|
||||
strongSelf.initialCall = EngineGroupCallDescription(id: value.id, accessHash: value.accessHash, title: value.title, scheduleTimestamp: nil, subscribedToScheduled: false, isStream: value.isStream)
|
||||
strongSelf.isStream = value.isStream
|
||||
|
||||
strongSelf.updateSessionState(internalState: .active(value), audioSessionControl: strongSelf.audioSessionControl)
|
||||
} else {
|
||||
|
@ -161,7 +161,7 @@ public final class CachedChannelData: CachedPeerData {
|
||||
public var title: String?
|
||||
public var scheduleTimestamp: Int32?
|
||||
public var subscribedToScheduled: Bool
|
||||
public var isStream: Bool
|
||||
public var isStream: Bool?
|
||||
|
||||
public init(
|
||||
id: Int64,
|
||||
@ -169,7 +169,7 @@ public final class CachedChannelData: CachedPeerData {
|
||||
title: String?,
|
||||
scheduleTimestamp: Int32?,
|
||||
subscribedToScheduled: Bool,
|
||||
isStream: Bool
|
||||
isStream: Bool?
|
||||
) {
|
||||
self.id = id
|
||||
self.accessHash = accessHash
|
||||
@ -185,7 +185,7 @@ public final class CachedChannelData: CachedPeerData {
|
||||
self.title = decoder.decodeOptionalStringForKey("title")
|
||||
self.scheduleTimestamp = decoder.decodeOptionalInt32ForKey("scheduleTimestamp")
|
||||
self.subscribedToScheduled = decoder.decodeBoolForKey("subscribed", orElse: false)
|
||||
self.isStream = decoder.decodeBoolForKey("isStream", orElse: false)
|
||||
self.isStream = decoder.decodeOptionalBoolForKey("isStream_v2")
|
||||
}
|
||||
|
||||
public func encode(_ encoder: PostboxEncoder) {
|
||||
@ -202,7 +202,11 @@ public final class CachedChannelData: CachedPeerData {
|
||||
encoder.encodeNil(forKey: "scheduleTimestamp")
|
||||
}
|
||||
encoder.encodeBool(self.subscribedToScheduled, forKey: "subscribed")
|
||||
encoder.encodeBool(self.isStream, forKey: "isStream")
|
||||
if let isStream = self.isStream {
|
||||
encoder.encodeBool(isStream, forKey: "isStream")
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "isStream")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -342,17 +342,17 @@ public enum GetGroupCallParticipantsError {
|
||||
}
|
||||
|
||||
func _internal_getGroupCallParticipants(account: Account, callId: Int64, accessHash: Int64, offset: String, ssrcs: [UInt32], limit: Int32, sortAscending: Bool?) -> Signal<GroupCallParticipantsContext.State, GetGroupCallParticipantsError> {
|
||||
let sortAscendingValue: Signal<(Bool, Int32?, Bool, GroupCallParticipantsContext.State.DefaultParticipantsAreMuted?, Bool, Int), GetGroupCallParticipantsError>
|
||||
let sortAscendingValue: Signal<(Bool, Int32?, Bool, GroupCallParticipantsContext.State.DefaultParticipantsAreMuted?, Bool, Int, Bool), GetGroupCallParticipantsError>
|
||||
|
||||
sortAscendingValue = _internal_getCurrentGroupCall(account: account, callId: callId, accessHash: accessHash)
|
||||
|> mapError { _ -> GetGroupCallParticipantsError in
|
||||
return .generic
|
||||
}
|
||||
|> mapToSignal { result -> Signal<(Bool, Int32?, Bool, GroupCallParticipantsContext.State.DefaultParticipantsAreMuted?, Bool, Int), GetGroupCallParticipantsError> in
|
||||
|> mapToSignal { result -> Signal<(Bool, Int32?, Bool, GroupCallParticipantsContext.State.DefaultParticipantsAreMuted?, Bool, Int, Bool), GetGroupCallParticipantsError> in
|
||||
guard let result = result else {
|
||||
return .fail(.generic)
|
||||
}
|
||||
return .single((sortAscending ?? result.info.sortAscending, result.info.scheduleTimestamp, result.info.subscribedToScheduled, result.info.defaultParticipantsAreMuted, result.info.isVideoEnabled, result.info.unmutedVideoLimit))
|
||||
return .single((sortAscending ?? result.info.sortAscending, result.info.scheduleTimestamp, result.info.subscribedToScheduled, result.info.defaultParticipantsAreMuted, result.info.isVideoEnabled, result.info.unmutedVideoLimit, result.info.isStream))
|
||||
}
|
||||
|
||||
return combineLatest(
|
||||
@ -369,7 +369,7 @@ func _internal_getGroupCallParticipants(account: Account, callId: Int64, accessH
|
||||
let version: Int32
|
||||
let nextParticipantsFetchOffset: String?
|
||||
|
||||
let (sortAscendingValue, scheduleTimestamp, subscribedToScheduled, defaultParticipantsAreMuted, isVideoEnabled, unmutedVideoLimit) = sortAscendingAndScheduleTimestamp
|
||||
let (sortAscendingValue, scheduleTimestamp, subscribedToScheduled, defaultParticipantsAreMuted, isVideoEnabled, unmutedVideoLimit, isStream) = sortAscendingAndScheduleTimestamp
|
||||
|
||||
switch result {
|
||||
case let .groupParticipants(count, participants, nextOffset, chats, users, apiVersion):
|
||||
@ -423,6 +423,7 @@ func _internal_getGroupCallParticipants(account: Account, callId: Int64, accessH
|
||||
totalCount: totalCount,
|
||||
isVideoEnabled: isVideoEnabled,
|
||||
unmutedVideoLimit: unmutedVideoLimit,
|
||||
isStream: isStream,
|
||||
version: version
|
||||
)
|
||||
}
|
||||
@ -1047,6 +1048,7 @@ public final class GroupCallParticipantsContext {
|
||||
public var totalCount: Int
|
||||
public var isVideoEnabled: Bool
|
||||
public var unmutedVideoLimit: Int
|
||||
public var isStream: Bool
|
||||
public var version: Int32
|
||||
|
||||
public mutating func mergeActivity(from other: State, myPeerId: PeerId?, previousMyPeerId: PeerId?, mergeActivityTimestamps: Bool) {
|
||||
@ -1081,6 +1083,7 @@ public final class GroupCallParticipantsContext {
|
||||
totalCount: Int,
|
||||
isVideoEnabled: Bool,
|
||||
unmutedVideoLimit: Int,
|
||||
isStream: Bool,
|
||||
version: Int32
|
||||
) {
|
||||
self.participants = participants
|
||||
@ -1096,6 +1099,7 @@ public final class GroupCallParticipantsContext {
|
||||
self.totalCount = totalCount
|
||||
self.isVideoEnabled = isVideoEnabled
|
||||
self.unmutedVideoLimit = unmutedVideoLimit
|
||||
self.isStream = isStream
|
||||
self.version = version
|
||||
}
|
||||
}
|
||||
@ -1398,6 +1402,7 @@ public final class GroupCallParticipantsContext {
|
||||
totalCount: strongSelf.stateValue.state.totalCount,
|
||||
isVideoEnabled: strongSelf.stateValue.state.isVideoEnabled,
|
||||
unmutedVideoLimit: strongSelf.stateValue.state.unmutedVideoLimit,
|
||||
isStream: strongSelf.stateValue.state.isStream,
|
||||
version: strongSelf.stateValue.state.version
|
||||
),
|
||||
overlayState: strongSelf.stateValue.overlayState
|
||||
@ -1471,6 +1476,14 @@ public final class GroupCallParticipantsContext {
|
||||
}
|
||||
}
|
||||
|
||||
public func removeLocalPeerId() {
|
||||
var state = self.stateValue.state
|
||||
|
||||
state.participants.removeAll(where: { $0.peer.id == self.myPeerId })
|
||||
|
||||
self.stateValue.state = state
|
||||
}
|
||||
|
||||
private func takeNextActivityRank() -> Int {
|
||||
let value = self.serviceState.nextActivityRank
|
||||
self.serviceState.nextActivityRank += 1
|
||||
@ -1537,6 +1550,7 @@ public final class GroupCallParticipantsContext {
|
||||
totalCount: strongSelf.stateValue.state.totalCount,
|
||||
isVideoEnabled: strongSelf.stateValue.state.isVideoEnabled,
|
||||
unmutedVideoLimit: strongSelf.stateValue.state.unmutedVideoLimit,
|
||||
isStream: strongSelf.stateValue.state.isStream,
|
||||
version: strongSelf.stateValue.state.version
|
||||
),
|
||||
overlayState: strongSelf.stateValue.overlayState
|
||||
@ -1758,6 +1772,7 @@ public final class GroupCallParticipantsContext {
|
||||
let scheduleTimestamp = strongSelf.stateValue.state.scheduleTimestamp
|
||||
let subscribedToScheduled = strongSelf.stateValue.state.subscribedToScheduled
|
||||
let isVideoEnabled = strongSelf.stateValue.state.isVideoEnabled
|
||||
let isStream = strongSelf.stateValue.state.isStream
|
||||
let unmutedVideoLimit = strongSelf.stateValue.state.unmutedVideoLimit
|
||||
|
||||
updatedParticipants.sort(by: { GroupCallParticipantsContext.Participant.compare(lhs: $0, rhs: $1, sortAscending: strongSelf.stateValue.state.sortAscending) })
|
||||
@ -1777,6 +1792,7 @@ public final class GroupCallParticipantsContext {
|
||||
totalCount: updatedTotalCount,
|
||||
isVideoEnabled: isVideoEnabled,
|
||||
unmutedVideoLimit: unmutedVideoLimit,
|
||||
isStream: isStream,
|
||||
version: update.version
|
||||
),
|
||||
overlayState: updatedOverlayState
|
||||
|
@ -6,7 +6,7 @@ public final class EngineGroupCallDescription {
|
||||
public let title: String?
|
||||
public let scheduleTimestamp: Int32?
|
||||
public let subscribedToScheduled: Bool
|
||||
public let isStream: Bool
|
||||
public let isStream: Bool?
|
||||
|
||||
public init(
|
||||
id: Int64,
|
||||
@ -14,7 +14,7 @@ public final class EngineGroupCallDescription {
|
||||
title: String?,
|
||||
scheduleTimestamp: Int32?,
|
||||
subscribedToScheduled: Bool,
|
||||
isStream: Bool
|
||||
isStream: Bool?
|
||||
) {
|
||||
self.id = id
|
||||
self.accessHash = accessHash
|
||||
|
@ -349,7 +349,7 @@ func _internal_fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId rawPee
|
||||
if let inputCall = chatFullCall {
|
||||
switch inputCall {
|
||||
case let .inputGroupCall(id, accessHash):
|
||||
updatedActiveCall = CachedChannelData.ActiveCall(id: id, accessHash: accessHash, title: previous.activeCall?.title, scheduleTimestamp: previous.activeCall?.scheduleTimestamp, subscribedToScheduled: previous.activeCall?.subscribedToScheduled ?? false, isStream: previous.activeCall?.isStream ?? false)
|
||||
updatedActiveCall = CachedChannelData.ActiveCall(id: id, accessHash: accessHash, title: previous.activeCall?.title, scheduleTimestamp: previous.activeCall?.scheduleTimestamp, subscribedToScheduled: previous.activeCall?.subscribedToScheduled ?? false, isStream: previous.activeCall?.isStream)
|
||||
}
|
||||
}
|
||||
|
||||
@ -568,7 +568,7 @@ func _internal_fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId rawPee
|
||||
if let inputCall = inputCall {
|
||||
switch inputCall {
|
||||
case let .inputGroupCall(id, accessHash):
|
||||
updatedActiveCall = CachedChannelData.ActiveCall(id: id, accessHash: accessHash, title: previous.activeCall?.title, scheduleTimestamp: previous.activeCall?.scheduleTimestamp, subscribedToScheduled: previous.activeCall?.subscribedToScheduled ?? false, isStream: previous.activeCall?.isStream ?? false)
|
||||
updatedActiveCall = CachedChannelData.ActiveCall(id: id, accessHash: accessHash, title: previous.activeCall?.title, scheduleTimestamp: previous.activeCall?.scheduleTimestamp, subscribedToScheduled: previous.activeCall?.subscribedToScheduled ?? false, isStream: previous.activeCall?.isStream)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user