[asterisk-commits] file: trunk r358730 - in /trunk: ./ apps/ apps/confbridge/ apps/confbridge/in...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Mar 10 14:06:51 CST 2012


Author: file
Date: Sat Mar 10 14:06:46 2012
New Revision: 358730

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=358730
Log:
Transition app_page to using app_confbridge internally for the conference bridge portion of paging. This also adds a new 'announcement' option to ConfBridge user profiles.

Modified:
    trunk/CHANGES
    trunk/apps/app_confbridge.c
    trunk/apps/app_page.c
    trunk/apps/confbridge/conf_config_parser.c
    trunk/apps/confbridge/include/confbridge.h
    trunk/configs/confbridge.conf.sample
    trunk/include/asterisk/dial.h
    trunk/main/dial.c

Modified: trunk/CHANGES
URL: http://svnview.digium.com/svn/asterisk/trunk/CHANGES?view=diff&rev=358730&r1=358729&r2=358730
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Sat Mar 10 14:06:46 2012
@@ -39,6 +39,8 @@
    occurs to be overriden using sound_participants_unmuted and sound_participants_muted.
  * Added menu action participant_count.  This will playback the number of current
    participants in a conference.
+ * Added announcement configuration option to user profile. If set the sound file will
+   be played to the user, and only the user, upon joining the conference bridge.
 
 Voicemail
 ------------------

Modified: trunk/apps/app_confbridge.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_confbridge.c?view=diff&rev=358730&r1=358729&r2=358730
==============================================================================
--- trunk/apps/app_confbridge.c (original)
+++ trunk/apps/app_confbridge.c Sat Mar 10 14:06:46 2012
@@ -997,6 +997,17 @@
 		ast_devstate_changed(AST_DEVICE_INUSE, "confbridge:%s", conference_bridge->name);
 	}
 
+	/* If an announcement is to be played play it */
+	if (!ast_strlen_zero(conference_bridge_user->u_profile.announcement)) {
+		if (play_prompt_to_channel(conference_bridge,
+					   conference_bridge_user->chan,
+					   conference_bridge_user->u_profile.announcement)) {
+			ao2_unlock(conference_bridge);
+			leave_conference_bridge(conference_bridge, conference_bridge_user);
+			return NULL;
+		}
+	}
+
 	/* 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 | USER_OPT_WAITMARKED)) {
 		if (post_join_marked(conference_bridge, conference_bridge_user)) {

Modified: trunk/apps/app_page.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_page.c?view=diff&rev=358730&r1=358729&r2=358730
==============================================================================
--- trunk/apps/app_page.c (original)
+++ trunk/apps/app_page.c Sat Mar 10 14:06:46 2012
@@ -26,8 +26,7 @@
  */
 
 /*** MODULEINFO
-	<depend>dahdi</depend>
-	<depend>app_meetme</depend>
+	<depend>app_confbridge</depend>
 	<support_level>core</support_level>
  ***/
 
@@ -76,7 +75,7 @@
 						<para>Quiet, do not play beep to caller</para>
 					</option>
 					<option name="r">
-						<para>Record the page into a file (meetme option <literal>r</literal>)</para>
+						<para>Record the page into a file (ConfBridge option <literal>r</literal>)</para>
 					</option>
 					<option name="s">
 						<para>Only dial a channel if its device state says that it is <literal>NOT_INUSE</literal></para>
@@ -105,7 +104,7 @@
 			destroyed when the original callers leaves.</para>
 		</description>
 		<see-also>
-			<ref type="application">MeetMe</ref>
+			<ref type="application">ConfBridge</ref>
 		</see-also>
 	</application>
  ***/
@@ -136,12 +135,46 @@
 	AST_APP_OPTION('n', PAGE_NOCALLERANNOUNCE),
 });
 
+/* We use this structure as a way to pass this to all dialed channels */
+struct page_options {
+	char *opts[OPT_ARG_ARRAY_SIZE];
+	struct ast_flags flags;
+};
+
+static void page_state_callback(struct ast_dial *dial)
+{
+	struct ast_channel *chan;
+	struct page_options *options;
+
+	if (ast_dial_state(dial) != AST_DIAL_RESULT_ANSWERED ||
+	    !(chan = ast_dial_answered(dial)) ||
+	    !(options = ast_dial_get_user_data(dial))) {
+		return;
+	}
+
+	ast_func_write(chan, "CONFBRIDGE(bridge,template)", "default_bridge");
+
+	if (ast_test_flag(&options->flags, PAGE_RECORD)) {
+		ast_func_write(chan, "CONFBRIDGE(bridge,record_conference)", "yes");
+	}
+
+	ast_func_write(chan, "CONFBRIDGE(user,quiet)", "yes");
+	ast_func_write(chan, "CONFBRIDGE(user,end_marked)", "yes");
+
+	if (!ast_test_flag(&options->flags, PAGE_DUPLEX)) {
+		ast_func_write(chan, "CONFBRIDGE(user,startmuted)", "yes");
+	}
+
+	if (ast_test_flag(&options->flags, PAGE_ANNOUNCE) && !ast_strlen_zero(options->opts[OPT_ARG_ANNOUNCE])) {
+		ast_func_write(chan, "CONFBRIDGE(user,announcement)", options->opts[OPT_ARG_ANNOUNCE]);
+	}
+}
 
 static int page_exec(struct ast_channel *chan, const char *data)
 {
 	char *tech, *resource, *tmp;
-	char meetmeopts[128], originator[AST_CHANNEL_NAME], *opts[OPT_ARG_ARRAY_SIZE];
-	struct ast_flags flags = { 0 };
+	char confbridgeopts[128], originator[AST_CHANNEL_NAME];
+	struct page_options options = { { 0, }, { 0, } };
 	unsigned int confid = ast_random();
 	struct ast_app *app;
 	int res = 0, pos = 0, i = 0;
@@ -161,8 +194,8 @@
 		return -1;
 	}
 
-	if (!(app = pbx_findapp("MeetMe"))) {
-		ast_log(LOG_WARNING, "There is no MeetMe application available!\n");
+	if (!(app = pbx_findapp("ConfBridge"))) {
+		ast_log(LOG_WARNING, "There is no ConfBridge application available!\n");
 		return -1;
 	};
 
@@ -176,20 +209,14 @@
 	}
 
 	if (!ast_strlen_zero(args.options)) {
-		ast_app_parse_options(page_opts, &flags, opts, args.options);
+		ast_app_parse_options(page_opts, &options.flags, options.opts, args.options);
 	}
 
 	if (!ast_strlen_zero(args.timeout)) {
 		timeout = atoi(args.timeout);
 	}
 
-	if (ast_test_flag(&flags, PAGE_ANNOUNCE) && !ast_strlen_zero(opts[OPT_ARG_ANNOUNCE])) {
-		snprintf(meetmeopts, sizeof(meetmeopts), "MeetMe,%ud,%s%sqxdw(5)G(%s)", confid, (ast_test_flag(&flags, PAGE_DUPLEX) ? "" : "m"),
-						 (ast_test_flag(&flags, PAGE_RECORD) ? "r" : ""), opts[OPT_ARG_ANNOUNCE] );
-	} else {
-		snprintf(meetmeopts, sizeof(meetmeopts), "MeetMe,%ud,%s%sqxdw(5)", confid, (ast_test_flag(&flags, PAGE_DUPLEX) ? "" : "m"),
-		(ast_test_flag(&flags, PAGE_RECORD) ? "r" : "") );
-	}
+	snprintf(confbridgeopts, sizeof(confbridgeopts), "ConfBridge,%u", confid);
 
 	/* Count number of extensions in list by number of ampersands + 1 */
 	num_dials = 1;
@@ -222,7 +249,7 @@
 		}
 
 		/* Ensure device is not in use if skip option is enabled */
-		if (ast_test_flag(&flags, PAGE_SKIP)) {
+		if (ast_test_flag(&options.flags, PAGE_SKIP)) {
 			state = ast_device_state(tech);
 			if (state == AST_DEVICE_UNKNOWN) {
 				ast_log(LOG_WARNING, "Destination '%s' has device state '%s'. Paging anyway.\n", tech, ast_devstate2str(state));
@@ -247,15 +274,18 @@
 		}
 
 		/* Set ANSWER_EXEC as global option */
-		ast_dial_option_global_enable(dial, AST_DIAL_OPTION_ANSWER_EXEC, meetmeopts);
+		ast_dial_option_global_enable(dial, AST_DIAL_OPTION_ANSWER_EXEC, confbridgeopts);
 
 		if (timeout) {
 			ast_dial_set_global_timeout(dial, timeout * 1000);
 		}
 
-		if (ast_test_flag(&flags, PAGE_IGNORE_FORWARDS)) {
+		if (ast_test_flag(&options.flags, PAGE_IGNORE_FORWARDS)) {
 			ast_dial_option_global_enable(dial, AST_DIAL_OPTION_DISABLE_CALL_FORWARDING, NULL);
 		}
+
+		ast_dial_set_state_callback(dial, &page_state_callback);
+		ast_dial_set_user_data(dial, &options);
 
 		/* Run this dial in async mode */
 		ast_dial_run(dial, chan, 1);
@@ -264,29 +294,32 @@
 		dial_list[pos++] = dial;
 	}
 
-	if (!ast_test_flag(&flags, PAGE_QUIET)) {
+	if (!ast_test_flag(&options.flags, PAGE_QUIET)) {
 		res = ast_streamfile(chan, "beep", ast_channel_language(chan));
 		if (!res)
 			res = ast_waitstream(chan, "");
 	}
 
 	if (!res) {
-		/* Default behaviour */
-		snprintf(meetmeopts, sizeof(meetmeopts), "%ud,A%s%sqxd", confid, (ast_test_flag(&flags, PAGE_DUPLEX) ? "" : "t"), 
-			(ast_test_flag(&flags, PAGE_RECORD) ? "r" : "") );
-		if (ast_test_flag(&flags, PAGE_ANNOUNCE) && !ast_strlen_zero(opts[OPT_ARG_ANNOUNCE]) &&
-				!ast_test_flag(&flags, PAGE_NOCALLERANNOUNCE)) {
-			snprintf(meetmeopts, sizeof(meetmeopts), "%ud,A%s%sqxdG(%s)", confid, (ast_test_flag(&flags, PAGE_DUPLEX) ? "" : "t"), 
- 			  (ast_test_flag(&flags, PAGE_RECORD) ? "r" : ""), opts[OPT_ARG_ANNOUNCE] );
-		}
-		pbx_exec(chan, app, meetmeopts);
+		ast_func_write(chan, "CONFBRIDGE(bridge,template)", "default_bridge");
+
+		if (ast_test_flag(&options.flags, PAGE_RECORD)) {
+			ast_func_write(chan, "CONFBRIDGE(bridge,record_conference)", "yes");
+		}
+
+		ast_func_write(chan, "CONFBRIDGE(user,quiet)", "yes");
+		ast_func_write(chan, "CONFBRIDGE(user,marked)", "yes");
+
+		snprintf(confbridgeopts, sizeof(confbridgeopts), "%u", confid);
+
+		pbx_exec(chan, app, confbridgeopts);
 	}
 
 	/* Go through each dial attempt cancelling, joining, and destroying */
 	for (i = 0; i < pos; i++) {
 		struct ast_dial *dial = dial_list[i];
 
-		/* We have to wait for the async thread to exit as it's possible Meetme won't throw them out immediately */
+		/* We have to wait for the async thread to exit as it's possible ConfBridge won't throw them out immediately */
 		ast_dial_join(dial);
 
 		/* Hangup all channels */

Modified: trunk/apps/confbridge/conf_config_parser.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/confbridge/conf_config_parser.c?view=diff&rev=358730&r1=358729&r2=358730
==============================================================================
--- trunk/apps/confbridge/conf_config_parser.c (original)
+++ trunk/apps/confbridge/conf_config_parser.c Sat Mar 10 14:06:46 2012
@@ -187,6 +187,8 @@
 		ast_copy_string(u_profile->pin, value, sizeof(u_profile->pin));
 	} else if (!strcasecmp(name, "music_on_hold_class")) {
 		ast_copy_string(u_profile->moh_class, value, sizeof(u_profile->moh_class));
+	} else if (!strcasecmp(name, "announcement")) {
+		ast_copy_string(u_profile->announcement, value, sizeof(u_profile->announcement));
 	} else if (!strcasecmp(name, "denoise")) {
 		ast_set2_flag(u_profile, ast_true(value), USER_OPT_DENOISE);
 	} else if (!strcasecmp(name, "dsp_talking_threshold")) {
@@ -515,6 +517,7 @@
 	u_profile->talking_threshold = DEFAULT_TALKING_THRESHOLD;
 	memset(u_profile->pin, 0, sizeof(u_profile->pin));
 	memset(u_profile->moh_class, 0, sizeof(u_profile->moh_class));
+	memset(u_profile->announcement, 0, sizeof(u_profile->announcement));
 	for (var = ast_variable_browse(cfg, cat); var; var = var->next) {
 		if (!strcasecmp(var->name, "type")) {
 			continue;
@@ -859,6 +862,8 @@
 	ast_cli(a->fd,"MOH Class:               %s\n",
 		ast_strlen_zero(u_profile.moh_class) ?
 		"default" : u_profile.moh_class);
+	ast_cli(a->fd,"Announcement:            %s\n",
+		u_profile.announcement);
 	ast_cli(a->fd,"Quiet:                   %s\n",
 		u_profile.flags & USER_OPT_QUIET ?
 		"enabled" : "disabled");

Modified: trunk/apps/confbridge/include/confbridge.h
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/confbridge/include/confbridge.h?view=diff&rev=358730&r1=358729&r2=358730
==============================================================================
--- trunk/apps/confbridge/include/confbridge.h (original)
+++ trunk/apps/confbridge/include/confbridge.h Sat Mar 10 14:06:46 2012
@@ -128,6 +128,7 @@
 	char name[128];
 	char pin[MAX_PIN];
 	char moh_class[128];
+	char announcement[PATH_MAX];
 	unsigned int flags;
 	unsigned int announce_user_count_all_after;
 	/*! The time in ms of talking before a user is considered to be talking by the dsp. */

Modified: trunk/configs/confbridge.conf.sample
URL: http://svnview.digium.com/svn/asterisk/trunk/configs/confbridge.conf.sample?view=diff&rev=358730&r1=358729&r2=358730
==============================================================================
--- trunk/configs/confbridge.conf.sample (original)
+++ trunk/configs/confbridge.conf.sample Sat Mar 10 14:06:46 2012
@@ -126,6 +126,7 @@
                          ; the conference. This option is off by default.
 ;dtmf_passthrough=yes  ; Sets whether or not DTMF should pass through the conference.
                        ; This option is off by default.
+;announcement=</path/to/file> ; Play a sound file to the user when they join the conference.
 
 ; --- ConfBridge Bridge Profile Options ---
 [default_bridge]

Modified: trunk/include/asterisk/dial.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/dial.h?view=diff&rev=358730&r1=358729&r2=358730
==============================================================================
--- trunk/include/asterisk/dial.h (original)
+++ trunk/include/asterisk/dial.h Sat Mar 10 14:06:46 2012
@@ -152,6 +152,19 @@
  */
 void ast_dial_set_state_callback(struct ast_dial *dial, ast_dial_state_callback callback);
 
+/*! \brief Set user data on a dial structure
+ * \param dial The dial structure to set a user data pointer on
+ * \param user_data The user data pointer
+ * \return nothing
+ */
+void ast_dial_set_user_data(struct ast_dial *dial, void *user_data);
+
+/*! \brief Return the user data on a dial structure
+ * \param dial The dial structure
+ * \return A pointer to the user data
+ */
+void *ast_dial_get_user_data(struct ast_dial *dial);
+
 /*! \brief Set the maximum time (globally) allowed for trying to ring phones
  * \param dial The dial structure to apply the time limit to
  * \param timeout Maximum time allowed in milliseconds

Modified: trunk/main/dial.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/dial.c?view=diff&rev=358730&r1=358729&r2=358730
==============================================================================
--- trunk/main/dial.c (original)
+++ trunk/main/dial.c Sat Mar 10 14:06:46 2012
@@ -47,6 +47,7 @@
 	enum ast_dial_result state;                        /*!< Status of dial */
 	void *options[AST_DIAL_OPTION_MAX];                /*!< Global options */
 	ast_dial_state_callback state_callback;            /*!< Status callback */
+	void *user_data;                                   /*!< Attached user data */
 	AST_LIST_HEAD(, ast_dial_channel) channels; /*!< Channels being dialed */
 	pthread_t thread;                                  /*!< Thread (if running in async) */
 	ast_mutex_t lock;                                  /*! Lock to protect the thread information above */
@@ -1049,6 +1050,16 @@
 	dial->state_callback = callback;
 }
 
+void ast_dial_set_user_data(struct ast_dial *dial, void *user_data)
+{
+	dial->user_data = user_data;
+}
+
+void *ast_dial_get_user_data(struct ast_dial *dial)
+{
+	return dial->user_data;
+}
+
 /*! \brief Set the maximum time (globally) allowed for trying to ring phones
  * \param dial The dial structure to apply the time limit to
  * \param timeout Maximum time allowed




More information about the asterisk-commits mailing list