]> sjero.net Git - linphone/blobdiff - coreapi/linphonecall.c
uPnP in progress
[linphone] / coreapi / linphonecall.c
index 6c8b4a74395ca074fc75916690addb192ef44a4c..8af948df5f4f07399258e696a7b91e60185d9426 100644 (file)
@@ -451,7 +451,7 @@ LinphoneCall * linphone_call_new_outgoing(struct _LinphoneCore *lc, LinphoneAddr
        }
 #ifdef BUILD_UPNP
        if (linphone_core_get_firewall_policy(call->core) == LinphonePolicyUseUpnp) {
-               call->upnp_session = upnp_session_new();
+               call->upnp_session = upnp_session_new(call);
        }
 #endif //BUILD_UPNP
        call->camera_active=params->has_video;
@@ -515,6 +515,19 @@ LinphoneCall * linphone_call_new_incoming(LinphoneCore *lc, LinphoneAddress *fro
                case LinphonePolicyUseStun:
                        call->ping_time=linphone_core_run_stun_tests(call->core,call);
                        /* No break to also destroy ice session in this case. */
+                       break;
+               case LinphonePolicyUseUpnp:
+#ifdef BUILD_UPNP
+               call->upnp_session = upnp_session_new(call);
+               if (call->ice_session != NULL) {
+                       linphone_call_init_media_streams(call);
+                       if (linphone_core_update_upnp(call->core,call)<0) {
+                               /* uPnP port mappings failed, proceed with the call anyway. */
+                               linphone_call_delete_upnp_session(call);
+                       }
+               }
+#endif //BUILD_UPNP
+                       break;
                default:
                        break;
        }
@@ -663,6 +676,9 @@ void linphone_call_set_state(LinphoneCall *call, LinphoneCallState cstate, const
 
 static void linphone_call_destroy(LinphoneCall *obj)
 {
+#ifdef BUILD_UPNP
+       linphone_call_delete_upnp_session(obj);
+#endif //BUILD_UPNP
        linphone_call_delete_ice_session(obj);
        if (obj->op!=NULL) {
                sal_op_release(obj->op);
@@ -1674,6 +1690,15 @@ void linphone_call_delete_ice_session(LinphoneCall *call){
        }
 }
 
+#ifdef BUILD_UPNP
+void linphone_call_delete_upnp_session(LinphoneCall *call){
+       if(call->upnp_session!=NULL) {
+               upnp_session_destroy(call->upnp_session);
+               call->upnp_session=NULL;
+       }
+}
+#endif //BUILD_UPNP
+
 static void linphone_call_log_fill_stats(LinphoneCallLog *log, AudioStream *st){
        audio_stream_get_local_rtp_stats (st,&log->local_stats);
        log->quality=audio_stream_get_average_quality_rating(st);
@@ -1984,6 +2009,11 @@ void linphone_call_background_tasks(LinphoneCall *call, bool_t one_second_elapse
                report_bandwidth(call,as,vs);
                ms_message("Thread processing load: audio=%f\tvideo=%f",audio_load,video_load);
        }
+
+#ifdef BUILD_UPNP
+       upnp_call_process(call);
+#endif //BUILD_UPNP
+
 #ifdef VIDEO_ENABLED
        if (call->videostream!=NULL) {
                OrtpEvent *ev;