diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 8dcdddf03..0b3dbf327 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -4293,7 +4293,9 @@ void linphone_core_set_firewall_policy(LinphoneCore *lc, LinphoneFirewallPolicy ms_warning("UPNP is not available, reset firewall policy to no firewall"); pol = LinphonePolicyNoFirewall; } -#else //BUILD_UPNP +#endif //BUILD_UPNP + lc->net_conf.firewall_policy=pol; +#ifdef BUILD_UPNP if(pol == LinphonePolicyUseUpnp) { if(lc->upnp == NULL) { lc->upnp = linphone_upnp_context_new(lc); @@ -4303,9 +4305,9 @@ void linphone_core_set_firewall_policy(LinphoneCore *lc, LinphoneFirewallPolicy linphone_upnp_context_destroy(lc->upnp); lc->upnp = NULL; } - } + } + linphone_core_enable_keep_alive(lc, (lc->sip_conf.keepalive_period > 0)); #endif //BUILD_UPNP - lc->net_conf.firewall_policy=pol; if (lc->sip_conf.contact) update_primary_contact(lc); if (linphone_core_ready(lc)) lp_config_set_int(lc->config,"net","firewall_policy",pol); @@ -5559,6 +5561,11 @@ const char *linphone_error_to_string(LinphoneReason err){ * Enables signaling keep alive */ void linphone_core_enable_keep_alive(LinphoneCore* lc,bool_t enable) { +#ifdef BUILD_UPNP + if (linphone_core_get_firewall_policy(lc)==LinphonePolicyUseUpnp) { + enable = FALSE; + } +#endif //BUILD_UPNP if (enable > 0) { sal_use_tcp_tls_keepalive(lc->sal,lc->sip_conf.tcp_tls_keepalive); sal_set_keepalive_period(lc->sal,lc->sip_conf.keepalive_period); diff --git a/coreapi/upnp.c b/coreapi/upnp.c index deb096b9c..4f56e0c1a 100644 --- a/coreapi/upnp.c +++ b/coreapi/upnp.c @@ -661,6 +661,11 @@ int linphone_upnp_call_process(LinphoneCall *call) { */ linphone_upnp_update_stream_state(call->upnp_session->video); + /* + * Update stat + */ + linphone_core_update_upnp_state_in_call_stats(call); + /* * Update session state */ @@ -678,41 +683,34 @@ int linphone_upnp_call_process(LinphoneCall *call) { call->upnp_session->state = LinphoneUpnpStateIdle; } newState = call->upnp_session->state; - - /* When change is done proceed update */ - if(oldState != LinphoneUpnpStateOk && oldState != LinphoneUpnpStateKo && - (call->upnp_session->state == LinphoneUpnpStateOk || call->upnp_session->state == LinphoneUpnpStateKo)) { - if(call->upnp_session->state == LinphoneUpnpStateOk) - ms_message("uPnP IGD: uPnP for Call %p is ok", call); - else - ms_message("uPnP IGD: uPnP for Call %p is ko", call); - - switch (call->state) { - case LinphoneCallUpdating: - linphone_core_start_update_call(lc, call); - break; - case LinphoneCallUpdatedByRemote: - linphone_core_start_accept_call_update(lc, call); - break; - case LinphoneCallOutgoingInit: - linphone_core_proceed_with_invite_if_ready(lc, call, NULL); - break; - case LinphoneCallIdle: - linphone_core_notify_incoming_call(lc, call); - break; - default: - break; - } - } } ms_mutex_unlock(&lupnp->mutex); + + /* When change is done proceed update */ + if(oldState != LinphoneUpnpStateOk && oldState != LinphoneUpnpStateKo && + (newState == LinphoneUpnpStateOk || newState == LinphoneUpnpStateKo)) { + if(call->upnp_session->state == LinphoneUpnpStateOk) + ms_message("uPnP IGD: uPnP for Call %p is ok", call); + else + ms_message("uPnP IGD: uPnP for Call %p is ko", call); - /* - * Update uPnP call stats - */ - if(oldState != newState) { - linphone_core_update_upnp_state_in_call_stats(call); + switch (call->state) { + case LinphoneCallUpdating: + linphone_core_start_update_call(lc, call); + break; + case LinphoneCallUpdatedByRemote: + linphone_core_start_accept_call_update(lc, call); + break; + case LinphoneCallOutgoingInit: + linphone_core_proceed_with_invite_if_ready(lc, call, NULL); + break; + case LinphoneCallIdle: + linphone_core_notify_incoming_call(lc, call); + break; + default: + break; + } } return ret;