[svn-commits] dvossel: branch dvossel/hd_confbridge r310883 - in /team/dvossel/hd_confbridg...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Mar 16 08:38:12 CDT 2011


Author: dvossel
Date: Wed Mar 16 08:38:06 2011
New Revision: 310883

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=310883
Log:
Added ability for talker detection in the bridging technology to make its way up to the briding application.

Modified:
    team/dvossel/hd_confbridge/bridges/bridge_softmix.c
    team/dvossel/hd_confbridge/include/asterisk/bridging.h
    team/dvossel/hd_confbridge/include/asterisk/bridging_features.h
    team/dvossel/hd_confbridge/include/asterisk/bridging_technology.h
    team/dvossel/hd_confbridge/main/bridging.c

Modified: team/dvossel/hd_confbridge/bridges/bridge_softmix.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/hd_confbridge/bridges/bridge_softmix.c?view=diff&rev=310883&r1=310882&r2=310883
==============================================================================
--- team/dvossel/hd_confbridge/bridges/bridge_softmix.c (original)
+++ team/dvossel/hd_confbridge/bridges/bridge_softmix.c Wed Mar 16 08:38:06 2011
@@ -398,6 +398,7 @@
 	struct softmix_channel *sc = bridge_channel->bridge_pvt;
 	struct softmix_bridge_data *bridge_data = bridge->bridge_pvt;
 	int totalsilence = 0;
+	int update_talking = -1;  /* if this is set to 0 or 1, tell the bridge that the channel has started or stopped talking. */
 
 	/* Only accept audio frames, all others are unsupported */
 	if (frame->frametype != AST_FRAME_VOICE) {
@@ -406,10 +407,17 @@
 
 	ast_mutex_lock(&sc->lock);
 
-	sc->talking = 0;
 	ast_dsp_silence(sc->dsp, frame, &totalsilence);
 	if (totalsilence < SILENCE_THRESHOLD) {
+		if (!sc->talking) {
+			update_talking = 1;
+		}
 		sc->talking = 1; /* tell the write process we have audio to be mixed out */
+	} else {
+		if (sc->talking) {
+			update_talking = 0;
+		}
+		sc->talking = 0;
 	}
 
 	/* Before adding audio in, make sure we haven't fallen behind. If audio has fallen
@@ -432,6 +440,10 @@
 
 	/* Alllll done */
 	ast_mutex_unlock(&sc->lock);
+
+	if (update_talking != -1) {
+		ast_bridge_notify_talking(bridge, bridge_channel, update_talking);
+	}
 
 	return AST_BRIDGE_WRITE_SUCCESS;
 }

Modified: team/dvossel/hd_confbridge/include/asterisk/bridging.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/hd_confbridge/include/asterisk/bridging.h?view=diff&rev=310883&r1=310882&r2=310883
==============================================================================
--- team/dvossel/hd_confbridge/include/asterisk/bridging.h (original)
+++ team/dvossel/hd_confbridge/include/asterisk/bridging.h Wed Mar 16 08:38:06 2011
@@ -97,6 +97,10 @@
 	AST_BRIDGE_CHANNEL_STATE_FEATURE,
 	/*! Bridged channel is sending a DTMF stream out */
 	AST_BRIDGE_CHANNEL_STATE_DTMF,
+	/*! Bridged channel began talking */
+	AST_BRIDGE_CHANNEL_STATE_START_TALKING,
+	/*! Bridged channel has stopped talking */
+	AST_BRIDGE_CHANNEL_STATE_STOP_TALKING,
 };
 
 /*! \brief Return values for bridge technology write function */

Modified: team/dvossel/hd_confbridge/include/asterisk/bridging_features.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/hd_confbridge/include/asterisk/bridging_features.h?view=diff&rev=310883&r1=310882&r2=310883
==============================================================================
--- team/dvossel/hd_confbridge/include/asterisk/bridging_features.h (original)
+++ team/dvossel/hd_confbridge/include/asterisk/bridging_features.h Wed Mar 16 08:38:06 2011
@@ -69,6 +69,21 @@
  * \param hook_pvt Private data passed in when the hook was create to destroy
  */
 typedef void (*ast_bridge_features_hook_pvt_destructor)(void *hook_pvt);
+
+/*!
+ * \brief Talking indicator callback
+ *
+ * \details This callback can be registered with the bridge in order
+ * to receive updates on when a bridge_channel has started and stopped
+ * talking
+ *
+ * \param bridge The bridge that the channel is part of
+ * \param bridge_channel Channel executing the feature
+ *
+ * \retval 0 success
+ * \retval -1 failure
+ */
+typedef int (*ast_bridge_talking_indicate_callback)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel);
 
 /*!
  * \brief Maximum length of a DTMF feature string
@@ -97,12 +112,10 @@
 struct ast_bridge_features {
 	/*! Attached DTMF based feature hooks */
 	AST_LIST_HEAD_NOLOCK(, ast_bridge_features_hook) hooks;
+	/*! Callback to indicate when a bridge channel has started and stopped talking */
+	ast_bridge_talking_indicate_callback talker;
 	/*! Feature flags that are enabled */
 	struct ast_flags feature_flags;
-	/*! The number of ms of silence before channel read audio is dropped as
-	 * silence from the bridge. When this varaible is 0, audio is never dropped
-	 * due to silence. */
-	unsigned int detect_silence;
 	/*! Bit to indicate that this structure is useful and should be considered when looking for features */
 	unsigned int usable:1;
 	/*! Bit to indicate whether the channel/bridge is muted or not */

Modified: team/dvossel/hd_confbridge/include/asterisk/bridging_technology.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/hd_confbridge/include/asterisk/bridging_technology.h?view=diff&rev=310883&r1=310882&r2=310883
==============================================================================
--- team/dvossel/hd_confbridge/include/asterisk/bridging_technology.h (original)
+++ team/dvossel/hd_confbridge/include/asterisk/bridging_technology.h Wed Mar 16 08:38:06 2011
@@ -143,6 +143,21 @@
  */
 void ast_bridge_handle_trip(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_channel *chan, int outfd);
 
+/*! \brief Lets the bridging indicate when a bridge channel has stopped or started talking.
+ *
+ * \note All DSP functionality on the bridge has been pushed down to the lowest possible
+ * layer, which in this case is the specific bridging technology being used. Since it
+ * is necessary for the knowledge of which channels are talking to make its way up to the
+ * application, this function has been created to allow the bridging technology to communicate
+ * that information with the bridging core.
+ *
+ * \param bridge The bridge that the channel is a part of.
+ * \param bridge_channel The bridge channel that has either started or stopped talking.
+ * \param started_talking, set to 1 when this indicates the channel has started talking, set to 0
+ * when this indicates the channel has stopped talking.
+ */
+void ast_bridge_notify_talking(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, int started_talking);
+
 /*! \brief Suspend a bridge technology from consideration
  *
  * \param technology The bridge technology to suspend

Modified: team/dvossel/hd_confbridge/main/bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/hd_confbridge/main/bridging.c?view=diff&rev=310883&r1=310882&r2=310883
==============================================================================
--- team/dvossel/hd_confbridge/main/bridging.c (original)
+++ team/dvossel/hd_confbridge/main/bridging.c Wed Mar 16 08:38:06 2011
@@ -273,6 +273,15 @@
 	}
 }
 
+void ast_bridge_notify_talking(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, int started_talking)
+{
+	if (started_talking) {
+		ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_START_TALKING);
+	} else {
+		ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_STOP_TALKING);
+	}
+}
+
 void ast_bridge_handle_trip(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_channel *chan, int outfd)
 {
 	/* If no bridge channel has been provided and the actual channel has been provided find it */
@@ -853,6 +862,16 @@
 	return;
 }
 
+static void bridge_channel_talking(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
+{
+	struct ast_bridge_features *features = (bridge_channel->features ? bridge_channel->features : &bridge->features);
+
+	if (features && features->talker) {
+		features->talker(bridge, bridge_channel);
+	}
+	ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_WAIT);
+}
+
 /*! \brief Internal function that plays back DTMF on a bridge channel */
 static void bridge_channel_dtmf_stream(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
 {
@@ -936,16 +955,25 @@
 		/* Execute the threading model */
 		state = (bridge_channel->bridge->technology->capabilities & AST_BRIDGE_CAPABILITY_MULTITHREADED ? bridge_channel_join_multithreaded(bridge_channel) : bridge_channel_join_singlethreaded(bridge_channel));
 		/* Depending on the above state see what we need to do */
-		if (state == AST_BRIDGE_CHANNEL_STATE_FEATURE) {
+		switch (state) {
+		case AST_BRIDGE_CHANNEL_STATE_FEATURE:
 			bridge_channel_suspend(bridge_channel->bridge, bridge_channel);
 			ao2_unlock(bridge_channel->bridge);
 			bridge_channel_feature(bridge_channel->bridge, bridge_channel);
 			ao2_lock(bridge_channel->bridge);
 			bridge_channel_unsuspend(bridge_channel->bridge, bridge_channel);
-		} else if (state == AST_BRIDGE_CHANNEL_STATE_DTMF) {
+			break;
+		case AST_BRIDGE_CHANNEL_STATE_DTMF:
 			bridge_channel_suspend(bridge_channel->bridge, bridge_channel);
 			bridge_channel_dtmf_stream(bridge_channel->bridge, bridge_channel);
 			bridge_channel_unsuspend(bridge_channel->bridge, bridge_channel);
+			break;
+		case AST_BRIDGE_CHANNEL_STATE_START_TALKING:
+		case AST_BRIDGE_CHANNEL_STATE_STOP_TALKING:
+			bridge_channel_talking(bridge_channel->bridge, bridge_channel);
+			break;
+		default:
+			break;
 		}
 	}
 




More information about the svn-commits mailing list