]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
app_mixmonitor: Add option to delete files on exit.
authorNaveen Albert <asterisk@phreaknet.org>
Thu, 3 Nov 2022 20:56:01 +0000 (20:56 +0000)
committerGeorge Joseph <gjoseph@digium.com>
Tue, 8 Nov 2022 19:46:50 +0000 (13:46 -0600)
Adds an option that allows MixMonitor to delete
its copy of any recording files before exiting.

This can be handy in conjunction with options
like m, which copy the file elsewhere, and the
original files may no longer be needed.

ASTERISK-30284 #close

Change-Id: Ida093679c67e300efc154a97b6d8ec0f104e581e

apps/app_mixmonitor.c
doc/CHANGES-staging/app_mixmonitor_delete.txt [new file with mode: 0644]

index a0eb1dbf5deaf99e1783b74b33a2f01dbec7f2fc..e2b9e8c148bc57307934bec9bb41d03d9a900e4c 100644 (file)
                                                <para>Play a periodic beep while this call is being recorded.</para>
                                                <argument name="interval"><para>Interval, in seconds. Default is 15.</para></argument>
                                        </option>
+                                       <option name="d">
+                                               <para>Delete the recording file as soon as MixMonitor is done with it.</para>
+                                               <para>For example, if you use the m option to dispatch the recording to a voicemail box,
+                                               you can specify this option to delete the original copy of it afterwards.</para>
+                                       </option>
                                        <option name="v">
                                                <para>Adjust the <emphasis>heard</emphasis> volume by a factor of <replaceable>x</replaceable>
                                                (range <literal>-4</literal> to <literal>4</literal>)</para>
@@ -407,6 +412,7 @@ enum mixmonitor_flags {
        MUXFLAG_BEEP_STOP = (1 << 13),
        MUXFLAG_DEPRECATED_RWSYNC = (1 << 14),
        MUXFLAG_NO_RWSYNC = (1 << 15),
+       MUXFLAG_AUTO_DELETE = (1 << 16),
 };
 
 enum mixmonitor_args {
@@ -427,6 +433,7 @@ 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('d', MUXFLAG_AUTO_DELETE),
        AST_APP_OPTION('p', MUXFLAG_BEEP_START),
        AST_APP_OPTION('P', MUXFLAG_BEEP_STOP),
        AST_APP_OPTION_ARG('v', MUXFLAG_READVOLUME, OPT_ARG_READVOLUME),
@@ -860,6 +867,19 @@ static void *mixmonitor_thread(void *obj)
                ast_debug(3, "No recipients to forward monitor to, moving on.\n");
        }
 
+       if (ast_test_flag(mixmonitor, MUXFLAG_AUTO_DELETE)) {
+               ast_debug(3, "Deleting our copies of recording files\n");
+               if (!ast_strlen_zero(fs_ext)) {
+                       ast_filedelete(mixmonitor->filename, fs_ext);
+               }
+               if (!ast_strlen_zero(fs_read_ext)) {
+                       ast_filedelete(mixmonitor->filename_read, fs_ext);
+               }
+               if (!ast_strlen_zero(fs_write_ext)) {
+                       ast_filedelete(mixmonitor->filename_write, fs_ext);
+               }
+       }
+
        mixmonitor_free(mixmonitor);
 
        ast_module_unref(ast_module_info->self);
diff --git a/doc/CHANGES-staging/app_mixmonitor_delete.txt b/doc/CHANGES-staging/app_mixmonitor_delete.txt
new file mode 100644 (file)
index 0000000..924c9c0
--- /dev/null
@@ -0,0 +1,6 @@
+Subject: app_mixmonitor
+
+The d option for MixMonitor now allows deleting
+the original recording when MixMonitor exits,
+which can be useful when MixMonitor copies it
+somewhere else before exiting.