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() {
|
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)
|
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.displayNode = displayNode
|
||||||
self.isContentsReady.set(displayNode.isReady.get())
|
self.isContentsReady.set(displayNode.isReady.get())
|
||||||
@ -160,9 +163,6 @@ public final class CallController: ViewController {
|
|||||||
}
|
}
|
||||||
restoreUIForPictureInPicture(completion)
|
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()
|
self.displayNodeDidLoad()
|
||||||
|
|
||||||
|
@ -66,8 +66,10 @@ final class CallControllerNodeV2: ViewControllerTracingNode, CallControllerNodeP
|
|||||||
private var peerAvatarDisposable: Disposable?
|
private var peerAvatarDisposable: Disposable?
|
||||||
|
|
||||||
private var availableAudioOutputs: [AudioSessionOutput]?
|
private var availableAudioOutputs: [AudioSessionOutput]?
|
||||||
|
private var currentAudioOutput: AudioSessionOutput?
|
||||||
private var isMicrophoneMutedDisposable: Disposable?
|
private var isMicrophoneMutedDisposable: Disposable?
|
||||||
private var audioLevelDisposable: Disposable?
|
private var audioLevelDisposable: Disposable?
|
||||||
|
private var audioOutputCheckTimer: Foundation.Timer?
|
||||||
|
|
||||||
private var localVideo: AdaptedCallVideoSource?
|
private var localVideo: AdaptedCallVideoSource?
|
||||||
private var remoteVideo: AdaptedCallVideoSource?
|
private var remoteVideo: AdaptedCallVideoSource?
|
||||||
@ -194,10 +196,12 @@ final class CallControllerNodeV2: ViewControllerTracingNode, CallControllerNodeP
|
|||||||
self.peerAvatarDisposable?.dispose()
|
self.peerAvatarDisposable?.dispose()
|
||||||
self.isMicrophoneMutedDisposable?.dispose()
|
self.isMicrophoneMutedDisposable?.dispose()
|
||||||
self.audioLevelDisposable?.dispose()
|
self.audioLevelDisposable?.dispose()
|
||||||
|
self.audioOutputCheckTimer?.invalidate()
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateAudioOutputs(availableOutputs: [AudioSessionOutput], currentOutput: AudioSessionOutput?) {
|
func updateAudioOutputs(availableOutputs: [AudioSessionOutput], currentOutput: AudioSessionOutput?) {
|
||||||
self.availableAudioOutputs = availableOutputs
|
self.availableAudioOutputs = availableOutputs
|
||||||
|
self.currentAudioOutput = currentOutput
|
||||||
|
|
||||||
if var callScreenState = self.callScreenState {
|
if var callScreenState = self.callScreenState {
|
||||||
let mappedOutput: PrivateCallScreen.State.AudioOutput
|
let mappedOutput: PrivateCallScreen.State.AudioOutput
|
||||||
@ -218,6 +222,8 @@ final class CallControllerNodeV2: ViewControllerTracingNode, CallControllerNodeP
|
|||||||
callScreenState.audioOutput = mappedOutput
|
callScreenState.audioOutput = mappedOutput
|
||||||
self.callScreenState = callScreenState
|
self.callScreenState = callScreenState
|
||||||
self.update(transition: .animated(duration: 0.3, curve: .spring))
|
self.update(transition: .animated(duration: 0.3, curve: .spring))
|
||||||
|
|
||||||
|
self.setupAudioOutputForVideoIfNeeded()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -446,6 +452,8 @@ final class CallControllerNodeV2: ViewControllerTracingNode, CallControllerNodeP
|
|||||||
self.callScreenState = callScreenState
|
self.callScreenState = callScreenState
|
||||||
self.update(transition: .animated(duration: 0.35, curve: .spring))
|
self.update(transition: .animated(duration: 0.35, curve: .spring))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.setupAudioOutputForVideoIfNeeded()
|
||||||
}
|
}
|
||||||
|
|
||||||
if case let .terminated(_, _, reportRating) = callState.state {
|
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) {
|
func updatePeer(accountPeer: Peer, peer: Peer, hasOther: Bool) {
|
||||||
self.updatePeer(peer: EnginePeer(peer))
|
self.updatePeer(peer: EnginePeer(peer))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user