]> sjero.net Git - linphone/commitdiff
Starting uPNP integration
authorYann Diorcet <yann.diorcet@belledonne-communications.com>
Fri, 21 Dec 2012 09:11:06 +0000 (10:11 +0100)
committerYann Diorcet <yann.diorcet@belledonne-communications.com>
Fri, 21 Dec 2012 09:11:06 +0000 (10:11 +0100)
coreapi/Makefile.am
coreapi/linphonecall.c
coreapi/linphonecore.c
coreapi/linphonecore.h
coreapi/private.h
coreapi/upnp.c
coreapi/upnp.h [new file with mode: 0644]
mediastreamer2

index 822c0b8367ee173016bf74f8964d58986cca75a8..c5abd0360b9ae9127aeb62e9b60069b4cefffd66 100644 (file)
@@ -50,7 +50,7 @@ liblinphone_la_SOURCES=\
        $(GITVERSION_FILE)
 
 if BUILD_UPNP
-liblinphone_la_SOURCES+=upnp.c
+liblinphone_la_SOURCES+=upnp.c upnp.h
 endif
        
 if BUILD_WIZARD
index 5a18a052547ef6649a8b23e415a94c7bb0995fed..6c8b4a74395ca074fc75916690addb192ef44a4c 100644 (file)
@@ -449,6 +449,11 @@ LinphoneCall * linphone_call_new_outgoing(struct _LinphoneCore *lc, LinphoneAddr
        if (linphone_core_get_firewall_policy(call->core) == LinphonePolicyUseStun) {
                call->ping_time=linphone_core_run_stun_tests(call->core,call);
        }
+#ifdef BUILD_UPNP
+       if (linphone_core_get_firewall_policy(call->core) == LinphonePolicyUseUpnp) {
+               call->upnp_session = upnp_session_new();
+       }
+#endif //BUILD_UPNP
        call->camera_active=params->has_video;
        
        discover_mtu(lc,linphone_address_get_domain (to));
index e52fff00ebf228c9157a75e1241dfe0b81921151..8619552faf4698c948a746ca7b791d47a698e3ef 100644 (file)
@@ -1217,6 +1217,9 @@ static void linphone_core_init (LinphoneCore * lc, const LinphoneCoreVTable *vta
 #ifdef TUNNEL_ENABLED
        lc->tunnel=linphone_core_tunnel_new(lc);
        if (lc->tunnel) linphone_tunnel_configure(lc->tunnel);
+#endif
+#ifdef BUILD_UPNP
+       upnp_context_init(lc);
 #endif
        if (lc->vtable.display_status)
                lc->vtable.display_status(lc,_("Ready"));
@@ -4901,6 +4904,9 @@ static void linphone_core_uninit(LinphoneCore *lc)
 #ifdef TUNNEL_ENABLED
        if (lc->tunnel) linphone_tunnel_destroy(lc->tunnel);
 #endif
+#ifdef BUILD_UPNP
+       upnp_context_uninit(lc);
+#endif
 }
 
 static void set_network_reachable(LinphoneCore* lc,bool_t isReachable, time_t curtime){
index f1a9174c8e3ad0c03447d8a01ad6e053e7676359..b4c25380a7217c92749e9feb311ae65955c37a47 100644 (file)
@@ -885,7 +885,8 @@ typedef enum _LinphoneFirewallPolicy{
        LinphonePolicyNoFirewall,
        LinphonePolicyUseNatAddress,
        LinphonePolicyUseStun,
-       LinphonePolicyUseIce
+       LinphonePolicyUseIce,
+       LinphonePolicyUseUpnp,
 } LinphoneFirewallPolicy;
 
 typedef enum _LinphoneWaitingState{
index f69eb2ff028ce344d628b850b5fa9f1cdfb3f118..6af7e09eead520585b45099e1b0ca8b01eb3ac60 100644 (file)
 extern "C" {
 #endif
 #include "linphonecore.h"
+#include "linphonefriend.h"
 #include "linphone_tunnel.h"
 #include "linphonecore_utils.h"
 #include "sal.h"
+#include "sipsetup.h"
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -39,7 +41,7 @@ extern "C" {
 #include "mediastreamer2/mediastream.h"
 #include "mediastreamer2/msconference.h"
 #ifdef BUILD_UPNP
-#include "mediastreamer2/upnp_igd.h"
+#include "upnp.h"
 #endif
 
 #ifndef LIBLINPHONE_VERSION
@@ -148,6 +150,9 @@ struct _LinphoneCall
        OrtpEvQueue *videostream_app_evq;
        CallCallbackObj nextVideoFrameDecoded;
        LinphoneCallStats stats[2];
+#ifdef BUILD_UPNP
+       UpnpSession *upnp_session;
+#endif //BUILD_UPNP
        IceSession *ice_session;
        LinphoneChatMessage* pending_message;
        int ping_time;
@@ -572,15 +577,15 @@ struct _LinphoneCore
        char* device_id;
        MSList *last_recv_msg_ids;
 #ifdef BUILD_UPNP
-       upnp_igd_context *upnp_igd_ctxt;
-#endif
+       UpnpContext upnp;
+#endif //BUILD_UPNP
 };
 
 LinphoneTunnel *linphone_core_tunnel_new(LinphoneCore *lc);
 void linphone_tunnel_destroy(LinphoneTunnel *tunnel);
 void linphone_tunnel_configure(LinphoneTunnel *tunnel);
 void linphone_tunnel_enable_logs_with_handler(LinphoneTunnel *tunnel, bool_t enabled, OrtpLogFunc logHandler);
-       
+
 bool_t linphone_core_can_we_add_call(LinphoneCore *lc);
 int linphone_core_add_call( LinphoneCore *lc, LinphoneCall *call);
 int linphone_core_del_call( LinphoneCore *lc, LinphoneCall *call);
index 31fb5c5f1b0c174e5013d186b8a5282ee35f4370..34622bf51eba4f26bb288b5ef5de037177958c15 100644 (file)
@@ -17,8 +17,8 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
 
+#include "upnp.h"
 #include "private.h"
-#include "mediastreamer2/upnp_igd.h"
 
 /* Convert uPnP IGD logs to ortp logs */
 void linphone_upnp_igd_print(void *cookie, upnp_igd_print_level level, const char *fmt, va_list list) {
@@ -36,16 +36,41 @@ void linphone_upnp_igd_print(void *cookie, upnp_igd_print_level level, const cha
        default:
                break;
        }
-       ortp_logv(level, fmt, list);
+       ortp_logv(ortp_level, fmt, list);
 }
 
 void linphone_upnp_igd_callback(void *cookie, upnp_igd_event event, void *arg) {
+       LinphoneCore *lc = (LinphoneCore *)cookie;
+       UpnpContext *lupnp = &lc->upnp;
+       switch(event) {
+       case UPNP_IGD_EXTERNAL_IPADDRESS_CHANGED:
+       case UPNP_IGD_NAT_ENABLED_CHANGED:
+       case UPNP_IGD_CONNECTION_STATUS_CHANGED:
+               break;
+
+       default:
+               break;
+       }
 }
 
-int linphone_upnp_init(LinphoneCore *lc) {
-       lc->upnp_igd_ctxt = NULL;
+int upnp_context_init(LinphoneCore *lc) {
+       UpnpContext *lupnp = &lc->upnp;
+       lupnp->upnp_igd_ctxt = NULL;
+       lupnp->upnp_igd_ctxt = upnp_igd_create(linphone_upnp_igd_callback, linphone_upnp_igd_print, lc);
+       if(lupnp->upnp_igd_ctxt == NULL) {
+               ms_error("Can't create uPnP IGD context");
+               return -1;
+       }
        return 0;
 }
-void linphone_upnp_destroy(LinphoneCore *lc) {
 
+void upnp_context_uninit(LinphoneCore *lc) {
+       UpnpContext *lupnp = &lc->upnp;
+       if(lupnp->upnp_igd_ctxt != NULL) {
+               upnp_igd_destroy(lupnp->upnp_igd_ctxt);
+       }
+}
+
+UpnpSession* upnp_session_new() {
+       return NULL;
 }
diff --git a/coreapi/upnp.h b/coreapi/upnp.h
new file mode 100644 (file)
index 0000000..c5ff5ec
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+linphone
+Copyright (C) 2012  Belledonne Communications SARL
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+*/
+
+#ifndef LINPHONE_UPNP_H
+#define LINPHONE_UPNP_H
+
+#include "mediastreamer2/upnp_igd.h"
+#include "linphonecore.h"
+
+typedef struct _UpnpSession {
+
+} UpnpSession;
+
+typedef struct _UpnpContext {
+       upnp_igd_context *upnp_igd_ctxt;
+} UpnpContext;
+
+UpnpSession* upnp_session_new();
+int upnp_context_init(LinphoneCore *lc);
+void upnp_context_uninit(LinphoneCore *lc);
+
+#endif //LINPHONE_UPNP_H
index 2093868ac68ffe62310cd0ad20b58ffa6860d7e3..a1f113529f506aa178765cf70773db80e5768139 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 2093868ac68ffe62310cd0ad20b58ffa6860d7e3
+Subproject commit a1f113529f506aa178765cf70773db80e5768139