diff --git a/configure.ac b/configure.ac index 1005ab2f5..659a872b4 100644 --- a/configure.ac +++ b/configure.ac @@ -149,6 +149,32 @@ AC_ARG_ENABLE(tools, *) AC_MSG_ERROR(bad value ${enableval} for --enable-tools) ;; esac],[build_tools=check]) +dnl check for installed version of libupnp +AC_ARG_ENABLE(upnp, + [AS_HELP_STRING([--disable-upnp], [Disable uPnP support])], + [case "${enableval}" in + yes) build_upnp=true ;; + no) build_upnp=false ;; + *) AC_MSG_ERROR(bad value ${enableval} for --disable-upnp) ;; + esac],[build_upnp=auto]) + +if test "$build_upnp" != "false" ; then +PKG_CHECK_MODULES([LIBUPNP], [libupnp], [build_upnp=true], + [ + if test "$build_upnp" == "true" ; then + AC_MSG_ERROR([libupnp not found.]) + else + build_upnp=false + fi + ]) + +fi + +AM_CONDITIONAL(BUILD_UPNP, test x$build_upnp != xfalse) +if test "$build_upnp" != "false" ; then + AC_DEFINE(BUILD_UPNP, 1, [Define if upnp enabled]) +fi + dnl check libxml2 (needed for tools) if test "$build_tools" != "false" ; then PKG_CHECK_MODULES(LIBXML2, [libxml-2.0],[], diff --git a/coreapi/Makefile.am b/coreapi/Makefile.am index 790612cab..6d55a731f 100644 --- a/coreapi/Makefile.am +++ b/coreapi/Makefile.am @@ -49,6 +49,10 @@ liblinphone_la_SOURCES=\ conference.c \ linphone_tunnel.cc \ $(GITVERSION_FILE) + +if BUILD_UPNP +liblinphone_la_SOURCES+=upnp.c +endif if BUILD_WIZARD liblinphone_la_SOURCES+=sipwizard.c diff --git a/coreapi/private.h b/coreapi/private.h index 925a30360..f69eb2ff0 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -38,6 +38,9 @@ extern "C" { #include "mediastreamer2/ice.h" #include "mediastreamer2/mediastream.h" #include "mediastreamer2/msconference.h" +#ifdef BUILD_UPNP +#include "mediastreamer2/upnp_igd.h" +#endif #ifndef LIBLINPHONE_VERSION #define LIBLINPHONE_VERSION LINPHONE_VERSION @@ -558,8 +561,8 @@ struct _LinphoneCore bool_t network_reachable; bool_t use_preview_window; - time_t network_last_check; - bool_t network_last_status; + time_t network_last_check; + bool_t network_last_status; bool_t ringstream_autorelease; bool_t pad[3]; @@ -568,6 +571,9 @@ struct _LinphoneCore LinphoneTunnel *tunnel; char* device_id; MSList *last_recv_msg_ids; +#ifdef BUILD_UPNP + upnp_igd_context *upnp_igd_ctxt; +#endif }; LinphoneTunnel *linphone_core_tunnel_new(LinphoneCore *lc); @@ -642,6 +648,9 @@ void call_logs_write_to_config_file(LinphoneCore *lc); int linphone_core_get_edge_bw(LinphoneCore *lc); int linphone_core_get_edge_ptime(LinphoneCore *lc); +int linphone_upnp_init(LinphoneCore *lc); +void linphone_upnp_destroy(LinphoneCore *lc); + #ifdef __cplusplus } #endif diff --git a/coreapi/upnp.c b/coreapi/upnp.c new file mode 100644 index 000000000..31fb5c5f1 --- /dev/null +++ b/coreapi/upnp.c @@ -0,0 +1,51 @@ +/* +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. +*/ + +#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) { + int ortp_level = ORTP_DEBUG; + switch(level) { + case UPNP_IGD_MESSAGE: + ortp_level = ORTP_MESSAGE; + break; + case UPNP_IGD_WARNING: + ortp_level = ORTP_WARNING; + break; + case UPNP_IGD_ERROR: + ortp_level = ORTP_ERROR; + break; + default: + break; + } + ortp_logv(level, fmt, list); +} + +void linphone_upnp_igd_callback(void *cookie, upnp_igd_event event, void *arg) { +} + +int linphone_upnp_init(LinphoneCore *lc) { + lc->upnp_igd_ctxt = NULL; + return 0; +} +void linphone_upnp_destroy(LinphoneCore *lc) { + +} diff --git a/mediastreamer2 b/mediastreamer2 index 9c3f1bdf1..2093868ac 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 9c3f1bdf1f7b51c5eeb020f68ef9a4019c66cc52 +Subproject commit 2093868ac68ffe62310cd0ad20b58ffa6860d7e3