summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2006-08-30 01:29:59 +0000
committerJoshua Colp <jcolp@digium.com>2006-08-30 01:29:59 +0000
commitda7d969ae10e89c3fb2719dbac5099e5d09c56ef (patch)
tree0030cbea1fea99d6cdf9e1ae18a88bab8fd2d583 /main
parentca33d2ecc64c9bc5e2a2a9da7dd0255801fb9f34 (diff)
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.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@41303 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main')
-rw-r--r--main/rtp.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/main/rtp.c b/main/rtp.c
index 55533157f..ce81738a0 100644
--- a/main/rtp.c
+++ b/main/rtp.c
@@ -173,6 +173,7 @@ static int bridge_p2p_rtcp_write(struct ast_rtp *rtp, unsigned int *rtcpheader,
#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 @@ struct ast_rtp *ast_rtp_new_with_bindaddr(struct sched_context *sched, struct io
}
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 @@ static int p2p_callback_enable(struct ast_channel *chan, struct ast_rtp *rtp, in
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 @@ static int p2p_callback_disable(struct ast_channel *chan, struct ast_rtp *rtp, i
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;
}