[asterisk-commits] trunk r21126 - /trunk/channels/chan_iax2.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Apr 18 07:23:16 MST 2006


Author: rizzo
Date: Tue Apr 18 09:23:14 2006
New Revision: 21126

URL: http://svn.digium.com/view/asterisk?rev=21126&view=rev
Log:
simplify logic in iax2_bridge()


Modified:
    trunk/channels/chan_iax2.c

Modified: trunk/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_iax2.c?rev=21126&r1=21125&r2=21126&view=diff
==============================================================================
--- trunk/channels/chan_iax2.c (original)
+++ trunk/channels/chan_iax2.c Tue Apr 18 09:23:14 2006
@@ -3337,7 +3337,7 @@
 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 @@
 			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];



More information about the asterisk-commits mailing list