diff --git a/coreapi/account_creator.c b/coreapi/account_creator.c index 4d18c8663..f9bcff7a3 100644 --- a/coreapi/account_creator.c +++ b/coreapi/account_creator.c @@ -122,9 +122,11 @@ LinphoneProxyConfig * linphone_account_creator_create_proxy_config(const Linphon if (creator->display_name) { linphone_address_set_display_name(identity, creator->display_name); } + /*deprecated, use default proxy config instead*/ if (creator->route) { route = ms_strdup_printf("%s", creator->route); } + /*deprecated, use default proxy config instead*/ if (creator->domain) { domain = ms_strdup_printf("%s;transport=%s", creator->domain, linphone_transport_to_string(creator->transport)); } @@ -137,12 +139,7 @@ LinphoneProxyConfig * linphone_account_creator_create_proxy_config(const Linphon snprintf(buff, sizeof(buff), "%d", dial_prefix_number); linphone_proxy_config_set_dial_prefix(cfg, buff); } - if (linphone_proxy_config_get_server_addr(cfg) == NULL) - linphone_proxy_config_set_server_addr(cfg, domain); - if (linphone_proxy_config_get_route(cfg) == NULL) - linphone_proxy_config_set_route(cfg, route); - linphone_proxy_config_enable_publish(cfg, FALSE); linphone_proxy_config_enable_register(cfg, TRUE); info = linphone_auth_info_new(linphone_address_get_username(identity), // username diff --git a/coreapi/friend.c b/coreapi/friend.c index 5ebb7423a..ff47cabff 100644 --- a/coreapi/friend.c +++ b/coreapi/friend.c @@ -1160,6 +1160,7 @@ bool_t linphone_friend_create_vcard(LinphoneFriend *fr, const char *name) { } linphone_vcard_set_full_name(vcard, name); linphone_friend_set_vcard(fr, vcard); + linphone_vcard_unref(vcard); return TRUE; } diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 2aa0a76bf..888765c98 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -1109,6 +1109,20 @@ static void linphone_call_init_common(LinphoneCall *call, LinphoneAddress *from, linphone_call_init_stats(call->audio_stats, LINPHONE_CALL_STATS_AUDIO); linphone_call_init_stats(call->video_stats, LINPHONE_CALL_STATS_VIDEO); linphone_call_init_stats(call->text_stats, LINPHONE_CALL_STATS_TEXT); + + if (call->dest_proxy == NULL) { + /* Try to define the destination proxy if it has not already been done to have a correct contact field in the SIP messages */ + call->dest_proxy = linphone_core_lookup_known_proxy(call->core, call->log->to); + } + + + if (call->dest_proxy != NULL) + call->nat_policy = linphone_proxy_config_get_nat_policy(call->dest_proxy); + if (call->nat_policy == NULL) + call->nat_policy = linphone_core_get_nat_policy(call->core); + + linphone_nat_policy_ref(call->nat_policy); + } void linphone_call_init_stats(LinphoneCallStats *stats, int type) { @@ -1283,7 +1297,7 @@ void linphone_call_fill_media_multicast_addr(LinphoneCall *call) { void linphone_call_check_ice_session(LinphoneCall *call, IceRole role, bool_t is_reinvite){ if (call->ice_session) return; /*already created*/ - if (!linphone_nat_policy_ice_enabled(linphone_core_get_nat_policy(call->core))){ + if (!linphone_nat_policy_ice_enabled(call->nat_policy)){ return; } @@ -1321,7 +1335,7 @@ LinphoneCall * linphone_call_new_outgoing(struct _LinphoneCore *lc, LinphoneAddr linphone_call_check_ice_session(call, IR_Controlling, FALSE); - if (linphone_core_get_firewall_policy(call->core) == LinphonePolicyUseStun) { + if (linphone_nat_policy_ice_enabled(call->nat_policy)) { call->ping_time=linphone_core_run_stun_tests(call->core,call); } #ifdef BUILD_UPNP @@ -1566,8 +1580,6 @@ LinphoneCall * linphone_call_new_incoming(LinphoneCore *lc, LinphoneAddress *fro } } - if (call->dest_proxy != NULL) nat_policy = linphone_proxy_config_get_nat_policy(call->dest_proxy); - if (nat_policy == NULL) nat_policy = linphone_core_get_nat_policy(call->core); if ((nat_policy != NULL) && linphone_nat_policy_ice_enabled(nat_policy)) { /* Create the ice session now if ICE is required */ if (md){ @@ -1958,6 +1970,8 @@ static void linphone_call_destroy(LinphoneCall *obj){ if (obj->onhold_file) ms_free(obj->onhold_file); if (obj->ei) linphone_error_info_unref(obj->ei); + if (obj->nat_policy) + linphone_nat_policy_unref(obj->nat_policy); } LinphoneCall * linphone_call_ref(LinphoneCall *obj){ @@ -2380,7 +2394,7 @@ static void port_config_set_random_choosed(LinphoneCall *call, int stream_index, static void _linphone_call_prepare_ice_for_stream(LinphoneCall *call, int stream_index, bool_t create_checklist){ MediaStream *ms = stream_index == call->main_audio_stream_index ? (MediaStream*)call->audiostream : stream_index == call->main_video_stream_index ? (MediaStream*)call->videostream : (MediaStream*)call->textstream; - if ((linphone_core_get_firewall_policy(call->core) == LinphonePolicyUseIce) && (call->ice_session != NULL)){ + if (linphone_nat_policy_ice_enabled(call->nat_policy) && (call->ice_session != NULL)){ IceCheckList *cl; rtp_session_set_pktinfo(ms->sessions.rtp_session, TRUE); cl=ice_session_check_list(call->ice_session, stream_index); @@ -2400,7 +2414,7 @@ int linphone_call_prepare_ice(LinphoneCall *call, bool_t incoming_offer){ int err; bool_t has_video=FALSE; - if ((linphone_core_get_firewall_policy(call->core) == LinphonePolicyUseIce) && (call->ice_session != NULL)){ + if (linphone_nat_policy_ice_enabled(call->nat_policy) && (call->ice_session != NULL)){ if (incoming_offer){ remote=sal_call_get_remote_media_description(call->op); has_video=linphone_core_video_enabled(call->core) && linphone_core_media_description_contains_video_stream(remote); @@ -4918,12 +4932,6 @@ static LinphoneAddress *get_fixed_contact(LinphoneCore *lc, LinphoneCall *call , void linphone_call_set_contact_op(LinphoneCall* call) { LinphoneAddress *contact; - - if (call->dest_proxy == NULL) { - /* Try to define the destination proxy if it has not already been done to have a correct contact field in the SIP messages */ - call->dest_proxy = linphone_core_lookup_known_proxy(call->core, call->log->to); - } - contact=get_fixed_contact(call->core,call,call->dest_proxy); if (contact){ SalTransport tport=sal_address_get_transport((SalAddress*)contact); diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 6449b058a..782d9e7d4 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -3164,7 +3164,7 @@ void linphone_core_iterate(LinphoneCore *lc){ /*start the call even if the OPTIONS reply did not arrive*/ if (call->ice_session != NULL) { ms_warning("ICE candidates gathering from [%s] has not finished yet, proceed with the call without ICE anyway." - ,linphone_core_get_stun_server(lc)); + ,linphone_nat_policy_get_stun_server(call->nat_policy)); linphone_call_delete_ice_session(call); linphone_call_stop_media_streams_for_ice_gathering(call); } @@ -3517,7 +3517,7 @@ LinphoneCall * linphone_core_invite_address_with_params(LinphoneCore *lc, const call->log->start_date_time=ms_time(NULL); linphone_call_init_media_streams(call); - if (linphone_core_get_firewall_policy(call->core) == LinphonePolicyUseIce) { + if (linphone_nat_policy_ice_enabled(call->nat_policy)) { if (lc->sip_conf.sdp_200_ack){ ms_warning("ICE is not supported when sending INVITE without SDP"); }else{ diff --git a/coreapi/misc.c b/coreapi/misc.c index 9f5f216a3..4ad769c9f 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -517,7 +517,7 @@ static void stun_auth_requested_cb(LinphoneCall *call, const char *realm, const if (nat_policy != NULL) { user = linphone_nat_policy_get_stun_server_username(nat_policy); } else { - nat_policy = linphone_core_get_nat_policy(call->core); + nat_policy = call->nat_policy; if (nat_policy != NULL) { user = linphone_nat_policy_get_stun_server_username(nat_policy); } @@ -598,11 +598,9 @@ int linphone_core_gather_ice_candidates(LinphoneCore *lc, LinphoneCall *call){ IceCheckList *audio_cl; IceCheckList *video_cl; IceCheckList *text_cl; - LinphoneNatPolicy *nat_policy = NULL; + LinphoneNatPolicy *nat_policy = call->nat_policy; const char *server = NULL; - if (call->dest_proxy != NULL) nat_policy = linphone_proxy_config_get_nat_policy(call->dest_proxy); - if (nat_policy == NULL) nat_policy = linphone_core_get_nat_policy(lc); if (nat_policy != NULL) server = linphone_nat_policy_get_stun_server(nat_policy); if (call->ice_session == NULL) return -1; diff --git a/coreapi/private.h b/coreapi/private.h index 14665b01b..8546ca9d4 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -400,6 +400,7 @@ struct _LinphoneCall{ bctbx_list_t *callbacks; /* A list of LinphoneCallCbs object */ LinphoneCallCbs *current_cbs; /* The current LinphoneCallCbs object used to call a callback */ + LinphoneNatPolicy *nat_policy; /*nat policy for this call, either from proxy nor from core*/ }; BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneCall); diff --git a/coreapi/proxy.c b/coreapi/proxy.c index 03d07e395..09a9cc801 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -1454,7 +1454,10 @@ LinphoneNatPolicy * linphone_proxy_config_get_nat_policy(const LinphoneProxyConf } void linphone_proxy_config_set_nat_policy(LinphoneProxyConfig *cfg, LinphoneNatPolicy *policy) { - if (policy != NULL) policy = linphone_nat_policy_ref(policy); /* Prevent object destruction if the same policy is used */ + if (policy != NULL) { + policy = linphone_nat_policy_ref(policy); /* Prevent object destruction if the same policy is used */ + policy->lc = cfg->lc; + } if (cfg->nat_policy != NULL) linphone_nat_policy_unref(cfg->nat_policy); cfg->nat_policy = policy; }