[asterisk-commits] dvossel: branch dvossel/hd_confbridge r309341 - in /team/dvossel/hd_confbridg...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Mar 3 09:55:58 CST 2011


Author: dvossel
Date: Thu Mar  3 09:55:52 2011
New Revision: 309341

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=309341
Log:
Allows a static locked sample rate to be set on a conference bridge using a bridge profile

Modified:
    team/dvossel/hd_confbridge/apps/app_confbridge.c
    team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c
    team/dvossel/hd_confbridge/apps/confbridge/include/confbridge.h
    team/dvossel/hd_confbridge/bridges/bridge_softmix.c
    team/dvossel/hd_confbridge/configs/confbridge.conf.sample
    team/dvossel/hd_confbridge/include/asterisk/bridging.h
    team/dvossel/hd_confbridge/main/bridging.c

Modified: team/dvossel/hd_confbridge/apps/app_confbridge.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/hd_confbridge/apps/app_confbridge.c?view=diff&rev=309341&r1=309340&r2=309341
==============================================================================
--- team/dvossel/hd_confbridge/apps/app_confbridge.c (original)
+++ team/dvossel/hd_confbridge/apps/app_confbridge.c Thu Mar  3 09:55:52 2011
@@ -363,6 +363,9 @@
 			return NULL;
 		}
 
+		/* Set the internal sample rate on the bridge from the bridge profile */
+		ast_bridge_set_internal_sample_rate(conference_bridge->bridge, conference_bridge->b_profile.internal_sample_rate);
+
 		/* Setup lock for playback channel */
 		ast_mutex_init(&conference_bridge->playback_lock);
 
@@ -396,8 +399,7 @@
 	}
 
 	/* If the caller is a marked user or is waiting for a marked user to enter pass 'em off, otherwise pass them off to do regular joining stuff */
-	if (ast_test_flag(&conference_bridge_user->u_profile, USER_OPT_MARKEDUSER) ||
-		ast_test_flag(&conference_bridge_user->b_profile, BRIDGE_OPT_WAITMARKED)) {
+	if (ast_test_flag(&conference_bridge_user->u_profile, USER_OPT_MARKEDUSER | USER_OPT_WAITMARKED)) {
 		post_join_marked(conference_bridge, conference_bridge_user);
 	} else {
 		post_join_unmarked(conference_bridge, conference_bridge_user);

Modified: team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c?view=diff&rev=309341&r1=309340&r2=309341
==============================================================================
--- team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c (original)
+++ team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c Thu Mar  3 09:55:52 2011
@@ -124,7 +124,6 @@
 	ao2_lock(b_profile);
 	/* set defaults */
 	b_profile->internal_sample_rate = 0;
-	b_profile->flags = 0;
 
 	for (var = ast_variable_browse(cfg, cat); var; var = var->next) {
 		if (!strcasecmp(var->name, "internal_sample_rate")) {
@@ -134,10 +133,6 @@
 				ast_log(LOG_WARNING, "internal_sample_rate '%s' at line %d of %s is not supported.\n",
 						var->value, var->lineno, CONF_CONFIG);
 			}
-		} else if (!strcasecmp(var->name, "wait_marked")) {
-			b_profile->flags = ast_true(var->value) ?
-				b_profile->flags | BRIDGE_OPT_WAITMARKED :
-				b_profile->flags & ~BRIDGE_OPT_WAITMARKED;
 		} else if (!strcasecmp(var->name, "type")) {
 			continue;
 		} else {
@@ -171,7 +166,6 @@
 	ao2_lock(u_profile);
 	/* set defaults */
 	u_profile->flags = 0;
-	u_profile->volume = 0;
 	for (var = ast_variable_browse(cfg, cat); var; var = var->next) {
 		if (!strcasecmp(var->name, "type")) {
 			continue;
@@ -203,6 +197,10 @@
 			u_profile->flags = ast_true(var->value) ?
 				u_profile->flags & ~USER_OPT_NOONLYPERSON :
 				u_profile->flags | USER_OPT_NOONLYPERSON;
+		} else if (!strcasecmp(var->name, "wait_marked")) {
+			u_profile->flags = ast_true(var->value) ?
+				u_profile->flags | USER_OPT_WAITMARKED :
+				u_profile->flags & ~USER_OPT_WAITMARKED;
 		} else {
 			ast_log(LOG_WARNING, "Unknown option '%s' at line %d of %s is not supported.\n",
 				var->name, var->lineno, CONF_CONFIG);
@@ -316,6 +314,9 @@
 	ast_cli(a->fd,"Announce User Count: %s\n",
 		u_profile.flags & USER_OPT_ANNOUNCEUSERCOUNT ?
 		"enabled" : "disabled");
+	ast_cli(a->fd,"Wait Marked:         %s\n",
+		u_profile.flags & USER_OPT_WAITMARKED ?
+		"enabled" : "disabled");
 	ast_cli(a->fd,"\n");
 
 	return CLI_SUCCESS;
@@ -377,9 +378,6 @@
 		snprintf(tmp, sizeof(tmp), "auto");
 	}
 	ast_cli(a->fd,"Internal Sample Rate: %s\n", tmp);
-	ast_cli(a->fd,"Wait Marked:          %s\n",
-		b_profile.flags & BRIDGE_OPT_WAITMARKED ?
-		"enabled" : "disabled");
 	ast_cli(a->fd,"\n");
 
 	return CLI_SUCCESS;

Modified: team/dvossel/hd_confbridge/apps/confbridge/include/confbridge.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/hd_confbridge/apps/confbridge/include/confbridge.h?view=diff&rev=309341&r1=309340&r2=309341
==============================================================================
--- team/dvossel/hd_confbridge/apps/confbridge/include/confbridge.h (original)
+++ team/dvossel/hd_confbridge/apps/confbridge/include/confbridge.h Thu Mar  3 09:55:52 2011
@@ -28,17 +28,14 @@
 #define MAX_CONF_NAME 32
 
 enum user_profile_flags {
-	USER_OPT_ADMIN = (1 << 0),             /*!< Set if the caller is an administrator */
-	USER_OPT_MARKEDUSER = (1 << 2),        /*!< Set if the caller is a marked user */
-	USER_OPT_STARTMUTED = (1 << 3),        /*!< Set if the caller should be initially set muted */
-	USER_OPT_MUSICONHOLD = (1 << 4),     /*!< Set if music on hold should be played if nobody else is in the conference bridge */
-	USER_OPT_QUIET = (1 << 5),        /*!< Set if no audio prompts should be played */
+	USER_OPT_ADMIN =        (1 << 0), /*!< Set if the caller is an administrator */
+	USER_OPT_NOONLYPERSON = (1 << 1), /*!< Set if the "you are currently the only person in this conference" sound file should not be played */
+	USER_OPT_MARKEDUSER =   (1 << 2), /*!< Set if the caller is a marked user */
+	USER_OPT_STARTMUTED =   (1 << 3), /*!< Set if the caller should be initially set muted */
+	USER_OPT_MUSICONHOLD =  (1 << 4), /*!< Set if music on hold should be played if nobody else is in the conference bridge */
+	USER_OPT_QUIET =        (1 << 5), /*!< Set if no audio prompts should be played */
 	USER_OPT_ANNOUNCEUSERCOUNT = (1 << 6), /*!< Set if the number of users should be announced to the caller */
-	USER_OPT_NOONLYPERSON = (1 << 1), /*!< Set if the "you are currently the only person in this conference" sound file should not be played */
-};
-
-enum bridge_profile_flags {
-	BRIDGE_OPT_WAITMARKED = (1 << 0),   /*!< Set if the conference must wait for a marked user before starting */
+	USER_OPT_WAITMARKED = (1 << 7), /*!< Set if the conference must wait for a marked user before starting */
 };
 
 struct conf_menu {
@@ -49,13 +46,11 @@
 struct user_profile {
 	char name[64];
 	unsigned int flags;
-	int volume;
 	int delme;
 };
 
 struct bridge_profile {
 	char name[64];
-	unsigned int flags;
 	unsigned int internal_sample_rate;     /*!< The internal sample rate of the bridge. 0 when set to auto adjust mode. */
 	int delme;
 };

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=309341&r1=309340&r2=309341
==============================================================================
--- team/dvossel/hd_confbridge/bridges/bridge_softmix.c (original)
+++ team/dvossel/hd_confbridge/bridges/bridge_softmix.c Thu Mar  3 09:55:52 2011
@@ -23,10 +23,6 @@
  * \author Joshua Colp <jcolp at digium.com>
  *
  * \ingroup bridges
- *
- * \todo This bridge operates in 8 kHz mode unless a define is uncommented.
- * This needs to be improved so the bridge moves between the dominant codec as needed depending
- * on channels present in the bridge and transcoding capabilities.
  */
 
 #include "asterisk.h"
@@ -241,6 +237,8 @@
 		unsigned int num_at_internal_rate;
 		/*! the absolute highest sample rate supported by any channel in the bridge */
 		unsigned int highest_supported_rate;
+		/*! Is the sample rate locked by the bridge, if so what is that rate.*/
+		unsigned int locked_rate;
 	} stats;
 	struct softmix_bridge_data *bridge_data = bridge->bridge_pvt;
 	struct ast_timer *timer = bridge_data->timer;
@@ -258,6 +256,9 @@
 		/* these variables help determine if a rate change is required */
 		memset(&stats, 0, sizeof(stats));
 		stats.highest_supported_rate = 8000;
+		/* If the bridge has an internal sample rate set, we must lock in
+		 * on that rate */
+		stats.locked_rate = bridge->internal_sample_rate;
 
 		/* Go through pulling audio from each factory that has it available */
 		AST_LIST_TRAVERSE(&bridge->channels, bridge_channel, entry) {
@@ -334,11 +335,22 @@
 			pthread_kill(bridge_channel->thread, SIGURG);
 		}
 
+		update_all_rates = 0;
 		/* Re-adjust the internal bridge sample rate if
-		 * 1. two or more channels support a higher sample rate
-		 * 2. no channels support the current sample rate or a higher rate
+		 * 1. The bridge's internal sample rate is locked in at a sample
+		 *    rate other than the current sample rate being used.
+		 * 2. two or more channels support a higher sample rate
+		 * 3. no channels support the current sample rate or a higher rate
 		 */
-		if (stats.num_above_internal_rate >= 2) {
+		if (stats.locked_rate) {
+			/* if the rate is locked by the bridge, only update it if it differs
+			 * from the current rate we are using. */
+			if (bridge_data->internal_rate != stats.locked_rate) {
+				bridge_data->internal_rate = stats.locked_rate;
+				ast_debug(1, " Bridge is locked in at sample rate %d\n", bridge_data->internal_rate);
+				update_all_rates = 1;
+			}
+		} else if (stats.num_above_internal_rate >= 2) {
 			/* the highest rate is just used as a starting point */
 			unsigned int best_rate = stats.highest_supported_rate;
 			int best_index = -1;
@@ -363,13 +375,10 @@
 			bridge_data->internal_rate = best_rate;
 			update_all_rates = 1;
 		} else if (!stats.num_at_internal_rate && !stats.num_above_internal_rate) {
-			update_all_rates = 1;
 			/* in this case, the highest supported rate is actually lower than the internal rate */
 			bridge_data->internal_rate = stats.highest_supported_rate;
 			ast_debug(1, " Bridge changed from %d to %d\n", bridge_data->internal_rate, stats.highest_supported_rate);
 			update_all_rates = 1;
-		} else {
-			update_all_rates = 0;
 		}
 
 		ao2_unlock(bridge);

Modified: team/dvossel/hd_confbridge/configs/confbridge.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/hd_confbridge/configs/confbridge.conf.sample?view=diff&rev=309341&r1=309340&r2=309341
==============================================================================
--- team/dvossel/hd_confbridge/configs/confbridge.conf.sample (original)
+++ team/dvossel/hd_confbridge/configs/confbridge.conf.sample Thu Mar  3 09:55:52 2011
@@ -18,9 +18,8 @@
                           ; caller.  Off by default.
 ;announce_only_user=yes   ; Sets if the only user announcement should be played
                           ; when a channel enters a empty conference.  On by default.
-
-
-
+;wait_marked=yes      ; Sets if the user must wait for a marked user to enter before
+                      ; joining the conference. Off by default
 
 [default_bridge]
 type=bridge
@@ -32,9 +31,6 @@
                                ; closest sample rate Asterisk does support to the one requested
                                ; will be used.
 
-;wait_marked=yes      ; Sets if the conference must wait for a marked user
-                      ; to enter before starting. Off by default.
-
 [default_menu]
 type=menu
 

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=309341&r1=309340&r2=309341
==============================================================================
--- team/dvossel/hd_confbridge/include/asterisk/bridging.h (original)
+++ team/dvossel/hd_confbridge/include/asterisk/bridging.h Thu Mar  3 09:55:52 2011
@@ -149,6 +149,9 @@
 struct ast_bridge {
 	/*! Number of channels participating in the bridge */
 	int num;
+	/*! The internal sample rate this bridge is mixed at when multiple channels are being mixed.
+	 *  If this value is 0, the bridge technology may auto adjust the internal mixing rate. */
+	unsigned int internal_sample_rate;
 	/*! Bit to indicate that the bridge thread is waiting on channels in the bridge array */
 	unsigned int waiting:1;
 	/*! Bit to indicate the bridge thread should stop */
@@ -419,6 +422,17 @@
  */
 void ast_bridge_change_state(struct ast_bridge_channel *bridge_channel, enum ast_bridge_channel_state new_state);
 
+/*! \brief Adjust the internal mixing sample rate of a bridge used during
+ *         multimix mode.
+ *
+ * \param bridge_channel Channel to change the sample rate on.
+ * \param sample rate, the sample rate to change to. If a
+ *        value of 0 is passed here, the bridge will be free to pick
+ *        what ever sample rate it chooses.
+ *
+ */
+void ast_bridge_set_internal_sample_rate(struct ast_bridge *bridge, unsigned int sample_rate);
+
 #if defined(__cplusplus) || defined(c_plusplus)
 }
 #endif

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=309341&r1=309340&r2=309341
==============================================================================
--- team/dvossel/hd_confbridge/main/bridging.c (original)
+++ team/dvossel/hd_confbridge/main/bridging.c Thu Mar  3 09:55:52 2011
@@ -1357,3 +1357,11 @@
 
 	return 0;
 }
+
+void ast_bridge_set_internal_sample_rate(struct ast_bridge *bridge, unsigned int sample_rate)
+{
+
+	ao2_lock(bridge);
+	bridge->internal_sample_rate = sample_rate;
+	ao2_unlock(bridge);
+}




More information about the asterisk-commits mailing list