From 0b779eaea98d986dbca1972732e0c05d3f43fe0d Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Thu, 7 Jan 2016 16:04:56 +0100 Subject: [PATCH] audio: fix ringbacktone by using liblinphone api --- Classes/CallView.m | 14 +++++++------- Classes/LinphoneManager.m | 35 ++++++++++++++++++++++------------- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/Classes/CallView.m b/Classes/CallView.m index 577cbc0c5..15de76156 100644 --- a/Classes/CallView.m +++ b/Classes/CallView.m @@ -297,7 +297,7 @@ static void hideSpinner(LinphoneCall *call, void *user_data) { } - (void)hideControls:(BOOL)hidden sender:(id)sender { - if (videoHidden) + if (videoHidden && hidden) return; if (hideControlsTimer) { @@ -320,12 +320,12 @@ static void hideSpinner(LinphoneCall *call, void *user_data) { [PhoneMainView.instance hideTabBar:hidden]; if (!hidden) { - // hide controls in 5 sec - hideControlsTimer = [NSTimer scheduledTimerWithTimeInterval:5.0 - target:self - selector:@selector(timerHideControls:) - userInfo:nil - repeats:NO]; + // hide controls in 5 sec + hideControlsTimer = [NSTimer scheduledTimerWithTimeInterval:5.0 + target:self + selector:@selector(timerHideControls:) + userInfo:nil + repeats:NO]; } } } diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index b8060ef0f..7e160f0e1 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -1448,22 +1448,31 @@ static BOOL libStarted = FALSE; libmsbcg729_init(); libmswebrtc_init(); - // Set audio assets - NSString *ring = ([LinphoneManager bundleFile:[self lpConfigStringForKey:@"local_ring" inSection:@"sound"].lastPathComponent] - ?: [LinphoneManager bundleFile:@"notes_of_the_optimistic.caf"]) - .lastPathComponent; - NSString *ringback = ([LinphoneManager bundleFile:[self lpConfigStringForKey:@"ringback_tone" inSection:@"sound"].lastPathComponent] - ?: [LinphoneManager bundleFile:@"ringback.wav"]) - .lastPathComponent; - NSString *hold = ([LinphoneManager bundleFile:[self lpConfigStringForKey:@"hold_music" inSection:@"sound"].lastPathComponent] - ?: [LinphoneManager bundleFile:@"hold.caf"]) - .lastPathComponent; - [self lpConfigSetString:[LinphoneManager bundleFile:ring] forKey:@"local_ring" inSection:@"sound"]; - [self lpConfigSetString:[LinphoneManager bundleFile:ringback] forKey:@"ringback_tone" inSection:@"sound"]; - [self lpConfigSetString:[LinphoneManager bundleFile:hold] forKey:@"hold_music" inSection:@"sound"]; theLinphoneCore = linphone_core_new_with_config(&linphonec_vtable, configDb, (__bridge void *)(self)); LOGI(@"Create linphonecore %p", theLinphoneCore); + // Set audio assets + NSString *ring = + ([LinphoneManager + bundleFile:[NSString stringWithUTF8String:linphone_core_get_ringback(theLinphoneCore)].lastPathComponent] + ?: [LinphoneManager bundleFile:@"notes_of_the_optimistic.caf"]) + .lastPathComponent; + NSString *ringback = + ([LinphoneManager + bundleFile:[NSString stringWithUTF8String:linphone_core_get_remote_ringback_tone(theLinphoneCore)] + .lastPathComponent] + ?: [LinphoneManager bundleFile:@"ringback.wav"]) + .lastPathComponent; + NSString *hold = + ([LinphoneManager + bundleFile:[NSString stringWithUTF8String:linphone_core_get_play_file(theLinphoneCore)].lastPathComponent] + ?: [LinphoneManager bundleFile:@"hold.caf"]) + .lastPathComponent; + + linphone_core_set_ringback(theLinphoneCore, [LinphoneManager bundleFile:ring].UTF8String); + linphone_core_set_remote_ringback_tone(theLinphoneCore, [LinphoneManager bundleFile:ringback].UTF8String); + linphone_core_set_play_file(theLinphoneCore, [LinphoneManager bundleFile:hold].UTF8String); + /* set the CA file no matter what, since the remote provisioning could be hitting an HTTPS server */ const char *lRootCa = [[LinphoneManager bundleFile:@"rootca.pem"] UTF8String]; linphone_core_set_root_ca(theLinphoneCore, lRootCa);