mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
[WIP] Call UI
This commit is contained in:
parent
49afa2a145
commit
3fc9d37ba7
@ -148,7 +148,10 @@ public final class CallController: ViewController {
|
||||
}
|
||||
|
||||
override public func loadDisplayNode() {
|
||||
if self.sharedContext.immediateExperimentalUISettings.callUIV2 {
|
||||
if let data = self.call.context.currentAppConfiguration.with({ $0 }).data, let _ = data["ios_killswitch_disable_callui_v2"] {
|
||||
self.displayNode = CallControllerNode(sharedContext: self.sharedContext, account: self.account, presentationData: self.presentationData, statusBar: self.statusBar, debugInfo: self.call.debugInfo(), shouldStayHiddenUntilConnection: !self.call.isOutgoing && self.call.isIntegratedWithCallKit, easyDebugAccess: self.easyDebugAccess, call: self.call)
|
||||
self.isContentsReady.set(.single(true))
|
||||
} else {
|
||||
let displayNode = CallControllerNodeV2(sharedContext: self.sharedContext, account: self.account, presentationData: self.presentationData, statusBar: self.statusBar, debugInfo: self.call.debugInfo(), easyDebugAccess: self.easyDebugAccess, call: self.call)
|
||||
self.displayNode = displayNode
|
||||
self.isContentsReady.set(displayNode.isReady.get())
|
||||
@ -160,9 +163,6 @@ public final class CallController: ViewController {
|
||||
}
|
||||
restoreUIForPictureInPicture(completion)
|
||||
}
|
||||
} else {
|
||||
self.displayNode = CallControllerNode(sharedContext: self.sharedContext, account: self.account, presentationData: self.presentationData, statusBar: self.statusBar, debugInfo: self.call.debugInfo(), shouldStayHiddenUntilConnection: !self.call.isOutgoing && self.call.isIntegratedWithCallKit, easyDebugAccess: self.easyDebugAccess, call: self.call)
|
||||
self.isContentsReady.set(.single(true))
|
||||
}
|
||||
self.displayNodeDidLoad()
|
||||
|
||||
|
@ -66,8 +66,10 @@ final class CallControllerNodeV2: ViewControllerTracingNode, CallControllerNodeP
|
||||
private var peerAvatarDisposable: Disposable?
|
||||
|
||||
private var availableAudioOutputs: [AudioSessionOutput]?
|
||||
private var currentAudioOutput: AudioSessionOutput?
|
||||
private var isMicrophoneMutedDisposable: Disposable?
|
||||
private var audioLevelDisposable: Disposable?
|
||||
private var audioOutputCheckTimer: Foundation.Timer?
|
||||
|
||||
private var localVideo: AdaptedCallVideoSource?
|
||||
private var remoteVideo: AdaptedCallVideoSource?
|
||||
@ -194,10 +196,12 @@ final class CallControllerNodeV2: ViewControllerTracingNode, CallControllerNodeP
|
||||
self.peerAvatarDisposable?.dispose()
|
||||
self.isMicrophoneMutedDisposable?.dispose()
|
||||
self.audioLevelDisposable?.dispose()
|
||||
self.audioOutputCheckTimer?.invalidate()
|
||||
}
|
||||
|
||||
func updateAudioOutputs(availableOutputs: [AudioSessionOutput], currentOutput: AudioSessionOutput?) {
|
||||
self.availableAudioOutputs = availableOutputs
|
||||
self.currentAudioOutput = currentOutput
|
||||
|
||||
if var callScreenState = self.callScreenState {
|
||||
let mappedOutput: PrivateCallScreen.State.AudioOutput
|
||||
@ -218,6 +222,8 @@ final class CallControllerNodeV2: ViewControllerTracingNode, CallControllerNodeP
|
||||
callScreenState.audioOutput = mappedOutput
|
||||
self.callScreenState = callScreenState
|
||||
self.update(transition: .animated(duration: 0.3, curve: .spring))
|
||||
|
||||
self.setupAudioOutputForVideoIfNeeded()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -446,6 +452,8 @@ final class CallControllerNodeV2: ViewControllerTracingNode, CallControllerNodeP
|
||||
self.callScreenState = callScreenState
|
||||
self.update(transition: .animated(duration: 0.35, curve: .spring))
|
||||
}
|
||||
|
||||
self.setupAudioOutputForVideoIfNeeded()
|
||||
}
|
||||
|
||||
if case let .terminated(_, _, reportRating) = callState.state {
|
||||
@ -468,6 +476,36 @@ final class CallControllerNodeV2: ViewControllerTracingNode, CallControllerNodeP
|
||||
}
|
||||
}
|
||||
|
||||
private func setupAudioOutputForVideoIfNeeded() {
|
||||
guard let callScreenState = self.callScreenState, let currentAudioOutput = self.currentAudioOutput else {
|
||||
return
|
||||
}
|
||||
if callScreenState.localVideo != nil || callScreenState.remoteVideo != nil {
|
||||
switch currentAudioOutput {
|
||||
case .headphones, .speaker:
|
||||
break
|
||||
case let .port(port) where port.type == .bluetooth || port.type == .wired:
|
||||
break
|
||||
default:
|
||||
self.setCurrentAudioOutput?(.speaker)
|
||||
}
|
||||
|
||||
if self.audioOutputCheckTimer == nil {
|
||||
self.audioOutputCheckTimer = Foundation.Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true, block: { [weak self] _ in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
self.setupAudioOutputForVideoIfNeeded()
|
||||
})
|
||||
}
|
||||
} else {
|
||||
if let audioOutputCheckTimer = self.audioOutputCheckTimer {
|
||||
self.audioOutputCheckTimer = nil
|
||||
audioOutputCheckTimer.invalidate()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func updatePeer(accountPeer: Peer, peer: Peer, hasOther: Bool) {
|
||||
self.updatePeer(peer: EnginePeer(peer))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user