From 969b73cad8ed3fb542848e398a4620a9f1d40f9e Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Mon, 30 Jan 2017 15:40:40 -0500 Subject: [PATCH] Implement call holding (call swapping still broken). - Alice calls Bob on Signal and they start talking - Charlie calls Alice on Not-Signal. - Alice chooses to "Hold & Accept" putting Bob on Hold while the call with Charlie connects. - If Alice ends the call with Charlie, we're back in Signal-iOS and talking to Bob, no problem. - However, if, before ending the call with Charlie, Alice tries to swap *back* to bob, bob won't hear any audio in the callkit screen. Alice has to switch back to the Signal screen before the audio is transmitted. // FREEBIE --- Signal/src/call/SignalCall.swift | 2 ++ .../Speakerbox/CallKitCallUIAdaptee.swift | 25 +++++++++---------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Signal/src/call/SignalCall.swift b/Signal/src/call/SignalCall.swift index 13f1bd4ff..c7e8b8f23 100644 --- a/Signal/src/call/SignalCall.swift +++ b/Signal/src/call/SignalCall.swift @@ -133,6 +133,8 @@ protocol CallObserver: class { } } + var isOnHold = false + var connectedDate: NSDate? var error: CallError? diff --git a/Signal/src/call/Speakerbox/CallKitCallUIAdaptee.swift b/Signal/src/call/Speakerbox/CallKitCallUIAdaptee.swift index 4cbbc9732..222b952b8 100644 --- a/Signal/src/call/Speakerbox/CallKitCallUIAdaptee.swift +++ b/Signal/src/call/Speakerbox/CallKitCallUIAdaptee.swift @@ -285,20 +285,19 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate { action.fail() return } - Logger.warn("TODO, unimplemented set held call: \(call)") - // TODO FIXME - // // Update the SpeakerboxCall's underlying hold state. - // call.isOnHold = action.isOnHold - // - // // Stop or start audio in response to holding or unholding the call. - // if call.isOnHold { - // // stopAudio() <-- SpeakerBox - // PeerConnectionClient.stopAudioSession() - // } else { - // // startAudio() <-- SpeakerBox - // PeerConnectionClient.startAudioSession() - // } + // Update the SignalCall's underlying hold state. + call.isOnHold = action.isOnHold + + // Stop or start audio in response to holding or unholding the call. + if call.isOnHold { + // stopAudio() <-- SpeakerBox + PeerConnectionClient.stopAudioSession() + } else { + // startAudio() <-- SpeakerBox + // This is redundant with what happens in `provider(_:didActivate:)` + //PeerConnectionClient.startAudioSession() + } // Signal to the system that the action has been successfully performed. action.fulfill()