mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 11:08:06 +00:00
Use the linphone functions for audio route management rather than IOS specific ones. Also removed redundant triggers on Speaker and Bluetooth buttons.
This commit is contained in:
parent
7ea46b5aab
commit
636e4cd67b
8 changed files with 51 additions and 41 deletions
|
|
@ -126,13 +126,13 @@ import AVFoundation
|
|||
#endif
|
||||
return false
|
||||
}
|
||||
|
||||
/*
|
||||
@objc func allowSpeaker() -> Bool {
|
||||
if (UIDevice.current.userInterfaceIdiom == .pad) {
|
||||
// For now, ipad support only speaker.
|
||||
return true
|
||||
}
|
||||
|
||||
return true
|
||||
var allow = true
|
||||
let newRoute = AVAudioSession.sharedInstance().currentRoute
|
||||
if (newRoute.outputs.count > 0) {
|
||||
|
|
@ -142,7 +142,39 @@ import AVFoundation
|
|||
|
||||
return allow
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
@objc func changeRouteToSpeaker() {
|
||||
speakerEnabled = true
|
||||
for device in lc!.audioDevices {
|
||||
if (device.type == AudioDeviceType.Speaker) {
|
||||
lc!.outputAudioDevice = device
|
||||
break
|
||||
}
|
||||
}
|
||||
UIDevice.current.isProximityMonitoringEnabled = false
|
||||
bluetoothEnabled = false
|
||||
}
|
||||
|
||||
@objc func changeRouteToBluetooth() {
|
||||
bluetoothEnabled = true
|
||||
for device in lc!.audioDevices {
|
||||
if (device.type == AudioDeviceType.Bluetooth || device.type == AudioDeviceType.BluetoothA2DP) {
|
||||
lc!.outputAudioDevice = device
|
||||
break
|
||||
}
|
||||
}
|
||||
speakerEnabled = false
|
||||
UIDevice.current.isProximityMonitoringEnabled = (lc!.callsNb > 0)
|
||||
}
|
||||
|
||||
@objc func changeRouteToDefault() {
|
||||
bluetoothEnabled = false
|
||||
speakerEnabled = false
|
||||
lc!.outputAudioDevice = lc!.defaultOutputAudioDevice
|
||||
}
|
||||
/*
|
||||
|
||||
@objc func enableSpeaker(enable: Bool) {
|
||||
speakerEnabled = enable
|
||||
do {
|
||||
|
|
@ -160,7 +192,7 @@ import AVFoundation
|
|||
Log.directLog(BCTBX_LOG_ERROR, text: "Failed to change audio route: err \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
func requestTransaction(_ transaction: CXTransaction, action: String) {
|
||||
callController.request(transaction) { error in
|
||||
if let error = error {
|
||||
|
|
@ -510,7 +542,7 @@ import AVFoundation
|
|||
|
||||
if (CallManager.instance().speakerBeforePause) {
|
||||
CallManager.instance().speakerBeforePause = false
|
||||
CallManager.instance().enableSpeaker(enable: true)
|
||||
CallManager.instance().changeRouteToSpeaker()
|
||||
CallManager.speaker_already_enabled = true
|
||||
}
|
||||
break
|
||||
|
|
@ -539,7 +571,7 @@ import AVFoundation
|
|||
UIDevice.current.isProximityMonitoringEnabled = false
|
||||
CallManager.speaker_already_enabled = false
|
||||
if (CallManager.instance().lc!.callsNb == 0) {
|
||||
CallManager.instance().enableSpeaker(enable: false)
|
||||
CallManager.instance().changeRouteToDefault()
|
||||
// disable this because I don't find anygood reason for it: _bluetoothAvailable = FALSE;
|
||||
// furthermore it introduces a bug when calling multiple times since route may not be
|
||||
// reconfigured between cause leading to bluetooth being disabled while it should not
|
||||
|
|
@ -605,7 +637,7 @@ import AVFoundation
|
|||
|
||||
if (cstate == .IncomingReceived || cstate == .OutgoingInit || cstate == .Connected || cstate == .StreamsRunning) {
|
||||
if ((call.currentParams?.videoEnabled ?? false) && !CallManager.speaker_already_enabled && !CallManager.instance().bluetoothEnabled) {
|
||||
CallManager.instance().enableSpeaker(enable: true)
|
||||
CallManager.instance().changeRouteToSpeaker()
|
||||
CallManager.speaker_already_enabled = true
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -127,20 +127,17 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
|
||||
- (IBAction)onRoutesBluetoothClick:(id)sender {
|
||||
[self hideRoutes:TRUE animated:TRUE];
|
||||
[CallManager.instance enableSpeakerWithEnable:FALSE];
|
||||
[LinphoneManager.instance setBluetoothEnabled:TRUE];
|
||||
[CallManager.instance changeRouteToBluetooth];
|
||||
}
|
||||
|
||||
- (IBAction)onRoutesEarpieceClick:(id)sender {
|
||||
[self hideRoutes:TRUE animated:TRUE];
|
||||
[CallManager.instance enableSpeakerWithEnable:FALSE];
|
||||
[LinphoneManager.instance setBluetoothEnabled:FALSE];
|
||||
[CallManager.instance changeRouteToDefault];
|
||||
}
|
||||
|
||||
- (IBAction)onRoutesSpeakerClick:(id)sender {
|
||||
[self hideRoutes:TRUE animated:TRUE];
|
||||
[LinphoneManager.instance setBluetoothEnabled:FALSE];
|
||||
[CallManager.instance enableSpeakerWithEnable:TRUE];
|
||||
[CallManager.instance changeRouteToSpeaker];
|
||||
}
|
||||
|
||||
- (IBAction)onRoutesClick:(id)sender {
|
||||
|
|
|
|||
|
|
@ -803,20 +803,17 @@ static void hideSpinner(LinphoneCall *call, void *user_data) {
|
|||
|
||||
- (IBAction)onRoutesBluetoothClick:(id)sender {
|
||||
[self hideRoutes:TRUE animated:TRUE];
|
||||
[CallManager.instance enableSpeakerWithEnable:FALSE];
|
||||
[LinphoneManager.instance setBluetoothEnabled:TRUE];
|
||||
[CallManager.instance changeRouteToBluetooth];
|
||||
}
|
||||
|
||||
- (IBAction)onRoutesEarpieceClick:(id)sender {
|
||||
[self hideRoutes:TRUE animated:TRUE];
|
||||
[CallManager.instance enableSpeakerWithEnable:FALSE];
|
||||
[LinphoneManager.instance setBluetoothEnabled:FALSE];
|
||||
[CallManager.instance changeRouteToDefault];
|
||||
}
|
||||
|
||||
- (IBAction)onRoutesSpeakerClick:(id)sender {
|
||||
[self hideRoutes:TRUE animated:TRUE];
|
||||
[LinphoneManager.instance setBluetoothEnabled:FALSE];
|
||||
[CallManager.instance enableSpeakerWithEnable:TRUE];
|
||||
[CallManager.instance changeRouteToSpeaker];
|
||||
}
|
||||
|
||||
- (IBAction)onRoutesClick:(id)sender {
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ typedef struct _LinphoneManagerSounds {
|
|||
- (void)migrationPerAccount;
|
||||
|
||||
- (void)setupGSMInteraction;
|
||||
- (void)setBluetoothEnabled:(BOOL)enable;
|
||||
//- (void)setBluetoothEnabled:(BOOL)enable;
|
||||
- (BOOL)isCTCallCenterExist;
|
||||
|
||||
@property (readonly) BOOL isTesting;
|
||||
|
|
|
|||
|
|
@ -1731,7 +1731,7 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
|
|||
- (void)audioRouteChangeListenerCallback:(NSNotification *)notif {
|
||||
if (IPAD)
|
||||
return;
|
||||
|
||||
|
||||
// there is at least one bug when you disconnect an audio bluetooth headset
|
||||
// since we only get notification of route having changed, we cannot tell if that is due to:
|
||||
// -bluetooth headset disconnected or
|
||||
|
|
@ -1760,7 +1760,7 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
|
|||
userInfo:dict];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
- (void)setBluetoothEnabled:(BOOL)enable {
|
||||
if (_bluetoothAvailable) {
|
||||
// The change of route will be done in enableSpeaker
|
||||
|
|
@ -1783,7 +1783,7 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
|
|||
}
|
||||
[CallManager.instance enableSpeakerWithEnable:CallManager.instance.speakerEnabled];
|
||||
}
|
||||
|
||||
*/
|
||||
#pragma mark - Call Functions
|
||||
- (void)send:(NSString *)replyText toChatRoom:(LinphoneChatRoom *)room {
|
||||
LinphoneChatMessage *msg = linphone_chat_room_create_message(room, replyText.UTF8String);
|
||||
|
|
|
|||
|
|
@ -29,14 +29,6 @@
|
|||
if (au != 0) \
|
||||
LOGE(@"UIBluetoothButton error for %s: ret=%ld", method, au)
|
||||
|
||||
- (void)onOn {
|
||||
[LinphoneManager.instance setBluetoothEnabled:TRUE];
|
||||
}
|
||||
|
||||
- (void)onOff {
|
||||
[LinphoneManager.instance setBluetoothEnabled:FALSE];
|
||||
}
|
||||
|
||||
- (bool)onUpdate {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,16 +45,7 @@ INIT_WITH_COMMON_CF {
|
|||
[self update];});
|
||||
}
|
||||
|
||||
- (void)onOn {
|
||||
[CallManager.instance enableSpeakerWithEnable:TRUE];
|
||||
}
|
||||
|
||||
- (void)onOff {
|
||||
[CallManager.instance enableSpeakerWithEnable:FALSE];
|
||||
}
|
||||
|
||||
- (bool)onUpdate {
|
||||
self.enabled = [CallManager.instance allowSpeaker];
|
||||
return CallManager.instance.speakerEnabled;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,8 @@ INIT_WITH_COMMON_CF {
|
|||
|
||||
if (!linphone_core_video_display_enabled(LC))
|
||||
return;
|
||||
[CallManager.instance enableSpeakerWithEnable:FALSE];
|
||||
[CallManager.instance changeRouteToDefault];
|
||||
//[CallManager.instance enableSpeakerWithEnable:FALSE];
|
||||
[self setEnabled:FALSE];
|
||||
[waitView startAnimating];
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue