[asterisk-commits] qwell: branch qwell/pimp_my_sip-butnotwithpjproject r382148 - in /team/qwell/...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Feb 26 15:01:42 CST 2013


Author: qwell
Date: Tue Feb 26 15:01:38 2013
New Revision: 382148

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=382148
Log:
Multiple revisions 382060-382061,382146

........
  r382060 | qwell | 2013-02-25 14:37:48 -0600 (Mon, 25 Feb 2013) | 4 lines
  
  Potentially make res_rtp_asterisk work without pjproject being installed.
  
  Maybe.  Probably not.  Completely untested (but it compiles.  Maybe.)
........
  r382061 | qwell | 2013-02-25 14:41:27 -0600 (Mon, 25 Feb 2013) | 1 line
  
  Bootstrap, because this got screwy somewhere on automerge.
........
  r382146 | qwell | 2013-02-26 14:42:01 -0600 (Tue, 26 Feb 2013) | 1 line
  
  Assume autoconf was used to build pjproject, because we need it to have been.
........

Merged revisions 382060-382061,382146 from http://svn.asterisk.org/svn/asterisk/team/qwell/pjsip-shared-libs

Modified:
    team/qwell/pimp_my_sip-butnotwithpjproject/   (props changed)
    team/qwell/pimp_my_sip-butnotwithpjproject/configure
    team/qwell/pimp_my_sip-butnotwithpjproject/configure.ac
    team/qwell/pimp_my_sip-butnotwithpjproject/res/res_rtp_asterisk.c

Propchange: team/qwell/pimp_my_sip-butnotwithpjproject/
------------------------------------------------------------------------------
Binary property 'branchmerge' - no diff available.

Modified: team/qwell/pimp_my_sip-butnotwithpjproject/configure.ac
URL: http://svnview.digium.com/svn/asterisk/team/qwell/pimp_my_sip-butnotwithpjproject/configure.ac?view=diff&rev=382148&r1=382147&r2=382148
==============================================================================
--- team/qwell/pimp_my_sip-butnotwithpjproject/configure.ac (original)
+++ team/qwell/pimp_my_sip-butnotwithpjproject/configure.ac Tue Feb 26 15:01:38 2013
@@ -1994,10 +1994,11 @@
    fi
 fi
 
-AST_EXT_LIB_CHECK([PJLIB], [pj], [pj_init], [pjlib.h])
-AST_EXT_LIB_CHECK([PJLIB_UTIL], [pjlib-util], [pjlib_util_init], [pjlib-util.h])
-AST_EXT_LIB_CHECK([PJMEDIA], [pjmedia], [pjmedia_session_create], [pjmedia.h])
-AST_EXT_LIB_CHECK([PJNATH], [pjnath], [pjnath_init], [pjnath.h])
+AST_EXT_LIB_CHECK([PJLIB], [pj], [pj_init], [pjlib.h], [], [-DPJ_AUTOCONF=1])
+AST_EXT_LIB_CHECK([PJLIB_UTIL], [pjlib-util], [pjlib_util_init], [pjlib-util.h], [], [-DPJ_AUTOCONF=1])
+AST_EXT_LIB_CHECK([PJMEDIA], [pjmedia], [pjmedia_session_create], [pjmedia.h], [], [-DPJ_AUTOCONF=1])
+AST_EXT_LIB_CHECK([PJNATH], [pjnath], [pjnath_init], [pjnath.h], [], [-DPJ_AUTOCONF=1])
+
 AST_EXT_LIB_CHECK([PJSIP], [pjsip], [pjsip_endpt_create], [pjsip.h])
 AST_EXT_LIB_CHECK([PJSIP_SIMPLE], [pjsip-simple], [pjsip_subscribe_method], [pjsip_simple.h])
 AST_EXT_LIB_CHECK([PJSIP_UA], [pjsip-ua], [pjsip_inv_usage_init], [pjsip_ua.h])

Modified: team/qwell/pimp_my_sip-butnotwithpjproject/res/res_rtp_asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/pimp_my_sip-butnotwithpjproject/res/res_rtp_asterisk.c?view=diff&rev=382148&r1=382147&r2=382148
==============================================================================
--- team/qwell/pimp_my_sip-butnotwithpjproject/res/res_rtp_asterisk.c (original)
+++ team/qwell/pimp_my_sip-butnotwithpjproject/res/res_rtp_asterisk.c Tue Feb 26 15:01:38 2013
@@ -29,9 +29,7 @@
  */
 
 /*** MODULEINFO
-	<depend>pjlib</depend>
-	<depend>pjlib_util</depend>
-	<depend>pjnath</depend>
+	<use type="external">pjnath</use>
 	<support_level>core</support_level>
  ***/
 
@@ -49,6 +47,7 @@
 #include <openssl/bio.h>
 #endif
 
+#ifdef HAVE_PJNATH
 /* Asterisk discourages the use of bzero in favor of memset, in fact if you try to use bzero it will tell you to use memset. As a result bzero has to be undefined
  * here since it is used internally by pjlib. The only other option would be to modify pjlib... which won't happen. */
 #undef bzero
@@ -56,6 +55,7 @@
 #include "pjlib.h"
 #include "pjlib-util.h"
 #include "pjnath.h"
+#endif
 
 #include "asterisk/stun.h"
 #include "asterisk/pbx.h"
@@ -136,6 +136,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_PJNATH
 static int icesupport = DEFAULT_ICESUPPORT;
 static struct sockaddr_in stunaddr;
 static pj_str_t turnaddr;
@@ -160,6 +161,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)
@@ -251,12 +253,14 @@
 
 	struct rtp_red *red;
 
+	ast_mutex_t lock;           /*!< Lock for synchronization purposes */
+	ast_cond_t cond;            /*!< Condition for signaling */
+
+#ifdef HAVE_PJNATH
 	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 */
 
@@ -268,6 +272,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 */
@@ -395,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_PJNATH
+	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_PJNATH
 /*! \brief Destructor for locally created ICE candidates */
 static void ast_rtp_ice_candidate_destroy(void *obj)
 {
@@ -475,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)
@@ -693,6 +701,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)
@@ -1020,13 +1029,16 @@
 	.stop = ast_rtp_stop,
 	.qos = ast_rtp_qos_set,
 	.sendcng = ast_rtp_sendcng,
+#ifdef HAVE_PJNATH
 	.ice = &ast_rtp_ice,
+#endif
 #ifdef HAVE_OPENSSL_SRTP
 	.dtls = &ast_rtp_dtls,
 	.activate = ast_rtp_activate,
 #endif
 };
 
+#ifdef HAVE_PJNATH
 static void ast_rtp_on_ice_rx_data(pj_ice_sess *ice, unsigned comp_id, unsigned transport_id, void *pkt, pj_size_t size, const pj_sockaddr_t *src_addr, unsigned src_addr_len)
 {
 	struct ast_rtp *rtp = ice->user_data;
@@ -1181,6 +1193,7 @@
 
 	return 0;
 }
+#endif
 
 static inline int rtp_debug_test_addr(struct ast_sockaddr *addr)
 {
@@ -1435,6 +1448,7 @@
 	}
 #endif
 
+#ifdef HAVE_PJNATH
 	if (rtp->ice) {
 		pj_str_t combined = pj_str(ast_sockaddr_stringify(sa));
 		pj_sockaddr address;
@@ -1460,6 +1474,7 @@
 		}
 		rtp->passthrough = 0;
 	}
+#endif
 
 	if ((*in > 1) && res_srtp && srtp && res_srtp->unprotect(srtp, buf, &len, rtcp) < 0) {
 	   return -1;
@@ -1491,6 +1506,7 @@
 		return -1;
 	}
 
+#ifdef HAVE_PJNATH
 	if (rtp->ice) {
 		pj_thread_register_check();
 
@@ -1499,6 +1515,7 @@
 			return 0;
 		}
 	}
+#endif
 
 	return ast_sendto(rtcp ? rtp->rtcp->s : rtp->s, temp, len, flags, sa);
 }
@@ -1622,6 +1639,7 @@
 	return probation;
 }
 
+#ifdef HAVE_PJNATH
 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)
 {
@@ -1686,6 +1704,7 @@
 		}
 	}
 }
+#endif
 
 static int ast_rtp_new(struct ast_rtp_instance *instance,
 		       struct ast_sched_context *sched, struct ast_sockaddr *addr,
@@ -1693,8 +1712,10 @@
 {
 	struct ast_rtp *rtp = NULL;
 	int x, startplace;
+#ifdef HAVE_PJNATH
 	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)))) {
@@ -1751,6 +1772,7 @@
 		}
 	}
 
+#ifdef HAVE_PJNATH
 	pj_thread_register_check();
 
 	pj_stun_config_init(&stun_config, &cachingpool.factory, 0, ioqueue, timerheap);
@@ -1770,6 +1792,7 @@
 		/* 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;
@@ -1812,6 +1835,7 @@
 		ast_free(rtp->red);
 	}
 
+#ifdef HAVE_PJNATH
 	pj_thread_register_check();
 
 	/* Destroy the ICE session if being used */
@@ -1839,6 +1863,7 @@
 	if (rtp->remote_candidates) {
 		ao2_ref(rtp->remote_candidates, -1);
 	}
+#endif
 
 #ifdef HAVE_OPENSSL_SRTP
 	/* Destroy the SSL context if present */
@@ -3895,10 +3920,12 @@
 			ast_debug(1, "Setup RTCP on RTP instance '%p'\n", instance);
 			rtp->rtcp->schedid = -1;
 
+#ifdef HAVE_PJNATH
 			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 {
@@ -4375,12 +4402,14 @@
 	 * the pool this will cause a small memory leak.
 	 */
 
+#ifdef HAVE_PJNATH
 	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"))) {
@@ -4431,6 +4460,7 @@
 					DEFAULT_LEARNING_MIN_SEQUENTIAL);
 			}
 		}
+#ifdef HAVE_PJNATH
 		if ((s = ast_variable_retrieve(cfg, "general", "icesupport"))) {
 			icesupport = ast_true(s);
 		}
@@ -4458,6 +4488,7 @@
 		if ((s = ast_variable_retrieve(cfg, "general", "turnpassword"))) {
 			pj_strdup2(pool, &turnpassword, s);
 		}
+#endif
 		ast_config_destroy(cfg);
 	}
 	if (rtpstart >= rtpend) {
@@ -4477,6 +4508,7 @@
 
 static int load_module(void)
 {
+#ifdef HAVE_PJNATH
 	pj_lock_t *lock;
 
 	pj_log_set_level(0);
@@ -4524,23 +4556,28 @@
 		pj_shutdown();
 		return AST_MODULE_LOAD_DECLINE;
 	}
+#endif
 
 	if (ast_rtp_engine_register(&asterisk_rtp_engine)) {
+#ifdef HAVE_PJNATH
 		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_PJNATH
 		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;
 	}
 
@@ -4554,6 +4591,7 @@
 	ast_rtp_engine_unregister(&asterisk_rtp_engine);
 	ast_cli_unregister_multiple(cli_rtp, ARRAY_LEN(cli_rtp));
 
+#ifdef HAVE_PJNATH
 	worker_terminate = 1;
 
 	pj_thread_register_check();
@@ -4563,6 +4601,7 @@
 
 	pj_caching_pool_destroy(&cachingpool);
 	pj_shutdown();
+#endif
 
 	return 0;
 }




More information about the asterisk-commits mailing list