Stop any lingering audio session if provider resets.

I've never actually seen this happen, but I think it makes sense.

// FREEBIE
pull/1/head
Michael Kirk 9 years ago
parent 2216dc8d37
commit 43e7defa28

@ -201,20 +201,12 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
AssertIsOnMainThread() AssertIsOnMainThread()
Logger.debug("\(self.TAG) \(#function)") Logger.debug("\(self.TAG) \(#function)")
// TODO // Stop any in-progress WebRTC related audio.
// copied from Speakerbox, but is there a corallary with peerconnection, since peer connection starts the audio PeerConnectionClient.stopAudioSession()
// session when adding an audiotrack
// stopAudio()
/* // End any ongoing calls if the provider resets, and remove them from the app's list of calls,
End any ongoing calls if the provider resets, and remove them from the app's list of calls, // since they are no longer valid.
since they are no longer valid.
*/
// This is a little goofy because CallKit assumes multiple calls (maybe some are held, or group calls?)
// but CallService currently just has one call at a time.
for call in callManager.calls {
callService.handleFailedCall(error: .providerReset) callService.handleFailedCall(error: .providerReset)
}
// Remove all calls from the app's list of calls. // Remove all calls from the app's list of calls.
callManager.removeAllCalls() callManager.removeAllCalls()
@ -225,7 +217,6 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
Logger.debug("\(TAG) in \(#function) CXStartCallAction") Logger.debug("\(TAG) in \(#function) CXStartCallAction")
// TODO does this work when `action.handle.value` is not in e164 format, e.g. if called via intent?
guard let call = callManager.callWithLocalId(action.callUUID) else { guard let call = callManager.callWithLocalId(action.callUUID) else {
Logger.error("\(TAG) unable to find call in \(#function)") Logger.error("\(TAG) unable to find call in \(#function)")
return return
@ -245,22 +236,12 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
AssertIsOnMainThread() AssertIsOnMainThread()
Logger.debug("\(TAG) Received \(#function) CXAnswerCallAction") Logger.debug("\(TAG) Received \(#function) CXAnswerCallAction")
// Retrieve the SpeakerboxCall instance corresponding to the action's call UUID // Retrieve the instance corresponding to the action's call UUID
guard let call = callManager.callWithLocalId(action.callUUID) else { guard let call = callManager.callWithLocalId(action.callUUID) else {
action.fail() action.fail()
return return
} }
// Original Speakerbox implementation
// /*
// Configure the audio session, but do not start call audio here, since it must be done once
// the audio session has been activated by the system after having its priority elevated.
// */
// configureAudioSession()
//
// // Trigger the call to be answered via the underlying network service.
// call.answerSpeakerboxCall()
self.callService.handleAnswerCall(call) self.callService.handleAnswerCall(call)
self.showCall(call) self.showCall(call)
action.fulfill() action.fulfill()
@ -275,12 +256,6 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
return return
} }
// Original Speakerbox implementation
// // Stop call audio whenever ending the call.
// stopAudio()
// // Trigger the call to be ended via the underlying network service.
// call.endSpeakerboxCall()
self.callService.handleLocalHungupCall(call) self.callService.handleLocalHungupCall(call)
// Signal to the system that the action has been successfully performed. // Signal to the system that the action has been successfully performed.

Loading…
Cancel
Save