]> sjero.net Git - linphone/blobdiff - coreapi/callbacks.c
Merge branch 'upnp'
[linphone] / coreapi / callbacks.c
index 784c1f1bdc838b300f6eb3d505620a0014cda5f1..948fc720b37fa65fcd0cdb1c16749d6130e7a862 100644 (file)
@@ -261,6 +261,13 @@ static void call_received(SalOp *h){
                ms_message("Defer ringing to gather ICE candidates");
                return;
        }
+#ifdef BUILD_UPNP
+       if ((linphone_core_get_firewall_policy(lc) == LinphonePolicyUseUpnp) && (call->upnp_session != NULL)) {
+               /* Defer ringing until the end of the ICE candidates gathering process. */
+               ms_message("Defer ringing to gather uPnP candidates");
+               return;
+       }
+#endif //BUILD_UPNP
 
        linphone_core_notify_incoming_call(lc,call);
 }
@@ -334,6 +341,11 @@ static void call_accepted(SalOp *op){
        if (call->ice_session != NULL) {
                linphone_core_update_ice_from_remote_media_description(call, sal_call_get_remote_media_description(op));
        }
+#ifdef BUILD_UPNP
+       if (call->upnp_session != NULL) {
+               linphone_core_update_upnp_from_remote_media_description(call, sal_call_get_remote_media_description(op));
+       }
+#endif //BUILD_UPNP
 
        md=sal_call_get_final_media_description(op);
        call->params.has_video &= linphone_core_media_description_contains_video_stream(md);
@@ -426,6 +438,12 @@ static void call_accept_update(LinphoneCore *lc, LinphoneCall *call){
                linphone_core_update_ice_from_remote_media_description(call,rmd);
                linphone_core_update_local_media_description_from_ice(call->localdesc,call->ice_session);
        }
+#ifdef BUILD_UPNP
+       if(call->upnp_session != NULL) {
+               linphone_core_update_upnp_from_remote_media_description(call, rmd);
+               linphone_core_update_local_media_description_from_upnp(call->localdesc,call->upnp_session);
+       }
+#endif //BUILD_UPNP
        linphone_call_update_remote_session_id_and_ver(call);
        sal_call_accept(call->op);
        md=sal_call_get_final_media_description(call->op);
@@ -522,6 +540,10 @@ static void call_terminated(SalOp *op, const char *from){
        if (lc->vtable.display_status!=NULL)
                lc->vtable.display_status(lc,_("Call terminated."));
 
+#ifdef BUILD_UPNP
+       linphone_call_delete_upnp_session(call);
+#endif //BUILD_UPNP
+
        linphone_call_set_state(call, LinphoneCallEnd,"Call ended");
 }
 
@@ -618,6 +640,11 @@ static void call_failure(SalOp *op, SalError error, SalReason sr, const char *de
                /*resume to the call that send us the refer automatically*/
                linphone_core_resume_call(lc,call->referer);
        }
+
+#ifdef BUILD_UPNP
+       linphone_call_delete_upnp_session(call);
+#endif //BUILD_UPNP
+
        if (sr == SalReasonDeclined) {
                call->reason=LinphoneReasonDeclined;
                linphone_call_set_state(call,LinphoneCallEnd,"Call declined.");