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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Mar 21 15:43:45 CDT 2011


Author: dvossel
Date: Mon Mar 21 15:43:40 2011
New Revision: 311491

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=311491
Log:
Addition of the 'template' option for CONFBRIDGE function.

The 'template' option allows a bridge/user profile defined
in confbridge.conf to be used as a starting point when defining
a dynamic bridge/user profile using the CONFBRIDGE dialplan
function.

Modified:
    team/dvossel/hd_confbridge/apps/app_confbridge.c
    team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.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=311491&r1=311490&r2=311491
==============================================================================
--- team/dvossel/hd_confbridge/apps/app_confbridge.c (original)
+++ team/dvossel/hd_confbridge/apps/app_confbridge.c Mon Mar 21 15:43:40 2011
@@ -63,6 +63,7 @@
                     </parameter>
                     <parameter name="bridge_profile">
                             <para>The bridge profile name from confbridge.conf.  When left blank, the 'default_bridge' profile found in confbridge.conf will be used if present.</para>
+                            <para>It is important to note that while user profiles may be unique for each participant, mixing bridge profiles on a single conference is _NOT_ recommended and will produce undefined results.</para>
                     </parameter>
                     <parameter name="user_profile">
                             <para>The user profile name from confbridge.conf.  When left blank, the 'default_user' profile found in confbridge.conf will be used if present.</para>
@@ -79,7 +80,7 @@
     </application>
 	<function name="CONFBRIDGE" language="en_US">
 		<synopsis>
-			Set a custom dynamic bridge and user profile on a channel for the ConfBridge application.
+			Set a custom dynamic bridge and user profile on a channel for the ConfBridge application using the same options defined in confbridge.conf.
 		</synopsis>
 		<syntax>
 			<parameter name="type" required="true">
@@ -90,11 +91,19 @@
 			</parameter>
 		</syntax>
 		<description>
-            <para>Examples:</para>
+            <para>---- Example 1 ----</para>
+			<para>In this example the custom set user profile on this channel will automatically be used by the ConfBridge app.</para> 
             <para>exten => 1,1,Answer() </para>
-            <para>exten => 1,n,Set(CONFBRIDGE(user,announce_join_leave)=yes) ;Have the user record a name before entering </para>
-            <para>exten => 1,n,Set(CONFBRIDGE(user,startmuted)=yes) ; start the user muted</para>
-            <para>exten => 1,n,ConfBridge(1) ; The custom set user profile on this channel will automatically be used. </para>
+            <para>exten => 1,n,Set(CONFBRIDGE(user,announce_join_leave)=yes)</para>
+            <para>exten => 1,n,Set(CONFBRIDGE(user,startmuted)=yes)</para>
+            <para>exten => 1,n,ConfBridge(1) </para>
+            <para>---- Example 2 ----</para>
+			<para>This example shows how to use a predefined user or bridge profile in confbridge.conf as a template for a dynamic profile. Here we make a admin/marked user out of the default_user profile that is already defined in confbridge.conf.</para> 
+            <para>exten => 1,1,Answer() </para>
+            <para>exten => 1,n,Set(CONFBRIDGE(user,template)=default_user)</para>
+            <para>exten => 1,n,Set(CONFBRIDGE(user,admin)=yes)</para>
+            <para>exten => 1,n,Set(CONFBRIDGE(user,marked)=yes)</para>
+            <para>exten => 1,n,ConfBridge(1)</para>
 		</description>
 	</function>
  ***/
@@ -560,16 +569,6 @@
 
 	if (conference_bridge && conference_bridge->b_profile.max_members) {
 		max_members_reached = conference_bridge->b_profile.max_members > conference_bridge->users ? 0 : 1;
-	}
-
-	if (conference_bridge && strcasecmp(conference_bridge->b_profile.name, conference_bridge_user->b_profile.name)) {
-		ast_log(LOG_ERROR, "Conference bridge '%s' found, but user bridge profile %s does not match the conference's bridge profile %s\n",
-			name,
-			conference_bridge_user->b_profile.name,
-			conference_bridge->b_profile.name);
-		ao2_unlock(conference_bridges);
-		ao2_ref(conference_bridge, -1);
-		return NULL;
 	}
 
 	/* When finding a conference bridge that already exists make sure that it is not locked, and if so that we are not an admin */

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=311491&r1=311490&r2=311491
==============================================================================
--- team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c (original)
+++ team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c Mon Mar 21 15:43:40 2011
@@ -207,6 +207,8 @@
 		u_profile->flags = ast_true(value) ?
 			u_profile->flags | USER_OPT_DROP_SILENCE :
 			u_profile->flags & ~USER_OPT_DROP_SILENCE;
+	} else if (!strcasecmp(name, "template") && !(conf_find_user_profile(NULL, value, u_profile))) {
+		return -1;
 	} else {
 		return -1;
 	}
@@ -277,6 +279,40 @@
 		if (set_sound(name, value, b_profile->sounds)) {
 			return -1;
 		}
+	} else if (!strcasecmp(name, "template")) { /* Only documented for use in CONFBRIDGE dialplan function */
+		struct bridge_profile *tmp = b_profile;
+		struct bridge_profile_sounds *sounds = bridge_profile_sounds_alloc();
+		struct bridge_profile_sounds *oldsounds = b_profile->sounds;
+		if (!sounds) {
+			return -1;
+		}
+		if (!(conf_find_bridge_profile(NULL, value, tmp))) {
+			ao2_ref(sounds, -1);
+			return -1;
+		}
+		/* Using a bridge profile as a template is a little complicated due to the sounds. Since the sounds
+		 * structure of a dynamic profile will need to be altered, a completely new sounds structure must be
+		 * create instead of simply holding a reference to the one built by the config file. */
+		ast_string_field_set(sounds, onlyperson, tmp->sounds->onlyperson);
+		ast_string_field_set(sounds, hasjoin, tmp->sounds->hasjoin);
+		ast_string_field_set(sounds, hasleft, tmp->sounds->hasleft);
+		ast_string_field_set(sounds, kicked, tmp->sounds->kicked);
+		ast_string_field_set(sounds, muted, tmp->sounds->muted);
+		ast_string_field_set(sounds, unmuted, tmp->sounds->unmuted);
+		ast_string_field_set(sounds, thereare, tmp->sounds->thereare);
+		ast_string_field_set(sounds, otherinparty, tmp->sounds->otherinparty);
+		ast_string_field_set(sounds, placeintoconf, tmp->sounds->placeintoconf);
+		ast_string_field_set(sounds, waitforleader, tmp->sounds->waitforleader);
+		ast_string_field_set(sounds, getpin, tmp->sounds->getpin);
+		ast_string_field_set(sounds, invalidpin, tmp->sounds->invalidpin);
+		ast_string_field_set(sounds, locked, tmp->sounds->locked);
+		ast_string_field_set(sounds, unlockednow, tmp->sounds->unlockednow);
+		ast_string_field_set(sounds, lockednow, tmp->sounds->lockednow);
+		ast_string_field_set(sounds, errormenu, tmp->sounds->errormenu);
+
+		ao2_ref(tmp->sounds, -1); /* sounds struct copied over to it from the template by reference only. */
+		ao2_ref(oldsounds,-1);    /* original sounds struct we don't need anymore */
+		tmp->sounds = sounds;     /* the new sounds struct that is a deep copy of the one from the template. */
 	} else {
 		return -1;
 	}
@@ -1107,16 +1143,18 @@
 	struct func_confbridge_data *b_data = NULL;
 	ast_copy_string(tmp.name, user_profile_name, sizeof(tmp.name));
 
-	ast_channel_lock(chan);
-	if ((datastore = ast_channel_datastore_find(chan, &confbridge_datastore, NULL))) {
+	if (chan) {
+		ast_channel_lock(chan);
+		if ((datastore = ast_channel_datastore_find(chan, &confbridge_datastore, NULL))) {
+			ast_channel_unlock(chan);
+			b_data = datastore->data;
+			if (b_data->u_usable) {
+				memcpy(result, &b_data->u_profile, sizeof(*result));
+				return result;
+			}
+		}
 		ast_channel_unlock(chan);
-		b_data = datastore->data;
-		if (b_data->u_usable) {
-			memcpy(result, &b_data->u_profile, sizeof(*result));
-			return result;
-		}
-	}
-	ast_channel_unlock(chan);
+	}
 
 	if (ast_strlen_zero(user_profile_name)) {
 		user_profile_name = DEFAULT_USER_PROFILE;
@@ -1156,17 +1194,18 @@
 	struct func_confbridge_data *b_data = NULL;
 	ast_copy_string(tmp.name, bridge_profile_name, sizeof(tmp.name));
 
-	ast_channel_lock(chan);
-	if ((datastore = ast_channel_datastore_find(chan, &confbridge_datastore, NULL))) {
+	if (chan) {
+		ast_channel_lock(chan);
+		if ((datastore = ast_channel_datastore_find(chan, &confbridge_datastore, NULL))) {
+			ast_channel_unlock(chan);
+			b_data = datastore->data;
+			if (b_data->b_usable) {
+				conf_bridge_profile_copy(result, &b_data->b_profile);
+				return result;
+			}
+		}
 		ast_channel_unlock(chan);
-		b_data = datastore->data;
-		if (b_data->b_usable) {
-			conf_bridge_profile_copy(result, &b_data->b_profile);
-			return result;
-		}
-	}
-	ast_channel_unlock(chan);
-
+	}
 	if (ast_strlen_zero(bridge_profile_name)) {
 		bridge_profile_name = DEFAULT_BRIDGE_PROFILE;
 	}




More information about the asterisk-commits mailing list