Commit 8026b597 authored by Yann Diorcet's avatar Yann Diorcet

Starting uPNP integration

parent 9898c4be
...@@ -50,7 +50,7 @@ liblinphone_la_SOURCES=\ ...@@ -50,7 +50,7 @@ liblinphone_la_SOURCES=\
$(GITVERSION_FILE) $(GITVERSION_FILE)
if BUILD_UPNP if BUILD_UPNP
liblinphone_la_SOURCES+=upnp.c liblinphone_la_SOURCES+=upnp.c upnp.h
endif endif
if BUILD_WIZARD if BUILD_WIZARD
......
...@@ -449,6 +449,11 @@ LinphoneCall * linphone_call_new_outgoing(struct _LinphoneCore *lc, LinphoneAddr ...@@ -449,6 +449,11 @@ LinphoneCall * linphone_call_new_outgoing(struct _LinphoneCore *lc, LinphoneAddr
if (linphone_core_get_firewall_policy(call->core) == LinphonePolicyUseStun) { if (linphone_core_get_firewall_policy(call->core) == LinphonePolicyUseStun) {
call->ping_time=linphone_core_run_stun_tests(call->core,call); 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; call->camera_active=params->has_video;
discover_mtu(lc,linphone_address_get_domain (to)); discover_mtu(lc,linphone_address_get_domain (to));
......
...@@ -1217,6 +1217,9 @@ static void linphone_core_init (LinphoneCore * lc, const LinphoneCoreVTable *vta ...@@ -1217,6 +1217,9 @@ static void linphone_core_init (LinphoneCore * lc, const LinphoneCoreVTable *vta
#ifdef TUNNEL_ENABLED #ifdef TUNNEL_ENABLED
lc->tunnel=linphone_core_tunnel_new(lc); lc->tunnel=linphone_core_tunnel_new(lc);
if (lc->tunnel) linphone_tunnel_configure(lc->tunnel); if (lc->tunnel) linphone_tunnel_configure(lc->tunnel);
#endif
#ifdef BUILD_UPNP
upnp_context_init(lc);
#endif #endif
if (lc->vtable.display_status) if (lc->vtable.display_status)
lc->vtable.display_status(lc,_("Ready")); lc->vtable.display_status(lc,_("Ready"));
...@@ -4901,6 +4904,9 @@ static void linphone_core_uninit(LinphoneCore *lc) ...@@ -4901,6 +4904,9 @@ static void linphone_core_uninit(LinphoneCore *lc)
#ifdef TUNNEL_ENABLED #ifdef TUNNEL_ENABLED
if (lc->tunnel) linphone_tunnel_destroy(lc->tunnel); if (lc->tunnel) linphone_tunnel_destroy(lc->tunnel);
#endif #endif
#ifdef BUILD_UPNP
upnp_context_uninit(lc);
#endif
} }
static void set_network_reachable(LinphoneCore* lc,bool_t isReachable, time_t curtime){ static void set_network_reachable(LinphoneCore* lc,bool_t isReachable, time_t curtime){
......
...@@ -885,7 +885,8 @@ typedef enum _LinphoneFirewallPolicy{ ...@@ -885,7 +885,8 @@ typedef enum _LinphoneFirewallPolicy{
LinphonePolicyNoFirewall, LinphonePolicyNoFirewall,
LinphonePolicyUseNatAddress, LinphonePolicyUseNatAddress,
LinphonePolicyUseStun, LinphonePolicyUseStun,
LinphonePolicyUseIce LinphonePolicyUseIce,
LinphonePolicyUseUpnp,
} LinphoneFirewallPolicy; } LinphoneFirewallPolicy;
typedef enum _LinphoneWaitingState{ typedef enum _LinphoneWaitingState{
......
...@@ -28,9 +28,11 @@ ...@@ -28,9 +28,11 @@
extern "C" { extern "C" {
#endif #endif
#include "linphonecore.h" #include "linphonecore.h"
#include "linphonefriend.h"
#include "linphone_tunnel.h" #include "linphone_tunnel.h"
#include "linphonecore_utils.h" #include "linphonecore_utils.h"
#include "sal.h" #include "sal.h"
#include "sipsetup.h"
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "config.h" #include "config.h"
...@@ -39,7 +41,7 @@ extern "C" { ...@@ -39,7 +41,7 @@ extern "C" {
#include "mediastreamer2/mediastream.h" #include "mediastreamer2/mediastream.h"
#include "mediastreamer2/msconference.h" #include "mediastreamer2/msconference.h"
#ifdef BUILD_UPNP #ifdef BUILD_UPNP
#include "mediastreamer2/upnp_igd.h" #include "upnp.h"
#endif #endif
#ifndef LIBLINPHONE_VERSION #ifndef LIBLINPHONE_VERSION
...@@ -148,6 +150,9 @@ struct _LinphoneCall ...@@ -148,6 +150,9 @@ struct _LinphoneCall
OrtpEvQueue *videostream_app_evq; OrtpEvQueue *videostream_app_evq;
CallCallbackObj nextVideoFrameDecoded; CallCallbackObj nextVideoFrameDecoded;
LinphoneCallStats stats[2]; LinphoneCallStats stats[2];
#ifdef BUILD_UPNP
UpnpSession *upnp_session;
#endif //BUILD_UPNP
IceSession *ice_session; IceSession *ice_session;
LinphoneChatMessage* pending_message; LinphoneChatMessage* pending_message;
int ping_time; int ping_time;
...@@ -572,15 +577,15 @@ struct _LinphoneCore ...@@ -572,15 +577,15 @@ struct _LinphoneCore
char* device_id; char* device_id;
MSList *last_recv_msg_ids; MSList *last_recv_msg_ids;
#ifdef BUILD_UPNP #ifdef BUILD_UPNP
upnp_igd_context *upnp_igd_ctxt; UpnpContext upnp;
#endif #endif //BUILD_UPNP
}; };
LinphoneTunnel *linphone_core_tunnel_new(LinphoneCore *lc); LinphoneTunnel *linphone_core_tunnel_new(LinphoneCore *lc);
void linphone_tunnel_destroy(LinphoneTunnel *tunnel); void linphone_tunnel_destroy(LinphoneTunnel *tunnel);
void linphone_tunnel_configure(LinphoneTunnel *tunnel); void linphone_tunnel_configure(LinphoneTunnel *tunnel);
void linphone_tunnel_enable_logs_with_handler(LinphoneTunnel *tunnel, bool_t enabled, OrtpLogFunc logHandler); void linphone_tunnel_enable_logs_with_handler(LinphoneTunnel *tunnel, bool_t enabled, OrtpLogFunc logHandler);
bool_t linphone_core_can_we_add_call(LinphoneCore *lc); bool_t linphone_core_can_we_add_call(LinphoneCore *lc);
int linphone_core_add_call( LinphoneCore *lc, LinphoneCall *call); int linphone_core_add_call( LinphoneCore *lc, LinphoneCall *call);
int linphone_core_del_call( LinphoneCore *lc, LinphoneCall *call); int linphone_core_del_call( LinphoneCore *lc, LinphoneCall *call);
......
...@@ -17,8 +17,8 @@ along with this program; if not, write to the Free Software ...@@ -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. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "upnp.h"
#include "private.h" #include "private.h"
#include "mediastreamer2/upnp_igd.h"
/* Convert uPnP IGD logs to ortp logs */ /* 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) { 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 ...@@ -36,16 +36,41 @@ void linphone_upnp_igd_print(void *cookie, upnp_igd_print_level level, const cha
default: default:
break; 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) { 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) { int upnp_context_init(LinphoneCore *lc) {
lc->upnp_igd_ctxt = NULL; 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; 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;
} }
/*
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
mediastreamer2 @ a1f11352
Subproject commit 2093868ac68ffe62310cd0ad20b58ffa6860d7e3 Subproject commit a1f113529f506aa178765cf70773db80e5768139
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment