apps/app_mixmonitor: Add Options To Play Beep At Start Or Stop
authorMichael L. Young <elgueromexicano@gmail.com>
Tue, 22 Jul 2014 20:01:42 +0000 (20:01 +0000)
committerMichael L. Young <elgueromexicano@gmail.com>
Tue, 22 Jul 2014 20:01:42 +0000 (20:01 +0000)
We have a new periodic beep feature but sometimes a user needs some sort of
feedback, without the need to have a periodic beep during the recording, to let
them know that MixMonitor started recording or ended the recording.  The use
case where this patch is being used is when using Dynamic Features to start and
end MixMonitor.

This patch adds an option to play a beep when MixMonitor starts and an option to
play a beep when MixMonitor ends.

ASTERISK-24051 #close
Reported by: Michael L. Young
patches:
  mixmonitor-play-beep-start-stop.diff
                                     uploaded by Michael L. Young (license 5026)

Review: https://reviewboard.asterisk.org/r/3820/

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@419238 65c4cc65-6c06-0410-ace0-fbb531ad65f3

CHANGES
apps/app_mixmonitor.c

diff --git a/CHANGES b/CHANGES
index 112efa7..c6957d3 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -182,6 +182,13 @@ res_config_pgsql
    for res_config_pgsql via the dbappname configuration setting in
    res_pgsql.conf.
 
    for res_config_pgsql via the dbappname configuration setting in
    res_pgsql.conf.
 
+MixMonitor
+------------------
+ * New options to play a beep when starting a recording and stopping a recording
+   have been added.  The option "p" will play a beep to the channel that starts
+   the recording.  The option "P" will play a beep to the channel that stops the
+   recording.
+
 ------------------------------------------------------------------------------
 --- Functionality changes from Asterisk 12.4.0 to Asterisk 12.5.0 ------------
 ------------------------------------------------------------------------------
 ------------------------------------------------------------------------------
 --- Functionality changes from Asterisk 12.4.0 to Asterisk 12.5.0 ------------
 ------------------------------------------------------------------------------
@@ -367,7 +374,6 @@ MixMonitor
  * A new option, B(), has been added that will turn on a periodic beep while the
    call is being recorded.
 
  * A new option, B(), has been added that will turn on a periodic beep while the
    call is being recorded.
 
-
 Channel Drivers
 -------------------------
 
 Channel Drivers
 -------------------------
 
index 1e7833c..5212894 100644 (file)
@@ -120,6 +120,12 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
                                                <argument name="chanvar" required="true" />
                                                <para>Stores the MixMonitor's ID on this channel variable.</para>
                                        </option>
                                                <argument name="chanvar" required="true" />
                                                <para>Stores the MixMonitor's ID on this channel variable.</para>
                                        </option>
+                                       <option name="p">
+                                               <para>Play a beep on the channel that starts the recording.</para>
+                                       </option>
+                                       <option name="P">
+                                               <para>Play a beep on the channel that stops the recording.</para>
+                                       </option>
                                        <option name="m">
                                                <argument name="mailbox" required="true" />
                                                <para>Create a copy of the recording as a voicemail in the indicated <emphasis>mailbox</emphasis>(es)
                                        <option name="m">
                                                <argument name="mailbox" required="true" />
                                                <para>Create a copy of the recording as a voicemail in the indicated <emphasis>mailbox</emphasis>(es)
@@ -326,6 +332,8 @@ enum mixmonitor_flags {
        MUXFLAG_UID = (1 << 9),
        MUXFLAG_VMRECIPIENTS = (1 << 10),
        MUXFLAG_BEEP = (1 << 11),
        MUXFLAG_UID = (1 << 9),
        MUXFLAG_VMRECIPIENTS = (1 << 10),
        MUXFLAG_BEEP = (1 << 11),
+       MUXFLAG_BEEP_START = (1 << 12),
+       MUXFLAG_BEEP_STOP = (1 << 13)
 };
 
 enum mixmonitor_args {
 };
 
 enum mixmonitor_args {
@@ -344,6 +352,8 @@ AST_APP_OPTIONS(mixmonitor_opts, {
        AST_APP_OPTION('a', MUXFLAG_APPEND),
        AST_APP_OPTION('b', MUXFLAG_BRIDGED),
        AST_APP_OPTION_ARG('B', MUXFLAG_BEEP, OPT_ARG_BEEP_INTERVAL),
        AST_APP_OPTION('a', MUXFLAG_APPEND),
        AST_APP_OPTION('b', MUXFLAG_BRIDGED),
        AST_APP_OPTION_ARG('B', MUXFLAG_BEEP, OPT_ARG_BEEP_INTERVAL),
+       AST_APP_OPTION('p', MUXFLAG_BEEP_START),
+       AST_APP_OPTION('P', MUXFLAG_BEEP_STOP),
        AST_APP_OPTION_ARG('v', MUXFLAG_READVOLUME, OPT_ARG_READVOLUME),
        AST_APP_OPTION_ARG('V', MUXFLAG_WRITEVOLUME, OPT_ARG_WRITEVOLUME),
        AST_APP_OPTION_ARG('W', MUXFLAG_VOLUME, OPT_ARG_VOLUME),
        AST_APP_OPTION_ARG('v', MUXFLAG_READVOLUME, OPT_ARG_READVOLUME),
        AST_APP_OPTION_ARG('V', MUXFLAG_WRITEVOLUME, OPT_ARG_WRITEVOLUME),
        AST_APP_OPTION_ARG('W', MUXFLAG_VOLUME, OPT_ARG_VOLUME),
@@ -733,6 +743,11 @@ static void *mixmonitor_thread(void *obj)
                                                                        "File: %s\r\n",
                                                                        ast_channel_name(mixmonitor->autochan->chan),
                                                                        mixmonitor->filename);
                                                                        "File: %s\r\n",
                                                                        ast_channel_name(mixmonitor->autochan->chan),
                                                                        mixmonitor->filename);
+       ast_channel_lock(mixmonitor->autochan->chan);
+       if (ast_test_flag(mixmonitor, MUXFLAG_BEEP_STOP)) {
+               ast_stream_and_wait(mixmonitor->autochan->chan, "beep", "");
+       }
+       ast_channel_unlock(mixmonitor->autochan->chan);
 
        ast_audiohook_unlock(&mixmonitor->audiohook);
 
 
        ast_audiohook_unlock(&mixmonitor->audiohook);
 
@@ -805,6 +820,11 @@ static int setup_mixmonitor_ds(struct mixmonitor *mixmonitor, struct ast_channel
                return -1;
        }
 
                return -1;
        }
 
+       ast_channel_lock(mixmonitor->autochan->chan);
+       if (ast_test_flag(mixmonitor, MUXFLAG_BEEP_START)) {
+               ast_stream_and_wait(mixmonitor->autochan->chan, "beep", "");
+       }
+       ast_channel_unlock(mixmonitor->autochan->chan);
 
        mixmonitor_ds->samp_rate = 8000;
        mixmonitor_ds->audiohook = &mixmonitor->audiohook;
 
        mixmonitor_ds->samp_rate = 8000;
        mixmonitor_ds->audiohook = &mixmonitor->audiohook;
@@ -1164,6 +1184,7 @@ static int stop_mixmonitor_full(struct ast_channel *chan, const char *data)
        if (!ast_channel_datastore_remove(chan, datastore)) {
                ast_datastore_free(datastore);
        }
        if (!ast_channel_datastore_remove(chan, datastore)) {
                ast_datastore_free(datastore);
        }
+
        ast_channel_unlock(chan);
 
        if (!ast_strlen_zero(beep_id)) {
        ast_channel_unlock(chan);
 
        if (!ast_strlen_zero(beep_id)) {