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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Mar 29 15:02:39 CDT 2013


Author: rmudgett
Date: Fri Mar 29 15:02:35 2013
New Revision: 384364

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=384364
Log:
Made write DTMF passthrough string to the bridge instad of to each channel.

Let the bridge technology determine how to distribute the passthrough DTMF
string.

* Made softmix bridge technology distribute AST_FRAME_BRIDGE_ACTION
frames.

* Eliminated some redundant code used by softmix_bridge_write_video()
calling softmix_pass_video_all().

* Made ast_bridge_channel_queue_frame() check if the bridge_channel is
leaving the bridge before putting the frame onto the queue.

* Remove unneeded API call ast_bridge_dtmf_stream().

Modified:
    team/group/bridge_construction/bridges/bridge_holding.c
    team/group/bridge_construction/bridges/bridge_simple.c
    team/group/bridge_construction/bridges/bridge_softmix.c
    team/group/bridge_construction/include/asterisk/bridging_features.h
    team/group/bridge_construction/main/bridging.c

Modified: team/group/bridge_construction/bridges/bridge_holding.c
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/bridges/bridge_holding.c?view=diff&rev=384364&r1=384363&r2=384364
==============================================================================
--- team/group/bridge_construction/bridges/bridge_holding.c (original)
+++ team/group/bridge_construction/bridges/bridge_holding.c Fri Mar 29 15:02:35 2013
@@ -255,7 +255,7 @@
 
 static int holding_bridge_write(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
 {
-	struct ast_bridge_channel *other;
+	struct ast_bridge_channel *cur;
 	struct holding_channel *hc = bridge_channel->tech_pvt;
 
 	/* If there is no tech_pvt, then the channel failed to allocate one when it joined and is borked. Don't listen to him. */
@@ -269,17 +269,12 @@
 	}
 
 	/* Ok, so we are the announcer and there are one or more people available to receive our writes. Let's do it. */
-	AST_LIST_TRAVERSE(&bridge->channels, other, entry) {
-		if (!other->tech_pvt) {
+	AST_LIST_TRAVERSE(&bridge->channels, cur, entry) {
+		if (bridge_channel == cur || !cur->tech_pvt) {
 			continue;
 		}
-		if (bridge_channel == other) {
-			continue;
-		}
-
-		if (other->state == AST_BRIDGE_CHANNEL_STATE_WAIT) {
-			ast_bridge_channel_queue_frame(other, frame);
-		}
+
+		ast_bridge_channel_queue_frame(cur, frame);
 	}
 
 	return 0;

Modified: team/group/bridge_construction/bridges/bridge_simple.c
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/bridges/bridge_simple.c?view=diff&rev=384364&r1=384363&r2=384364
==============================================================================
--- team/group/bridge_construction/bridges/bridge_simple.c (original)
+++ team/group/bridge_construction/bridges/bridge_simple.c Fri Mar 29 15:02:35 2013
@@ -82,9 +82,7 @@
 	}
 
 	/* The bridging core takes care of freeing the passed in frame. */
-	if (other->state == AST_BRIDGE_CHANNEL_STATE_WAIT) {
-		ast_bridge_channel_queue_frame(other, frame);
-	}
+	ast_bridge_channel_queue_frame(other, frame);
 
 	return 0;
 }

Modified: team/group/bridge_construction/bridges/bridge_softmix.c
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/bridges/bridge_softmix.c?view=diff&rev=384364&r1=384363&r2=384364
==============================================================================
--- team/group/bridge_construction/bridges/bridge_softmix.c (original)
+++ team/group/bridge_construction/bridges/bridge_softmix.c Fri Mar 29 15:02:35 2013
@@ -451,9 +451,28 @@
 
 /*!
  * \internal
- * \brief If the bridging core passes DTMF to us, then they want it to be distributed out to all memebers. Do that here.
- */
-static void softmix_pass_dtmf(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
+ * \brief Pass the given frame to everyone else.
+ * \since 12.0.0
+ *
+ * \param bridge What bridge to distribute frame.
+ * \param bridge_channel Channel to optionally not pass frame to. (NULL to pass to everyone)
+ * \param frame Frame to pass.
+ *
+ * \return Nothing
+ */
+static void softmix_pass_everyone_else(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
+{
+	struct ast_bridge_channel *cur;
+
+	AST_LIST_TRAVERSE(&bridge->channels, cur, entry) {
+		if (cur == bridge_channel) {
+			continue;
+		}
+		ast_bridge_channel_queue_frame(cur, frame);
+	}
+}
+
+static void softmix_pass_video_top_priority(struct ast_bridge *bridge, struct ast_frame *frame)
 {
 	struct ast_bridge_channel *cur;
 
@@ -461,40 +480,10 @@
 		if (cur->suspended) {
 			continue;
 		}
-		if (cur == bridge_channel) {
-			continue;
-		}
-		ast_bridge_channel_queue_frame(cur, frame);
-	}
-}
-
-static void softmix_pass_video_top_priority(struct ast_bridge *bridge, struct ast_frame *frame)
-{
-	struct ast_bridge_channel *cur;
-
-	AST_LIST_TRAVERSE(&bridge->channels, cur, entry) {
-		if (cur->suspended) {
-			continue;
-		}
 		if (ast_bridge_is_video_src(bridge, cur->chan) == 1) {
 			ast_bridge_channel_queue_frame(cur, frame);
 			break;
 		}
-	}
-}
-
-static void softmix_pass_video_all(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame, int echo)
-{
-	struct ast_bridge_channel *cur;
-
-	AST_LIST_TRAVERSE(&bridge->channels, cur, entry) {
-		if (cur->suspended) {
-			continue;
-		}
-		if (cur == bridge_channel && !echo) {
-			continue;
-		}
-		ast_bridge_channel_queue_frame(cur, frame);
 	}
 }
 
@@ -511,32 +500,33 @@
  */
 static void softmix_bridge_write_video(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
 {
-	struct softmix_channel *sc = bridge_channel->tech_pvt;
-	int num_src;
+	struct softmix_channel *sc;
 	int video_src_priority;
-
-	num_src = ast_bridge_number_video_src(bridge);
-	video_src_priority = ast_bridge_is_video_src(bridge, bridge_channel->chan);
 
 	/* Determine if the video frame should be distributed or not */
 	switch (bridge->video_mode.mode) {
 	case AST_BRIDGE_VIDEO_MODE_NONE:
 		break;
 	case AST_BRIDGE_VIDEO_MODE_SINGLE_SRC:
+		video_src_priority = ast_bridge_is_video_src(bridge, bridge_channel->chan);
 		if (video_src_priority == 1) {
-			softmix_pass_video_all(bridge, bridge_channel, frame, 1);
+			/* Pass to me and everyone else. */
+			softmix_pass_everyone_else(bridge, NULL, frame);
 		}
 		break;
 	case AST_BRIDGE_VIDEO_MODE_TALKER_SRC:
+		sc = bridge_channel->tech_pvt;
 		ast_mutex_lock(&sc->lock);
 		ast_bridge_update_talker_src_video_mode(bridge, bridge_channel->chan,
 			sc->video_talker.energy_average,
 			ast_format_get_video_mark(&frame->subclass.format));
 		ast_mutex_unlock(&sc->lock);
+		video_src_priority = ast_bridge_is_video_src(bridge, bridge_channel->chan);
 		if (video_src_priority == 1) {
+			int num_src = ast_bridge_number_video_src(bridge);
 			int echo = num_src > 1 ? 0 : 1;
 
-			softmix_pass_video_all(bridge, bridge_channel, frame, echo);
+			softmix_pass_everyone_else(bridge, echo ? NULL : bridge_channel, frame);
 		} else if (video_src_priority == 2) {
 			softmix_pass_video_top_priority(bridge, frame);
 		}
@@ -659,7 +649,7 @@
 	switch (frame->frametype) {
 	case AST_FRAME_DTMF_BEGIN:
 	case AST_FRAME_DTMF_END:
-		softmix_pass_dtmf(bridge, bridge_channel, frame);
+		softmix_pass_everyone_else(bridge, bridge_channel, frame);
 		break;
 	case AST_FRAME_VOICE:
 		softmix_bridge_write_voice(bridge, bridge_channel, frame);
@@ -669,6 +659,9 @@
 		break;
 	case AST_FRAME_CONTROL:
 		softmix_bridge_write_control(bridge, bridge_channel, frame);
+		break;
+	case AST_FRAME_BRIDGE_ACTION:
+		softmix_pass_everyone_else(bridge, bridge_channel, frame);
 		break;
 	default:
 		ast_debug(3, "Frame type %d unsupported\n", frame->frametype);

Modified: team/group/bridge_construction/include/asterisk/bridging_features.h
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/include/asterisk/bridging_features.h?view=diff&rev=384364&r1=384363&r2=384364
==============================================================================
--- team/group/bridge_construction/include/asterisk/bridging_features.h (original)
+++ team/group/bridge_construction/include/asterisk/bridging_features.h Fri Mar 29 15:02:35 2013
@@ -643,28 +643,6 @@
  */
 void ast_bridge_features_destroy(struct ast_bridge_features *features);
 
-/*!
- * \brief Play a DTMF stream into a bridge, optionally not to a given channel
- *
- * \param bridge Bridge to play stream into
- * \param dtmf DTMF to play
- * \param chan Channel to optionally not play to
- *
- * \retval 0 on success
- * \retval -1 on failure
- *
- * Example usage:
- *
- * \code
- * ast_bridge_dtmf_stream(bridge, "0123456789", NULL);
- * \endcode
- *
- * This sends the DTMF digits '0123456789' to all channels in the bridge pointed to
- * by the bridge pointer. Optionally a channel may be excluded by passing it's channel pointer
- * using the chan parameter.
- */
-int ast_bridge_dtmf_stream(struct ast_bridge *bridge, const char *dtmf, struct ast_channel *chan);
-
 #if defined(__cplusplus) || defined(c_plusplus)
 }
 #endif

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=384364&r1=384363&r2=384364
==============================================================================
--- team/group/bridge_construction/main/bridging.c (original)
+++ team/group/bridge_construction/main/bridging.c Fri Mar 29 15:02:35 2013
@@ -311,6 +311,13 @@
 	}
 
 	ast_bridge_channel_lock(bridge_channel);
+	if (bridge_channel->state != AST_BRIDGE_CHANNEL_STATE_WAIT) {
+		/* Drop frames on channels leaving the bridge. */
+		ast_bridge_channel_unlock(bridge_channel);
+		ast_frfree(dup);
+		return 0;
+	}
+
 	AST_LIST_INSERT_TAIL(&bridge_channel->wr_queue, dup, frame_list);
 	if (write(bridge_channel->alert_pipe[1], &nudge, sizeof(nudge)) != sizeof(nudge)) {
 		ast_log(LOG_ERROR, "We couldn't write alert pipe for %p(%s)... something is VERY wrong\n",
@@ -1536,6 +1543,20 @@
 	ast_heap_unlock(bridge_channel->features->interval_hooks);
 }
 
+static void bridge_channel_write_dtmf_stream(struct ast_bridge_channel *bridge_channel, const char *dtmf)
+{
+	struct ast_frame action = {
+		.frametype = AST_FRAME_BRIDGE_ACTION,
+		.subclass.integer = AST_BRIDGE_ACTION_DTMF_STREAM,
+		.datalen = strlen(dtmf) + 1,
+		.data.ptr = (char *) dtmf,
+	};
+
+	ast_bridge_channel_lock_bridge(bridge_channel);
+	bridge_channel->bridge->technology->write(bridge_channel->bridge, bridge_channel, &action);
+	ast_bridge_unlock(bridge_channel->bridge);
+}
+
 /*!
  * \brief Internal function that executes a feature on a bridge channel
  * \note Neither the bridge nor the bridge_channel locks should be held when entering
@@ -1621,7 +1642,7 @@
 			bridge_handle_hangup(bridge_channel);
 		}
 	} else if (features->dtmf_passthrough) {
-		ast_bridge_dtmf_stream(bridge_channel->bridge, dtmf, bridge_channel->chan);
+		bridge_channel_write_dtmf_stream(bridge_channel, dtmf);
 	}
 }
 
@@ -3305,30 +3326,6 @@
 	return features;
 }
 
-int ast_bridge_dtmf_stream(struct ast_bridge *bridge, const char *dtmf, struct ast_channel *chan)
-{
-	struct ast_bridge_channel *bridge_channel;
-	struct ast_frame action = {
-		.frametype = AST_FRAME_BRIDGE_ACTION,
-		.subclass.integer = AST_BRIDGE_ACTION_DTMF_STREAM,
-		.datalen = strlen(dtmf) + 1,
-		.data.ptr = (char *) dtmf,
-	};
-
-	ast_bridge_lock(bridge);
-
-	AST_LIST_TRAVERSE(&bridge->channels, bridge_channel, entry) {
-		if (bridge_channel->chan == chan) {
-			continue;
-		}
-		ast_bridge_channel_queue_frame(bridge_channel, &action);
-	}
-
-	ast_bridge_unlock(bridge);
-
-	return 0;
-}
-
 void ast_bridge_set_mixing_interval(struct ast_bridge *bridge, unsigned int mixing_interval)
 {
 	ast_bridge_lock(bridge);




More information about the asterisk-commits mailing list