aboutsummaryrefslogtreecommitdiffstats
path: root/channels
diff options
context:
space:
mode:
authorrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2006-04-18 14:23:14 +0000
committerrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2006-04-18 14:23:14 +0000
commit232d4d60ba92218f2f73850f49c0a7e71542790f (patch)
tree3278b195e86dda14dff97a6e4f77b209b3f855b9 /channels
parent3f25044e557a1a1bf171a07d7bbe7ce45622dd0a (diff)
simplify logic in iax2_bridge()
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@21126 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_iax2.c54
1 files changed, 16 insertions, 38 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 7a5b38134..c3a6bb156 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -3337,7 +3337,7 @@ static void unlock_both(unsigned short callno0, unsigned short callno1)
static enum ast_bridge_result iax2_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc, int timeoutms)
{
struct ast_channel *cs[3];
- struct ast_channel *who;
+ struct ast_channel *who, *other;
int to = -1;
int res = -1;
int transferstarted=0;
@@ -3443,49 +3443,27 @@ static enum ast_bridge_result iax2_bridge(struct ast_channel *c0, struct ast_cha
res = AST_BRIDGE_COMPLETE;
break;
}
+ other = (who == c0) ? c1 : c0; /* the 'other' channel */
if ((f->frametype == AST_FRAME_VOICE) ||
(f->frametype == AST_FRAME_TEXT) ||
(f->frametype == AST_FRAME_VIDEO) ||
(f->frametype == AST_FRAME_IMAGE) ||
(f->frametype == AST_FRAME_DTMF)) {
- if ((f->frametype == AST_FRAME_DTMF) &&
- (flags & (AST_BRIDGE_DTMF_CHANNEL_0 | AST_BRIDGE_DTMF_CHANNEL_1))) {
- if ((who == c0)) {
- if ((flags & AST_BRIDGE_DTMF_CHANNEL_0)) {
- *rc = c0;
- *fo = f;
- res = AST_BRIDGE_COMPLETE;
- /* Remove from native mode */
- break;
- } else
- goto tackygoto;
- } else
- if ((who == c1)) {
- if (flags & AST_BRIDGE_DTMF_CHANNEL_1) {
- *rc = c1;
- *fo = f;
- res = AST_BRIDGE_COMPLETE;
- break;
- } else
- goto tackygoto;
- }
- } else {
-#if 0
- if (iaxdebug && option_debug)
- ast_log(LOG_DEBUG, "Read from %s\n", who->name);
- if (who == last)
- ast_log(LOG_DEBUG, "Servicing channel %s twice in a row?\n", last->name);
- last = who;
-#endif
-tackygoto:
- if (who == c0)
- ast_write(c1, f);
- else
- ast_write(c0, f);
+ /* monitored dtmf take out of the bridge.
+ * check if we monitor the specific source.
+ */
+ int monitored_source = (who == c0) ? AST_BRIDGE_DTMF_CHANNEL_0 : AST_BRIDGE_DTMF_CHANNEL_1;
+ if (f->frametype == AST_FRAME_DTMF && (flags & monitored_source)) {
+ *rc = who;
+ *fo = f;
+ res = AST_BRIDGE_COMPLETE;
+ /* Remove from native mode */
+ break;
}
- ast_frfree(f);
- } else
- ast_frfree(f);
+ /* everything else goes to the other side */
+ ast_write(other, f);
+ }
+ ast_frfree(f);
/* Swap who gets priority */
cs[2] = cs[0];
cs[0] = cs[1];