From 4a92f613d9abb6df2815244a881e2c7fa7c703db Mon Sep 17 00:00:00 2001 From: -g Date: Fri, 13 Oct 2023 12:03:21 +0000 Subject: [PATCH 1/2] Speaker Toggle Fix --- TelnyxWebRTCDemo/Extensions/ViewControllerVoIPExtension.swift | 3 +++ TelnyxWebRTCDemo/ViewController.swift | 2 ++ 2 files changed, 5 insertions(+) diff --git a/TelnyxWebRTCDemo/Extensions/ViewControllerVoIPExtension.swift b/TelnyxWebRTCDemo/Extensions/ViewControllerVoIPExtension.swift index a31cfb6e..06af1b89 100644 --- a/TelnyxWebRTCDemo/Extensions/ViewControllerVoIPExtension.swift +++ b/TelnyxWebRTCDemo/Extensions/ViewControllerVoIPExtension.swift @@ -106,6 +106,9 @@ extension ViewController : VoIPDelegate { if(self.isCallOutGoing()){ self.appDelegate.executeOutGoingCall() } + if(self.isSpeakerActive){ + self.telnyxClient?.setSpeaker() + } break case .DONE: self.resetCallStates() diff --git a/TelnyxWebRTCDemo/ViewController.swift b/TelnyxWebRTCDemo/ViewController.swift index 596ea144..c2f9def4 100644 --- a/TelnyxWebRTCDemo/ViewController.swift +++ b/TelnyxWebRTCDemo/ViewController.swift @@ -17,6 +17,7 @@ class ViewController: UIViewController { var userDefaults: UserDefaults = UserDefaults.init() var telnyxClient: TxClient? var incomingCall: Bool = false + var isSpeakerActive : Bool = false var loadingView: UIAlertController? @@ -245,6 +246,7 @@ extension ViewController : UICallScreenDelegate { } func onToggleSpeaker(isSpeakerActive: Bool) { + self.isSpeakerActive = isSpeakerActive if (isSpeakerActive) { self.telnyxClient?.setSpeaker() } else { From b0d0d0f25018ab584db43ef267288bfe1cf1f1de Mon Sep 17 00:00:00 2001 From: -g Date: Mon, 16 Oct 2023 12:25:05 +0000 Subject: [PATCH 2/2] [Enhancement] - Set Current Output for Ringing and Active Call State --- .../Extensions/ViewControllerVoIPExtension.swift | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/TelnyxWebRTCDemo/Extensions/ViewControllerVoIPExtension.swift b/TelnyxWebRTCDemo/Extensions/ViewControllerVoIPExtension.swift index 06af1b89..7f059491 100644 --- a/TelnyxWebRTCDemo/Extensions/ViewControllerVoIPExtension.swift +++ b/TelnyxWebRTCDemo/Extensions/ViewControllerVoIPExtension.swift @@ -97,6 +97,7 @@ extension ViewController : VoIPDelegate { case .CONNECTING: break case .RINGING: + self.setCurrentAudioOutput() break case .NEW: break @@ -106,9 +107,7 @@ extension ViewController : VoIPDelegate { if(self.isCallOutGoing()){ self.appDelegate.executeOutGoingCall() } - if(self.isSpeakerActive){ - self.telnyxClient?.setSpeaker() - } + self.setCurrentAudioOutput() break case .DONE: self.resetCallStates() @@ -120,6 +119,12 @@ extension ViewController : VoIPDelegate { } } + func setCurrentAudioOutput(){ + if(self.isSpeakerActive){ + self.telnyxClient?.setSpeaker() + } + } + func executeCall(callUUID: UUID, completionHandler: @escaping (Call?) -> Void) { do { guard let callerName = self.settingsView.callerIdNameLabel.text,