[asterisk-commits] file: branch 1.4 r48964 - in /branches/1.4: channels/ include/asterisk/ main/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon Dec 25 21:31:59 MST 2006


Author: file
Date: Mon Dec 25 22:31:58 2006
New Revision: 48964

URL: http://svn.digium.com/view/asterisk?view=rev&rev=48964
Log:
Add an API call that initializes an RTP structure. We need this because chan_sip is cheeky and uses a temporary RTP structure for codec purposes, and the API calls that are used rely on the lock. (Pointed out on asterisk-dev by Andy Wang)

Modified:
    branches/1.4/channels/chan_sip.c
    branches/1.4/include/asterisk/rtp.h
    branches/1.4/main/rtp.c

Modified: branches/1.4/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/chan_sip.c?view=diff&rev=48964&r1=48963&r2=48964
==============================================================================
--- branches/1.4/channels/chan_sip.c (original)
+++ branches/1.4/channels/chan_sip.c Mon Dec 25 22:31:58 2006
@@ -4696,10 +4696,12 @@
 	/* Initialize the temporary RTP structures we use to evaluate the offer from the peer */
 	newaudiortp = alloca(ast_rtp_alloc_size());
 	memset(newaudiortp, 0, ast_rtp_alloc_size());
+	ast_rtp_new_init(newaudiortp);
 	ast_rtp_pt_clear(newaudiortp);
 
 	newvideortp = alloca(ast_rtp_alloc_size());
 	memset(newvideortp, 0, ast_rtp_alloc_size());
+	ast_rtp_new_init(newvideortp);
 	ast_rtp_pt_clear(newvideortp);
 
 	/* Update our last rtprx when we receive an SDP, too */

Modified: branches/1.4/include/asterisk/rtp.h
URL: http://svn.digium.com/view/asterisk/branches/1.4/include/asterisk/rtp.h?view=diff&rev=48964&r1=48963&r2=48964
==============================================================================
--- branches/1.4/include/asterisk/rtp.h (original)
+++ branches/1.4/include/asterisk/rtp.h Mon Dec 25 22:31:58 2006
@@ -208,6 +208,8 @@
 
 /*! \brief Send an H.261 fast update request. Some devices need this rather than the XML message  in SIP */
 int ast_rtcp_send_h261fur(void *data);
+
+void ast_rtp_new_init(struct ast_rtp *rtp);
 
 void ast_rtp_init(void);
 

Modified: branches/1.4/main/rtp.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/rtp.c?view=diff&rev=48964&r1=48963&r2=48964
==============================================================================
--- branches/1.4/main/rtp.c (original)
+++ branches/1.4/main/rtp.c Mon Dec 25 22:31:58 2006
@@ -1798,6 +1798,23 @@
 	return rtcp;
 }
 
+/*!
+ * \brief Initialize a new RTP structure.
+ *
+ */
+void ast_rtp_new_init(struct ast_rtp *rtp)
+{
+	ast_mutex_init(&rtp->bridge_lock);
+
+	rtp->them.sin_family = AF_INET;
+	rtp->us.sin_family = AF_INET;
+	rtp->ssrc = ast_random();
+	rtp->seqno = ast_random() & 0xffff;
+	ast_set_flag(rtp, FLAG_HAS_DTMF);
+
+	return;
+}
+
 struct ast_rtp *ast_rtp_new_with_bindaddr(struct sched_context *sched, struct io_context *io, int rtcpenable, int callbackmode, struct in_addr addr)
 {
 	struct ast_rtp *rtp;
@@ -1808,14 +1825,9 @@
 	if (!(rtp = ast_calloc(1, sizeof(*rtp))))
 		return NULL;
 
-	ast_mutex_init(&rtp->bridge_lock);
-
-	rtp->them.sin_family = AF_INET;
-	rtp->us.sin_family = AF_INET;
+	ast_rtp_new_init(rtp);
+
 	rtp->s = rtp_socket();
-	rtp->ssrc = ast_random();
-	rtp->seqno = ast_random() & 0xffff;
-	ast_set_flag(rtp, FLAG_HAS_DTMF);
 	if (rtp->s < 0) {
 		free(rtp);
 		ast_log(LOG_ERROR, "Unable to allocate socket: %s\n", strerror(errno));



More information about the asterisk-commits mailing list