Merge pull request #1658 from WhisperSystems/mkirk/webrtc/call-mux

Better concurrent call handling
pull/1/head
Michael Kirk 8 years ago committed by GitHub
commit ae1a97196e

@ -133,6 +133,8 @@ protocol CallObserver: class {
} }
} }
var isOnHold = false
var connectedDate: NSDate? var connectedDate: NSDate?
var error: CallError? var error: CallError?

@ -91,10 +91,7 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
let update = CXCallUpdate() let update = CXCallUpdate()
update.remoteHandle = CXHandle(type: .phoneNumber, value: call.remotePhoneNumber) update.remoteHandle = CXHandle(type: .phoneNumber, value: call.remotePhoneNumber)
update.hasVideo = call.hasLocalVideo update.hasVideo = call.hasLocalVideo
update.supportsHolding = false disableUnsupportedFeatures(callUpdate: update)
update.supportsGrouping = false
update.supportsUngrouping = false
update.supportsDTMF = false
// Report the incoming call to the system // Report the incoming call to the system
provider.reportNewIncomingCall(with: call.localId, update: update) { error in provider.reportNewIncomingCall(with: call.localId, update: update) { error in
@ -138,8 +135,12 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
func recipientAcceptedCall(_ call: SignalCall) { func recipientAcceptedCall(_ call: SignalCall) {
AssertIsOnMainThread() AssertIsOnMainThread()
// no - op self.provider.reportOutgoingCall(with: call.localId, connectedAt: nil)
// TODO provider update call connected?
let update = CXCallUpdate()
disableUnsupportedFeatures(callUpdate: update)
provider.reportCall(with: call.localId, updated: update)
} }
func localHangupCall(_ call: SignalCall) { func localHangupCall(_ call: SignalCall) {
@ -213,27 +214,15 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
} }
CallService.signalingQueue.async { CallService.signalingQueue.async {
self.callService.handleOutgoingCall(call).then { self.callService.handleOutgoingCall(call).then { () -> Void in
action.fulfill() action.fulfill()
self.provider.reportOutgoingCall(with: call.localId, startedConnectingAt: nil)
}.catch { error in }.catch { error in
Logger.error("\(self.TAG) error \(error) in \(#function)") Logger.error("\(self.TAG) error \(error) in \(#function)")
self.callManager.removeCall(call) self.callManager.removeCall(call)
action.fail() action.fail()
} }
} }
// TODO FIXME
// /*
// Set callback blocks for significant events in the call's lifecycle, so that the CXProvider may be updated
// to reflect the updated state.
// */
// call.hasStartedConnectingDidChange = { [weak self] in
// self?.provider.reportOutgoingCall(with: call.uuid, startedConnectingAt: call.connectingDate)
// }
// call.hasConnectedDidChange = { [weak self] in
// self?.provider.reportOutgoingCall(with: call.uuid, connectedAt: call.connectDate)
// }
} }
func provider(_ provider: CXProvider, perform action: CXAnswerCallAction) { func provider(_ provider: CXProvider, perform action: CXAnswerCallAction) {
@ -298,20 +287,19 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
action.fail() action.fail()
return return
} }
Logger.warn("TODO, unimplemented set held call: \(call)")
// TODO FIXME // Update the SignalCall's underlying hold state.
// // Update the SpeakerboxCall's underlying hold state. call.isOnHold = action.isOnHold
// call.isOnHold = action.isOnHold
// // Stop or start audio in response to holding or unholding the call.
// // Stop or start audio in response to holding or unholding the call. if call.isOnHold {
// if call.isOnHold { // stopAudio() <-- SpeakerBox
// // stopAudio() <-- SpeakerBox PeerConnectionClient.stopAudioSession()
// PeerConnectionClient.stopAudioSession() } else {
// } else { // startAudio() <-- SpeakerBox
// // startAudio() <-- SpeakerBox // This is redundant with what happens in `provider(_:didActivate:)`
//PeerConnectionClient.startAudioSession() //PeerConnectionClient.startAudioSession()
// } }
// Signal to the system that the action has been successfully performed. // Signal to the system that the action has been successfully performed.
action.fulfill() action.fulfill()
@ -372,4 +360,19 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
de-activated after having its priority restored to normal. de-activated after having its priority restored to normal.
*/ */
} }
// MARK: - Util
private func disableUnsupportedFeatures(callUpdate: CXCallUpdate) {
// Call Holding is failing to restart audio when "swapping" calls on the CallKit screen
// until user returns to in-app call screen.
callUpdate.supportsHolding = false
// Not yet supported
callUpdate.supportsGrouping = false
callUpdate.supportsUngrouping = false
// Is there any reason to support this?
callUpdate.supportsDTMF = false
}
} }

Loading…
Cancel
Save