This commit is contained in:
Isaac 2025-11-05 22:36:17 +04:00
parent 16cd9b3c29
commit 11ed074079
7 changed files with 30 additions and 7 deletions

View file

@ -216,8 +216,14 @@ public struct PresentationGroupCallState: Equatable {
case muted
}
public enum ConnectionMode {
case rtc
case stream
}
public var myPeerId: EnginePeer.Id
public var networkState: NetworkState
public var connectionMode: ConnectionMode
public var canManageCall: Bool
public var adminIds: Set<EnginePeer.Id>
public var muteState: GroupCallParticipantsContext.Participant.MuteState?
@ -238,6 +244,7 @@ public struct PresentationGroupCallState: Equatable {
public init(
myPeerId: EnginePeer.Id,
networkState: NetworkState,
connectionMode: ConnectionMode,
canManageCall: Bool,
adminIds: Set<EnginePeer.Id>,
muteState: GroupCallParticipantsContext.Participant.MuteState?,
@ -257,6 +264,7 @@ public struct PresentationGroupCallState: Equatable {
) {
self.myPeerId = myPeerId
self.networkState = networkState
self.connectionMode = connectionMode
self.canManageCall = canManageCall
self.adminIds = adminIds
self.muteState = muteState

View file

@ -24,6 +24,7 @@ private extension PresentationGroupCallState {
return PresentationGroupCallState(
myPeerId: myPeerId,
networkState: .connecting,
connectionMode: .rtc,
canManageCall: false,
adminIds: Set(),
muteState: GroupCallParticipantsContext.Participant.MuteState(canUnmute: true, mutedByYou: false),
@ -76,7 +77,7 @@ extension CurrentImpl {
case let .call(callContext):
return callContext.networkState
case .mediaStream, .externalMediaStream:
return .single(OngoingGroupCallContext.NetworkState(isConnected: true, isTransitioningFromBroadcastToRtc: false))
return .single(OngoingGroupCallContext.NetworkState(isConnected: true, isTransitioningFromBroadcastToRtc: false, isBroadcast: true))
}
}
@ -2148,10 +2149,19 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
} else {
mappedState = .connecting
}
let mappedMode: PresentationGroupCallState.ConnectionMode
if state.isBroadcast {
mappedMode = .stream
} else {
mappedMode = .rtc
}
let wasConnecting = self.stateValue.networkState == .connecting
if self.stateValue.networkState != mappedState {
self.stateValue.networkState = mappedState
if self.stateValue.networkState != mappedState || self.stateValue.connectionMode != mappedMode {
var stateValue = self.stateValue
stateValue.networkState = mappedState
stateValue.connectionMode = mappedMode
self.stateValue = stateValue
}
let isConnecting = mappedState == .connecting

View file

@ -1204,6 +1204,7 @@ final class VideoChatScreenComponent: Component {
let callState = PresentationGroupCallState(
myPeerId: accountPeerId,
networkState: mappedNetworkState,
connectionMode: .rtc,
canManageCall: false,
adminIds: Set([accountPeerId, conferenceSourcePeerId]),
muteState: isMuted ? GroupCallParticipantsContext.Participant.MuteState(canUnmute: true, mutedByYou: true) : nil,

View file

@ -1113,7 +1113,7 @@ final class StoryItemContentComponent: Component {
areMessagesEnabled: state.messagesAreEnabled,
minMessagePrice: state.sendPaidMessageStars,
isAdmin: state.canManageCall,
isUnifiedStream: state.isUnifiedStream
isUnifiedStream: state.connectionMode != .rtc
)
if self.mediaStreamCallState != mappedState {
self.mediaStreamCallState = mappedState

View file

@ -260,10 +260,12 @@ public final class OngoingGroupCallContext {
public struct NetworkState: Equatable {
public var isConnected: Bool
public var isTransitioningFromBroadcastToRtc: Bool
public var isBroadcast: Bool
public init(isConnected: Bool, isTransitioningFromBroadcastToRtc: Bool) {
public init(isConnected: Bool, isTransitioningFromBroadcastToRtc: Bool, isBroadcast: Bool) {
self.isConnected = isConnected
self.isTransitioningFromBroadcastToRtc = isTransitioningFromBroadcastToRtc
self.isBroadcast = isBroadcast
}
}
@ -481,7 +483,7 @@ public final class OngoingGroupCallContext {
#endif
let joinPayload = Promise<(String, UInt32)>()
let networkState = ValuePromise<NetworkState>(NetworkState(isConnected: false, isTransitioningFromBroadcastToRtc: false), ignoreRepeated: true)
let networkState = ValuePromise<NetworkState>(NetworkState(isConnected: false, isTransitioningFromBroadcastToRtc: false, isBroadcast: false), ignoreRepeated: true)
let isMuted = ValuePromise<Bool>(true, ignoreRepeated: true)
let isNoiseSuppressionEnabled = ValuePromise<Bool>(true, ignoreRepeated: true)
let audioLevels = ValuePipe<[(AudioLevelKey, Float, Bool)]>()
@ -787,7 +789,7 @@ public final class OngoingGroupCallContext {
guard let strongSelf = self else {
return
}
strongSelf.networkState.set(NetworkState(isConnected: state.isConnected, isTransitioningFromBroadcastToRtc: state.isTransitioningFromBroadcastToRtc))
strongSelf.networkState.set(NetworkState(isConnected: state.isConnected, isTransitioningFromBroadcastToRtc: state.isTransitioningFromBroadcastToRtc, isBroadcast: state.isBroadcast))
}
}

View file

@ -322,6 +322,7 @@ typedef NS_ENUM(int32_t, OngoingCallDataSavingWebrtc) {
typedef struct {
bool isConnected;
bool isTransitioningFromBroadcastToRtc;
bool isBroadcast;
} GroupCallNetworkState;
typedef NS_ENUM(int32_t, OngoingGroupCallMediaChannelType) {

View file

@ -2484,6 +2484,7 @@ encryptDecrypt:(NSData * _Nullable (^ _Nullable)(NSData * _Nonnull, int64_t, boo
GroupCallNetworkState mappedState;
mappedState.isConnected = networkState.isConnected;
mappedState.isTransitioningFromBroadcastToRtc = networkState.isTransitioningFromBroadcastToRtc;
mappedState.isBroadcast = networkState.connectionMode == tgcalls::GroupConnectionMode::GroupConnectionModeBroadcast;
networkStateUpdated(mappedState);
}];
},