mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios
This commit is contained in:
@@ -167,9 +167,16 @@ public final class PresentationCallImpl: PresentationCall {
|
||||
public let isOutgoing: Bool
|
||||
public let peer: Peer?
|
||||
|
||||
private let serializedData: String?
|
||||
private let dataSaving: VoiceCallDataSaving
|
||||
private let derivedState: VoipDerivedState
|
||||
private let proxyServer: ProxyServerSettings?
|
||||
private let currentNetworkType: NetworkType
|
||||
private let updatedNetworkType: Signal<NetworkType, NoError>
|
||||
|
||||
private var sessionState: CallSession?
|
||||
private var callContextState: OngoingCallContextState?
|
||||
private var ongoingContext: OngoingCallContext
|
||||
private var ongoingContext: OngoingCallContext?
|
||||
private var ongoingContextStateDisposable: Disposable?
|
||||
private var reception: Int32?
|
||||
private var receptionDisposable: Disposable?
|
||||
@@ -198,6 +205,8 @@ public final class PresentationCallImpl: PresentationCall {
|
||||
return self.audioOutputStatePromise.get()
|
||||
}
|
||||
|
||||
private let debugInfoValue = Promise<(String, String)>(("", ""))
|
||||
|
||||
private let canBeRemovedPromise = Promise<Bool>(false)
|
||||
private var didSetCanBeRemoved = false
|
||||
public var canBeRemoved: Signal<Bool, NoError> {
|
||||
@@ -233,7 +242,12 @@ public final class PresentationCallImpl: PresentationCall {
|
||||
self.isOutgoing = isOutgoing
|
||||
self.peer = peer
|
||||
|
||||
self.ongoingContext = OngoingCallContext(account: account, callSessionManager: self.callSessionManager, internalId: self.internalId, proxyServer: proxyServer, initialNetworkType: currentNetworkType, updatedNetworkType: updatedNetworkType, serializedData: serializedData, dataSaving: dataSaving, derivedState: derivedState)
|
||||
self.serializedData = serializedData
|
||||
self.dataSaving = dataSaving
|
||||
self.derivedState = derivedState
|
||||
self.proxyServer = proxyServer
|
||||
self.currentNetworkType = currentNetworkType
|
||||
self.updatedNetworkType = updatedNetworkType
|
||||
|
||||
var didReceiveAudioOutputs = false
|
||||
|
||||
@@ -251,28 +265,6 @@ public final class PresentationCallImpl: PresentationCall {
|
||||
}
|
||||
})
|
||||
|
||||
self.ongoingContextStateDisposable = (self.ongoingContext.state
|
||||
|> deliverOnMainQueue).start(next: { [weak self] contextState in
|
||||
if let strongSelf = self {
|
||||
if let sessionState = strongSelf.sessionState {
|
||||
strongSelf.updateSessionState(sessionState: sessionState, callContextState: contextState, reception: strongSelf.reception, audioSessionControl: strongSelf.audioSessionControl)
|
||||
} else {
|
||||
strongSelf.callContextState = contextState
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
self.receptionDisposable = (self.ongoingContext.reception
|
||||
|> deliverOnMainQueue).start(next: { [weak self] reception in
|
||||
if let strongSelf = self {
|
||||
if let sessionState = strongSelf.sessionState {
|
||||
strongSelf.updateSessionState(sessionState: sessionState, callContextState: strongSelf.callContextState, reception: reception, audioSessionControl: strongSelf.audioSessionControl)
|
||||
} else {
|
||||
strongSelf.reception = reception
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
self.audioSessionDisposable = audioSession.push(audioSessionType: .voiceCall, manualActivate: { [weak self] control in
|
||||
Queue.mainQueue().async {
|
||||
if let strongSelf = self {
|
||||
@@ -443,7 +435,7 @@ public final class PresentationCallImpl: PresentationCall {
|
||||
presentationState = .terminated(id, reason, self.callWasActive && (options.contains(.reportRating) || self.shouldPresentCallRating))
|
||||
case let .requesting(ringing):
|
||||
presentationState = .requesting(ringing)
|
||||
case let .active(_, _, keyVisualHash, _, _, _):
|
||||
case let .active(_, _, keyVisualHash, _, _, _, _):
|
||||
self.callWasActive = true
|
||||
if let callContextState = callContextState {
|
||||
switch callContextState {
|
||||
@@ -481,11 +473,38 @@ public final class PresentationCallImpl: PresentationCall {
|
||||
if let _ = audioSessionControl {
|
||||
self.audioSessionShouldBeActive.set(true)
|
||||
}
|
||||
case let .active(id, key, _, connections, maxLayer, allowsP2P):
|
||||
case let .active(id, key, _, connections, maxLayer, version, allowsP2P):
|
||||
self.audioSessionShouldBeActive.set(true)
|
||||
if let _ = audioSessionControl, !wasActive || previousControl == nil {
|
||||
let logName = "\(id.id)_\(id.accessHash)"
|
||||
self.ongoingContext.start(key: key, isOutgoing: sessionState.isOutgoing, connections: connections, maxLayer: maxLayer, allowP2P: allowsP2P, audioSessionActive: self.audioSessionActive.get(), logName: logName)
|
||||
|
||||
let ongoingContext = OngoingCallContext(account: account, callSessionManager: self.callSessionManager, internalId: self.internalId, proxyServer: proxyServer, initialNetworkType: self.currentNetworkType, updatedNetworkType: self.updatedNetworkType, serializedData: self.serializedData, dataSaving: dataSaving, derivedState: self.derivedState, key: key, isOutgoing: sessionState.isOutgoing, connections: connections, maxLayer: maxLayer, version: version, allowP2P: allowsP2P, audioSessionActive: self.audioSessionActive.get(), logName: logName)
|
||||
self.ongoingContext = ongoingContext
|
||||
|
||||
self.debugInfoValue.set(ongoingContext.debugInfo())
|
||||
|
||||
self.ongoingContextStateDisposable = (ongoingContext.state
|
||||
|> deliverOnMainQueue).start(next: { [weak self] contextState in
|
||||
if let strongSelf = self {
|
||||
if let sessionState = strongSelf.sessionState {
|
||||
strongSelf.updateSessionState(sessionState: sessionState, callContextState: contextState, reception: strongSelf.reception, audioSessionControl: strongSelf.audioSessionControl)
|
||||
} else {
|
||||
strongSelf.callContextState = contextState
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
self.receptionDisposable = (ongoingContext.reception
|
||||
|> deliverOnMainQueue).start(next: { [weak self] reception in
|
||||
if let strongSelf = self {
|
||||
if let sessionState = strongSelf.sessionState {
|
||||
strongSelf.updateSessionState(sessionState: sessionState, callContextState: strongSelf.callContextState, reception: reception, audioSessionControl: strongSelf.audioSessionControl)
|
||||
} else {
|
||||
strongSelf.reception = reception
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
if sessionState.isOutgoing {
|
||||
self.callKitIntegration?.reportOutgoingCallConnected(uuid: sessionState.id, at: Date())
|
||||
}
|
||||
@@ -494,13 +513,13 @@ public final class PresentationCallImpl: PresentationCall {
|
||||
self.audioSessionShouldBeActive.set(true)
|
||||
if wasActive {
|
||||
let debugLogValue = Promise<String?>()
|
||||
self.ongoingContext.stop(callId: id, sendDebugLogs: options.contains(.sendDebugLogs), debugLogValue: debugLogValue)
|
||||
self.ongoingContext?.stop(callId: id, sendDebugLogs: options.contains(.sendDebugLogs), debugLogValue: debugLogValue)
|
||||
}
|
||||
default:
|
||||
self.audioSessionShouldBeActive.set(false)
|
||||
if wasActive {
|
||||
let debugLogValue = Promise<String?>()
|
||||
self.ongoingContext.stop(debugLogValue: debugLogValue)
|
||||
self.ongoingContext?.stop(debugLogValue: debugLogValue)
|
||||
}
|
||||
}
|
||||
if case .terminated = sessionState.state, !wasTerminated {
|
||||
@@ -531,9 +550,9 @@ public final class PresentationCallImpl: PresentationCall {
|
||||
self.statePromise.set(presentationState)
|
||||
self.updateTone(presentationState, callContextState: callContextState, previous: previous)
|
||||
}
|
||||
|
||||
|
||||
if !self.shouldPresentCallRating {
|
||||
self.ongoingContext.needsRating { needsRating in
|
||||
self.ongoingContext?.needsRating { needsRating in
|
||||
// self.shouldPresentCallRating = needsRating
|
||||
}
|
||||
}
|
||||
@@ -617,7 +636,7 @@ public final class PresentationCallImpl: PresentationCall {
|
||||
public func hangUp() -> Signal<Bool, NoError> {
|
||||
let debugLogValue = Promise<String?>()
|
||||
self.callSessionManager.drop(internalId: self.internalId, reason: .hangUp, debugLog: debugLogValue.get())
|
||||
self.ongoingContext.stop(debugLogValue: debugLogValue)
|
||||
self.ongoingContext?.stop(debugLogValue: debugLogValue)
|
||||
|
||||
return self.hungUpPromise.get()
|
||||
}
|
||||
@@ -625,7 +644,7 @@ public final class PresentationCallImpl: PresentationCall {
|
||||
public func rejectBusy() {
|
||||
self.callSessionManager.drop(internalId: self.internalId, reason: .busy, debugLog: .single(nil))
|
||||
let debugLog = Promise<String?>()
|
||||
self.ongoingContext.stop(debugLogValue: debugLog)
|
||||
self.ongoingContext?.stop(debugLogValue: debugLog)
|
||||
}
|
||||
|
||||
public func toggleIsMuted() {
|
||||
@@ -635,7 +654,7 @@ public final class PresentationCallImpl: PresentationCall {
|
||||
public func setIsMuted(_ value: Bool) {
|
||||
self.isMutedValue = value
|
||||
self.isMutedPromise.set(self.isMutedValue)
|
||||
self.ongoingContext.setIsMuted(self.isMutedValue)
|
||||
self.ongoingContext?.setIsMuted(self.isMutedValue)
|
||||
}
|
||||
|
||||
public func setCurrentAudioOutput(_ output: AudioSessionOutput) {
|
||||
@@ -656,6 +675,6 @@ public final class PresentationCallImpl: PresentationCall {
|
||||
}
|
||||
|
||||
public func debugInfo() -> Signal<(String, String), NoError> {
|
||||
return self.ongoingContext.debugInfo()
|
||||
return self.debugInfoValue.get()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user