mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Voice chat improvements
This commit is contained in:
parent
17fad2b0e0
commit
e1d40e7ef4
@ -2687,6 +2687,7 @@ Unused sets are archived when you add more.";
|
|||||||
"Channel.AdminLogFilter.EventsEditedMessages" = "Edited Messages";
|
"Channel.AdminLogFilter.EventsEditedMessages" = "Edited Messages";
|
||||||
"Channel.AdminLogFilter.EventsPinned" = "Pinned Messages";
|
"Channel.AdminLogFilter.EventsPinned" = "Pinned Messages";
|
||||||
"Channel.AdminLogFilter.EventsLeaving" = "Members Removed";
|
"Channel.AdminLogFilter.EventsLeaving" = "Members Removed";
|
||||||
|
"Channel.AdminLogFilter.EventsCalls" = "Vocie Chats";
|
||||||
"Channel.AdminLogFilter.AdminsTitle" = "ADMINS";
|
"Channel.AdminLogFilter.AdminsTitle" = "ADMINS";
|
||||||
"Channel.AdminLogFilter.AdminsAll" = "All Admins";
|
"Channel.AdminLogFilter.AdminsAll" = "All Admins";
|
||||||
|
|
||||||
|
@ -132,6 +132,7 @@ public protocol PresentationCall: class {
|
|||||||
var peer: Peer? { get }
|
var peer: Peer? { get }
|
||||||
|
|
||||||
var state: Signal<PresentationCallState, NoError> { get }
|
var state: Signal<PresentationCallState, NoError> { get }
|
||||||
|
var audioLevel: Signal<Float, NoError> { get }
|
||||||
|
|
||||||
var isMuted: Signal<Bool, NoError> { get }
|
var isMuted: Signal<Bool, NoError> { get }
|
||||||
|
|
||||||
|
@ -244,6 +244,13 @@ public class CallStatusBarNodeImpl: CallStatusBarNode {
|
|||||||
strongSelf.update()
|
strongSelf.update()
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
self.audioLevelDisposable.set((call.audioLevel
|
||||||
|
|> deliverOnMainQueue).start(next: { [weak self] audioLevel in
|
||||||
|
guard let strongSelf = self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
strongSelf.backgroundNode.audioLevel = audioLevel
|
||||||
|
}))
|
||||||
case let .groupCall(sharedContext, account, call):
|
case let .groupCall(sharedContext, account, call):
|
||||||
self.presentationData = sharedContext.currentPresentationData.with { $0 }
|
self.presentationData = sharedContext.currentPresentationData.with { $0 }
|
||||||
self.presentationDataDisposable.set((sharedContext.presentationData
|
self.presentationDataDisposable.set((sharedContext.presentationData
|
||||||
|
@ -93,7 +93,7 @@ final class PresentationCallToneRenderer {
|
|||||||
var takenCount = 0
|
var takenCount = 0
|
||||||
while takenCount < frameSize {
|
while takenCount < frameSize {
|
||||||
let dataOffset = (takeOffset + takenCount) % toneData.count
|
let dataOffset = (takeOffset + takenCount) % toneData.count
|
||||||
let dataCount = min(frameSize, toneData.count - dataOffset)
|
let dataCount = min(frameSize - takenCount, toneData.count - dataOffset)
|
||||||
//print("take from \(dataOffset) count: \(dataCount)")
|
//print("take from \(dataOffset) count: \(dataCount)")
|
||||||
memcpy(bytes.advanced(by: takenCount), dataBytes.advanced(by: dataOffset), dataCount)
|
memcpy(bytes.advanced(by: takenCount), dataBytes.advanced(by: dataOffset), dataCount)
|
||||||
takenCount += dataCount
|
takenCount += dataCount
|
||||||
@ -200,6 +200,7 @@ public final class PresentationCallImpl: PresentationCall {
|
|||||||
private var requestedVideoAspect: Float?
|
private var requestedVideoAspect: Float?
|
||||||
private var reception: Int32?
|
private var reception: Int32?
|
||||||
private var receptionDisposable: Disposable?
|
private var receptionDisposable: Disposable?
|
||||||
|
private var audioLevelDisposable: Disposable?
|
||||||
private var reportedIncomingCall = false
|
private var reportedIncomingCall = false
|
||||||
|
|
||||||
private var batteryLevelDisposable: Disposable?
|
private var batteryLevelDisposable: Disposable?
|
||||||
@ -219,6 +220,11 @@ public final class PresentationCallImpl: PresentationCall {
|
|||||||
return self.statePromise.get()
|
return self.statePromise.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private let audioLevelPromise = ValuePromise<Float>(0.0)
|
||||||
|
public var audioLevel: Signal<Float, NoError> {
|
||||||
|
return self.audioLevelPromise.get()
|
||||||
|
}
|
||||||
|
|
||||||
private let isMutedPromise = ValuePromise<Bool>(false)
|
private let isMutedPromise = ValuePromise<Bool>(false)
|
||||||
private var isMutedValue = false
|
private var isMutedValue = false
|
||||||
public var isMuted: Signal<Bool, NoError> {
|
public var isMuted: Signal<Bool, NoError> {
|
||||||
@ -436,6 +442,7 @@ public final class PresentationCallImpl: PresentationCall {
|
|||||||
self.sessionStateDisposable?.dispose()
|
self.sessionStateDisposable?.dispose()
|
||||||
self.ongoingContextStateDisposable?.dispose()
|
self.ongoingContextStateDisposable?.dispose()
|
||||||
self.receptionDisposable?.dispose()
|
self.receptionDisposable?.dispose()
|
||||||
|
self.audioLevelDisposable?.dispose()
|
||||||
self.batteryLevelDisposable?.dispose()
|
self.batteryLevelDisposable?.dispose()
|
||||||
self.audioSessionDisposable?.dispose()
|
self.audioSessionDisposable?.dispose()
|
||||||
|
|
||||||
@ -656,6 +663,13 @@ public final class PresentationCallImpl: PresentationCall {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
self.audioLevelDisposable = (ongoingContext.audioLevel
|
||||||
|
|> deliverOnMainQueue).start(next: { [weak self] level in
|
||||||
|
if let strongSelf = self {
|
||||||
|
strongSelf.audioLevelPromise.set(level)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
func batteryLevelIsLowSignal() -> Signal<Bool, NoError> {
|
func batteryLevelIsLowSignal() -> Signal<Bool, NoError> {
|
||||||
return Signal { subscriber in
|
return Signal { subscriber in
|
||||||
let device = UIDevice.current
|
let device = UIDevice.current
|
||||||
|
@ -578,7 +578,7 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
|
|||||||
switch update {
|
switch update {
|
||||||
case let .state(update):
|
case let .state(update):
|
||||||
for participantUpdate in update.participantUpdates {
|
for participantUpdate in update.participantUpdates {
|
||||||
if participantUpdate.isRemoved {
|
if case .left = participantUpdate.participationStatusChange {
|
||||||
removedSsrc.append(participantUpdate.ssrc)
|
removedSsrc.append(participantUpdate.ssrc)
|
||||||
|
|
||||||
if participantUpdate.peerId == strongSelf.accountContext.account.peerId {
|
if participantUpdate.peerId == strongSelf.accountContext.account.peerId {
|
||||||
@ -590,6 +590,7 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
|
|||||||
if case let .estabilished(_, _, ssrc, _) = strongSelf.internalState, ssrc != participantUpdate.ssrc {
|
if case let .estabilished(_, _, ssrc, _) = strongSelf.internalState, ssrc != participantUpdate.ssrc {
|
||||||
strongSelf._canBeRemoved.set(.single(true))
|
strongSelf._canBeRemoved.set(.single(true))
|
||||||
}
|
}
|
||||||
|
} else if case .joined = participantUpdate.participationStatusChange {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case let .call(isTerminated, _):
|
case let .call(isTerminated, _):
|
||||||
|
@ -614,12 +614,18 @@ public final class GroupCallParticipantsContext {
|
|||||||
public enum Update {
|
public enum Update {
|
||||||
public struct StateUpdate {
|
public struct StateUpdate {
|
||||||
public struct ParticipantUpdate {
|
public struct ParticipantUpdate {
|
||||||
|
public enum ParticipationStatusChange {
|
||||||
|
case none
|
||||||
|
case joined
|
||||||
|
case left
|
||||||
|
}
|
||||||
|
|
||||||
public var peerId: PeerId
|
public var peerId: PeerId
|
||||||
public var ssrc: UInt32
|
public var ssrc: UInt32
|
||||||
public var joinTimestamp: Int32
|
public var joinTimestamp: Int32
|
||||||
public var activityTimestamp: Double?
|
public var activityTimestamp: Double?
|
||||||
public var muteState: Participant.MuteState?
|
public var muteState: Participant.MuteState?
|
||||||
public var isRemoved: Bool
|
public var participationStatusChange: ParticipationStatusChange
|
||||||
}
|
}
|
||||||
|
|
||||||
public var participantUpdates: [ParticipantUpdate]
|
public var participantUpdates: [ParticipantUpdate]
|
||||||
@ -911,7 +917,7 @@ public final class GroupCallParticipantsContext {
|
|||||||
var updatedTotalCount = strongSelf.stateValue.state.totalCount
|
var updatedTotalCount = strongSelf.stateValue.state.totalCount
|
||||||
|
|
||||||
for participantUpdate in update.participantUpdates {
|
for participantUpdate in update.participantUpdates {
|
||||||
if participantUpdate.isRemoved {
|
if case .left = participantUpdate.participationStatusChange {
|
||||||
if let index = updatedParticipants.firstIndex(where: { $0.peer.id == participantUpdate.peerId }) {
|
if let index = updatedParticipants.firstIndex(where: { $0.peer.id == participantUpdate.peerId }) {
|
||||||
updatedParticipants.remove(at: index)
|
updatedParticipants.remove(at: index)
|
||||||
updatedTotalCount = max(0, updatedTotalCount - 1)
|
updatedTotalCount = max(0, updatedTotalCount - 1)
|
||||||
@ -927,7 +933,7 @@ public final class GroupCallParticipantsContext {
|
|||||||
if let index = updatedParticipants.firstIndex(where: { $0.peer.id == participantUpdate.peerId }) {
|
if let index = updatedParticipants.firstIndex(where: { $0.peer.id == participantUpdate.peerId }) {
|
||||||
previousActivityTimestamp = updatedParticipants[index].activityTimestamp
|
previousActivityTimestamp = updatedParticipants[index].activityTimestamp
|
||||||
updatedParticipants.remove(at: index)
|
updatedParticipants.remove(at: index)
|
||||||
} else {
|
} else if case .left = participantUpdate.participationStatusChange {
|
||||||
updatedTotalCount += 1
|
updatedTotalCount += 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1107,13 +1113,24 @@ extension GroupCallParticipantsContext.Update.StateUpdate.ParticipantUpdate {
|
|||||||
muteState = GroupCallParticipantsContext.Participant.MuteState(canUnmute: canUnmute)
|
muteState = GroupCallParticipantsContext.Participant.MuteState(canUnmute: canUnmute)
|
||||||
}
|
}
|
||||||
let isRemoved = (flags & (1 << 1)) != 0
|
let isRemoved = (flags & (1 << 1)) != 0
|
||||||
|
let justJoined = (flags & (1 << 4)) != 0
|
||||||
|
|
||||||
|
let participationStatusChange: GroupCallParticipantsContext.Update.StateUpdate.ParticipantUpdate.ParticipationStatusChange
|
||||||
|
if isRemoved {
|
||||||
|
participationStatusChange = .left
|
||||||
|
} else if justJoined {
|
||||||
|
participationStatusChange = .joined
|
||||||
|
} else {
|
||||||
|
participationStatusChange = .none
|
||||||
|
}
|
||||||
|
|
||||||
self.init(
|
self.init(
|
||||||
peerId: peerId,
|
peerId: peerId,
|
||||||
ssrc: ssrc,
|
ssrc: ssrc,
|
||||||
joinTimestamp: date,
|
joinTimestamp: date,
|
||||||
activityTimestamp: activeDate.flatMap(Double.init),
|
activityTimestamp: activeDate.flatMap(Double.init),
|
||||||
muteState: muteState,
|
muteState: muteState,
|
||||||
isRemoved: isRemoved
|
participationStatusChange: participationStatusChange
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1133,13 +1150,24 @@ extension GroupCallParticipantsContext.Update.StateUpdate {
|
|||||||
muteState = GroupCallParticipantsContext.Participant.MuteState(canUnmute: canUnmute)
|
muteState = GroupCallParticipantsContext.Participant.MuteState(canUnmute: canUnmute)
|
||||||
}
|
}
|
||||||
let isRemoved = (flags & (1 << 1)) != 0
|
let isRemoved = (flags & (1 << 1)) != 0
|
||||||
|
let justJoined = (flags & (1 << 4)) != 0
|
||||||
|
|
||||||
|
let participationStatusChange: GroupCallParticipantsContext.Update.StateUpdate.ParticipantUpdate.ParticipationStatusChange
|
||||||
|
if isRemoved {
|
||||||
|
participationStatusChange = .left
|
||||||
|
} else if justJoined {
|
||||||
|
participationStatusChange = .joined
|
||||||
|
} else {
|
||||||
|
participationStatusChange = .none
|
||||||
|
}
|
||||||
|
|
||||||
participantUpdates.append(GroupCallParticipantsContext.Update.StateUpdate.ParticipantUpdate(
|
participantUpdates.append(GroupCallParticipantsContext.Update.StateUpdate.ParticipantUpdate(
|
||||||
peerId: peerId,
|
peerId: peerId,
|
||||||
ssrc: ssrc,
|
ssrc: ssrc,
|
||||||
joinTimestamp: date,
|
joinTimestamp: date,
|
||||||
activityTimestamp: activeDate.flatMap(Double.init),
|
activityTimestamp: activeDate.flatMap(Double.init),
|
||||||
muteState: muteState,
|
muteState: muteState,
|
||||||
isRemoved: isRemoved
|
participationStatusChange: participationStatusChange
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -293,6 +293,7 @@ private func channelRecentActionsFilterControllerEntries(presentationData: Prese
|
|||||||
([.editMessages], presentationData.strings.Channel_AdminLogFilter_EventsEditedMessages),
|
([.editMessages], presentationData.strings.Channel_AdminLogFilter_EventsEditedMessages),
|
||||||
([.pinnedMessages], presentationData.strings.Channel_AdminLogFilter_EventsPinned),
|
([.pinnedMessages], presentationData.strings.Channel_AdminLogFilter_EventsPinned),
|
||||||
([.leave], presentationData.strings.Channel_AdminLogFilter_EventsLeaving),
|
([.leave], presentationData.strings.Channel_AdminLogFilter_EventsLeaving),
|
||||||
|
([.calls], presentationData.strings.Channel_AdminLogFilter_EventsCalls)
|
||||||
]
|
]
|
||||||
} else {
|
} else {
|
||||||
order = [
|
order = [
|
||||||
|
@ -559,6 +559,11 @@ public final class OngoingCallContext {
|
|||||||
return self.receptionPromise.get()
|
return self.receptionPromise.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private let audioLevelPromise = Promise<Float>(0.0)
|
||||||
|
public var audioLevel: Signal<Float, NoError> {
|
||||||
|
return self.audioLevelPromise.get()
|
||||||
|
}
|
||||||
|
|
||||||
private let audioSessionDisposable = MetaDisposable()
|
private let audioSessionDisposable = MetaDisposable()
|
||||||
private var networkTypeDisposable: Disposable?
|
private var networkTypeDisposable: Disposable?
|
||||||
|
|
||||||
@ -687,6 +692,9 @@ public final class OngoingCallContext {
|
|||||||
context.signalBarsChanged = { signalBars in
|
context.signalBarsChanged = { signalBars in
|
||||||
self?.receptionPromise.set(.single(signalBars))
|
self?.receptionPromise.set(.single(signalBars))
|
||||||
}
|
}
|
||||||
|
context.audioLevelUpdated = { level in
|
||||||
|
self?.audioLevelPromise.set(.single(level))
|
||||||
|
}
|
||||||
|
|
||||||
strongSelf.networkTypeDisposable = (updatedNetworkType
|
strongSelf.networkTypeDisposable = (updatedNetworkType
|
||||||
|> deliverOn(queue)).start(next: { networkType in
|
|> deliverOn(queue)).start(next: { networkType in
|
||||||
|
@ -127,6 +127,7 @@ typedef NS_ENUM(int32_t, OngoingCallDataSavingWebrtc) {
|
|||||||
|
|
||||||
@property (nonatomic, copy) void (^ _Nullable stateChanged)(OngoingCallStateWebrtc, OngoingCallVideoStateWebrtc, OngoingCallRemoteVideoStateWebrtc, OngoingCallRemoteAudioStateWebrtc, OngoingCallRemoteBatteryLevelWebrtc, float);
|
@property (nonatomic, copy) void (^ _Nullable stateChanged)(OngoingCallStateWebrtc, OngoingCallVideoStateWebrtc, OngoingCallRemoteVideoStateWebrtc, OngoingCallRemoteAudioStateWebrtc, OngoingCallRemoteBatteryLevelWebrtc, float);
|
||||||
@property (nonatomic, copy) void (^ _Nullable signalBarsChanged)(int32_t);
|
@property (nonatomic, copy) void (^ _Nullable signalBarsChanged)(int32_t);
|
||||||
|
@property (nonatomic, copy) void (^ _Nullable audioLevelUpdated)(float);
|
||||||
|
|
||||||
- (instancetype _Nonnull)initWithVersion:(NSString * _Nonnull)version queue:(id<OngoingCallThreadLocalContextQueueWebrtc> _Nonnull)queue proxy:(VoipProxyServerWebrtc * _Nullable)proxy networkType:(OngoingCallNetworkTypeWebrtc)networkType dataSaving:(OngoingCallDataSavingWebrtc)dataSaving derivedState:(NSData * _Nonnull)derivedState key:(NSData * _Nonnull)key isOutgoing:(bool)isOutgoing connections:(NSArray<OngoingCallConnectionDescriptionWebrtc *> * _Nonnull)connections maxLayer:(int32_t)maxLayer allowP2P:(BOOL)allowP2P allowTCP:(BOOL)allowTCP enableStunMarking:(BOOL)enableStunMarking logPath:(NSString * _Nonnull)logPath statsLogPath:(NSString * _Nonnull)statsLogPath sendSignalingData:(void (^ _Nonnull)(NSData * _Nonnull))sendSignalingData videoCapturer:(OngoingCallThreadLocalContextVideoCapturer * _Nullable)videoCapturer preferredVideoCodec:(NSString * _Nullable)preferredVideoCodec audioInputDeviceId: (NSString * _Nonnull)audioInputDeviceId;
|
- (instancetype _Nonnull)initWithVersion:(NSString * _Nonnull)version queue:(id<OngoingCallThreadLocalContextQueueWebrtc> _Nonnull)queue proxy:(VoipProxyServerWebrtc * _Nullable)proxy networkType:(OngoingCallNetworkTypeWebrtc)networkType dataSaving:(OngoingCallDataSavingWebrtc)dataSaving derivedState:(NSData * _Nonnull)derivedState key:(NSData * _Nonnull)key isOutgoing:(bool)isOutgoing connections:(NSArray<OngoingCallConnectionDescriptionWebrtc *> * _Nonnull)connections maxLayer:(int32_t)maxLayer allowP2P:(BOOL)allowP2P allowTCP:(BOOL)allowTCP enableStunMarking:(BOOL)enableStunMarking logPath:(NSString * _Nonnull)logPath statsLogPath:(NSString * _Nonnull)statsLogPath sendSignalingData:(void (^ _Nonnull)(NSData * _Nonnull))sendSignalingData videoCapturer:(OngoingCallThreadLocalContextVideoCapturer * _Nullable)videoCapturer preferredVideoCodec:(NSString * _Nullable)preferredVideoCodec audioInputDeviceId: (NSString * _Nonnull)audioInputDeviceId;
|
||||||
|
|
||||||
|
@ -463,6 +463,16 @@ static void (*InternalVoipLoggingFunction)(NSString *) = NULL;
|
|||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
},
|
},
|
||||||
|
.audioLevelUpdated = [weakSelf, queue](float level) {
|
||||||
|
[queue dispatch:^{
|
||||||
|
__strong OngoingCallThreadLocalContextWebrtc *strongSelf = weakSelf;
|
||||||
|
if (strongSelf) {
|
||||||
|
if (strongSelf->_audioLevelUpdated) {
|
||||||
|
strongSelf->_audioLevelUpdated(level);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
},
|
||||||
.remoteMediaStateUpdated = [weakSelf, queue](tgcalls::AudioState audioState, tgcalls::VideoState videoState) {
|
.remoteMediaStateUpdated = [weakSelf, queue](tgcalls::AudioState audioState, tgcalls::VideoState videoState) {
|
||||||
[queue dispatch:^{
|
[queue dispatch:^{
|
||||||
__strong OngoingCallThreadLocalContextWebrtc *strongSelf = weakSelf;
|
__strong OngoingCallThreadLocalContextWebrtc *strongSelf = weakSelf;
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 58f3f89352d164540067e197ad735c0717546172
|
Subproject commit 6ae73f4c388854d86a0ce66bf243561a11d9e719
|
Loading…
x
Reference in New Issue
Block a user