From 2d879e19cceec0611a20619e07c5be46505cdc58 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Tue, 9 Sep 2014 14:23:09 +0200 Subject: [PATCH] Add possibility to change adaptive rate algorithm in audio settings --- Classes/LinphoneCoreSettingsStore.m | 754 +++++++++++----------- Settings/InAppSettings.bundle/Audio.plist | 20 + submodules/belle-sip | 2 +- submodules/build/Makefile | 20 +- submodules/linphone | 2 +- 5 files changed, 411 insertions(+), 387 deletions(-) diff --git a/Classes/LinphoneCoreSettingsStore.m b/Classes/LinphoneCoreSettingsStore.m index 16d58ba71..e8a66aec9 100644 --- a/Classes/LinphoneCoreSettingsStore.m +++ b/Classes/LinphoneCoreSettingsStore.m @@ -4,18 +4,18 @@ * * 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 + * 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 "LinphoneCoreSettingsStore.h" @@ -43,14 +43,14 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); - (void)transformKeysToLinphoneCore { //LinphoneCore *lc=[LinphoneManager getLc]; - + } - (void)setString:(const char*)value forKey:(NSString*)key { id obj=Nil; if (value) obj=[[NSString alloc] initWithCString:value encoding:[NSString defaultCStringEncoding] ]; [self setObject:obj forKey:key]; - [obj release]; + [obj release]; } - (NSString*)stringForKey:(NSString*) key { @@ -64,7 +64,7 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); PayloadType *pt=(PayloadType*)elem->data; NSString *pref=[LinphoneManager getPreferenceForCodec:pt->mime_type withRate:pt->clock_rate]; if (pref){ - bool_t value = linphone_core_payload_type_enabled(lc,pt); + bool_t value = linphone_core_payload_type_enabled(lc,pt); [self setBool:value forKey: pref]; }else{ [LinphoneLogger logc:LinphoneLoggerWarning format:"Codec %s/%i supported by core is not shown in iOS app config view.", @@ -76,7 +76,7 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); - (void)transformLinphoneCoreToKeys { LinphoneCore *lc=[LinphoneManager getLc]; LinphoneProxyConfig *cfg=NULL; - LpConfig* conf = linphone_core_get_config(lc); + LpConfig* conf = linphone_core_get_config(lc); linphone_core_get_default_proxy(lc,&cfg); if (cfg){ const char *identity=linphone_proxy_config_get_identity(cfg); @@ -85,10 +85,10 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); const char *proxy=linphone_proxy_config_get_addr(cfg); LinphoneAddress *proxy_addr=linphone_address_new(proxy); int port=linphone_address_get_port(proxy_addr); - + [self setString: linphone_address_get_username(addr) forKey:@"username_preference"]; [self setString: linphone_address_get_domain(addr) forKey:@"domain_preference"]; - [self setInteger: linphone_proxy_config_get_expires(cfg) forKey:@"expire_preference"]; + [self setInteger: linphone_proxy_config_get_expires(cfg) forKey:@"expire_preference"]; [self setString: linphone_proxy_config_get_dial_prefix(cfg) forKey:@"prefix_preference"]; if (strcmp(linphone_address_get_domain(addr),linphone_address_get_domain(proxy_addr))!=0 || port>0){ char tmp[256]={0}; @@ -98,74 +98,74 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); [self setString:tmp forKey:@"proxy_preference"]; } - const char* tname = "udp"; - switch (linphone_address_get_transport(proxy_addr)) { - case LinphoneTransportTcp: tname = "tcp"; break; - case LinphoneTransportTls: tname = "tls"; break; - default: break; - } - [self setString:tname forKey:@"transport_preference"]; + const char* tname = "udp"; + switch (linphone_address_get_transport(proxy_addr)) { + case LinphoneTransportTcp: tname = "tcp"; break; + case LinphoneTransportTls: tname = "tls"; break; + default: break; + } + [self setString:tname forKey:@"transport_preference"]; linphone_address_destroy(addr); linphone_address_destroy(proxy_addr); [self setBool: (linphone_proxy_config_get_route(cfg)!=NULL) forKey:@"outbound_proxy_preference"]; [self setBool:linphone_proxy_config_get_dial_escape_plus(cfg) forKey:@"substitute_+_by_00_preference"]; - [self setBool:linphone_proxy_config_avpf_enabled(cfg) forKey:@"avpf_preference"]; - + [self setBool:linphone_proxy_config_avpf_enabled(cfg) forKey:@"avpf_preference"]; + } } else { [self setInteger: lp_config_get_int(conf,"default_values","reg_expires", 600) forKey:@"expire_preference"]; - [self setObject:@"" forKey:@"username_preference"]; - [self setObject:@"" forKey:@"domain_preference"]; - [self setObject:@"" forKey:@"proxy_preference"]; - [self setObject:@"" forKey:@"password_preference"]; - [self setBool:FALSE forKey:@"outbound_proxy_preference"]; - [self setString:"udp" forKey:@"transport_preference"]; - [self setBool:FALSE forKey:@"avpf_preference"]; + [self setObject:@"" forKey:@"username_preference"]; + [self setObject:@"" forKey:@"domain_preference"]; + [self setObject:@"" forKey:@"proxy_preference"]; + [self setObject:@"" forKey:@"password_preference"]; + [self setBool:FALSE forKey:@"outbound_proxy_preference"]; + [self setString:"udp" forKey:@"transport_preference"]; + [self setBool:FALSE forKey:@"avpf_preference"]; } - [self setBool:lp_config_get_int(conf, LINPHONERC_APPLICATION_KEY, "pushnotification_preference", 0) forKey:@"pushnotification_preference"]; - { - LinphoneAddress *parsed = linphone_core_get_primary_contact_parsed(lc); - if(parsed != NULL) { - [self setString: linphone_address_get_display_name(parsed) forKey:@"primary_displayname_preference"]; - [self setString: linphone_address_get_username(parsed) forKey:@"primary_username_preference"]; - } - linphone_address_destroy(parsed); - } - { - { - int minPort, maxPort; - linphone_core_get_audio_port_range(lc, &minPort, &maxPort); - if(minPort != maxPort) - [self setObject:[NSString stringWithFormat:@"%d-%d", minPort, maxPort] forKey:@"audio_port_preference"]; - else - [self setObject:[NSString stringWithFormat:@"%d", minPort] forKey:@"audio_port_preference"]; - } - { - int minPort, maxPort; - linphone_core_get_video_port_range(lc, &minPort, &maxPort); - if(minPort != maxPort) - [self setObject:[NSString stringWithFormat:@"%d-%d", minPort, maxPort] forKey:@"video_port_preference"]; - else - [self setObject:[NSString stringWithFormat:@"%d", minPort] forKey:@"video_port_preference"]; - } - } - { - [self setInteger: linphone_core_get_upload_bandwidth(lc) forKey:@"upload_bandwidth_preference"]; - [self setInteger: linphone_core_get_download_bandwidth(lc) forKey:@"download_bandwidth_preference"]; - } - { - [self setFloat:linphone_core_get_playback_gain_db(lc) forKey:@"playback_gain_preference"]; - [self setFloat:linphone_core_get_mic_gain_db(lc) forKey:@"microphone_gain_preference"]; - } + [self setBool:lp_config_get_int(conf, LINPHONERC_APPLICATION_KEY, "pushnotification_preference", 0) forKey:@"pushnotification_preference"]; { - int port = lp_config_get_int(conf, LINPHONERC_APPLICATION_KEY, "port_preference", 5060); - [self setInteger:port forKey:@"port_preference"]; - int random_port_preference = lp_config_get_int(conf,LINPHONERC_APPLICATION_KEY,"random_port_preference", 1); - [self setInteger:random_port_preference forKey:@"random_port_preference"]; + LinphoneAddress *parsed = linphone_core_get_primary_contact_parsed(lc); + if(parsed != NULL) { + [self setString: linphone_address_get_display_name(parsed) forKey:@"primary_displayname_preference"]; + [self setString: linphone_address_get_username(parsed) forKey:@"primary_username_preference"]; + } + linphone_address_destroy(parsed); + } + { + { + int minPort, maxPort; + linphone_core_get_audio_port_range(lc, &minPort, &maxPort); + if(minPort != maxPort) + [self setObject:[NSString stringWithFormat:@"%d-%d", minPort, maxPort] forKey:@"audio_port_preference"]; + else + [self setObject:[NSString stringWithFormat:@"%d", minPort] forKey:@"audio_port_preference"]; + } + { + int minPort, maxPort; + linphone_core_get_video_port_range(lc, &minPort, &maxPort); + if(minPort != maxPort) + [self setObject:[NSString stringWithFormat:@"%d-%d", minPort, maxPort] forKey:@"video_port_preference"]; + else + [self setObject:[NSString stringWithFormat:@"%d", minPort] forKey:@"video_port_preference"]; + } + } + { + [self setInteger: linphone_core_get_upload_bandwidth(lc) forKey:@"upload_bandwidth_preference"]; + [self setInteger: linphone_core_get_download_bandwidth(lc) forKey:@"download_bandwidth_preference"]; + } + { + [self setFloat:linphone_core_get_playback_gain_db(lc) forKey:@"playback_gain_preference"]; + [self setFloat:linphone_core_get_mic_gain_db(lc) forKey:@"microphone_gain_preference"]; + } + { + int port = lp_config_get_int(conf, LINPHONERC_APPLICATION_KEY, "port_preference", 5060); + [self setInteger:port forKey:@"port_preference"]; + int random_port_preference = lp_config_get_int(conf,LINPHONERC_APPLICATION_KEY,"random_port_preference", 1); + [self setInteger:random_port_preference forKey:@"random_port_preference"]; } { LinphoneAuthInfo *ai; @@ -173,25 +173,26 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); if (elem && (ai=(LinphoneAuthInfo*)elem->data)){ [self setString: linphone_auth_info_get_passwd(ai) forKey:@"password_preference"]; [self setString: linphone_auth_info_get_ha1(ai) forKey:@"ha1_preference"]; // hidden but useful if provisioned - [self setString:linphone_auth_info_get_userid(ai) forKey:@"userid_preference"]; + [self setString:linphone_auth_info_get_userid(ai) forKey:@"userid_preference"]; } } { [self setString: linphone_core_get_stun_server(lc) forKey:@"stun_preference"]; - [self setBool:linphone_core_get_firewall_policy(lc)==LinphonePolicyUseIce forKey:@"ice_preference"]; + [self setBool:linphone_core_get_firewall_policy(lc)==LinphonePolicyUseIce forKey:@"ice_preference"]; } - + { [self transformCodecsToKeys: linphone_core_get_audio_codecs(lc)]; [self transformCodecsToKeys: linphone_core_get_video_codecs(lc)]; - [self setBool:linphone_core_adaptive_rate_control_enabled(lc) forKey:@"adaptive_rate_control_preference"]; - [self setInteger:lp_config_get_int(conf, "audio", "codec_bitrate_limit", kLinphoneAudioVbrCodecDefaultBitrate) forKey:@"audio_codec_bitrate_limit_preference"]; + [self setBool:linphone_core_adaptive_rate_control_enabled(lc) forKey:@"adaptive_rate_control_preference"]; + [self setString:linphone_core_get_adaptive_rate_algorithm(lc) forKey:@"adaptive_rate_algorithm_preference"]; + [self setInteger:lp_config_get_int(conf, "audio", "codec_bitrate_limit", kLinphoneAudioVbrCodecDefaultBitrate) forKey:@"audio_codec_bitrate_limit_preference"]; } - [self setBool:lp_config_get_int(conf, LINPHONERC_APPLICATION_KEY, "advanced_account_preference", 0) forKey:@"advanced_account_preference"]; + [self setBool:lp_config_get_int(conf, LINPHONERC_APPLICATION_KEY, "advanced_account_preference", 0) forKey:@"advanced_account_preference"]; - { + { LinphoneMediaEncryption menc=linphone_core_get_media_encryption(lc); const char *val; switch(menc){ @@ -201,16 +202,16 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); } [self setString:val forKey:@"media_encryption_preference"]; } - [self setString: lp_config_get_string(conf, LINPHONERC_APPLICATION_KEY, "rotation_preference", "auto") forKey:@"rotation_preference"]; + [self setString: lp_config_get_string(conf, LINPHONERC_APPLICATION_KEY, "rotation_preference", "auto") forKey:@"rotation_preference"]; [self setBool: lp_config_get_int(conf, LINPHONERC_APPLICATION_KEY, "edge_opt_preference", 0) forKey:@"edge_opt_preference"]; - [self setBool: lp_config_get_int(conf, LINPHONERC_APPLICATION_KEY, "enable_first_login_view_preference", 0) forKey:@"enable_first_login_view_preference"]; + [self setBool: lp_config_get_int(conf, LINPHONERC_APPLICATION_KEY, "enable_first_login_view_preference", 0) forKey:@"enable_first_login_view_preference"]; [self setBool: lp_config_get_int(conf, LINPHONERC_APPLICATION_KEY, "debugenable_preference", 0) forKey:@"debugenable_preference"]; [self setBool: lp_config_get_int(conf, LINPHONERC_APPLICATION_KEY, "animations_preference", 1) forKey:@"animations_preference"]; [self setBool: lp_config_get_int(conf, LINPHONERC_APPLICATION_KEY, "wifi_only_preference", 0) forKey:@"wifi_only_preference"]; [self setString: lp_config_get_string(conf, LINPHONERC_APPLICATION_KEY, "sharing_server_preference", NULL) forKey:@"sharing_server_preference"]; - [self setBool:lp_config_get_int(conf, "sip", "use_ipv6", 0) forKey:@"use_ipv6"]; + [self setBool:lp_config_get_int(conf, "sip", "use_ipv6", 0) forKey:@"use_ipv6"]; + - [self setBool: lp_config_get_int(conf,LINPHONERC_APPLICATION_KEY,"start_at_boot_preference",1) forKey:@"start_at_boot_preference"]; [self setBool: lp_config_get_int(conf,LINPHONERC_APPLICATION_KEY,"backgroundmode_preference",1) forKey:@"backgroundmode_preference"]; [self setBool: lp_config_get_int(conf,LINPHONERC_APPLICATION_KEY,"autoanswer_notif_preference",1) forKey:@"autoanswer_notif_preference"]; @@ -221,10 +222,10 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); [self setBool: linphone_core_video_enabled(lc) forKey:@"enable_video_preference"]; pol=linphone_core_get_video_policy(lc); [self setBool:(pol->automatically_initiate) forKey:@"start_video_preference"]; - [self setBool:(pol->automatically_accept) forKey:@"accept_video_preference"]; - [self setBool:linphone_core_self_view_enabled(lc) forKey:@"self_video_preference"]; + [self setBool:(pol->automatically_accept) forKey:@"accept_video_preference"]; + [self setBool:linphone_core_self_view_enabled(lc) forKey:@"self_video_preference"]; BOOL previewEnabled=lp_config_get_int(conf,LINPHONERC_APPLICATION_KEY,"preview_preference",1); - [self setBool:previewEnabled forKey:@"preview_preference"]; + [self setBool:previewEnabled forKey:@"preview_preference"]; MSVideoSize vsize = linphone_core_get_preferred_video_size(lc); int index; if ((vsize.width == MS_VIDEO_SIZE_720P_W) && (vsize.height == MS_VIDEO_SIZE_720P_H)) { @@ -236,35 +237,35 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); } [self setInteger:index forKey:@"video_preferred_size_preference"]; } - { - [self setBool:linphone_core_get_use_info_for_dtmf(lc) forKey:@"sipinfo_dtmf_preference"]; - [self setBool:linphone_core_get_use_rfc2833_for_dtmf(lc) forKey:@"rfc_dtmf_preference"]; - - [self setInteger:linphone_core_get_inc_timeout(lc) forKey:@"incoming_call_timeout_preference"]; - [self setInteger:linphone_core_get_in_call_timeout(lc) forKey:@"in_call_timeout_preference"]; - } - - // Tunnel - if (linphone_core_tunnel_available()){ - LinphoneTunnel *tunnel = linphone_core_get_tunnel([LinphoneManager getLc]); - [self setString:lp_config_get_string(linphone_core_get_config(lc), LINPHONERC_APPLICATION_KEY, "tunnel_mode_preference", "off") forKey:@"tunnel_mode_preference"]; - const MSList* configs = linphone_tunnel_get_servers(tunnel); - if(configs != NULL) { - LinphoneTunnelConfig *ltc = (LinphoneTunnelConfig *)configs->data; - [self setString:linphone_tunnel_config_get_host(ltc) forKey:@"tunnel_address_preference"]; - [self setInteger:linphone_tunnel_config_get_port(ltc) forKey:@"tunnel_port_preference"]; - } else { - [self setString:"" forKey:@"tunnel_address_preference"]; - [self setInteger:443 forKey:@"tunnel_port_preference"]; - } - } - + { + [self setBool:linphone_core_get_use_info_for_dtmf(lc) forKey:@"sipinfo_dtmf_preference"]; + [self setBool:linphone_core_get_use_rfc2833_for_dtmf(lc) forKey:@"rfc_dtmf_preference"]; + + [self setInteger:linphone_core_get_inc_timeout(lc) forKey:@"incoming_call_timeout_preference"]; + [self setInteger:linphone_core_get_in_call_timeout(lc) forKey:@"in_call_timeout_preference"]; + } + + // Tunnel + if (linphone_core_tunnel_available()){ + LinphoneTunnel *tunnel = linphone_core_get_tunnel([LinphoneManager getLc]); + [self setString:lp_config_get_string(linphone_core_get_config(lc), LINPHONERC_APPLICATION_KEY, "tunnel_mode_preference", "off") forKey:@"tunnel_mode_preference"]; + const MSList* configs = linphone_tunnel_get_servers(tunnel); + if(configs != NULL) { + LinphoneTunnelConfig *ltc = (LinphoneTunnelConfig *)configs->data; + [self setString:linphone_tunnel_config_get_host(ltc) forKey:@"tunnel_address_preference"]; + [self setInteger:linphone_tunnel_config_get_port(ltc) forKey:@"tunnel_port_preference"]; + } else { + [self setString:"" forKey:@"tunnel_address_preference"]; + [self setInteger:443 forKey:@"tunnel_port_preference"]; + } + } + [changedDict release]; changedDict = [[NSMutableDictionary alloc] init]; - - // Post event - NSDictionary *eventDic = [NSDictionary dictionaryWithObject:self forKey:@"settings"]; - [[NSNotificationCenter defaultCenter] postNotificationName:kLinphoneLogsUpdate object:self userInfo:eventDic]; + + // Post event + NSDictionary *eventDic = [NSDictionary dictionaryWithObject:self forKey:@"settings"]; + [[NSNotificationCenter defaultCenter] postNotificationName:kLinphoneLogsUpdate object:self userInfo:eventDic]; } - (void)setObject:(id)value forKey:(NSString *)key { @@ -273,7 +274,7 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); } - (id)objectForKey:(NSString*)key { - return [dict valueForKey:key]; + return [dict valueForKey:key]; } - (BOOL)valueChangedForKey:(NSString*)key { @@ -281,70 +282,70 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); } - (void)alertAccountError:(NSString*)error { - UIAlertView* alertview = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Error", nil) - message:error - delegate:nil - cancelButtonTitle:NSLocalizedString(@"OK", nil) - otherButtonTitles: nil]; - [alertview show]; - [alertview release]; + UIAlertView* alertview = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Error", nil) + message:error + delegate:nil + cancelButtonTitle:NSLocalizedString(@"OK", nil) + otherButtonTitles: nil]; + [alertview show]; + [alertview release]; } - (void)synchronizeAccount { LinphoneCore *lc = [LinphoneManager getLc]; - LpConfig* conf = linphone_core_get_config(lc); + LpConfig* conf = linphone_core_get_config(lc); LinphoneProxyConfig* proxyCfg = NULL; BOOL isEditing = FALSE; - NSString* error = nil; + NSString* error = nil; int port_preference = [self integerForKey:@"port_preference"]; - - BOOL random_port_preference = [self boolForKey:@"random_port_preference"]; - lp_config_set_int(conf, LINPHONERC_APPLICATION_KEY, "random_port_preference", random_port_preference); - if(random_port_preference) { - port_preference = -1; - } + + BOOL random_port_preference = [self boolForKey:@"random_port_preference"]; + lp_config_set_int(conf, LINPHONERC_APPLICATION_KEY, "random_port_preference", random_port_preference); + if(random_port_preference) { + port_preference = -1; + } LCSipTransports transportValue={ port_preference, port_preference, -1, -1 }; - // will also update the sip_*_port section of the config - if (linphone_core_set_sip_transports(lc, &transportValue)) { - [LinphoneLogger logc:LinphoneLoggerError format:"cannot set transport"]; - } + // will also update the sip_*_port section of the config + if (linphone_core_set_sip_transports(lc, &transportValue)) { + [LinphoneLogger logc:LinphoneLoggerError format:"cannot set transport"]; + } - port_preference = linphone_core_get_sip_port(lc); - [self setInteger:port_preference forKey:@"port_preference"]; // Update back preference + port_preference = linphone_core_get_sip_port(lc); + [self setInteger:port_preference forKey:@"port_preference"]; // Update back preference - BOOL enable_ipv6 = [self boolForKey:@"use_ipv6"]; - lp_config_set_int(conf, "sip", "use_ipv6", enable_ipv6); - if( linphone_core_ipv6_enabled(lc) != enable_ipv6){ - [LinphoneLogger logc:LinphoneLoggerDebug format:"%@ IPV6", enable_ipv6?@"ENABLING":@"DISABLING"]; - linphone_core_enable_ipv6(lc, enable_ipv6); - } + BOOL enable_ipv6 = [self boolForKey:@"use_ipv6"]; + lp_config_set_int(conf, "sip", "use_ipv6", enable_ipv6); + if( linphone_core_ipv6_enabled(lc) != enable_ipv6){ + [LinphoneLogger logc:LinphoneLoggerDebug format:"%@ IPV6", enable_ipv6?@"ENABLING":@"DISABLING"]; + linphone_core_enable_ipv6(lc, enable_ipv6); + } //configure sip account - + //mandatory parameters NSString* username = [self stringForKey:@"username_preference"]; - NSString* userID = [self stringForKey:@"userid_preference"]; + NSString* userID = [self stringForKey:@"userid_preference"]; NSString* domain = [self stringForKey:@"domain_preference"]; - NSString* transport = [self stringForKey:@"transport_preference"]; - NSString* accountHa1 = [self stringForKey:@"ha1_preference"]; + NSString* transport = [self stringForKey:@"transport_preference"]; + NSString* accountHa1 = [self stringForKey:@"ha1_preference"]; NSString* accountPassword = [self stringForKey:@"password_preference"]; - bool isOutboundProxy = [self boolForKey:@"outbound_proxy_preference"]; - BOOL use_avpf = [self boolForKey:@"avpf_preference"]; + bool isOutboundProxy = [self boolForKey:@"outbound_proxy_preference"]; + BOOL use_avpf = [self boolForKey:@"avpf_preference"]; if (username && [username length] >0 && domain && [domain length]>0) { - int expire = [self integerForKey:@"expire_preference"]; - BOOL isWifiOnly = [self boolForKey:@"wifi_only_preference"]; - BOOL pushnotification = [self boolForKey:@"pushnotification_preference"]; - NSString* prefix = [self stringForKey:@"prefix_preference"]; - NSString* proxyAddress = [self stringForKey:@"proxy_preference"]; + int expire = [self integerForKey:@"expire_preference"]; + BOOL isWifiOnly = [self boolForKey:@"wifi_only_preference"]; + BOOL pushnotification = [self boolForKey:@"pushnotification_preference"]; + NSString* prefix = [self stringForKey:@"prefix_preference"]; + NSString* proxyAddress = [self stringForKey:@"proxy_preference"]; - LinphoneAuthInfo *info = NULL; - const char* route = NULL; + LinphoneAuthInfo *info = NULL; + const char* route = NULL; if( isWifiOnly && [LinphoneManager instance].connectivity == wwan ) expire = 0; @@ -353,19 +354,19 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); } else { proxyAddress = [NSString stringWithFormat:@"sip:%@",proxyAddress] ; } - + char* proxy = ms_strdup([proxyAddress cStringUsingEncoding:[NSString defaultCStringEncoding]]); - LinphoneAddress* proxy_addr = linphone_address_new(proxy); + LinphoneAddress* proxy_addr = linphone_address_new(proxy); - if( proxy_addr ){ - LinphoneTransportType type = LinphoneTransportUdp; - if ( [transport isEqualToString:@"tcp"] ) type = LinphoneTransportTcp; - else if ( [transport isEqualToString:@"tls"] ) type = LinphoneTransportTls; + if( proxy_addr ){ + LinphoneTransportType type = LinphoneTransportUdp; + if ( [transport isEqualToString:@"tcp"] ) type = LinphoneTransportTcp; + else if ( [transport isEqualToString:@"tls"] ) type = LinphoneTransportTls; - linphone_address_set_transport(proxy_addr, type); - ms_free(proxy); - proxy = linphone_address_as_string_uri_only(proxy_addr); - } + linphone_address_set_transport(proxy_addr, type); + ms_free(proxy); + proxy = linphone_address_as_string_uri_only(proxy_addr); + } // use proxy as route if outbound_proxy is enabled route = isOutboundProxy? proxy : NULL; @@ -391,7 +392,7 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); if( linphone_proxy_config_set_identity(proxyCfg, identity) == -1 ) { error = NSLocalizedString(@"Invalid username or domain",nil); goto bad_proxy;} - if( linphone_proxy_config_set_server_addr(proxyCfg, proxy) == -1 ) { error = NSLocalizedString(@"Invalid proxy address", nil); goto bad_proxy; } + if( linphone_proxy_config_set_server_addr(proxyCfg, proxy) == -1 ) { error = NSLocalizedString(@"Invalid proxy address", nil); goto bad_proxy; } if( linphone_proxy_config_set_route(proxyCfg, route) == -1 ) { error = NSLocalizedString(@"Invalid route", nil); goto bad_proxy; } if ([prefix length]>0) { @@ -403,26 +404,26 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); linphone_proxy_config_set_dial_escape_plus(proxyCfg,substitute_plus_by_00); } - lp_config_set_int(conf, LINPHONERC_APPLICATION_KEY, "pushnotification_preference", pushnotification); - if( pushnotification ) [[LinphoneManager instance] addPushTokenToProxyConfig:proxyCfg]; + lp_config_set_int(conf, LINPHONERC_APPLICATION_KEY, "pushnotification_preference", pushnotification); + if( pushnotification ) [[LinphoneManager instance] addPushTokenToProxyConfig:proxyCfg]; - linphone_proxy_config_enable_register(proxyCfg, true); - linphone_proxy_config_enable_avpf(proxyCfg, use_avpf); + linphone_proxy_config_enable_register(proxyCfg, true); + linphone_proxy_config_enable_avpf(proxyCfg, use_avpf); linphone_proxy_config_set_expires(proxyCfg, expire); // setup auth info LinphoneAddress *from = linphone_address_new(identity); if (from != 0){ - const char* userid_str = (userID != nil)? [userID UTF8String] : NULL; + const char* userid_str = (userID != nil)? [userID UTF8String] : NULL; info=linphone_auth_info_new(linphone_address_get_username(from),userid_str,password,ha1,NULL,linphone_proxy_config_get_domain(proxyCfg)); - linphone_address_destroy(from); + linphone_address_destroy(from); } - // We reached here without hitting the goto: the new settings are correct, so replace the previous ones. + // We reached here without hitting the goto: the new settings are correct, so replace the previous ones. // add auth info linphone_core_clear_all_auth_info(lc); - if( info ) { linphone_core_add_auth_info(lc,info); } + if( info ) { linphone_core_add_auth_info(lc,info); } // setup new proxycfg if( isEditing ){ @@ -433,116 +434,119 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); linphone_core_set_default_proxy(lc,proxyCfg); } - bad_proxy: + bad_proxy: if( linphoneAddress) - linphone_address_destroy(linphoneAddress); - if( proxy) - ms_free(proxy); - if( info ) - linphone_auth_info_destroy(info); + linphone_address_destroy(linphoneAddress); + if( proxy) + ms_free(proxy); + if( info ) + linphone_auth_info_destroy(info); // in case of error, show an alert to the user - if( error != nil ){ + if( error != nil ){ if( isEditing ) linphone_proxy_config_done(proxyCfg); else linphone_proxy_config_destroy(proxyCfg); - [self alertAccountError:error]; - } + [self alertAccountError:error]; + } } - [[[LinphoneManager instance] fastAddressBook] reload]; + [[[LinphoneManager instance] fastAddressBook] reload]; } + (int)validPort:(int)port { - if(port < 0) { - return 0; - } - if(port > 65535) { - return 65535; - } - return port; + if(port < 0) { + return 0; + } + if(port > 65535) { + return 65535; + } + return port; } + (BOOL)parsePortRange:(NSString*)text minPort:(int*)minPort maxPort:(int*)maxPort { - NSError* error = nil; - *minPort = -1; - *maxPort = -1; - NSRegularExpression* regex = [NSRegularExpression regularExpressionWithPattern:@"([0-9]+)(([^0-9]+)([0-9]+))?" options:0 error:&error]; - if(error != NULL) - return FALSE; - NSArray* matches = [regex matchesInString:text options:0 range:NSMakeRange(0, [text length])]; - if([matches count] == 1) { - NSTextCheckingResult *match = [matches objectAtIndex:0]; - bool range = [match rangeAtIndex:2].length > 0; - if(!range) { - NSRange rangeMinPort = [match rangeAtIndex:1]; - *minPort = [LinphoneCoreSettingsStore validPort:[[text substringWithRange:rangeMinPort] integerValue]]; - *maxPort = *minPort; - return TRUE; - } else { - NSRange rangeMinPort = [match rangeAtIndex:1]; - *minPort = [LinphoneCoreSettingsStore validPort:[[text substringWithRange:rangeMinPort] integerValue]]; - NSRange rangeMaxPort = [match rangeAtIndex:4]; - *maxPort = [LinphoneCoreSettingsStore validPort:[[text substringWithRange:rangeMaxPort] integerValue]]; - if(*minPort > *maxPort) { - *minPort = *maxPort; - } - return TRUE; - } - } - return FALSE; + NSError* error = nil; + *minPort = -1; + *maxPort = -1; + NSRegularExpression* regex = [NSRegularExpression regularExpressionWithPattern:@"([0-9]+)(([^0-9]+)([0-9]+))?" options:0 error:&error]; + if(error != NULL) + return FALSE; + NSArray* matches = [regex matchesInString:text options:0 range:NSMakeRange(0, [text length])]; + if([matches count] == 1) { + NSTextCheckingResult *match = [matches objectAtIndex:0]; + bool range = [match rangeAtIndex:2].length > 0; + if(!range) { + NSRange rangeMinPort = [match rangeAtIndex:1]; + *minPort = [LinphoneCoreSettingsStore validPort:[[text substringWithRange:rangeMinPort] integerValue]]; + *maxPort = *minPort; + return TRUE; + } else { + NSRange rangeMinPort = [match rangeAtIndex:1]; + *minPort = [LinphoneCoreSettingsStore validPort:[[text substringWithRange:rangeMinPort] integerValue]]; + NSRange rangeMaxPort = [match rangeAtIndex:4]; + *maxPort = [LinphoneCoreSettingsStore validPort:[[text substringWithRange:rangeMaxPort] integerValue]]; + if(*minPort > *maxPort) { + *minPort = *maxPort; + } + return TRUE; + } + } + return FALSE; } - (BOOL)synchronize { if (![LinphoneManager isLcReady]) return YES; LinphoneCore *lc=[LinphoneManager getLc]; - + BOOL account_changed; - - account_changed=[self valueChangedForKey:@"username_preference"] - || [self valueChangedForKey:@"password_preference"] - || [self valueChangedForKey:@"domain_preference"] - || [self valueChangedForKey:@"expire_preference"] + + account_changed=[self valueChangedForKey:@"username_preference"] + || [self valueChangedForKey:@"password_preference"] + || [self valueChangedForKey:@"domain_preference"] + || [self valueChangedForKey:@"expire_preference"] || [self valueChangedForKey:@"proxy_preference"] || [self valueChangedForKey:@"outbound_proxy_preference"] || [self valueChangedForKey:@"transport_preference"] - || [self valueChangedForKey:@"port_preference"] - || [self valueChangedForKey:@"random_port_preference"] + || [self valueChangedForKey:@"port_preference"] + || [self valueChangedForKey:@"random_port_preference"] || [self valueChangedForKey:@"prefix_preference"] || [self valueChangedForKey:@"substitute_+_by_00_preference"] - || [self valueChangedForKey:@"use_ipv6"] - || [self valueChangedForKey:@"avpf_preference"] - || [self valueChangedForKey:@"pushnotification_preference"]; - + || [self valueChangedForKey:@"use_ipv6"] + || [self valueChangedForKey:@"avpf_preference"] + || [self valueChangedForKey:@"pushnotification_preference"]; + if (account_changed) [self synchronizeAccount]; - + //Configure Codecs - + PayloadType *pt; const MSList *elem; - + for (elem=linphone_core_get_audio_codecs(lc);elem!=NULL;elem=elem->next){ pt=(PayloadType*)elem->data; NSString *pref=[LinphoneManager getPreferenceForCodec:pt->mime_type withRate:pt->clock_rate]; linphone_core_enable_payload_type(lc,pt,[self boolForKey: pref]); } - + for (elem=linphone_core_get_video_codecs(lc);elem!=NULL;elem=elem->next){ pt=(PayloadType*)elem->data; NSString *pref=[LinphoneManager getPreferenceForCodec:pt->mime_type withRate:pt->clock_rate]; linphone_core_enable_payload_type(lc,pt,[self boolForKey: pref]); } - LpConfig *config = linphone_core_get_config(lc); - lp_config_set_int(config, "audio", "codec_bitrate_limit", [self integerForKey:@"audio_codec_bitrate_limit_preference"]); + LpConfig *config = linphone_core_get_config(lc); + lp_config_set_int(config, "audio", "codec_bitrate_limit", [self integerForKey:@"audio_codec_bitrate_limit_preference"]); [[LinphoneManager instance] configureVbrCodecs]; - linphone_core_enable_adaptive_rate_control(lc, [self boolForKey:@"adaptive_rate_control_preference"]); - - linphone_core_set_use_info_for_dtmf(lc, [self boolForKey:@"sipinfo_dtmf_preference"]); - linphone_core_set_use_rfc2833_for_dtmf(lc, [self boolForKey:@"rfc_dtmf_preference"]); - linphone_core_set_inc_timeout(lc, [self integerForKey:@"incoming_call_timeout_preference"]); - linphone_core_set_in_call_timeout(lc, [self integerForKey:@"in_call_timeout_preference"]); - + linphone_core_enable_adaptive_rate_control(lc, [self boolForKey:@"adaptive_rate_control_preference"]); + linphone_core_set_adaptive_rate_algorithm(lc, [ + [self stringForKey:@"adaptive_rate_algorithm_preference"] cStringUsingEncoding:[NSString defaultCStringEncoding] + ]); + + linphone_core_set_use_info_for_dtmf(lc, [self boolForKey:@"sipinfo_dtmf_preference"]); + linphone_core_set_use_rfc2833_for_dtmf(lc, [self boolForKey:@"rfc_dtmf_preference"]); + linphone_core_set_inc_timeout(lc, [self integerForKey:@"incoming_call_timeout_preference"]); + linphone_core_set_in_call_timeout(lc, [self integerForKey:@"in_call_timeout_preference"]); + bool enableVideo = [self boolForKey:@"enable_video_preference"]; linphone_core_enable_video(lc, enableVideo, enableVideo); @@ -552,27 +556,27 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); else if (menc && [menc compare:@"ZRTP"] == NSOrderedSame) linphone_core_set_media_encryption(lc, LinphoneMediaEncryptionZRTP); else - linphone_core_set_media_encryption(lc, LinphoneMediaEncryptionNone); - - NSString* stun_server = [self stringForKey:@"stun_preference"]; - if ([stun_server length] > 0){ - linphone_core_set_stun_server(lc, [stun_server UTF8String]); - BOOL ice_preference = [self boolForKey:@"ice_preference"]; - if(ice_preference) { - linphone_core_set_firewall_policy(lc, LinphonePolicyUseIce); - } else { - linphone_core_set_firewall_policy(lc, LinphonePolicyUseStun); - } - } else { - linphone_core_set_stun_server(lc, NULL); - linphone_core_set_firewall_policy(lc, LinphonePolicyNoFirewall); - } - - LinphoneVideoPolicy policy; - policy.automatically_accept = [self boolForKey:@"accept_video_preference"]; - policy.automatically_initiate = [self boolForKey:@"start_video_preference"]; - linphone_core_set_video_policy(lc, &policy); - linphone_core_enable_self_view(lc, [self boolForKey:@"self_video_preference"]); + linphone_core_set_media_encryption(lc, LinphoneMediaEncryptionNone); + + NSString* stun_server = [self stringForKey:@"stun_preference"]; + if ([stun_server length] > 0){ + linphone_core_set_stun_server(lc, [stun_server UTF8String]); + BOOL ice_preference = [self boolForKey:@"ice_preference"]; + if(ice_preference) { + linphone_core_set_firewall_policy(lc, LinphonePolicyUseIce); + } else { + linphone_core_set_firewall_policy(lc, LinphonePolicyUseStun); + } + } else { + linphone_core_set_stun_server(lc, NULL); + linphone_core_set_firewall_policy(lc, LinphonePolicyNoFirewall); + } + + LinphoneVideoPolicy policy; + policy.automatically_accept = [self boolForKey:@"accept_video_preference"]; + policy.automatically_initiate = [self boolForKey:@"start_video_preference"]; + linphone_core_set_video_policy(lc, &policy); + linphone_core_enable_self_view(lc, [self boolForKey:@"self_video_preference"]); BOOL preview_preference=[self boolForKey:@"preview_preference"]; lp_config_set_int(config, LINPHONERC_APPLICATION_KEY, "preview_preference", preview_preference); MSVideoSize vsize; @@ -580,13 +584,13 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); switch ([self integerForKey:@"video_preferred_size_preference"]) { case 0: MS_VIDEO_SIZE_ASSIGN(vsize, 720P); - // 128 = margin for audio, the BW includes both video and audio + // 128 = margin for audio, the BW includes both video and audio bw = 1024 + 128; - break; + break; case 1: MS_VIDEO_SIZE_ASSIGN(vsize, VGA); - // no margin for VGA or QVGA, because video encoders can encode the - // target resulution in less than the asked bandwidth + // no margin for VGA or QVGA, because video encoders can encode the + // target resulution in less than the asked bandwidth bw = 512; break; case 2: @@ -598,47 +602,47 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); linphone_core_set_preferred_video_size(lc, vsize); [self setInteger: bw forKey:@"upload_bandwidth_preference"]; [self setInteger: bw forKey:@"download_bandwidth_preference"]; - - // Primary contact - NSString* displayname = [self stringForKey:@"primary_displayname_preference"]; - NSString* username = [self stringForKey:@"primary_username_preference"]; - LinphoneAddress *parsed = linphone_core_get_primary_contact_parsed(lc); - if(parsed != NULL) { - linphone_address_set_display_name(parsed,[displayname cStringUsingEncoding:[NSString defaultCStringEncoding]]); - linphone_address_set_username(parsed,[username cStringUsingEncoding:[NSString defaultCStringEncoding]]); - char *contact = linphone_address_as_string(parsed); - linphone_core_set_primary_contact(lc, contact); - ms_free(contact); - linphone_address_destroy(parsed); - } - - // Audio & Video Port - { - NSString *audio_port_preference = [self stringForKey:@"audio_port_preference"]; - int minPort, maxPort; - [LinphoneCoreSettingsStore parsePortRange:audio_port_preference minPort:&minPort maxPort:&maxPort]; - linphone_core_set_audio_port_range(lc, minPort, maxPort); - } - { - NSString *video_port_preference = [self stringForKey:@"video_port_preference"]; - int minPort, maxPort; - [LinphoneCoreSettingsStore parsePortRange:video_port_preference minPort:&minPort maxPort:&maxPort]; - linphone_core_set_video_port_range(lc, minPort, maxPort); - } - - int upload_bandwidth = [self integerForKey:@"upload_bandwidth_preference"]; - linphone_core_set_upload_bandwidth(lc, upload_bandwidth); - - int download_bandwidth = [self integerForKey:@"download_bandwidth_preference"]; - linphone_core_set_download_bandwidth(lc, download_bandwidth); - - float playback_gain = [self floatForKey:@"playback_gain_preference"]; - linphone_core_set_playback_gain_db(lc, playback_gain); - - float mic_gain = [self floatForKey:@"microphone_gain_preference"]; - linphone_core_set_mic_gain_db(lc, mic_gain); - + // Primary contact + NSString* displayname = [self stringForKey:@"primary_displayname_preference"]; + NSString* username = [self stringForKey:@"primary_username_preference"]; + LinphoneAddress *parsed = linphone_core_get_primary_contact_parsed(lc); + if(parsed != NULL) { + linphone_address_set_display_name(parsed,[displayname cStringUsingEncoding:[NSString defaultCStringEncoding]]); + linphone_address_set_username(parsed,[username cStringUsingEncoding:[NSString defaultCStringEncoding]]); + char *contact = linphone_address_as_string(parsed); + linphone_core_set_primary_contact(lc, contact); + ms_free(contact); + linphone_address_destroy(parsed); + } + + + // Audio & Video Port + { + NSString *audio_port_preference = [self stringForKey:@"audio_port_preference"]; + int minPort, maxPort; + [LinphoneCoreSettingsStore parsePortRange:audio_port_preference minPort:&minPort maxPort:&maxPort]; + linphone_core_set_audio_port_range(lc, minPort, maxPort); + } + { + NSString *video_port_preference = [self stringForKey:@"video_port_preference"]; + int minPort, maxPort; + [LinphoneCoreSettingsStore parsePortRange:video_port_preference minPort:&minPort maxPort:&maxPort]; + linphone_core_set_video_port_range(lc, minPort, maxPort); + } + + int upload_bandwidth = [self integerForKey:@"upload_bandwidth_preference"]; + linphone_core_set_upload_bandwidth(lc, upload_bandwidth); + + int download_bandwidth = [self integerForKey:@"download_bandwidth_preference"]; + linphone_core_set_download_bandwidth(lc, download_bandwidth); + + float playback_gain = [self floatForKey:@"playback_gain_preference"]; + linphone_core_set_playback_gain_db(lc, playback_gain); + + float mic_gain = [self floatForKey:@"microphone_gain_preference"]; + linphone_core_set_mic_gain_db(lc, mic_gain); + UIDevice* device = [UIDevice currentDevice]; bool backgroundSupported = false; if ([device respondsToSelector:@selector(isMultitaskingSupported)]) @@ -652,84 +656,84 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); lp_config_set_int(config, LINPHONERC_APPLICATION_KEY, "backgroundmode_preference", isbackgroundModeEnabled); lp_config_set_int(config, LINPHONERC_APPLICATION_KEY, "start_at_boot_preference", [self boolForKey:@"start_at_boot_preference"]); - lp_config_set_int(config, LINPHONERC_APPLICATION_KEY, "autoanswer_notif_preference", [self boolForKey:@"autoanswer_notif_preference"]); - lp_config_set_int(config, LINPHONERC_APPLICATION_KEY, "advanced_account_preference", [self boolForKey:@"advanced_account_preference"]); + lp_config_set_int(config, LINPHONERC_APPLICATION_KEY, "autoanswer_notif_preference", [self boolForKey:@"autoanswer_notif_preference"]); + lp_config_set_int(config, LINPHONERC_APPLICATION_KEY, "advanced_account_preference", [self boolForKey:@"advanced_account_preference"]); + + BOOL firstloginview = [self boolForKey:@"enable_first_login_view_preference"]; + lp_config_set_int(config, LINPHONERC_APPLICATION_KEY, "enable_first_login_view_preference", firstloginview); + + BOOL edgeOpt = [self boolForKey:@"edge_opt_preference"]; + lp_config_set_int(config, LINPHONERC_APPLICATION_KEY, "edge_opt_preference", edgeOpt); + + NSString *landscape = [self stringForKey:@"rotation_preference"]; + lp_config_set_string(config, LINPHONERC_APPLICATION_KEY, "rotation_preference", [landscape UTF8String]); - BOOL firstloginview = [self boolForKey:@"enable_first_login_view_preference"]; - lp_config_set_int(config, LINPHONERC_APPLICATION_KEY, "enable_first_login_view_preference", firstloginview); - - BOOL edgeOpt = [self boolForKey:@"edge_opt_preference"]; - lp_config_set_int(config, LINPHONERC_APPLICATION_KEY, "edge_opt_preference", edgeOpt); - - NSString *landscape = [self stringForKey:@"rotation_preference"]; - lp_config_set_string(config, LINPHONERC_APPLICATION_KEY, "rotation_preference", [landscape UTF8String]); - BOOL debugmode = [self boolForKey:@"debugenable_preference"]; lp_config_set_int(config, LINPHONERC_APPLICATION_KEY, "debugenable_preference", debugmode); if (debugmode) { - linphone_core_enable_logs_with_cb((OrtpLogFunc)linphone_iphone_log_handler); - ortp_set_log_level_mask(ORTP_DEBUG|ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR|ORTP_FATAL); - } else { - linphone_core_disable_logs(); - } - - BOOL animations = [self boolForKey:@"animations_preference"]; + linphone_core_enable_logs_with_cb((OrtpLogFunc)linphone_iphone_log_handler); + ortp_set_log_level_mask(ORTP_DEBUG|ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR|ORTP_FATAL); + } else { + linphone_core_disable_logs(); + } + + BOOL animations = [self boolForKey:@"animations_preference"]; lp_config_set_int(config, LINPHONERC_APPLICATION_KEY, "animations_preference", animations); - - BOOL wifiOnly = [self boolForKey:@"wifi_only_preference"]; + + BOOL wifiOnly = [self boolForKey:@"wifi_only_preference"]; lp_config_set_int(config, LINPHONERC_APPLICATION_KEY, "wifi_only_preference", wifiOnly); - if([self valueChangedForKey:@"wifi_only_preference"]) { - [[LinphoneManager instance] setupNetworkReachabilityCallback]; - } - + if([self valueChangedForKey:@"wifi_only_preference"]) { + [[LinphoneManager instance] setupNetworkReachabilityCallback]; + } + NSString* sharing_server = [self stringForKey:@"sharing_server_preference"]; [[LinphoneManager instance] lpConfigSetString:sharing_server forKey:@"sharing_server_preference"]; - - - //Tunnel - if (linphone_core_tunnel_available()){ - NSString* lTunnelPrefMode = [self stringForKey:@"tunnel_mode_preference"]; - NSString* lTunnelPrefAddress = [self stringForKey:@"tunnel_address_preference"]; - int lTunnelPrefPort = [self integerForKey:@"tunnel_port_preference"]; - LinphoneTunnel *tunnel = linphone_core_get_tunnel([LinphoneManager getLc]); - TunnelMode mode = tunnel_off; - int lTunnelPort = 443; - if (lTunnelPrefPort) { - lTunnelPort = lTunnelPrefPort; - } - - linphone_tunnel_clean_servers(tunnel); - if (lTunnelPrefAddress && [lTunnelPrefAddress length]) { - LinphoneTunnelConfig *ltc = linphone_tunnel_config_new(); - linphone_tunnel_config_set_host(ltc, [lTunnelPrefAddress UTF8String]); - linphone_tunnel_config_set_port(ltc, lTunnelPort); - linphone_tunnel_add_server(tunnel, ltc); - - if ([lTunnelPrefMode isEqualToString:@"off"]) { - mode = tunnel_off; - } else if ([lTunnelPrefMode isEqualToString:@"on"]) { - mode = tunnel_on; - } else if ([lTunnelPrefMode isEqualToString:@"wwan"]) { - mode = tunnel_wwan; - } else if ([lTunnelPrefMode isEqualToString:@"auto"]) { - mode = tunnel_auto; - } else { - [LinphoneLogger logc:LinphoneLoggerError format:"Unexpected tunnel mode [%s]",[lTunnelPrefMode cStringUsingEncoding:[NSString defaultCStringEncoding]]]; - } - } - - lp_config_set_string(linphone_core_get_config(lc), LINPHONERC_APPLICATION_KEY, "tunnel_mode_preference", [lTunnelPrefMode UTF8String]); - [[LinphoneManager instance] setTunnelMode:mode]; - } - + + + //Tunnel + if (linphone_core_tunnel_available()){ + NSString* lTunnelPrefMode = [self stringForKey:@"tunnel_mode_preference"]; + NSString* lTunnelPrefAddress = [self stringForKey:@"tunnel_address_preference"]; + int lTunnelPrefPort = [self integerForKey:@"tunnel_port_preference"]; + LinphoneTunnel *tunnel = linphone_core_get_tunnel([LinphoneManager getLc]); + TunnelMode mode = tunnel_off; + int lTunnelPort = 443; + if (lTunnelPrefPort) { + lTunnelPort = lTunnelPrefPort; + } + + linphone_tunnel_clean_servers(tunnel); + if (lTunnelPrefAddress && [lTunnelPrefAddress length]) { + LinphoneTunnelConfig *ltc = linphone_tunnel_config_new(); + linphone_tunnel_config_set_host(ltc, [lTunnelPrefAddress UTF8String]); + linphone_tunnel_config_set_port(ltc, lTunnelPort); + linphone_tunnel_add_server(tunnel, ltc); + + if ([lTunnelPrefMode isEqualToString:@"off"]) { + mode = tunnel_off; + } else if ([lTunnelPrefMode isEqualToString:@"on"]) { + mode = tunnel_on; + } else if ([lTunnelPrefMode isEqualToString:@"wwan"]) { + mode = tunnel_wwan; + } else if ([lTunnelPrefMode isEqualToString:@"auto"]) { + mode = tunnel_auto; + } else { + [LinphoneLogger logc:LinphoneLoggerError format:"Unexpected tunnel mode [%s]",[lTunnelPrefMode cStringUsingEncoding:[NSString defaultCStringEncoding]]]; + } + } + + lp_config_set_string(linphone_core_get_config(lc), LINPHONERC_APPLICATION_KEY, "tunnel_mode_preference", [lTunnelPrefMode UTF8String]); + [[LinphoneManager instance] setTunnelMode:mode]; + } + [changedDict release]; changedDict = [[NSMutableDictionary alloc] init]; - - // Post event - NSDictionary *eventDic = [NSDictionary dictionaryWithObject:self forKey:@"settings"]; - [[NSNotificationCenter defaultCenter] postNotificationName:kLinphoneSettingsUpdate object:self userInfo:eventDic]; - - return YES; + + // Post event + NSDictionary *eventDic = [NSDictionary dictionaryWithObject:self forKey:@"settings"]; + [[NSNotificationCenter defaultCenter] postNotificationName:kLinphoneSettingsUpdate object:self userInfo:eventDic]; + + return YES; } @end diff --git a/Settings/InAppSettings.bundle/Audio.plist b/Settings/InAppSettings.bundle/Audio.plist index ac3e769a2..a164683f5 100644 --- a/Settings/InAppSettings.bundle/Audio.plist +++ b/Settings/InAppSettings.bundle/Audio.plist @@ -198,6 +198,26 @@ Type PSToggleSwitchSpecifier + + DefaultValue + Simple + Key + adaptive_rate_algorithm_preference + Title + Adaptive rate algorithm + Titles + + Simple + Stateful + + Type + PSMultiValueSpecifier + Values + + Simple + Stateful + + DefaultValue 36 diff --git a/submodules/belle-sip b/submodules/belle-sip index ee99cb136..fa1c112cb 160000 --- a/submodules/belle-sip +++ b/submodules/belle-sip @@ -1 +1 @@ -Subproject commit ee99cb136b23558faadab3b0c654561f4a92e371 +Subproject commit fa1c112cb33d2c0a42b351652a4779a8aea77c56 diff --git a/submodules/build/Makefile b/submodules/build/Makefile index dedb3cd7b..056dc6e9a 100644 --- a/submodules/build/Makefile +++ b/submodules/build/Makefile @@ -1,5 +1,5 @@ ############################################################################ -# Makefile +# Makefile # Copyright (C) 2009 Belledonne Communications,Grenoble France # ############################################################################ @@ -56,7 +56,7 @@ endif ifeq ($(enable_gpl_third_parties),yes) warning: - @echo + @echo @echo "***************************************************************************" @echo "***************************************************************************" @echo "*****CAUTION, this liblinphone SDK is built using 3rd party GPL code ******" @@ -68,7 +68,7 @@ warning: @echo "***************************************************************************" else warning: - @echo + @echo @echo "*****************************************************************" @echo "*****************************************************************" @echo "*****Linphone SDK without 3rd party GPL software ******" @@ -84,17 +84,17 @@ LINPHONE_OPTIONS=enable_gpl_third_parties=$(enable_gpl_third_parties) \ enable_debug=$(enable_debug) enable_ffmpeg=$(enable_ffmpeg) enable_tunnel=$(enable_tunnel) -armv7-%: +armv7-%: make -f builder-iphone-os.mk $(LINPHONE_OPTIONS) $* -armv7s-%: +armv7s-%: make -f builder-iphone-os.mk host=armv7s-apple-darwin $(LINPHONE_OPTIONS) $* -simu-%: +simu-%: make -f builder-iphone-simulator.mk $(LINPHONE_OPTIONS) $* -build-% clean-% veryclean-%: +build-% clean-% veryclean-%: make -f builder-iphone-simulator.mk $(LINPHONE_OPTIONS) $@ \ && make -f builder-iphone-os.mk $(LINPHONE_OPTIONS) $@ \ && make -f builder-iphone-os.mk host=armv7s-apple-darwin $(LINPHONE_OPTIONS) $@ @@ -106,8 +106,8 @@ broadcast_%: && make -f builder-iphone-os.mk $(LINPHONE_OPTIONS) $* \ && make -f builder-iphone-os.mk host=armv7s-apple-darwin $(LINPHONE_OPTIONS) $* -sdk: - make -f builder-iphone-os.mk delivery-sdk +sdk: + make -f builder-iphone-os.mk delivery-sdk build: broadcast_all sdk @@ -119,7 +119,7 @@ veryclean: broadcast_veryclean zipres: - @tar -C ../.. -czf ../../ios_assets.tar.gz Resources iTunesArtwork + @tar -C ../.. -czf ../../ios_assets.tar.gz Resources iTunesArtwork @echo Archive 'ios_assets.tar.gz' placed in root directory help: diff --git a/submodules/linphone b/submodules/linphone index 3c32fd439..cb925cfff 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit 3c32fd43972ad9560f33e1f056ad7be694d8e685 +Subproject commit cb925cfff94bf0a2955271f953372d8e36d924f9