From 44d5e1db8c04d1d8a64bb326dcb88a9c6901811f Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Fri, 21 Oct 2011 09:51:48 +0200 Subject: [PATCH] Define sound interruption handler in objc. Used to pause sip call. --- Classes/LinphoneUI/LinphoneManager.h | 3 ++- Classes/LinphoneUI/LinphoneManager.m | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Classes/LinphoneUI/LinphoneManager.h b/Classes/LinphoneUI/LinphoneManager.h index 2ed3b0184..1acaebc93 100644 --- a/Classes/LinphoneUI/LinphoneManager.h +++ b/Classes/LinphoneUI/LinphoneManager.h @@ -18,6 +18,7 @@ */ #import +#import #import #include "linphonecore.h" #import "LogView.h" @@ -28,7 +29,7 @@ typedef enum _Connectivity { ,none } Connectivity; @class FastAddressBook; -@interface LinphoneManager : NSObject { +@interface LinphoneManager : NSObject { @private SCNetworkReachabilityContext proxyReachabilityContext; SCNetworkReachabilityRef proxyReachability; diff --git a/Classes/LinphoneUI/LinphoneManager.m b/Classes/LinphoneUI/LinphoneManager.m index 97b715318..546aa78dd 100644 --- a/Classes/LinphoneUI/LinphoneManager.m +++ b/Classes/LinphoneUI/LinphoneManager.m @@ -726,6 +726,7 @@ void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReach //init audio session AVAudioSession *audioSession = [AVAudioSession sharedInstance]; BOOL bAudioInputAvailable= [audioSession inputIsAvailable]; + [audioSession setDelegate:self]; if(!bAudioInputAvailable){ UIAlertView* error = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"No microphone",nil) @@ -780,4 +781,20 @@ void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReach mLogView = view; } +-(void) beginInterruption { + LinphoneCall* c = linphone_core_get_current_call(theLinphoneCore); + ms_message("Sound interruption detected!"); + if (c) { + linphone_core_pause_call(theLinphoneCore, c); + } +} + +-(void) endInterruption { + const MSList* c = linphone_core_get_calls(theLinphoneCore); + ms_message("Sound interruption ended!"); + if (c) { + linphone_core_resume_call(theLinphoneCore, (LinphoneCall*) c->data); + } +} + @end