[svn-commits] jrose: branch group/bridge_construction r382553 - in /team/group/bridge_const...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Mar 6 17:44:21 CST 2013


Author: jrose
Date: Wed Mar  6 17:44:16 2013
New Revision: 382553

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=382553
Log:
merge revisions 382551-382552 from team/jrose/bridge_projects
Bridging Roles and holding bridge/app_bridgewait usage of bridging roles

(issue ASTERISK-20905)
Review: https://reviewboard.asterisk.org/r/2360/

Added:
    team/group/bridge_construction/apps/app_bridgewait.c
      - copied unchanged from r382551, team/jrose/bridge_projects/apps/app_bridgewait.c
    team/group/bridge_construction/bridges/bridge_holding.c
      - copied unchanged from r382551, team/jrose/bridge_projects/bridges/bridge_holding.c
    team/group/bridge_construction/include/asterisk/bridging_roles.h
      - copied unchanged from r382551, team/jrose/bridge_projects/include/asterisk/bridging_roles.h
    team/group/bridge_construction/main/bridging_roles.c
      - copied unchanged from r382551, team/jrose/bridge_projects/main/bridging_roles.c
Modified:
    team/group/bridge_construction/include/asterisk/bridging.h
    team/group/bridge_construction/main/bridging.c

Modified: team/group/bridge_construction/include/asterisk/bridging.h
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/include/asterisk/bridging.h?view=diff&rev=382553&r1=382552&r2=382553
==============================================================================
--- team/group/bridge_construction/include/asterisk/bridging.h (original)
+++ team/group/bridge_construction/include/asterisk/bridging.h Wed Mar  6 17:44:16 2013
@@ -63,10 +63,13 @@
 #endif
 
 #include "asterisk/bridging_features.h"
+#include "asterisk/bridging_roles.h"
 #include "asterisk/dsp.h"
 
 /*! \brief Capabilities for a bridge technology */
 enum ast_bridge_capability {
+	/*! Bridge technology can service calls on hold */
+	AST_BRIDGE_CAPABILITY_HOLDING = (1 << 0),
 	/*! Bridge should natively bridge two channels if possible */
 	AST_BRIDGE_CAPABILITY_NATIVE = (1 << 1),
 	/*! Bridge is only capable of mixing 2 channels */
@@ -157,8 +160,14 @@
 	/*! Technology optimization parameters used by bridging technologies capable of
 	 *  optimizing based upon talk detection. */
 	struct ast_bridge_tech_optimizations tech_args;
+	/*! Copy of read format used by chan before join */
+	struct ast_format read_format;
+	/*! Copy of write format used by chan before join */
+	struct ast_format write_format;
 	/*! Call ID associated with bridge channel */
 	struct ast_callid *callid;
+	/*! A clone of the roles living on chan when the bridge channel joins the bridge. This may require some opacification */
+	struct bridge_roles_datastore *bridge_roles;
 	/*! Linked list information */
 	AST_LIST_ENTRY(ast_bridge_channel) entry;
 	/*! Queue of actions to perform on the channel. */
@@ -634,6 +643,14 @@
 int ast_bridge_channel_queue_action(struct ast_bridge_channel *bridge_channel, struct ast_frame *action);
 
 /*!
+ * \brief Restore the formats of a bridge channel's channel to how they were before bridge_channel_join
+ * \since 12.0.0
+ *
+ * \param bridge_channel Channel to restore
+ */
+void ast_bridge_channel_restore_formats(struct ast_bridge_channel *bridge_channel);
+
+/*!
  * \brief Adjust the internal mixing sample rate of a bridge
  * used during multimix mode.
  *

Modified: team/group/bridge_construction/main/bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/main/bridging.c?view=diff&rev=382553&r1=382552&r2=382553
==============================================================================
--- team/group/bridge_construction/main/bridging.c (original)
+++ team/group/bridge_construction/main/bridging.c Wed Mar  6 17:44:16 2013
@@ -209,6 +209,31 @@
 	ast_bridge_channel_poke(bridge_channel);
 	ao2_unlock(bridge_channel);
 	return 0;
+}
+
+void ast_bridge_channel_restore_formats(struct ast_bridge_channel *bridge_channel)
+{
+	/* Restore original formats of the channel as they came in */
+	if (ast_format_cmp(ast_channel_readformat(bridge_channel->chan), &bridge_channel->read_format) == AST_FORMAT_CMP_NOT_EQUAL) {
+		ast_debug(1, "Bridge is returning bridge channel %p(%s) to read format %s\n",
+			bridge_channel, ast_channel_name(bridge_channel->chan),
+			ast_getformatname(&bridge_channel->read_format));
+		if (ast_set_read_format(bridge_channel->chan, &bridge_channel->read_format)) {
+			ast_debug(1, "Bridge failed to return bridge channel %p(%s) to read format %s\n",
+				bridge_channel, ast_channel_name(bridge_channel->chan),
+				ast_getformatname(&bridge_channel->read_format));
+		}
+	}
+	if (ast_format_cmp(ast_channel_writeformat(bridge_channel->chan), &bridge_channel->write_format) == AST_FORMAT_CMP_NOT_EQUAL) {
+		ast_debug(1, "Bridge is returning bridge channel %p(%s) to write format %s\n",
+			bridge_channel, ast_channel_name(bridge_channel->chan),
+			ast_getformatname(&bridge_channel->write_format));
+		if (ast_set_write_format(bridge_channel->chan, &bridge_channel->write_format)) {
+			ast_debug(1, "Bridge failed to return bridge channel %p(%s) to write format %s\n",
+				bridge_channel, ast_channel_name(bridge_channel->chan),
+				ast_getformatname(&bridge_channel->write_format));
+		}
+	}
 }
 
 void ast_bridge_poke(struct ast_bridge *bridge)
@@ -1624,10 +1649,9 @@
 static void bridge_channel_join(struct ast_bridge_channel *bridge_channel)
 {
 	struct ast_frame *action;
-	struct ast_format formats[2];
-
-	ast_format_copy(&formats[0], ast_channel_readformat(bridge_channel->chan));
-	ast_format_copy(&formats[1], ast_channel_writeformat(bridge_channel->chan));
+
+	ast_format_copy(&bridge_channel->read_format, ast_channel_readformat(bridge_channel->chan));
+	ast_format_copy(&bridge_channel->write_format, ast_channel_writeformat(bridge_channel->chan));
 
 	ast_debug(1, "Joining bridge channel %p(%s) to bridge %p\n",
 		bridge_channel, ast_channel_name(bridge_channel->chan), bridge_channel->bridge);
@@ -1742,32 +1766,14 @@
 	}
 	ast_channel_internal_bridge_set(bridge_channel->chan, NULL);
 
-	/* Restore original formats of the channel as they came in */
-	if (ast_format_cmp(ast_channel_readformat(bridge_channel->chan), &formats[0]) == AST_FORMAT_CMP_NOT_EQUAL) {
-		ast_debug(1, "Bridge is returning bridge channel %p(%s) to read format %s\n",
-			bridge_channel, ast_channel_name(bridge_channel->chan),
-			ast_getformatname(&formats[0]));
-		if (ast_set_read_format(bridge_channel->chan, &formats[0])) {
-			ast_debug(1, "Bridge failed to return bridge channel %p(%s) to read format %s\n",
-				bridge_channel, ast_channel_name(bridge_channel->chan),
-				ast_getformatname(&formats[0]));
-		}
-	}
-	if (ast_format_cmp(ast_channel_writeformat(bridge_channel->chan), &formats[1]) == AST_FORMAT_CMP_NOT_EQUAL) {
-		ast_debug(1, "Bridge is returning bridge channel %p(%s) to write format %s\n",
-			bridge_channel, ast_channel_name(bridge_channel->chan),
-			ast_getformatname(&formats[1]));
-		if (ast_set_write_format(bridge_channel->chan, &formats[1])) {
-			ast_debug(1, "Bridge failed to return bridge channel %p(%s) to write format %s\n",
-				bridge_channel, ast_channel_name(bridge_channel->chan),
-				ast_getformatname(&formats[1]));
-		}
-	}
+	ast_bridge_channel_restore_formats(bridge_channel);
 }
 
 static void bridge_channel_destroy(void *obj)
 {
 	struct ast_bridge_channel *bridge_channel = obj;
+
+	ast_bridge_channel_clear_roles(bridge_channel);
 
 	if (bridge_channel->callid) {
 		bridge_channel->callid = ast_callid_unref(bridge_channel->callid);
@@ -1777,6 +1783,7 @@
 		ao2_ref(bridge_channel->bridge, -1);
 		bridge_channel->bridge = NULL;
 	}
+
 	/* Destroy elements of the bridge channel structure and the bridge channel structure itself */
 	ast_cond_destroy(&bridge_channel->cond);
 }
@@ -2106,6 +2113,14 @@
 	bridge_channel->swap = swap;
 	bridge_channel->features = features;
 
+	if (ast_bridge_channel_establish_roles(bridge_channel)) {
+		/* A bridge channel should not be allowed to join if its roles couldn't be copied properly. */
+		state = AST_BRIDGE_CHANNEL_STATE_HANGUP;
+		ast_channel_internal_bridge_channel_set(chan, NULL);
+		ao2_ref(bridge_channel, -1);
+		goto join_exit;
+	}
+
 	bridge_channel_join(bridge_channel);
 	state = bridge_channel->state;
 
@@ -2197,6 +2212,11 @@
 	bridge_channel->depart_wait = independent ? 0 : 1;
 	bridge_channel->callid = ast_read_threadstorage_callid();
 
+	if (ast_bridge_channel_establish_roles(bridge_channel)) {
+		res = -1;
+		goto bridge_impart_cleanup;
+	}
+
 	/* Actually create the thread that will handle the channel */
 	if (independent) {
 		/* Independently imparted channels cannot have a PBX. */
@@ -2211,6 +2231,8 @@
 		res = ast_pthread_create(&bridge_channel->thread, NULL,
 			bridge_channel_depart_thread, bridge_channel);
 	}
+
+bridge_impart_cleanup:
 	if (res) {
 		/* cleanup */
 		ast_channel_internal_bridge_channel_set(chan, NULL);




More information about the svn-commits mailing list