[asterisk-commits] qwell: branch 10-digiumphones r365396 - in /branches/10-digiumphones: ./ apps/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri May 4 16:28:31 CDT 2012


Author: qwell
Date: Fri May  4 16:28:27 2012
New Revision: 365396

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=365396
Log:
Add support for folders in MixMonitor 'm' option.  Backport manager actions.

The manager actions are needed, so MixMonitor can be executed on existing
channels.

(issue DPMA-68)
........

Merged revisions 365395 from http://svn.asterisk.org/svn/asterisk/certified/branches/1.8.11

Modified:
    branches/10-digiumphones/   (props changed)
    branches/10-digiumphones/apps/app_mixmonitor.c
    branches/10-digiumphones/apps/app_voicemail.c

Propchange: branches/10-digiumphones/
------------------------------------------------------------------------------
--- certified-branch-1.8.11-merged (original)
+++ certified-branch-1.8.11-merged Fri May  4 16:28:27 2012
@@ -1,1 +1,1 @@
-/certified/branches/1.8.11:364761
+/certified/branches/1.8.11:364761,365395

Modified: branches/10-digiumphones/apps/app_mixmonitor.c
URL: http://svnview.digium.com/svn/asterisk/branches/10-digiumphones/apps/app_mixmonitor.c?view=diff&rev=365396&r1=365395&r2=365396
==============================================================================
--- branches/10-digiumphones/apps/app_mixmonitor.c (original)
+++ branches/10-digiumphones/apps/app_mixmonitor.c Fri May  4 16:28:27 2012
@@ -112,7 +112,8 @@
 					<option name="m">
 						<argument name="mailbox" required="true" />
 						<para>Create a copy of the recording as a voicemail in each indicated <emphasis>mailbox</emphasis>
-						separated by commas eg. m(1111 at default,2222 at default,...)</para>
+						separated by commas eg. m(1111 at default,2222 at default,...).  Folders can be optionally specified using
+						the syntax: mailbox at context/folder</para>
 						<note><para>The recording will be deleted once all the copies are made.</para></note>
 					</option>
 				</optionlist>
@@ -173,6 +174,54 @@
 			<para>This action may be used to mute a MixMonitor recording.</para>
 		</description>
 	</manager>
+	<manager name="MixMonitor" language="en_US">
+		<synopsis>
+			Record a call and mix the audio during the recording.  Use of StopMixMonitor is required
+			to guarantee the audio file is available for processing during dialplan execution.
+		</synopsis>
+		<syntax>
+			<xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" />
+			<parameter name="Channel" required="true">
+				<para>Used to specify the channel to record.</para>
+			</parameter>
+			<parameter name="File">
+				<para>Is the name of the file created in the monitor spool directory.
+				Defaults to the same name as the channel (with slashes replaced with dashes).
+				This argument is optional if you specify to record unidirectional audio with
+				either the r(filename) or t(filename) options in the options field. If
+				neither MIXMONITOR_FILENAME or this parameter is set, the mixed stream won't
+				be recorded.</para>
+			</parameter>
+			<parameter name="options">
+				<para>Options that apply to the MixMonitor in the same way as they
+				would apply if invoked from the MixMonitor application. For a list of
+				available options, see the documentation for the mixmonitor application. </para>
+			</parameter>
+		</syntax>
+		<description>
+			<para>This action records the audio on the current channel to the specified file.</para>
+			<variablelist>
+				<variable name="MIXMONITOR_FILENAME">
+					<para>Will contain the filename used to record the mixed stream.</para>
+				</variable>
+			</variablelist>
+		</description>
+	</manager>
+	<manager name="StopMixMonitor" language="en_US">
+		<synopsis>
+			Stop recording a call through MixMonitor, and free the recording's file handle.
+		</synopsis>
+		<syntax>
+			<xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" />
+			<parameter name="Channel" required="true">
+				<para>The name of the channel monitored.</para>
+			</parameter>
+		</syntax>
+		<description>
+			<para>This action stops the audio recording that was started with the <literal>MixMonitor</literal>
+			action on the current channel.</para>
+		</description>
+	</manager>
 
  ***/
 
@@ -191,6 +240,7 @@
 struct vm_recipient {
 	char mailbox[AST_MAX_CONTEXT];
 	char context[AST_MAX_EXTENSION];
+	char folder[80];
 	AST_LIST_ENTRY(vm_recipient) list;
 };
 
@@ -359,9 +409,10 @@
  */
 static void add_vm_recipients_from_string(struct mixmonitor *mixmonitor, const char *vm_recipients)
 {
-	/* recipients are in a single string with a format format resembling "mailbox at context,mailbox2 at context2, mailbox3 at context3" */
+	/* recipients are in a single string with a format format resembling "mailbox at context/INBOX,mailbox2 at context2,mailbox3 at context3/Work" */
 	char *cur_mailbox = ast_strdupa(vm_recipients);
 	char *cur_context;
+	char *cur_folder;
 	char *next;
 	int elements_processed = 0;
 
@@ -371,6 +422,12 @@
 			*(next++) = '\0';
 		}
 
+		if ((cur_folder = strchr(cur_mailbox, '/'))) {
+			*(cur_folder++) = '\0';
+		} else {
+			cur_folder = "INBOX";
+		}
+
 		if ((cur_context = strchr(cur_mailbox, '@'))) {
 			*(cur_context++) = '\0';
 		} else {
@@ -378,7 +435,6 @@
 		}
 
 		if (!ast_strlen_zero(cur_mailbox) && !ast_strlen_zero(cur_context)) {
-
 			struct vm_recipient *recipient;
 			if (!(recipient = ast_malloc(sizeof(*recipient)))) {
 				ast_log(LOG_ERROR, "Failed to allocate recipient. Aborting function.\n");
@@ -386,11 +442,11 @@
 			}
 			ast_copy_string(recipient->context, cur_context, sizeof(recipient->context));
 			ast_copy_string(recipient->mailbox, cur_mailbox, sizeof(recipient->mailbox));
+			ast_copy_string(recipient->folder, cur_folder, sizeof(recipient->folder));
 
 			/* Add to list */
 			ast_verb(5, "Adding %s@%s to recipient list\n", recipient->mailbox, recipient->context);
 			AST_LIST_INSERT_HEAD(&mixmonitor->recipient_list, recipient, list);
-
 		} else {
 			ast_log(LOG_ERROR, "Failed to properly parse extension and/or context from element %d of recipient string: %s\n", elements_processed, vm_recipients);
 		}
@@ -491,9 +547,11 @@
 	recording_data.call_priority = mixmonitor->call_priority;
 
 	AST_LIST_TRAVERSE(&mixmonitor->recipient_list, recipient, list) {
-		/* context and mailbox need to be set per recipient */
+		/* context, mailbox, and folder need to be set per recipient */
 		ast_string_field_set(&recording_data, context, recipient->context);
 		ast_string_field_set(&recording_data, mailbox, recipient->mailbox);
+		ast_string_field_set(&recording_data, folder, recipient->folder);
+
 		ast_verb(4, "MixMonitor attempting to send voicemail copy to %s@%s\n", recording_data.mailbox,
 			recording_data.context);
 		ast_app_copy_recording_to_vm(&recording_data);
@@ -1064,6 +1122,95 @@
 	return AMI_SUCCESS;
 }
 
+static int manager_mixmonitor(struct mansession *s, const struct message *m)
+{
+	struct ast_channel *c = NULL;
+
+	const char *name = astman_get_header(m, "Channel");
+	const char *id = astman_get_header(m, "ActionID");
+	const char *file = astman_get_header(m, "File");
+	const char *options = astman_get_header(m, "Options");
+
+	int res;
+	char args[PATH_MAX] = "";
+	if (ast_strlen_zero(name)) {
+		astman_send_error(s, m, "No channel specified");
+		return AMI_SUCCESS;
+	}
+
+	c = ast_channel_get_by_name(name);
+
+	if (!c) {
+		astman_send_error(s, m, "No such channel");
+		return AMI_SUCCESS;
+	}
+
+	strcpy(args, file);
+	strcat(args, ",");
+	strcat(args, options);
+
+	ast_channel_lock(c);
+	res = mixmonitor_exec(c, args);
+	ast_channel_unlock(c);
+
+	if (res) {
+		astman_send_error(s, m, "Could not start monitoring channel");
+		return AMI_SUCCESS;
+	}
+
+	astman_append(s, "Response: Success\r\n");
+
+	if (!ast_strlen_zero(id)) {
+		astman_append(s, "ActionID: %s\r\n", id);
+	}
+
+	astman_append(s, "\r\n");
+
+	c = ast_channel_unref(c);
+
+	return AMI_SUCCESS;
+}
+
+static int manager_stop_mixmonitor(struct mansession *s, const struct message *m)
+{
+	struct ast_channel *c = NULL;
+
+	const char *name = astman_get_header(m, "Channel");
+	const char *id = astman_get_header(m, "ActionID");
+
+	int res;
+	if (ast_strlen_zero(name)) {
+		astman_send_error(s, m, "No channel specified");
+		return AMI_SUCCESS;
+	}
+
+	c = ast_channel_get_by_name(name);
+
+	if (!c) {
+		astman_send_error(s, m, "No such channel");
+		return AMI_SUCCESS;
+	}
+
+	res = stop_mixmonitor_exec(c, NULL);
+
+	if (res) {
+		astman_send_error(s, m, "Could not stop monitoring channel");
+		return AMI_SUCCESS;
+	}
+
+	astman_append(s, "Response: Success\r\n");
+
+	if (!ast_strlen_zero(id)) {
+		astman_append(s, "ActionID: %s\r\n", id);
+	}
+
+	astman_append(s, "\r\n");
+
+	c = ast_channel_unref(c);
+
+	return AMI_SUCCESS;
+}
+
 static struct ast_cli_entry cli_mixmonitor[] = {
 	AST_CLI_DEFINE(handle_cli_mixmonitor, "Execute a MixMonitor command")
 };
@@ -1076,6 +1223,8 @@
 	res = ast_unregister_application(stop_app);
 	res |= ast_unregister_application(app);
 	res |= ast_manager_unregister("MixMonitorMute");
+	res |= ast_manager_unregister("MixMonitor");
+	res |= ast_manager_unregister("StopMixMonitor");
 	
 	return res;
 }
@@ -1088,6 +1237,8 @@
 	res = ast_register_application_xml(app, mixmonitor_exec);
 	res |= ast_register_application_xml(stop_app, stop_mixmonitor_exec);
 	res |= ast_manager_register_xml("MixMonitorMute", 0, manager_mute_mixmonitor);
+	res |= ast_manager_register_xml("MixMonitor", 0, manager_mixmonitor);
+	res |= ast_manager_register_xml("StopMixMonitor", 0, manager_stop_mixmonitor);
 
 	return res;
 }

Modified: branches/10-digiumphones/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/branches/10-digiumphones/apps/app_voicemail.c?view=diff&rev=365396&r1=365395&r2=365396
==============================================================================
--- branches/10-digiumphones/apps/app_voicemail.c (original)
+++ branches/10-digiumphones/apps/app_voicemail.c Fri May  4 16:28:27 2012
@@ -5757,7 +5757,7 @@
 	/* At this point, the actual creation of a voicemail message should be finished.
 	 * Now we just need to copy the files being recorded into the receiving folder. */
 
-	create_dirpath(dir, sizeof(dir), recipient->context, recipient->mailbox, "INBOX");
+	create_dirpath(dir, sizeof(dir), recipient->context, recipient->mailbox, recdata->folder);
 
 #ifdef IMAP_STORAGE
 	/* make recipient info into an inboxcount friendly string */




More information about the asterisk-commits mailing list