repair background mode and fix double instanciation of settingsStore, causing inconsistencies between visible configuration and used one.

rename RFC dtmf.
This commit is contained in:
Simon Morlat 2012-08-14 23:47:51 +02:00
parent a506e6b2a1
commit c786f60d81
5 changed files with 43 additions and 30 deletions

View file

@ -82,22 +82,30 @@ int __aeabi_idiv(int a, int b) {
}
}
- (void)applicationDidEnterBackground:(UIApplication *)application{
[LinphoneLogger logc:LinphoneLoggerLog format:"applicationDidEnterBackground"];
if(![LinphoneManager isLcReady]) return;
[[LinphoneManager instance] enterBackgroundMode];
}
- (void)applicationWillResignActive:(UIApplication *)application {
[LinphoneLogger logc:LinphoneLoggerLog format:"applicationWillResignActive"];
if(![LinphoneManager isLcReady]) return;
LinphoneCore* lc = [LinphoneManager getLc];
LinphoneCall* call = linphone_core_get_current_call(lc);
if (call == NULL)
return;
if (call){
/* save call context */
LinphoneManager* instance = [LinphoneManager instance];
instance->currentCallContextBeforeGoingBackground.call = call;
instance->currentCallContextBeforeGoingBackground.cameraIsEnabled = linphone_call_camera_enabled(call);
/* save call context */
LinphoneManager* instance = [LinphoneManager instance];
instance->currentCallContextBeforeGoingBackground.call = call;
instance->currentCallContextBeforeGoingBackground.cameraIsEnabled = linphone_call_camera_enabled(call);
const LinphoneCallParams* params = linphone_call_get_current_params(call);
if (linphone_call_params_video_enabled(params)) {
linphone_call_enable_camera(call, false);
}
const LinphoneCallParams* params = linphone_call_get_current_params(call);
if (linphone_call_params_video_enabled(params)) {
linphone_call_enable_camera(call, false);
}
}
if (![[LinphoneManager instance] resignActive]) {
// destroying eventHandler if app cannot go in background.
@ -111,7 +119,8 @@ int __aeabi_idiv(int a, int b) {
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
- (void)applicationDidBecomeActive:(UIApplication *)application {
[LinphoneLogger logc:LinphoneLoggerLog format:"applicationDidBecomeActive"];
[self startApplication];
[[LinphoneManager instance] becomeActive];
@ -121,19 +130,19 @@ int __aeabi_idiv(int a, int b) {
LinphoneCore* lc = [LinphoneManager getLc];
LinphoneCall* call = linphone_core_get_current_call(lc);
if (call == NULL)
return;
LinphoneManager* instance = [LinphoneManager instance];
if (call == instance->currentCallContextBeforeGoingBackground.call) {
const LinphoneCallParams* params = linphone_call_get_current_params(call);
if (linphone_call_params_video_enabled(params)) {
linphone_call_enable_camera(
if (call){
LinphoneManager* instance = [LinphoneManager instance];
if (call == instance->currentCallContextBeforeGoingBackground.call) {
const LinphoneCallParams* params = linphone_call_get_current_params(call);
if (linphone_call_params_video_enabled(params)) {
linphone_call_enable_camera(
call,
instance->currentCallContextBeforeGoingBackground.cameraIsEnabled);
}
instance->currentCallContextBeforeGoingBackground.call = 0;
}
}
instance->currentCallContextBeforeGoingBackground.call = 0;
}
}
}
- (void)setupGSMInteraction {

View file

@ -377,9 +377,9 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args);
}
- (BOOL)synchronize {
if (![LinphoneManager isLcReady]) return YES;
LinphoneCore *lc=[LinphoneManager getLc];
if (lc==NULL) return YES;
BOOL account_changed;
account_changed=[self valueChangedForKey:@"username_preference"]

View file

@ -107,6 +107,7 @@ typedef struct _LinphoneManagerSounds {
- (void)destroyLibLinphone;
- (BOOL)resignActive;
- (void)becomeActive;
- (BOOL)enterBackgroundMode;
+ (void)kickOffNetworkConnection;
- (void)setupNetworkReachabilityCallback;

View file

@ -668,7 +668,8 @@ static LinphoneCoreVTable linphonec_vtable = {
else
ms_set_cpu_count(1);
settingsStore = [[LinphoneCoreSettingsStore alloc] init];
if (!settingsStore)
settingsStore = [[LinphoneCoreSettingsStore alloc] init];
[LinphoneLogger logc:LinphoneLoggerWarning format:"Linphone [%s] started on [%s]"
,linphone_core_get_version()
@ -686,10 +687,12 @@ static LinphoneCoreVTable linphonec_vtable = {
[mIterateTimer invalidate];
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
[audioSession setDelegate:nil];
#if 0
if (settingsStore != nil) {
[settingsStore release];
settingsStore = nil;
}
#endif
if (theLinphoneCore != nil) { //just in case application terminate before linphone core initialization
[LinphoneLogger logc:LinphoneLoggerLog format:"Destroy linphonecore"];
linphone_core_destroy(theLinphoneCore);
@ -705,19 +708,19 @@ static LinphoneCoreVTable linphonec_vtable = {
- (BOOL)resignActive {
if ([[LinphoneManager instance] settingsStore] != Nil)
[[[LinphoneManager instance] settingsStore] synchronize];
return [self enterBackgroundMode];
linphone_core_stop_dtmf_stream(theLinphoneCore);
return YES;
}
- (BOOL)enterBackgroundMode {
LinphoneProxyConfig* proxyCfg;
linphone_core_get_default_proxy(theLinphoneCore, &proxyCfg);
linphone_core_stop_dtmf_stream(theLinphoneCore);
if (proxyCfg && [settingsStore boolForKey:@"backgroundmode_preference"]) {
if (proxyCfg && [[NSUserDefaults standardUserDefaults] boolForKey:@"backgroundmode_preference"]) {
//For registration register
linphone_core_refresh_registers(theLinphoneCore);
//wait for registration answer
int i=0;
while (!linphone_proxy_config_is_registered(proxyCfg) && i++<40 ) {

View file

@ -36,7 +36,7 @@
<key>Type</key>
<string>PSToggleSwitchSpecifier</string>
<key>Title</key>
<string>Enable RFC DTMF</string>
<string>Send inband DTMFs</string>
<key>Key</key>
<string>rfc_dtmf_preference</string>
<key>DefaultValue</key>
@ -46,7 +46,7 @@
<key>Type</key>
<string>PSToggleSwitchSpecifier</string>
<key>Title</key>
<string>Enable SIPINFO DTMF</string>
<string>Send SIP INFO DTMFs</string>
<key>Key</key>
<string>sipinfo_dtmf_preference</string>
<key>DefaultValue</key>