[asterisk-commits] qwell: branch group/pimp_my_sip r382902 - in /team/group/pimp_my_sip: ./ buil...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Mar 12 14:13:30 CDT 2013
Author: qwell
Date: Tue Mar 12 14:13:26 2013
New Revision: 382902
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=382902
Log:
Switch to using external pjproject libraries.
ICE/STUN/TURN support in res_rtp_asterisk is also now optional.
........
Merged revisions 382900 from http://svn.asterisk.org/svn/asterisk/trunk
Removed:
team/group/pimp_my_sip/res/pjproject/
Modified:
team/group/pimp_my_sip/ (props changed)
team/group/pimp_my_sip/CHANGES
team/group/pimp_my_sip/build_tools/menuselect-deps.in
team/group/pimp_my_sip/configure
team/group/pimp_my_sip/configure.ac
team/group/pimp_my_sip/include/asterisk/autoconfig.h.in
team/group/pimp_my_sip/makeopts.in
team/group/pimp_my_sip/res/Makefile
team/group/pimp_my_sip/res/res_rtp_asterisk.c
Propchange: team/group/pimp_my_sip/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Mar 12 14:13:26 2013
@@ -1,1 +1,1 @@
-/trunk:1-382862
+/trunk:1-382901
Modified: team/group/pimp_my_sip/CHANGES
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/CHANGES?view=diff&rev=382902&r1=382901&r2=382902
==============================================================================
--- team/group/pimp_my_sip/CHANGES (original)
+++ team/group/pimp_my_sip/CHANGES Tue Mar 12 14:13:26 2013
@@ -110,6 +110,12 @@
* LDAP realtime configurations for SIP Users now have the AstAccountPathSupport
objectIdentifier. This maps to the supportpath option in sip.conf.
+
+RTP
+------------------
+ * ICE/STUN/TURN support in res_rtp_asterisk has been made optional. To enable
+ them, an Asterisk-specific version of pjproject needs to be installed.
+ Tarballs are available from https://github.com/asterisk/pjproject/tags/.
------------------------------------------------------------------------------
--- Functionality changes from Asterisk 10 to Asterisk 11 --------------------
Modified: team/group/pimp_my_sip/build_tools/menuselect-deps.in
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/build_tools/menuselect-deps.in?view=diff&rev=382902&r1=382901&r2=382902
==============================================================================
--- team/group/pimp_my_sip/build_tools/menuselect-deps.in (original)
+++ team/group/pimp_my_sip/build_tools/menuselect-deps.in Tue Mar 12 14:13:26 2013
@@ -44,6 +44,7 @@
OSPTK=@PBX_OSPTK@
OSS=@PBX_OSS@
PGSQL=@PBX_PGSQL@
+PJPROJECT=@PBX_PJPROJECT@
POPT=@PBX_POPT@
PORTAUDIO=@PBX_PORTAUDIO@
PRI=@PBX_PRI@
Modified: team/group/pimp_my_sip/configure.ac
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/configure.ac?view=diff&rev=382902&r1=382901&r2=382902
==============================================================================
--- team/group/pimp_my_sip/configure.ac (original)
+++ team/group/pimp_my_sip/configure.ac Tue Mar 12 14:13:26 2013
@@ -427,6 +427,7 @@
AST_EXT_LIB_SETUP([OSPTK], [OSP Toolkit], [osptk])
AST_EXT_LIB_SETUP([OSS], [Open Sound System], [oss])
AST_EXT_LIB_SETUP([PGSQL], [PostgreSQL], [postgres])
+AST_EXT_LIB_SETUP([PJPROJECT], [PJPROJECT], [pjproject])
AST_EXT_LIB_SETUP([POPT], [popt], [popt])
AST_EXT_LIB_SETUP([PORTAUDIO], [PortAudio], [portaudio])
AST_EXT_LIB_SETUP([PRI], [ISDN PRI], [pri])
@@ -1987,6 +1988,8 @@
fi
fi
+AST_PKG_CONFIG_CHECK([PJPROJECT], [libpjproject])
+
AST_EXT_LIB_CHECK([POPT], [popt], [poptStrerror], [popt.h])
AST_EXT_LIB_CHECK([PORTAUDIO], [portaudio], [Pa_GetDeviceCount], [portaudio.h])
Modified: team/group/pimp_my_sip/include/asterisk/autoconfig.h.in
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/include/asterisk/autoconfig.h.in?view=diff&rev=382902&r1=382901&r2=382902
==============================================================================
--- team/group/pimp_my_sip/include/asterisk/autoconfig.h.in (original)
+++ team/group/pimp_my_sip/include/asterisk/autoconfig.h.in Tue Mar 12 14:13:26 2013
@@ -550,6 +550,9 @@
/* Define to indicate presence of the pg_encoding_to_char API. */
#undef HAVE_PGSQL_pg_encoding_to_char
+
+/* Define if your system has the PJPROJECT libraries. */
+#undef HAVE_PJPROJECT
/* Define to 1 if your system defines IP_PKTINFO. */
#undef HAVE_PKTINFO
Modified: team/group/pimp_my_sip/makeopts.in
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/makeopts.in?view=diff&rev=382902&r1=382901&r2=382902
==============================================================================
--- team/group/pimp_my_sip/makeopts.in (original)
+++ team/group/pimp_my_sip/makeopts.in Tue Mar 12 14:13:26 2013
@@ -218,6 +218,9 @@
PGSQL_INCLUDE=@PGSQL_INCLUDE@
PGSQL_LIB=@PGSQL_LIB@
+PJPROJECT_INCLUDE=@PJPROJECT_INCLUDE@
+PJPROJECT_LIB=@PJPROJECT_LIB@
+
POPT_INCLUDE=@POPT_INCLUDE@
POPT_LIB=@POPT_LIB@
Modified: team/group/pimp_my_sip/res/Makefile
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/res/Makefile?view=diff&rev=382902&r1=382901&r2=382902
==============================================================================
--- team/group/pimp_my_sip/res/Makefile (original)
+++ team/group/pimp_my_sip/res/Makefile Tue Mar 12 14:13:26 2013
@@ -70,35 +70,4 @@
ael/pval.o: ael/pval.c
clean::
- @if [ -f pjproject/build.mak ]; then $(MAKE) -C pjproject realclean; fi
rm -f snmp/*.o snmp/*.i ael/*.o ael/*.i ais/*.o ais/*.i res_sip/*.o res_sip/*.i
-
-dist-clean::
- rm -f pjproject/build.mak
-
-pjproject/build.mak: pjproject/aconfigure
- (cd pjproject && CFLAGS="-fPIC" ./configure --build=$(BUILD_PLATFORM) --host=$(HOST_PLATFORM) --disable-floating-point --disable-sound --disable-oss --disable-speex-aec --disable-l16-codec --disable-gsm-codec --disable-g722-codec --disable-g7221-codec --disable-speex-codec --disable-ilbc-codec --disable-g711-codec)
-
-ifneq ($(findstring $(MAKECMDGOALS),all),)
--include pjproject/build.mak
-endif
-
-.PHONY: FORCE
-FORCE:
-
-$(PJ_LIB_FILES): FORCE
- $(MAKE) -C $(patsubst %/lib/,%,$(dir $@))/build/ ../lib/$(notdir $@)
-
-res_rtp_asterisk.o: $(PJ_LIB_FILES)
-res_rtp_asterisk.o: _ASTCFLAGS+=$(PJ_CFLAGS)
-res_rtp_asterisk.so: _ASTLDFLAGS+=$(PJ_LDFLAGS)
-res_rtp_asterisk.so: LIBS+=$(PJ_LDLIBS)
-
-res_sip/%.o: $(PJ_LIB_FILES)
-
-res_sip.o: $(PJ_LIB_FILES)
-res_sip.o: _ASTCFLAGS+=$(PJ_CFLAGS)
-res_sip.so: _ASTLDFLAGS+=$(PJ_LDFLAGS)
-res_sip.so: LIBS+=-Wl,--whole-archive $(PJ_LDLIBS) -Wl,--no-whole-archive
-
-res_sip_%.o: _ASTCFLAGS+=$(PJ_CFLAGS)
Modified: team/group/pimp_my_sip/res/res_rtp_asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/res/res_rtp_asterisk.c?view=diff&rev=382902&r1=382901&r2=382902
==============================================================================
--- team/group/pimp_my_sip/res/res_rtp_asterisk.c (original)
+++ team/group/pimp_my_sip/res/res_rtp_asterisk.c Tue Mar 12 14:13:26 2013
@@ -29,6 +29,7 @@
*/
/*** MODULEINFO
+ <use type="external">pjproject</use>
<support_level>core</support_level>
***/
@@ -46,9 +47,11 @@
#include <openssl/bio.h>
#endif
-#include "pjlib.h"
-#include "pjlib-util.h"
-#include "pjnath.h"
+#ifdef HAVE_PJPROJECT
+#include <pjlib.h>
+#include <pjlib-util.h>
+#include <pjnath.h>
+#endif
#include "asterisk/stun.h"
#include "asterisk/pbx.h"
@@ -129,6 +132,7 @@
#endif
static int strictrtp = DEFAULT_STRICT_RTP; /*< Only accept RTP frames from a defined source. If we receive an indication of a changing source, enter learning mode. */
static int learning_min_sequential = DEFAULT_LEARNING_MIN_SEQUENTIAL; /*< Number of sequential RTP frames needed from a single source during learning mode to accept new source. */
+#ifdef HAVE_PJPROJECT
static int icesupport = DEFAULT_ICESUPPORT;
static struct sockaddr_in stunaddr;
static pj_str_t turnaddr;
@@ -153,6 +157,7 @@
/*! \brief Notification that the ICE/TURN worker thread should stop */
static int worker_terminate;
+#endif
#define FLAG_3389_WARNING (1 << 0)
#define FLAG_NAT_ACTIVE (3 << 1)
@@ -249,12 +254,14 @@
struct rtp_red *red;
+ ast_mutex_t lock; /*!< Lock for synchronization purposes */
+ ast_cond_t cond; /*!< Condition for signaling */
+
+#ifdef HAVE_PJPROJECT
pj_ice_sess *ice; /*!< ICE session */
pj_turn_sock *turn_rtp; /*!< RTP TURN relay */
pj_turn_sock *turn_rtcp; /*!< RTCP TURN relay */
- ast_mutex_t lock; /*!< Lock for synchronization purposes */
pj_turn_state_t turn_state; /*!< Current state of the TURN relay session */
- ast_cond_t cond; /*!< Condition for signaling */
unsigned int passthrough:1; /*!< Bit to indicate that the received packet should be passed through */
unsigned int ice_started:1; /*!< Bit to indicate ICE connectivity checks have started */
@@ -266,6 +273,7 @@
struct ao2_container *local_candidates; /*!< The local ICE candidates */
struct ao2_container *remote_candidates; /*!< The remote ICE candidates */
+#endif
#ifdef HAVE_OPENSSL_SRTP
SSL_CTX *ssl_ctx; /*!< SSL context */
@@ -392,6 +400,22 @@
static int __rtp_sendto(struct ast_rtp_instance *instance, void *buf, size_t size, int flags, struct ast_sockaddr *sa, int rtcp, int *ice, int use_srtp);
+/*! \brief Helper function which updates an ast_sockaddr with the candidate used for the component */
+static void update_address_with_ice_candidate(struct ast_rtp *rtp, int component, struct ast_sockaddr *cand_address)
+{
+#ifdef HAVE_PJPROJECT
+ char address[PJ_INET6_ADDRSTRLEN];
+
+ if (!rtp->ice || (component < 1) || !rtp->ice->comp[component - 1].valid_check) {
+ return;
+ }
+
+ ast_sockaddr_parse(cand_address, pj_sockaddr_print(&rtp->ice->comp[component - 1].valid_check->rcand->addr, address, sizeof(address), 0), 0);
+ ast_sockaddr_set_port(cand_address, pj_sockaddr_get_port(&rtp->ice->comp[component - 1].valid_check->rcand->addr));
+#endif
+}
+
+#ifdef HAVE_PJPROJECT
/*! \brief Destructor for locally created ICE candidates */
static void ast_rtp_ice_candidate_destroy(void *obj)
{
@@ -472,19 +496,6 @@
ast_log(LOG_ERROR, "Coudln't register thread with PJLIB.\n");
}
return;
-}
-
-/*! \brief Helper function which updates an ast_sockaddr with the candidate used for the component */
-static void update_address_with_ice_candidate(struct ast_rtp *rtp, int component, struct ast_sockaddr *cand_address)
-{
- char address[PJ_INET6_ADDRSTRLEN];
-
- if (!rtp->ice || (component < 1) || !rtp->ice->comp[component - 1].valid_check) {
- return;
- }
-
- ast_sockaddr_parse(cand_address, pj_sockaddr_print(&rtp->ice->comp[component - 1].valid_check->rcand->addr, address, sizeof(address), 0), 0);
- ast_sockaddr_set_port(cand_address, pj_sockaddr_get_port(&rtp->ice->comp[component - 1].valid_check->rcand->addr));
}
static void ast_rtp_ice_start(struct ast_rtp_instance *instance)
@@ -691,6 +702,7 @@
.get_local_candidates = ast_rtp_ice_get_local_candidates,
.ice_lite = ast_rtp_ice_lite,
};
+#endif
#ifdef HAVE_OPENSSL_SRTP
static void dtls_info_callback(const SSL *ssl, int where, int ret)
@@ -1017,13 +1029,16 @@
.stop = ast_rtp_stop,
.qos = ast_rtp_qos_set,
.sendcng = ast_rtp_sendcng,
+#ifdef HAVE_PJPROJECT
.ice = &ast_rtp_ice,
+#endif
#ifdef HAVE_OPENSSL_SRTP
.dtls = &ast_rtp_dtls,
.activate = ast_rtp_activate,
#endif
};
+#ifdef HAVE_PJPROJECT
static void rtp_learning_seq_init(struct rtp_learning_info *info, uint16_t seq);
static void ast_rtp_on_ice_complete(pj_ice_sess *ice, pj_status_t status)
@@ -1193,6 +1208,7 @@
return 0;
}
+#endif
static inline int rtp_debug_test_addr(struct ast_sockaddr *addr)
{
@@ -1447,6 +1463,7 @@
}
#endif
+#ifdef HAVE_PJPROJECT
if (rtp->ice) {
pj_str_t combined = pj_str(ast_sockaddr_stringify(sa));
pj_sockaddr address;
@@ -1472,6 +1489,7 @@
}
rtp->passthrough = 0;
}
+#endif
if ((*in > 1) && res_srtp && srtp && res_srtp->unprotect(srtp, buf, &len, rtcp) < 0) {
return -1;
@@ -1503,6 +1521,7 @@
return -1;
}
+#ifdef HAVE_PJPROJECT
if (rtp->ice) {
pj_thread_register_check();
@@ -1511,6 +1530,7 @@
return 0;
}
}
+#endif
return ast_sendto(rtcp ? rtp->rtcp->s : rtp->s, temp, len, flags, sa);
}
@@ -1628,6 +1648,7 @@
return (info->packets == 0);
}
+#ifdef HAVE_PJPROJECT
static void rtp_add_candidates_to_ice(struct ast_rtp_instance *instance, struct ast_rtp *rtp, struct ast_sockaddr *addr, int port, int component,
int transport, const pj_turn_sock_cb *turn_cb, pj_turn_sock **turn_sock)
{
@@ -1692,6 +1713,7 @@
}
}
}
+#endif
static int ast_rtp_new(struct ast_rtp_instance *instance,
struct ast_sched_context *sched, struct ast_sockaddr *addr,
@@ -1699,8 +1721,10 @@
{
struct ast_rtp *rtp = NULL;
int x, startplace;
+#ifdef HAVE_PJPROJECT
pj_stun_config stun_config;
pj_str_t ufrag, passwd;
+#endif
/* Create a new RTP structure to hold all of our data */
if (!(rtp = ast_calloc(1, sizeof(*rtp)))) {
@@ -1758,6 +1782,7 @@
}
}
+#ifdef HAVE_PJPROJECT
pj_thread_register_check();
pj_stun_config_init(&stun_config, &cachingpool.factory, 0, ioqueue, timerheap);
@@ -1770,13 +1795,14 @@
ast_rtp_instance_set_data(instance, rtp);
/* Create an ICE session for ICE negotiation */
- if (icesupport && pj_ice_sess_create(&stun_config, NULL, PJ_ICE_SESS_ROLE_UNKNOWN, 2, &ast_rtp_ice_sess_cb, &ufrag, &passwd, &rtp->ice) == PJ_SUCCESS) {
+ if (icesupport && pj_ice_sess_create(&stun_config, NULL, PJ_ICE_SESS_ROLE_UNKNOWN, 2, &ast_rtp_ice_sess_cb, &ufrag, &passwd, NULL, &rtp->ice) == PJ_SUCCESS) {
/* Make this available for the callbacks */
rtp->ice->user_data = rtp;
/* Add all of the available candidates to the ICE session */
rtp_add_candidates_to_ice(instance, rtp, addr, x, COMPONENT_RTP, TRANSPORT_SOCKET_RTP, &ast_rtp_turn_rtp_sock_cb, &rtp->turn_rtp);
}
+#endif
/* Record any information we may need */
rtp->sched = sched;
@@ -1819,6 +1845,7 @@
ast_free(rtp->red);
}
+#ifdef HAVE_PJPROJECT
pj_thread_register_check();
/* Destroy the ICE session if being used */
@@ -1846,6 +1873,7 @@
if (rtp->remote_candidates) {
ao2_ref(rtp->remote_candidates, -1);
}
+#endif
#ifdef HAVE_OPENSSL_SRTP
/* Destroy the SSL context if present */
@@ -3904,10 +3932,12 @@
ast_debug(1, "Setup RTCP on RTP instance '%p'\n", instance);
rtp->rtcp->schedid = -1;
+#ifdef HAVE_PJPROJECT
if (rtp->ice) {
rtp_add_candidates_to_ice(instance, rtp, &rtp->rtcp->us, ast_sockaddr_port(&rtp->rtcp->us), COMPONENT_RTCP, TRANSPORT_SOCKET_RTCP,
&ast_rtp_turn_rtcp_sock_cb, &rtp->turn_rtcp);
}
+#endif
return;
} else {
@@ -4372,12 +4402,14 @@
* the pool this will cause a small memory leak.
*/
+#ifdef HAVE_PJPROJECT
icesupport = DEFAULT_ICESUPPORT;
turnport = DEFAULT_TURN_PORT;
memset(&stunaddr, 0, sizeof(stunaddr));
turnaddr = pj_str(NULL);
turnusername = pj_str(NULL);
turnpassword = pj_str(NULL);
+#endif
if (cfg) {
if ((s = ast_variable_retrieve(cfg, "general", "rtpstart"))) {
@@ -4428,6 +4460,7 @@
DEFAULT_LEARNING_MIN_SEQUENTIAL);
}
}
+#ifdef HAVE_PJPROJECT
if ((s = ast_variable_retrieve(cfg, "general", "icesupport"))) {
icesupport = ast_true(s);
}
@@ -4455,6 +4488,7 @@
if ((s = ast_variable_retrieve(cfg, "general", "turnpassword"))) {
pj_strdup2(pool, &turnpassword, s);
}
+#endif
ast_config_destroy(cfg);
}
if (rtpstart >= rtpend) {
@@ -4474,6 +4508,7 @@
static int load_module(void)
{
+#ifdef HAVE_PJPROJECT
pj_lock_t *lock;
pj_log_set_level(0);
@@ -4521,23 +4556,28 @@
pj_shutdown();
return AST_MODULE_LOAD_DECLINE;
}
+#endif
if (ast_rtp_engine_register(&asterisk_rtp_engine)) {
+#ifdef HAVE_PJPROJECT
worker_terminate = 1;
pj_thread_join(thread);
pj_thread_destroy(thread);
pj_caching_pool_destroy(&cachingpool);
pj_shutdown();
+#endif
return AST_MODULE_LOAD_DECLINE;
}
if (ast_cli_register_multiple(cli_rtp, ARRAY_LEN(cli_rtp))) {
+#ifdef HAVE_PJPROJECT
worker_terminate = 1;
pj_thread_join(thread);
pj_thread_destroy(thread);
ast_rtp_engine_unregister(&asterisk_rtp_engine);
pj_caching_pool_destroy(&cachingpool);
pj_shutdown();
+#endif
return AST_MODULE_LOAD_DECLINE;
}
@@ -4551,6 +4591,7 @@
ast_rtp_engine_unregister(&asterisk_rtp_engine);
ast_cli_unregister_multiple(cli_rtp, ARRAY_LEN(cli_rtp));
+#ifdef HAVE_PJPROJECT
worker_terminate = 1;
pj_thread_register_check();
@@ -4560,6 +4601,7 @@
pj_caching_pool_destroy(&cachingpool);
pj_shutdown();
+#endif
return 0;
}
More information about the asterisk-commits
mailing list