[asterisk-commits] rmudgett: branch group/bridge_construction r389369 - in /team/group/bridge_co...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue May 21 11:40:34 CDT 2013


Author: rmudgett
Date: Tue May 21 11:40:24 2013
New Revision: 389369

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=389369
Log:
Eliminate most calls to ast_channel_internal_bridged_channel().

Review: https://reviewboard.asterisk.org/r/2558/

Modified:
    team/group/bridge_construction/CHANGES
    team/group/bridge_construction/apps/app_dumpchan.c
    team/group/bridge_construction/channels/chan_unistim.c
    team/group/bridge_construction/channels/chan_vpb.cc
    team/group/bridge_construction/include/asterisk/channel.h
    team/group/bridge_construction/main/channel.c
    team/group/bridge_construction/main/cli.c
    team/group/bridge_construction/main/features.c
    team/group/bridge_construction/main/manager.c

Modified: team/group/bridge_construction/CHANGES
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/CHANGES?view=diff&rev=389369&r1=389368&r2=389369
==============================================================================
--- team/group/bridge_construction/CHANGES (original)
+++ team/group/bridge_construction/CHANGES Tue May 21 11:40:24 2013
@@ -71,6 +71,10 @@
    ChanVariable: bar=baz. When multiple channels are present in a single AMI
    event, the various ChanVariable fields will contain a suffix that specifies
    which channel they correspond to.
+
+ * The AMI 'Status' response event to the AMI Status action replaces the
+   BridgedChannel and BridgedUniqueid headers with the BridgeID header to
+   indicate what bridge the channel is currently in.
 
 Channel Drivers
 ------------------

Modified: team/group/bridge_construction/apps/app_dumpchan.c
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/apps/app_dumpchan.c?view=diff&rev=389369&r1=389368&r2=389369
==============================================================================
--- team/group/bridge_construction/apps/app_dumpchan.c (original)
+++ team/group/bridge_construction/apps/app_dumpchan.c Tue May 21 11:40:24 2013
@@ -41,6 +41,7 @@
 #include "asterisk/channel.h"
 #include "asterisk/app.h"
 #include "asterisk/translate.h"
+#include "asterisk/bridging.h"
 
 /*** DOCUMENTATION
 	<application name="DumpChan" language="en_US">
@@ -77,6 +78,7 @@
 	char pgrp[256];
 	struct ast_str *write_transpath = ast_str_alloca(256);
 	struct ast_str *read_transpath = ast_str_alloca(256);
+	struct ast_bridge *bridge;
 
 	now = ast_tvnow();
 	memset(buf, 0, size);
@@ -90,6 +92,9 @@
 		sec = elapsed_seconds % 60;
 	}
 
+	ast_channel_lock(c);
+	bridge = ast_channel_get_bridge(c);
+	ast_channel_unlock(c);
 	snprintf(buf,size,
 		"Name=               %s\n"
 		"Type=               %s\n"
@@ -117,8 +122,7 @@
 		"Framesout=          %d %s\n"
 		"TimetoHangup=       %ld\n"
 		"ElapsedTime=        %dh%dm%ds\n"
-		"DirectBridge=       %s\n"
-		"IndirectBridge=     %s\n"
+		"BridgeID=           %s\n"
 		"Context=            %s\n"
 		"Extension=          %s\n"
 		"Priority=           %d\n"
@@ -158,8 +162,7 @@
 		hour,
 		min,
 		sec,
-		ast_channel_internal_bridged_channel(c) ? ast_channel_name(ast_channel_internal_bridged_channel(c)) : "<none>",
-		ast_bridged_channel(c) ? ast_channel_name(ast_bridged_channel(c)) : "<none>", 
+		bridge ? bridge->uniqueid : "(Not bridged)",
 		ast_channel_context(c),
 		ast_channel_exten(c),
 		ast_channel_priority(c),
@@ -169,6 +172,7 @@
 		ast_channel_data(c) ? S_OR(ast_channel_data(c), "(Empty)") : "(None)",
 		(ast_test_flag(ast_channel_flags(c), AST_FLAG_BLOCKING) ? ast_channel_blockproc(c) : "(Not Blocking)"));
 
+	ao2_cleanup(bridge);
 	return 0;
 }
 

Modified: team/group/bridge_construction/channels/chan_unistim.c
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/channels/chan_unistim.c?view=diff&rev=389369&r1=389368&r2=389369
==============================================================================
--- team/group/bridge_construction/channels/chan_unistim.c (original)
+++ team/group/bridge_construction/channels/chan_unistim.c Tue May 21 11:40:24 2013
@@ -5825,7 +5825,6 @@
 	struct unistim_line *line;
 	struct unistim_subchannel *sub;
 	struct unistimsession *s;
-	struct ast_channel *tmp;
 
 	switch (cmd) {
 	case CLI_INIT:
@@ -5869,14 +5868,9 @@
 			if (!sub) {
 				continue;
 			}
-			if (!sub->owner) {
-				tmp = (void *) -42;
-			} else {
-				tmp = ast_channel_internal_bridged_channel(sub->owner);
-			}
 			ast_cli(a->fd,
-					"-->subtype=%s chan=%p rtp=%p bridge=%p line=%p alreadygone=%d softkey=%d\n",
-					subtype_tostr(sub->subtype), sub->owner, sub->rtp, tmp, sub->parent,
+					"-->subtype=%s chan=%p rtp=%p line=%p alreadygone=%d softkey=%d\n",
+					subtype_tostr(sub->subtype), sub->owner, sub->rtp, sub->parent,
 					sub->alreadygone, sub->softkey);
 		}
 		AST_LIST_UNLOCK(&device->subs);

Modified: team/group/bridge_construction/channels/chan_vpb.cc
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/channels/chan_vpb.cc?view=diff&rev=389369&r1=389368&r2=389369
==============================================================================
--- team/group/bridge_construction/channels/chan_vpb.cc (original)
+++ team/group/bridge_construction/channels/chan_vpb.cc Tue May 21 11:40:24 2013
@@ -2267,13 +2267,7 @@
 			else 
 				bridgerec = 0;
 		} else {
-			ast_verb(5, "%s: chanreads: No native bridge.\n", p->dev);
-			if (ast_channel_internal_bridged_channel(p->owner)) {
-				ast_verb(5, "%s: chanreads: Got Asterisk bridge with [%s].\n", p->dev, ast_channel_name(ast_channel_internal_bridged_channel(p->owner)));
-				bridgerec = 1;
-			} else {
-				bridgerec = 0;
-			}
+			bridgerec = ast_channel_is_bridged(p->owner) ? 1 : 0;
 		}
 
 /*		if ((p->owner->_state != AST_STATE_UP) || !bridgerec) */

Modified: team/group/bridge_construction/include/asterisk/channel.h
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/include/asterisk/channel.h?view=diff&rev=389369&r1=389368&r2=389369
==============================================================================
--- team/group/bridge_construction/include/asterisk/channel.h (original)
+++ team/group/bridge_construction/include/asterisk/channel.h Tue May 21 11:40:24 2013
@@ -643,6 +643,7 @@
 	/*! \brief Handle an exception, reading a frame */
 	struct ast_frame * (* const exception)(struct ast_channel *chan);
 
+/* BUGBUG this tech callback is to be removed. */
 	/*! \brief Bridge two channels of the same type together */
 	enum ast_bridge_result (* const bridge)(struct ast_channel *c0, struct ast_channel *c1, int flags,
 						struct ast_frame **fo, struct ast_channel **rc, int timeoutms);
@@ -671,6 +672,7 @@
 	/*! \brief Write a text frame, in standard format */
 	int (* const write_text)(struct ast_channel *chan, struct ast_frame *frame);
 
+/* BUGBUG this tech callback is to be removed. */
 	/*! \brief Find bridged channel */
 	struct ast_channel *(* const bridged_channel)(struct ast_channel *chan, struct ast_channel *bridge);
 
@@ -686,6 +688,7 @@
 	 */
 	int (* func_channel_write)(struct ast_channel *chan, const char *function, char *data, const char *value);
 
+/* BUGBUG this tech callback is to be removed. */
 	/*! \brief Retrieve base channel (agent and local) */
 	struct ast_channel* (* get_base_channel)(struct ast_channel *chan);
 

Modified: team/group/bridge_construction/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/main/channel.c?view=diff&rev=389369&r1=389368&r2=389369
==============================================================================
--- team/group/bridge_construction/main/channel.c (original)
+++ team/group/bridge_construction/main/channel.c Tue May 21 11:40:24 2013
@@ -6240,87 +6240,21 @@
 static int __ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clonechan, struct ast_datastore *xfer_ds)
 {
 	int res = -1;
-	struct ast_channel *final_orig, *final_clone, *base;
-
-	for (;;) {
-		final_orig = original;
-		final_clone = clonechan;
-
-		ast_channel_lock_both(original, clonechan);
-
-		if (ast_test_flag(ast_channel_flags(original), AST_FLAG_ZOMBIE)
-			|| ast_test_flag(ast_channel_flags(clonechan), AST_FLAG_ZOMBIE)) {
-			/* Zombies! Run! */
-			ast_log(LOG_WARNING,
-				"Can't setup masquerade. One or both channels is dead. (%s <-- %s)\n",
-				ast_channel_name(original), ast_channel_name(clonechan));
-			ast_channel_unlock(clonechan);
-			ast_channel_unlock(original);
-			return -1;
-		}
-
-		/*
-		 * Each of these channels may be sitting behind a channel proxy
-		 * (i.e. chan_agent) and if so, we don't really want to
-		 * masquerade it, but its proxy
-		 */
-		if (ast_channel_internal_bridged_channel(original)
-			&& (ast_channel_internal_bridged_channel(original) != ast_bridged_channel(original))
-			&& (ast_channel_internal_bridged_channel(ast_channel_internal_bridged_channel(original)) != original)) {
-			final_orig = ast_channel_internal_bridged_channel(original);
-		}
-		if (ast_channel_internal_bridged_channel(clonechan)
-			&& (ast_channel_internal_bridged_channel(clonechan) != ast_bridged_channel(clonechan))
-			&& (ast_channel_internal_bridged_channel(ast_channel_internal_bridged_channel(clonechan)) != clonechan)) {
-			final_clone = ast_channel_internal_bridged_channel(clonechan);
-		}
-		if (ast_channel_tech(final_clone)->get_base_channel
-			&& (base = ast_channel_tech(final_clone)->get_base_channel(final_clone))) {
-			final_clone = base;
-		}
-
-		if ((final_orig != original) || (final_clone != clonechan)) {
-			/*
-			 * Lots and lots of deadlock avoidance.  The main one we're
-			 * competing with is ast_write(), which locks channels
-			 * recursively, when working with a proxy channel.
-			 */
-			if (ast_channel_trylock(final_orig)) {
-				ast_channel_unlock(clonechan);
-				ast_channel_unlock(original);
-
-				/* Try again */
-				continue;
-			}
-			if (ast_channel_trylock(final_clone)) {
-				ast_channel_unlock(final_orig);
-				ast_channel_unlock(clonechan);
-				ast_channel_unlock(original);
-
-				/* Try again */
-				continue;
-			}
-			ast_channel_unlock(clonechan);
-			ast_channel_unlock(original);
-			original = final_orig;
-			clonechan = final_clone;
-
-			if (ast_test_flag(ast_channel_flags(original), AST_FLAG_ZOMBIE)
-				|| ast_test_flag(ast_channel_flags(clonechan), AST_FLAG_ZOMBIE)) {
-				/* Zombies! Run! */
-				ast_log(LOG_WARNING,
-					"Can't setup masquerade. One or both channels is dead. (%s <-- %s)\n",
-					ast_channel_name(original), ast_channel_name(clonechan));
-				ast_channel_unlock(clonechan);
-				ast_channel_unlock(original);
-				return -1;
-			}
-		}
-		break;
-	}
 
 	if (original == clonechan) {
-		ast_log(LOG_WARNING, "Can't masquerade channel '%s' into itself!\n", ast_channel_name(original));
+		ast_log(LOG_WARNING, "Can't masquerade channel '%s' into itself!\n",
+			ast_channel_name(original));
+		return -1;
+	}
+
+	ast_channel_lock_both(original, clonechan);
+
+	if (ast_test_flag(ast_channel_flags(original), AST_FLAG_ZOMBIE)
+		|| ast_test_flag(ast_channel_flags(clonechan), AST_FLAG_ZOMBIE)) {
+		/* Zombies! Run! */
+		ast_log(LOG_WARNING,
+			"Can't setup masquerade. One or both channels is dead. (%s <-- %s)\n",
+			ast_channel_name(original), ast_channel_name(clonechan));
 		ast_channel_unlock(clonechan);
 		ast_channel_unlock(original);
 		return -1;
@@ -6641,15 +6575,33 @@
 	ast_cel_linkedid_ref(linkedid);
 }
 
-/*!
-  \brief Propagate the oldest linkedid between associated channels
-
-*/
+/*! \brief Propagate the oldest linkedid between associated channels */
 void ast_channel_set_linkgroup(struct ast_channel *chan, struct ast_channel *peer)
 {
 	const char* linkedid=NULL;
 	struct ast_channel *bridged;
 
+/*
+ * BUGBUG this needs to be updated to not use ast_channel_internal_bridged_channel().
+ * BUGBUG this needs to be updated to not use ast_bridged_channel().
+ *
+ * We may be better off making this a function of the bridging
+ * framework.  Essentially, as each channel joins a bridge, the
+ * oldest linkedid should be propagated between all pairs of
+ * channels.  This should be handled by bridging (unless you're
+ * in an infinite wait bridge...) just like the BRIDGEPEER
+ * channel variable.
+ *
+ * This is currently called in two places:
+ *
+ * (1) In channel masquerade. To some extent this shouldn't
+ * really be done any longer - we don't really want a channel to
+ * have its linkedid change, even if it replaces a channel that
+ * had an older linkedid.  The two channels aren't really
+ * 'related', they're simply swapping with each other.
+ *
+ * (2) In features.c as two channels are bridged.
+ */
 	linkedid = oldest_linkedid(ast_channel_linkedid(chan), ast_channel_linkedid(peer));
 	linkedid = oldest_linkedid(linkedid, ast_channel_uniqueid(chan));
 	linkedid = oldest_linkedid(linkedid, ast_channel_uniqueid(peer));
@@ -7149,11 +7101,6 @@
 
 	/* copy over accuntcode and set peeraccount across the bridge */
 	ast_channel_accountcode_set(original, S_OR(ast_channel_accountcode(clonechan), ""));
-	if (ast_channel_internal_bridged_channel(original)) {
-		/* XXX - should we try to lock original's bridged channel here? */
-		ast_channel_peeraccount_set(ast_channel_internal_bridged_channel(original), S_OR(ast_channel_accountcode(clonechan), ""));
-		ast_cel_report_event(original, AST_CEL_BRIDGE_UPDATE, NULL, NULL, NULL);
-	}
 
 	ast_debug(1, "Putting channel %s in %s/%s formats\n", ast_channel_name(original),
 		ast_getformatname(&wformat), ast_getformatname(&rformat));
@@ -7353,14 +7300,10 @@
 	return 0;
 }
 
-/*! \brief Find bridged channel */
+/*! BUGBUG ast_bridged_channel() is to be removed. */
 struct ast_channel *ast_bridged_channel(struct ast_channel *chan)
 {
-	struct ast_channel *bridged;
-	bridged = ast_channel_internal_bridged_channel(chan);
-	if (bridged && ast_channel_tech(bridged)->bridged_channel)
-		bridged = ast_channel_tech(bridged)->bridged_channel(chan, bridged);
-	return bridged;
+	return NULL;
 }
 
 static void bridge_playfile(struct ast_channel *chan, struct ast_channel *peer, const char *sound, int remain)

Modified: team/group/bridge_construction/main/cli.c
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/main/cli.c?view=diff&rev=389369&r1=389368&r2=389369
==============================================================================
--- team/group/bridge_construction/main/cli.c (original)
+++ team/group/bridge_construction/main/cli.c Tue May 21 11:40:24 2013
@@ -60,6 +60,7 @@
 #include "asterisk/lock.h"
 #include "asterisk/threadstorage.h"
 #include "asterisk/translate.h"
+#include "asterisk/bridging.h"
 
 /*!
  * \brief List of restrictions per user.
@@ -899,7 +900,7 @@
 			ast_cli(a->fd, FORMAT_STRING2, "Channel", "Location", "State", "Application(Data)");
 		else if (verbose)
 			ast_cli(a->fd, VERBOSE_FORMAT_STRING2, "Channel", "Context", "Extension", "Priority", "State", "Application", "Data",
-				"CallerID", "Duration", "Accountcode", "PeerAccount", "BridgedTo");
+				"CallerID", "Duration", "Accountcode", "PeerAccount", "BridgeID");
 	}
 
 	if (!count && !(iter = ast_channel_iterator_all_new())) {
@@ -907,12 +908,12 @@
 	}
 
 	for (; iter && (c = ast_channel_iterator_next(iter)); ast_channel_unref(c)) {
-		struct ast_channel *bc;
+		struct ast_bridge *bridge;
 		char durbuf[10] = "-";
 
 		ast_channel_lock(c);
 
-		bc = ast_bridged_channel(c);
+		bridge = ast_channel_get_bridge(c);
 
 		if (!count) {
 			if ((concise || verbose)  && ast_channel_cdr(c) && !ast_tvzero(ast_channel_cdr(c)->start)) {
@@ -935,7 +936,7 @@
 					S_OR(ast_channel_peeraccount(c), ""),
 					ast_channel_amaflags(c),
 					durbuf,
-					bc ? ast_channel_name(bc) : "(None)",
+					bridge ? bridge->uniqueid : "(Not bridged)",
 					ast_channel_uniqueid(c));
 			} else if (verbose) {
 				ast_cli(a->fd, VERBOSE_FORMAT_STRING, ast_channel_name(c), ast_channel_context(c), ast_channel_exten(c), ast_channel_priority(c), ast_state2str(ast_channel_state(c)),
@@ -945,7 +946,7 @@
 					durbuf,
 					S_OR(ast_channel_accountcode(c), ""),
 					S_OR(ast_channel_peeraccount(c), ""),
-					bc ? ast_channel_name(bc) : "(None)");
+					bridge ? bridge->uniqueid : "(Not bridged)");
 			} else {
 				char locbuf[40] = "(None)";
 				char appdata[40] = "(None)";
@@ -958,6 +959,7 @@
 			}
 		}
 		ast_channel_unlock(c);
+		ao2_cleanup(bridge);
 	}
 
 	if (iter) {
@@ -1412,6 +1414,7 @@
 #ifdef CHANNEL_TRACE
 	int trace_enabled;
 #endif
+	struct ast_bridge *bridge;
 
 	switch (cmd) {
 	case CLI_INIT:
@@ -1463,6 +1466,7 @@
 	}
 
 	effective_connected_id = ast_channel_connected_effective_id(c);
+	bridge = ast_channel_get_bridge(c);
 
 	ast_str_append(&output, 0,
 		" -- General --\n"
@@ -1490,8 +1494,7 @@
 		"     Frames out: %d%s\n"
 		" Time to Hangup: %ld\n"
 		"   Elapsed Time: %s\n"
-		"  Direct Bridge: %s\n"
-		"Indirect Bridge: %s\n"
+		"      Bridge ID: %s\n"
 		" --   PBX   --\n"
 		"        Context: %s\n"
 		"      Extension: %s\n"
@@ -1502,7 +1505,10 @@
 		"           Data: %s\n"
 		"    Blocking in: %s\n"
 		" Call Identifer: %s\n",
-		ast_channel_name(c), ast_channel_tech(c)->type, ast_channel_uniqueid(c), ast_channel_linkedid(c),
+		ast_channel_name(c),
+		ast_channel_tech(c)->type,
+		ast_channel_uniqueid(c),
+		ast_channel_linkedid(c),
 		S_COR(ast_channel_caller(c)->id.number.valid, ast_channel_caller(c)->id.number.str, "(N/A)"),
 		S_COR(ast_channel_caller(c)->id.name.valid, ast_channel_caller(c)->id.name.str, "(N/A)"),
 		S_COR(ast_channel_connected(c)->id.number.valid, ast_channel_connected(c)->id.number.str, "(N/A)"),
@@ -1511,7 +1517,9 @@
 		S_COR(effective_connected_id.name.valid, effective_connected_id.name.str, "(N/A)"),
 		S_OR(ast_channel_dialed(c)->number.str, "(N/A)"),
 		ast_channel_language(c),
-		ast_state2str(ast_channel_state(c)), ast_channel_state(c), ast_channel_rings(c),
+		ast_state2str(ast_channel_state(c)),
+		ast_channel_state(c),
+		ast_channel_rings(c),
 		ast_getformatname_multiple(nf, sizeof(nf), ast_channel_nativeformats(c)),
 		ast_getformatname(ast_channel_writeformat(c)),
 		ast_getformatname(ast_channel_readformat(c)),
@@ -1520,11 +1528,19 @@
 		ast_channel_readtrans(c) ? "Yes" : "No",
 		ast_translate_path_to_str(ast_channel_readtrans(c), &read_transpath),
 		ast_channel_fd(c, 0),
-		ast_channel_fin(c) & ~DEBUGCHAN_FLAG, (ast_channel_fin(c) & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "",
-		ast_channel_fout(c) & ~DEBUGCHAN_FLAG, (ast_channel_fout(c) & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "",
-		(long)ast_channel_whentohangup(c)->tv_sec,
-		cdrtime, ast_channel_internal_bridged_channel(c) ? ast_channel_name(ast_channel_internal_bridged_channel(c)) : "<none>", ast_bridged_channel(c) ? ast_channel_name(ast_bridged_channel(c)) : "<none>",
-		ast_channel_context(c), ast_channel_exten(c), ast_channel_priority(c), ast_channel_callgroup(c), ast_channel_pickupgroup(c), (ast_channel_appl(c) ? ast_channel_appl(c) : "(N/A)" ),
+		ast_channel_fin(c) & ~DEBUGCHAN_FLAG,
+		(ast_channel_fin(c) & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "",
+		ast_channel_fout(c) & ~DEBUGCHAN_FLAG,
+		(ast_channel_fout(c) & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "",
+		(long) ast_channel_whentohangup(c)->tv_sec,
+		cdrtime,
+		bridge ? bridge->uniqueid : "(Not bridged)",
+		ast_channel_context(c),
+		ast_channel_exten(c),
+		ast_channel_priority(c),
+		ast_channel_callgroup(c),
+		ast_channel_pickupgroup(c),
+		(ast_channel_appl(c) ? ast_channel_appl(c) : "(N/A)" ),
 		(ast_channel_data(c) ? S_OR(ast_channel_data(c), "(Empty)") : "(None)"),
 		(ast_test_flag(ast_channel_flags(c), AST_FLAG_BLOCKING) ? ast_channel_blockproc(c) : "(Not Blocking)"),
 		S_OR(call_identifier_str, "(None)"));
@@ -1548,6 +1564,7 @@
 
 	ast_channel_unlock(c);
 	c = ast_channel_unref(c);
+	ao2_cleanup(bridge);
 
 	ast_cli(a->fd, "%s", ast_str_buffer(output));
 	ast_free(output);

Modified: team/group/bridge_construction/main/features.c
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/main/features.c?view=diff&rev=389369&r1=389368&r2=389369
==============================================================================
--- team/group/bridge_construction/main/features.c (original)
+++ team/group/bridge_construction/main/features.c Tue May 21 11:40:24 2013
@@ -4033,18 +4033,17 @@
 {
 	ast_log(LOG_NOTICE, "______ %s (%lx)______\n", title, (unsigned long) chan);
 	ast_log(LOG_NOTICE, "CHAN: name: %s;  appl: %s; data: %s; contxt: %s;  exten: %s; pri: %d;\n",
-		ast_channel_name(chan), ast_channel_appl(chan), ast_channel_data(chan), ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan));
+		ast_channel_name(chan), ast_channel_appl(chan), ast_channel_data(chan),
+		ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan));
 	ast_log(LOG_NOTICE, "CHAN: acctcode: %s;  dialcontext: %s; amaflags: %x; maccontxt: %s;  macexten: %s; macpri: %d;\n",
-		ast_channel_accountcode(chan), ast_channel_dialcontext(chan), ast_channel_amaflags(chan), ast_channel_macrocontext(chan), ast_channel_macroexten(chan), ast_channel_macropriority(chan));
-	ast_log(LOG_NOTICE, "CHAN: masq: %p;  masqr: %p; _bridge: %p; uniqueID: %s; linkedID:%s\n",
+		ast_channel_accountcode(chan), ast_channel_dialcontext(chan), ast_channel_amaflags(chan),
+		ast_channel_macrocontext(chan), ast_channel_macroexten(chan), ast_channel_macropriority(chan));
+	ast_log(LOG_NOTICE, "CHAN: masq: %p;  masqr: %p; uniqueID: %s; linkedID:%s\n",
 		ast_channel_masq(chan), ast_channel_masqr(chan),
-		ast_channel_internal_bridged_channel(chan), ast_channel_uniqueid(chan), ast_channel_linkedid(chan));
+		ast_channel_uniqueid(chan), ast_channel_linkedid(chan));
 	if (ast_channel_masqr(chan)) {
 		ast_log(LOG_NOTICE, "CHAN: masquerading as: %s;  cdr: %p;\n",
 			ast_channel_name(ast_channel_masqr(chan)), ast_channel_cdr(ast_channel_masqr(chan)));
-	}
-	if (ast_channel_internal_bridged_channel(chan)) {
-		ast_log(LOG_NOTICE, "CHAN: Bridged to %s\n", ast_channel_name(ast_channel_internal_bridged_channel(chan)));
 	}
 
 	ast_log(LOG_NOTICE, "===== done ====\n");

Modified: team/group/bridge_construction/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/main/manager.c?view=diff&rev=389369&r1=389368&r2=389369
==============================================================================
--- team/group/bridge_construction/main/manager.c (original)
+++ team/group/bridge_construction/main/manager.c Tue May 21 11:40:24 2013
@@ -3558,7 +3558,8 @@
 	const char *cvariables = astman_get_header(m, "Variables");
 	char *variables = ast_strdupa(S_OR(cvariables, ""));
 	struct ast_channel *c;
-	char bridge[256];
+	struct ast_bridge *bridge;
+	char bridge_text[256];
 	struct timeval now = ast_tvnow();
 	long elapsed_seconds = 0;
 	int channels = 0;
@@ -3627,44 +3628,52 @@
 		}
 
 		channels++;
-		if (ast_channel_internal_bridged_channel(c)) {
-			snprintf(bridge, sizeof(bridge), "BridgedChannel: %s\r\nBridgedUniqueid: %s\r\n", ast_channel_name(ast_channel_internal_bridged_channel(c)), ast_channel_uniqueid(ast_channel_internal_bridged_channel(c)));
+		bridge = ast_channel_get_bridge(c);
+		if (bridge) {
+			snprintf(bridge_text, sizeof(bridge_text), "BridgeID: %s\r\n",
+				bridge->uniqueid);
+			ao2_ref(bridge, -1);
 		} else {
-			bridge[0] = '\0';
+			bridge_text[0] = '\0';
 		}
 		if (ast_channel_pbx(c)) {
 			if (ast_channel_cdr(c)) {
 				elapsed_seconds = now.tv_sec - ast_channel_cdr(c)->start.tv_sec;
 			}
 			astman_append(s,
-			"Event: Status\r\n"
-			"Privilege: Call\r\n"
-			"Channel: %s\r\n"
-			"CallerIDNum: %s\r\n"
-			"CallerIDName: %s\r\n"
-			"ConnectedLineNum: %s\r\n"
-			"ConnectedLineName: %s\r\n"
-			"Accountcode: %s\r\n"
-			"ChannelState: %d\r\n"
-			"ChannelStateDesc: %s\r\n"
-			"Context: %s\r\n"
-			"Extension: %s\r\n"
-			"Priority: %d\r\n"
-			"Seconds: %ld\r\n"
-			"%s"
-			"Uniqueid: %s\r\n"
-			"%s"
-			"%s"
-			"\r\n",
-			ast_channel_name(c),
-			S_COR(ast_channel_caller(c)->id.number.valid, ast_channel_caller(c)->id.number.str, "<unknown>"),
-			S_COR(ast_channel_caller(c)->id.name.valid, ast_channel_caller(c)->id.name.str, "<unknown>"),
-			S_COR(ast_channel_connected(c)->id.number.valid, ast_channel_connected(c)->id.number.str, "<unknown>"),
-			S_COR(ast_channel_connected(c)->id.name.valid, ast_channel_connected(c)->id.name.str, "<unknown>"),
-			ast_channel_accountcode(c),
-			ast_channel_state(c),
-			ast_state2str(ast_channel_state(c)), ast_channel_context(c),
-			ast_channel_exten(c), ast_channel_priority(c), (long)elapsed_seconds, bridge, ast_channel_uniqueid(c), ast_str_buffer(str), idText);
+				"Event: Status\r\n"
+				"Privilege: Call\r\n"
+				"Channel: %s\r\n"
+				"CallerIDNum: %s\r\n"
+				"CallerIDName: %s\r\n"
+				"ConnectedLineNum: %s\r\n"
+				"ConnectedLineName: %s\r\n"
+				"Accountcode: %s\r\n"
+				"ChannelState: %d\r\n"
+				"ChannelStateDesc: %s\r\n"
+				"Context: %s\r\n"
+				"Extension: %s\r\n"
+				"Priority: %d\r\n"
+				"Seconds: %ld\r\n"
+				"%s"
+				"Uniqueid: %s\r\n"
+				"%s"
+				"%s"
+				"\r\n",
+				ast_channel_name(c),
+				S_COR(ast_channel_caller(c)->id.number.valid, ast_channel_caller(c)->id.number.str, "<unknown>"),
+				S_COR(ast_channel_caller(c)->id.name.valid, ast_channel_caller(c)->id.name.str, "<unknown>"),
+				S_COR(ast_channel_connected(c)->id.number.valid, ast_channel_connected(c)->id.number.str, "<unknown>"),
+				S_COR(ast_channel_connected(c)->id.name.valid, ast_channel_connected(c)->id.name.str, "<unknown>"),
+				ast_channel_accountcode(c),
+				ast_channel_state(c),
+				ast_state2str(ast_channel_state(c)),
+				ast_channel_context(c), ast_channel_exten(c), ast_channel_priority(c),
+				(long) elapsed_seconds,
+				bridge_text,
+				ast_channel_uniqueid(c),
+				ast_str_buffer(str),
+				idText);
 		} else {
 			astman_append(s,
 				"Event: Status\r\n"
@@ -3687,8 +3696,11 @@
 				S_COR(ast_channel_connected(c)->id.number.valid, ast_channel_connected(c)->id.number.str, "<unknown>"),
 				S_COR(ast_channel_connected(c)->id.name.valid, ast_channel_connected(c)->id.name.str, "<unknown>"),
 				ast_channel_accountcode(c),
-				ast_state2str(ast_channel_state(c)), bridge, ast_channel_uniqueid(c),
-				ast_str_buffer(str), idText);
+				ast_state2str(ast_channel_state(c)),
+				bridge_text,
+				ast_channel_uniqueid(c),
+				ast_str_buffer(str),
+				idText);
 		}
 
 		ast_channel_unlock(c);
@@ -5738,7 +5750,7 @@
 		return -1;
 	}
 
-	cat_str = authority_to_str (category, &auth);
+	cat_str = authority_to_str(category, &auth);
 	ast_str_set(&buf, 0,
 			"Event: %s\r\nPrivilege: %s\r\n",
 			 event, cat_str);
@@ -8126,4 +8138,3 @@
 	ao2_ref(ev, +1);
 	return ev;
 }
-




More information about the asterisk-commits mailing list