]> sjero.net Git - linphone/blobdiff - coreapi/upnp.c
Update REGISTER contact with uPnP external informations
[linphone] / coreapi / upnp.c
index d86c8a42a4234a3fe51dd6cc278fbacf32e42225..105f4a8ddab2bcc79b6d504011edbfa4d136e99d 100644 (file)
@@ -368,8 +368,32 @@ void linphone_upnp_context_destroy(UpnpContext *lupnp) {
        ms_free(lupnp);
 }
 
-LinphoneUpnpState linphone_upnp_context_get_state(UpnpContext *ctx) {
-       return ctx->state;
+LinphoneUpnpState linphone_upnp_context_get_state(UpnpContext *lupnp) {
+       LinphoneUpnpState state;
+       ms_mutex_lock(&lupnp->mutex);
+       state = lupnp->state;
+       ms_mutex_unlock(&lupnp->mutex);
+       return state;
+}
+
+int linphone_upnp_context_get_external_port(UpnpContext *lupnp) {
+       int port = -1;
+       ms_mutex_lock(&lupnp->mutex);
+       
+       /* Send port binding removes */
+       if(lupnp->sip_udp != NULL) {
+               if(lupnp->sip_udp->state == LinphoneUpnpStateOk)
+                       port = lupnp->sip_udp->external_port;
+       } else if(lupnp->sip_tcp != NULL) {
+               if(lupnp->sip_tcp->state == LinphoneUpnpStateOk)
+                       port = lupnp->sip_tcp->external_port;
+       } else if(lupnp->sip_tls != NULL) {
+               if(lupnp->sip_tls->state == LinphoneUpnpStateOk)
+                       port = lupnp->sip_tls->external_port;
+       }
+       
+       ms_mutex_unlock(&lupnp->mutex);
+       return port;
 }
 
 const char* linphone_upnp_context_get_external_ipaddress(UpnpContext *ctx) {
@@ -964,6 +988,7 @@ LinphoneUpnpState linphone_upnp_session_get_state(UpnpSession *session) {
        return session->state;
 }
 
+
 /*
  * uPnP Config
  */