mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios
This commit is contained in:
commit
6d3df54eef
@ -758,21 +758,25 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
|
||||
return
|
||||
}
|
||||
var result: [(PeerId, Float)] = []
|
||||
for (ssrc, level) in levels {
|
||||
if let peerId = strongSelf.ssrcMapping[ssrc] {
|
||||
var myLevel: Float = 0.0
|
||||
for (ssrcKey, level) in levels {
|
||||
var peerId: PeerId?
|
||||
switch ssrcKey {
|
||||
case .local:
|
||||
peerId = strongSelf.accountContext.account.peerId
|
||||
case let .source(ssrc):
|
||||
peerId = strongSelf.ssrcMapping[ssrc]
|
||||
}
|
||||
if let peerId = peerId {
|
||||
if case .local = ssrcKey {
|
||||
myLevel = level
|
||||
}
|
||||
result.append((peerId, level))
|
||||
}
|
||||
}
|
||||
strongSelf.speakingParticipantsContext.update(levels: result)
|
||||
}))
|
||||
|
||||
self.myAudioLevelDisposable.set((callContext.myAudioLevel
|
||||
|> deliverOnMainQueue).start(next: { [weak self] level in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
|
||||
let mappedLevel = level * 1.5
|
||||
let mappedLevel = myLevel * 1.5
|
||||
|
||||
strongSelf.myAudioLevelPipe.putNext(mappedLevel)
|
||||
strongSelf.processMyAudioLevel(level: mappedLevel)
|
||||
|
@ -1543,20 +1543,6 @@ public final class VoiceChatController: ViewController {
|
||||
}
|
||||
|
||||
private func updateMembers(muteState: GroupCallParticipantsContext.Participant.MuteState?, groupMembers: [RenderedChannelParticipant], callMembers: [GroupCallParticipantsContext.Participant], invitedPeers: [Peer], speakingPeers: Set<PeerId>) {
|
||||
var sortedCallMembers = callMembers
|
||||
sortedCallMembers.sort()
|
||||
|
||||
/*for i in 0 ..< sortedCallMembers.count {
|
||||
if sortedCallMembers[i].peer.id == self.context.account.peerId {
|
||||
let member = sortedCallMembers[i]
|
||||
sortedCallMembers.remove(at: i)
|
||||
sortedCallMembers.insert(member, at: 0)
|
||||
break
|
||||
}
|
||||
}*/
|
||||
|
||||
//assert(sortedCallMembers == callMembers)
|
||||
|
||||
self.currentGroupMembers = groupMembers
|
||||
self.currentCallMembers = callMembers
|
||||
self.currentSpeakingPeers = speakingPeers
|
||||
|
@ -719,14 +719,14 @@ public final class GroupCallParticipantsContext {
|
||||
|
||||
if updated {
|
||||
updatedParticipants.sort()
|
||||
for i in 0 ..< updatedParticipants.count {
|
||||
/*for i in 0 ..< updatedParticipants.count {
|
||||
if updatedParticipants[i].peer.id == strongSelf.account.peerId {
|
||||
let member = updatedParticipants[i]
|
||||
updatedParticipants.remove(at: i)
|
||||
updatedParticipants.insert(member, at: 0)
|
||||
break
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
strongSelf.stateValue = InternalState(
|
||||
state: State(
|
||||
@ -803,14 +803,14 @@ public final class GroupCallParticipantsContext {
|
||||
|
||||
if updated {
|
||||
updatedParticipants.sort()
|
||||
for i in 0 ..< updatedParticipants.count {
|
||||
/*for i in 0 ..< updatedParticipants.count {
|
||||
if updatedParticipants[i].peer.id == strongSelf.account.peerId {
|
||||
let member = updatedParticipants[i]
|
||||
updatedParticipants.remove(at: i)
|
||||
updatedParticipants.insert(member, at: 0)
|
||||
break
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
strongSelf.stateValue = InternalState(
|
||||
state: State(
|
||||
@ -933,14 +933,14 @@ public final class GroupCallParticipantsContext {
|
||||
let defaultParticipantsAreMuted = strongSelf.stateValue.state.defaultParticipantsAreMuted
|
||||
|
||||
updatedParticipants.sort()
|
||||
for i in 0 ..< updatedParticipants.count {
|
||||
/*for i in 0 ..< updatedParticipants.count {
|
||||
if updatedParticipants[i].peer.id == strongSelf.account.peerId {
|
||||
let member = updatedParticipants[i]
|
||||
updatedParticipants.remove(at: i)
|
||||
updatedParticipants.insert(member, at: 0)
|
||||
break
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
strongSelf.stateValue = InternalState(
|
||||
state: State(
|
||||
|
@ -32,6 +32,11 @@ public final class OngoingGroupCallContext {
|
||||
case connected
|
||||
}
|
||||
|
||||
public enum AudioLevelKey: Hashable {
|
||||
case local
|
||||
case source(UInt32)
|
||||
}
|
||||
|
||||
private final class Impl {
|
||||
let queue: Queue
|
||||
let context: GroupCallThreadLocalContext
|
||||
@ -41,15 +46,13 @@ public final class OngoingGroupCallContext {
|
||||
let joinPayload = Promise<(String, UInt32)>()
|
||||
let networkState = ValuePromise<NetworkState>(.connecting, ignoreRepeated: true)
|
||||
let isMuted = ValuePromise<Bool>(true, ignoreRepeated: true)
|
||||
let audioLevels = ValuePipe<[(UInt32, Float)]>()
|
||||
let myAudioLevel = ValuePipe<Float>()
|
||||
let audioLevels = ValuePipe<[(AudioLevelKey, Float)]>()
|
||||
|
||||
init(queue: Queue, inputDeviceId: String, outputDeviceId: String) {
|
||||
self.queue = queue
|
||||
|
||||
var networkStateUpdatedImpl: ((GroupCallNetworkState) -> Void)?
|
||||
var audioLevelsUpdatedImpl: (([NSNumber]) -> Void)?
|
||||
var myAudioLevelUpdatedImpl: ((Float) -> Void)?
|
||||
|
||||
self.context = GroupCallThreadLocalContext(
|
||||
queue: ContextQueueImpl(queue: queue),
|
||||
@ -59,9 +62,6 @@ public final class OngoingGroupCallContext {
|
||||
audioLevelsUpdated: { levels in
|
||||
audioLevelsUpdatedImpl?(levels)
|
||||
},
|
||||
myAudioLevelUpdated: { level in
|
||||
myAudioLevelUpdatedImpl?(level)
|
||||
},
|
||||
inputDeviceId: inputDeviceId,
|
||||
outputDeviceId: outputDeviceId
|
||||
)
|
||||
@ -88,10 +88,17 @@ public final class OngoingGroupCallContext {
|
||||
|
||||
let audioLevels = self.audioLevels
|
||||
audioLevelsUpdatedImpl = { levels in
|
||||
var mappedLevels: [(UInt32, Float)] = []
|
||||
var mappedLevels: [(AudioLevelKey, Float)] = []
|
||||
var i = 0
|
||||
while i < levels.count {
|
||||
mappedLevels.append((levels[i].uint32Value, levels[i + 1].floatValue))
|
||||
let uintValue = levels[i].uint32Value
|
||||
let key: AudioLevelKey
|
||||
if uintValue == 0 {
|
||||
key = .local
|
||||
} else {
|
||||
key = .source(uintValue)
|
||||
}
|
||||
mappedLevels.append((key, levels[i + 1].floatValue))
|
||||
i += 2
|
||||
}
|
||||
queue.async {
|
||||
@ -99,13 +106,6 @@ public final class OngoingGroupCallContext {
|
||||
}
|
||||
}
|
||||
|
||||
let myAudioLevel = self.myAudioLevel
|
||||
myAudioLevelUpdatedImpl = { level in
|
||||
queue.async {
|
||||
myAudioLevel.putNext(level)
|
||||
}
|
||||
}
|
||||
|
||||
self.context.emitJoinPayload({ [weak self] payload, ssrc in
|
||||
queue.async {
|
||||
guard let strongSelf = self else {
|
||||
@ -177,7 +177,7 @@ public final class OngoingGroupCallContext {
|
||||
}
|
||||
}
|
||||
|
||||
public var audioLevels: Signal<[(UInt32, Float)], NoError> {
|
||||
public var audioLevels: Signal<[(AudioLevelKey, Float)], NoError> {
|
||||
return Signal { subscriber in
|
||||
let disposable = MetaDisposable()
|
||||
self.impl.with { impl in
|
||||
@ -189,18 +189,6 @@ public final class OngoingGroupCallContext {
|
||||
}
|
||||
}
|
||||
|
||||
public var myAudioLevel: Signal<Float, NoError> {
|
||||
return Signal { subscriber in
|
||||
let disposable = MetaDisposable()
|
||||
self.impl.with { impl in
|
||||
disposable.set(impl.myAudioLevel.signal().start(next: { value in
|
||||
subscriber.putNext(value)
|
||||
}))
|
||||
}
|
||||
return disposable
|
||||
}
|
||||
}
|
||||
|
||||
public var isMuted: Signal<Bool, NoError> {
|
||||
return Signal { subscriber in
|
||||
let disposable = MetaDisposable()
|
||||
|
@ -158,7 +158,7 @@ typedef NS_ENUM(int32_t, GroupCallNetworkState) {
|
||||
|
||||
@interface GroupCallThreadLocalContext : NSObject
|
||||
|
||||
- (instancetype _Nonnull)initWithQueue:(id<OngoingCallThreadLocalContextQueueWebrtc> _Nonnull)queue networkStateUpdated:(void (^ _Nonnull)(GroupCallNetworkState))networkStateUpdated audioLevelsUpdated:(void (^ _Nonnull)(NSArray<NSNumber *> * _Nonnull))audioLevelsUpdated myAudioLevelUpdated:(void (^ _Nonnull)(float))myAudioLevelUpdated inputDeviceId:(NSString * _Nonnull)inputDeviceId outputDeviceId:(NSString * _Nonnull)outputDeviceId;
|
||||
- (instancetype _Nonnull)initWithQueue:(id<OngoingCallThreadLocalContextQueueWebrtc> _Nonnull)queue networkStateUpdated:(void (^ _Nonnull)(GroupCallNetworkState))networkStateUpdated audioLevelsUpdated:(void (^ _Nonnull)(NSArray<NSNumber *> * _Nonnull))audioLevelsUpdated inputDeviceId:(NSString * _Nonnull)inputDeviceId outputDeviceId:(NSString * _Nonnull)outputDeviceId;
|
||||
|
||||
- (void)stop;
|
||||
|
||||
|
@ -807,7 +807,7 @@ static void (*InternalVoipLoggingFunction)(NSString *) = NULL;
|
||||
|
||||
@implementation GroupCallThreadLocalContext
|
||||
|
||||
- (instancetype _Nonnull)initWithQueue:(id<OngoingCallThreadLocalContextQueueWebrtc> _Nonnull)queue networkStateUpdated:(void (^ _Nonnull)(GroupCallNetworkState))networkStateUpdated audioLevelsUpdated:(void (^ _Nonnull)(NSArray<NSNumber *> * _Nonnull))audioLevelsUpdated myAudioLevelUpdated:(void (^ _Nonnull)(float))myAudioLevelUpdated inputDeviceId:(NSString * _Nonnull)inputDeviceId outputDeviceId:(NSString * _Nonnull)outputDeviceId {
|
||||
- (instancetype _Nonnull)initWithQueue:(id<OngoingCallThreadLocalContextQueueWebrtc> _Nonnull)queue networkStateUpdated:(void (^ _Nonnull)(GroupCallNetworkState))networkStateUpdated audioLevelsUpdated:(void (^ _Nonnull)(NSArray<NSNumber *> * _Nonnull))audioLevelsUpdated inputDeviceId:(NSString * _Nonnull)inputDeviceId outputDeviceId:(NSString * _Nonnull)outputDeviceId {
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
_queue = queue;
|
||||
@ -833,9 +833,6 @@ static void (*InternalVoipLoggingFunction)(NSString *) = NULL;
|
||||
}
|
||||
audioLevelsUpdated(result);
|
||||
},
|
||||
.myAudioLevelUpdated = [myAudioLevelUpdated](float level) {
|
||||
myAudioLevelUpdated(level);
|
||||
},
|
||||
.initialInputDeviceId = inputDeviceId.UTF8String,
|
||||
.initialOutputDeviceId = outputDeviceId.UTF8String
|
||||
}));
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 7f2022780754c0b3a23f8ce8a940042101120077
|
||||
Subproject commit 7c6b9e7e74fd3f7197df7632d3f8170de1cb23f5
|
Loading…
x
Reference in New Issue
Block a user