[asterisk-commits] dvossel: trunk r327640 - in /trunk: bridges/ include/asterisk/ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jul 11 13:44:09 CDT 2011


Author: dvossel
Date: Mon Jul 11 13:44:06 2011
New Revision: 327640

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=327640
Log:
Updates follow_talker video_mode in confbridge application.

follow_talker mode originally echoed the same video stream
to all participants. As the primary talker switched around, the
video stream would result in the talker seeing themselves.  Now
the primary talker sees the last person who was talking rather than
themselves.

Modified:
    trunk/bridges/bridge_softmix.c
    trunk/include/asterisk/bridging.h
    trunk/main/bridging.c

Modified: trunk/bridges/bridge_softmix.c
URL: http://svnview.digium.com/svn/asterisk/trunk/bridges/bridge_softmix.c?view=diff&rev=327640&r1=327639&r2=327640
==============================================================================
--- trunk/bridges/bridge_softmix.c (original)
+++ trunk/bridges/bridge_softmix.c Mon Jul 11 13:44:06 2011
@@ -435,11 +435,28 @@
 	}
 }
 
-static void softmix_pass_video(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
+static void softmix_pass_video_top_priority(struct ast_bridge *bridge, struct ast_frame *frame)
 {
 	struct ast_bridge_channel *tmp;
 	AST_LIST_TRAVERSE(&bridge->channels, tmp, entry) {
 		if (tmp->suspended) {
+			continue;
+		}
+		if (ast_bridge_is_video_src(bridge, tmp->chan) == 1) {
+			ast_write(tmp->chan, 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 *tmp;
+	AST_LIST_TRAVERSE(&bridge->channels, tmp, entry) {
+		if (tmp->suspended) {
+			continue;
+		}
+		if ((tmp->chan == bridge_channel->chan) && !echo) {
 			continue;
 		}
 		ast_write(tmp->chan, frame);
@@ -472,20 +489,26 @@
 
 	/* Determine if this video frame should be distributed or not */
 	if (frame->frametype == AST_FRAME_VIDEO) {
+		int num_src = ast_bridge_number_video_src(bridge);
+		int video_src_priority = ast_bridge_is_video_src(bridge, bridge_channel->chan);
+
 		switch (bridge->video_mode.mode) {
 		case AST_BRIDGE_VIDEO_MODE_NONE:
 			break;
 		case AST_BRIDGE_VIDEO_MODE_SINGLE_SRC:
-			if (ast_bridge_is_video_src(bridge, bridge_channel->chan)) {
-				softmix_pass_video(bridge, bridge_channel, frame);
+			if (video_src_priority == 1) {
+				softmix_pass_video_all(bridge, bridge_channel, frame, 1);
 			}
 			break;
 		case AST_BRIDGE_VIDEO_MODE_TALKER_SRC:
 			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);
-			if (ast_bridge_is_video_src(bridge, bridge_channel->chan)) {
-				softmix_pass_video(bridge, bridge_channel, frame);
+			if (video_src_priority == 1) {
+				int echo = num_src > 1 ? 0 : 1;
+				softmix_pass_video_all(bridge, bridge_channel, frame, echo);
+			} else if (video_src_priority == 2) {
+				softmix_pass_video_top_priority(bridge, frame);
 			}
 			break;
 		}

Modified: trunk/include/asterisk/bridging.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/bridging.h?view=diff&rev=327640&r1=327639&r2=327640
==============================================================================
--- trunk/include/asterisk/bridging.h (original)
+++ trunk/include/asterisk/bridging.h Mon Jul 11 13:44:06 2011
@@ -190,6 +190,9 @@
 	/*! Only accept video coming from this channel */
 	struct ast_channel *chan_vsrc;
 	int average_talking_energy;
+
+	/*! Current talker see's this person */
+	struct ast_channel *chan_old_vsrc;
 };
 
 struct ast_bridge_video_mode {
@@ -528,7 +531,17 @@
 void ast_bridge_update_talker_src_video_mode(struct ast_bridge *bridge, struct ast_channel *chan, int talker_energy, int is_keyfame);
 
 /*!
+ * \brief Returns the number of video sources currently active in the bridge
+ */
+int ast_bridge_number_video_src(struct ast_bridge *bridge);
+
+/*!
  * \brief Determine if a channel is a video src for the bridge
+ *
+ * \retval 0 Not a current video source of the bridge.
+ * \retval None 0, is a video source of the bridge, The number
+ *         returned represents the priority this video stream has
+ *         on the bridge where 1 is the highest priority.
  */
 int ast_bridge_is_video_src(struct ast_bridge *bridge, struct ast_channel *chan);
 

Modified: trunk/main/bridging.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/bridging.c?view=diff&rev=327640&r1=327639&r2=327640
==============================================================================
--- trunk/main/bridging.c (original)
+++ trunk/main/bridging.c Mon Jul 11 13:44:06 2011
@@ -1489,6 +1489,9 @@
 		if (bridge->video_mode.mode_data.talker_src_data.chan_vsrc) {
 			ast_channel_unref(bridge->video_mode.mode_data.talker_src_data.chan_vsrc);
 		}
+		if (bridge->video_mode.mode_data.talker_src_data.chan_old_vsrc) {
+			ast_channel_unref(bridge->video_mode.mode_data.talker_src_data.chan_old_vsrc);
+		}
 	}
 	memset(&bridge->video_mode, 0, sizeof(bridge->video_mode));
 }
@@ -1525,20 +1528,51 @@
 	if (data->chan_vsrc == chan) {
 		data->average_talking_energy = talker_energy;
 	} else if ((data->average_talking_energy < talker_energy) && is_keyframe) {
+		if (data->chan_old_vsrc) {
+			ast_channel_unref(data->chan_old_vsrc);
+		}
 		if (data->chan_vsrc) {
-			ast_channel_unref(data->chan_vsrc);
+			data->chan_old_vsrc = data->chan_vsrc;
+			ast_indicate(data->chan_old_vsrc, AST_CONTROL_VIDUPDATE);
 		}
 		data->chan_vsrc = ast_channel_ref(chan);
 		data->average_talking_energy = talker_energy;
-		ast_indicate(chan, AST_CONTROL_VIDUPDATE);
 	} else if ((data->average_talking_energy < talker_energy) && !is_keyframe) {
 		ast_indicate(chan, AST_CONTROL_VIDUPDATE);
 	} else if (!data->chan_vsrc && is_keyframe) {
 		data->chan_vsrc = ast_channel_ref(chan);
 		data->average_talking_energy = talker_energy;
 		ast_indicate(chan, AST_CONTROL_VIDUPDATE);
+	} else if (!data->chan_old_vsrc && is_keyframe) {
+		data->chan_old_vsrc = ast_channel_ref(chan);
+		ast_indicate(chan, AST_CONTROL_VIDUPDATE);
 	}
 	ao2_unlock(bridge);
+}
+
+int ast_bridge_number_video_src(struct ast_bridge *bridge)
+{
+	int res = 0;
+
+	ao2_lock(bridge);
+	switch (bridge->video_mode.mode) {
+	case AST_BRIDGE_VIDEO_MODE_NONE:
+		break;
+	case AST_BRIDGE_VIDEO_MODE_SINGLE_SRC:
+		if (bridge->video_mode.mode_data.single_src_data.chan_vsrc) {
+			res = 1;
+		}
+		break;
+	case AST_BRIDGE_VIDEO_MODE_TALKER_SRC:
+		if (bridge->video_mode.mode_data.talker_src_data.chan_vsrc) {
+			res++;
+		}
+		if (bridge->video_mode.mode_data.talker_src_data.chan_old_vsrc) {
+			res++;
+		}
+	}
+	ao2_unlock(bridge);
+	return res;
 }
 
 int ast_bridge_is_video_src(struct ast_bridge *bridge, struct ast_channel *chan)
@@ -1557,7 +1591,10 @@
 	case AST_BRIDGE_VIDEO_MODE_TALKER_SRC:
 		if (bridge->video_mode.mode_data.talker_src_data.chan_vsrc == chan) {
 			res = 1;
-		}
+		} else if (bridge->video_mode.mode_data.talker_src_data.chan_old_vsrc == chan) {
+			res = 2;
+		}
+
 	}
 	ao2_unlock(bridge);
 	return res;
@@ -1583,6 +1620,13 @@
 				ast_channel_unref(bridge->video_mode.mode_data.talker_src_data.chan_vsrc);
 			}
 			bridge->video_mode.mode_data.talker_src_data.chan_vsrc = NULL;
+			bridge->video_mode.mode_data.talker_src_data.average_talking_energy = 0;
+		}
+		if (bridge->video_mode.mode_data.talker_src_data.chan_old_vsrc == chan) {
+			if (bridge->video_mode.mode_data.talker_src_data.chan_old_vsrc) {
+				ast_channel_unref(bridge->video_mode.mode_data.talker_src_data.chan_old_vsrc);
+			}
+			bridge->video_mode.mode_data.talker_src_data.chan_old_vsrc = NULL;
 		}
 	}
 	ao2_unlock(bridge);




More information about the asterisk-commits mailing list