[asterisk-commits] file: trunk r41303 - /trunk/main/rtp.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Aug 29 18:30:00 MST 2006


Author: file
Date: Tue Aug 29 20:29:59 2006
New Revision: 41303

URL: http://svn.digium.com/view/asterisk?rev=41303&view=rev
Log:
If the RTP stack is already being operated in callback mode, then suspend it upon switching to P2P callback bridging. Once P2P callback bridging has ended, then restore callback mode.

Modified:
    trunk/main/rtp.c

Modified: trunk/main/rtp.c
URL: http://svn.digium.com/view/asterisk/trunk/main/rtp.c?rev=41303&r1=41302&r2=41303&view=diff
==============================================================================
--- trunk/main/rtp.c (original)
+++ trunk/main/rtp.c Tue Aug 29 20:29:59 2006
@@ -173,6 +173,7 @@
 #define FLAG_HAS_DTMF			(1 << 3)
 #define FLAG_P2P_SENT_MARK              (1 << 4)
 #define FLAG_P2P_NEED_DTMF              (1 << 5)
+#define FLAG_CALLBACK_MODE              (1 << 6)
 
 /*!
  * \brief Structure defining an RTCP session.
@@ -1791,8 +1792,10 @@
 	}
 	rtp->sched = sched;
 	rtp->io = io;
-	if (callbackmode)
+	if (callbackmode) {
 		rtp->ioid = ast_io_add(rtp->io, rtp->s, rtpread, AST_IO_IN, rtp);
+		ast_set_flag(rtp, FLAG_CALLBACK_MODE);
+	}
 	ast_rtp_pt_default(rtp);
 	return rtp;
 }
@@ -2785,6 +2788,12 @@
 	if (ast_test_flag(rtp, FLAG_P2P_NEED_DTMF) || !rtp->io)
 		return 0;
 
+	/* If the RTP structure is already in callback mode, remove it temporarily */
+	if (rtp->ioid) {
+		ast_io_remove(rtp->io, rtp->ioid);
+		rtp->ioid = NULL;
+	}
+
 	/* Steal the file descriptors from the channel and stash them away */
 	fds[0] = chan->fds[0];
 	fds[1] = chan->fds[1];
@@ -2809,6 +2818,9 @@
 	chan->fds[0] = fds[0];
 	chan->fds[1] = fds[1];
 	ast_channel_unlock(chan);
+	/* Restore callback mode if previously used */
+	if (ast_test_flag(rtp, FLAG_CALLBACK_MODE))
+	    rtp->ioid = ast_io_add(rtp->io, rtp->s, rtpread, AST_IO_IN, rtp);
 	return 0;
 }
 



More information about the asterisk-commits mailing list