Pause SIP call when audio is interrupted by OS (on incoming GSM call for instance)

The SIP call is automatically resumed when audio is available.
This commit is contained in:
Pierre-Eric Pelloux-Prayer 2011-10-24 11:28:49 +02:00
parent 44d5e1db8c
commit fc530ed057
10 changed files with 596 additions and 526 deletions

View file

@ -51,6 +51,8 @@
}
-(void) displayIncallFromUI:(UIViewController*) viewCtrl forUser:(NSString*) username withDisplayName:(NSString*) displayName {
[self presentModalViewController:mIncallViewController animated:true];
[super displayIncallFromUI:viewCtrl
forUser:username
withDisplayName:displayName];
@ -65,6 +67,12 @@
[mIncallViewController displayStatus:message];
}
-(void) updateUIFromLinphoneState:(UIViewController*) viewCtrl {
[super updateUIFromLinphoneState:viewCtrl];
[mIncallViewController updateUIFromLinphoneState:viewCtrl];
}
- (void)dealloc {
[mIncallViewController release];
[super dealloc];

View file

@ -35,6 +35,7 @@
UIHangUpButton* endCtrl;
UIButton* dialer;
UIMuteButton* mute;
UIPauseResumeButton* pause;
UISpeakerButton* speaker;
UIButton* contacts;
@ -74,6 +75,7 @@
@property (nonatomic, retain) IBOutlet UIButton* endCtrl;
@property (nonatomic, retain) IBOutlet UIButton* dialer;
@property (nonatomic, retain) IBOutlet UIButton* mute;
@property (nonatomic, retain) IBOutlet UIButton* pause;
@property (nonatomic, retain) IBOutlet UIButton* speaker;
@property (nonatomic, retain) IBOutlet UIButton* contacts;

View file

@ -35,6 +35,7 @@
@synthesize endCtrl;
@synthesize close;
@synthesize mute;
@synthesize pause;
@synthesize dialer;
@synthesize speaker;
@synthesize contacts;
@ -70,6 +71,7 @@
[super viewDidLoad];
//Controls
[mute initWithOnImage:[UIImage imageNamed:@"mic_muted.png"] offImage:[UIImage imageNamed:@"mic_active.png"] ];
[pause initWithOnImage:[UIImage imageNamed:@"resumecall.png"] offImage:[UIImage imageNamed:@"pausecall.png"] ];
[speaker initWithOnImage:[UIImage imageNamed:@"Speaker-32-on.png"] offImage:[UIImage imageNamed:@"Speaker-32-off.png"] ];
@ -127,6 +129,11 @@
[callDuration stop];
[self dismissModalViewControllerAnimated:true];
}
-(void) updateUIFromLinphoneState:(UIViewController *)viewCtrl {
[mute reset];
[pause reset];
}
- (IBAction)doAction:(id)sender {
if (sender == dialer) {

File diff suppressed because it is too large Load diff

View file

@ -790,11 +790,15 @@ void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReach
}
-(void) endInterruption {
const MSList* c = linphone_core_get_calls(theLinphoneCore);
ms_message("Sound interruption ended!");
const MSList* c = linphone_core_get_calls(theLinphoneCore);
if (c) {
ms_message("Auto resuming call");
linphone_core_resume_call(theLinphoneCore, (LinphoneCall*) c->data);
}
}
[callDelegate updateUIFromLinphoneState:mCurrentViewController];
}
@end

View file

@ -25,6 +25,7 @@
-(void) displayCallInProgressFromUI:(UIViewController*) viewCtrl forUser:(NSString*) username withDisplayName:(NSString*) displayName;
-(void) displayIncomingCallNotigicationFromUI:(UIViewController*) viewCtrl forUser:(NSString*) username withDisplayName:(NSString*) displayName;
-(void) displayIncallFromUI:(UIViewController*) viewCtrl forUser:(NSString*) username withDisplayName:(NSString*) displayName;
-(void) updateUIFromLinphoneState:(UIViewController*) viewCtrl;
//status reporting
-(void) displayStatus:(NSString*) message;
@end

View file

@ -26,3 +26,4 @@
#import "UIDuration.h"
#import "UIEraseButton.h"
#import "LinphoneUIDelegates.h"
#import "UIPauseResumeButton.h"

View file

@ -0,0 +1,28 @@
/* UIMuteButton.h
*
* Copyright (C) 2011 Belledonne Comunications, Grenoble, France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#import <UIKit/UIKit.h>
#import "UIToggleButton.h"
@interface UIPauseResumeButton : UIToggleButton<UIToggleButtonDelegate> {
}
@end

View file

@ -0,0 +1,69 @@
/* UIMuteButton.m
*
* Copyright (C) 2011 Belledonne Comunications, Grenoble, France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#import "UIPauseResumeButton.h"
#include "LinphoneManager.h"
@implementation UIPauseResumeButton
-(void) onOn {
LinphoneCall* c = linphone_core_get_current_call([LinphoneManager getLc]);
if (c) {
linphone_core_pause_call([LinphoneManager getLc], c);
}
}
-(void) onOff {
const MSList* c = linphone_core_get_calls([LinphoneManager getLc]);
if (c) {
linphone_core_resume_call([LinphoneManager getLc], (LinphoneCall*) c->data);
}
}
-(bool) isInitialStateOn {
@try {
const MSList* c = linphone_core_get_calls([LinphoneManager getLc]);
if (c) {
return linphone_call_get_state((LinphoneCall*)c->data) == LinphoneCallPaused;
} else {
return false;
}
} @catch(NSException* e) {
//not ready yet
return false;
}
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
// Drawing code.
}
*/
- (void)dealloc {
[super dealloc];
}
@end

View file

@ -234,6 +234,10 @@
[status setText:message];
}
-(void) updateUIFromLinphoneState:(UIViewController*) viewCtrl {
[mute reset];
}
-(void) displayIncomingCallNotigicationFromUI:(UIViewController*) viewCtrl forUser:(NSString*) username withDisplayName:(NSString*) displayName {