mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 03:20:57 +00:00
audiohook.c: Substitute silence for unavailable audio frames
There are 4 scenarios to consider when capturing audio from a channel with an audiohook: 1. There is no rx and no tx audio, so return nothing. 2. There is rx but no tx audio, so return rx. 3. There is tx but no rx audio, so return tx. 4. There is rx and tx audio, so mix them and return. The file passed as the primary argument to MixMonitor will be written to in scenarios 2, 3, and 4. However, if you pass the r() and t() options to MixMonitor, a frame will only be written to the r() file if there was rx audio and a frame will only be written to the t() file if there was tx audio. If you subsequently take the r() and t() files and try to mix them, the sides of the conversation will 'drift' and be non-representative of the user experience. This patch adds a new 'S' option to MixMonitor that injects a frame of silence on either the r() side or the t() side of the channel so that when later mixed, there is no such drift. Change-Id: Ibf5ed73a811087727bd561a89a59f4447b4ee20e
This commit is contained in:
@@ -115,6 +115,11 @@
|
||||
Like with the basic filename argument, if an absolute path isn't given, it will create
|
||||
the file in the configured monitoring directory.</para>
|
||||
</option>
|
||||
<option name="S">
|
||||
<para>When combined with the <replaceable>r</replaceable> or <replaceable>t</replaceable>
|
||||
option, inserts silence when necessary to maintain synchronization between the receive
|
||||
and transmit audio streams.</para>
|
||||
</option>
|
||||
<option name="i">
|
||||
<argument name="chanvar" required="true" />
|
||||
<para>Stores the MixMonitor's ID on this channel variable.</para>
|
||||
@@ -347,7 +352,8 @@ enum mixmonitor_flags {
|
||||
MUXFLAG_VMRECIPIENTS = (1 << 10),
|
||||
MUXFLAG_BEEP = (1 << 11),
|
||||
MUXFLAG_BEEP_START = (1 << 12),
|
||||
MUXFLAG_BEEP_STOP = (1 << 13)
|
||||
MUXFLAG_BEEP_STOP = (1 << 13),
|
||||
MUXFLAG_RWSYNC = (1 << 14),
|
||||
};
|
||||
|
||||
enum mixmonitor_args {
|
||||
@@ -359,6 +365,7 @@ enum mixmonitor_args {
|
||||
OPT_ARG_UID,
|
||||
OPT_ARG_VMRECIPIENTS,
|
||||
OPT_ARG_BEEP_INTERVAL,
|
||||
OPT_ARG_RWSYNC,
|
||||
OPT_ARG_ARRAY_SIZE, /* Always last element of the enum */
|
||||
};
|
||||
|
||||
@@ -375,6 +382,7 @@ AST_APP_OPTIONS(mixmonitor_opts, {
|
||||
AST_APP_OPTION_ARG('t', MUXFLAG_WRITE, OPT_ARG_WRITENAME),
|
||||
AST_APP_OPTION_ARG('i', MUXFLAG_UID, OPT_ARG_UID),
|
||||
AST_APP_OPTION_ARG('m', MUXFLAG_VMRECIPIENTS, OPT_ARG_VMRECIPIENTS),
|
||||
AST_APP_OPTION_ARG('S', MUXFLAG_RWSYNC, OPT_ARG_RWSYNC),
|
||||
});
|
||||
|
||||
struct mixmonitor_ds {
|
||||
@@ -962,6 +970,9 @@ static int launch_monitor_thread(struct ast_channel *chan, const char *filename,
|
||||
}
|
||||
|
||||
ast_set_flag(&mixmonitor->audiohook, AST_AUDIOHOOK_TRIGGER_SYNC);
|
||||
if ((ast_test_flag(mixmonitor, MUXFLAG_RWSYNC))) {
|
||||
ast_set_flag(&mixmonitor->audiohook, AST_AUDIOHOOK_SUBSTITUTE_SILENCE);
|
||||
}
|
||||
|
||||
if (readvol)
|
||||
mixmonitor->audiohook.options.read_volume = readvol;
|
||||
|
Reference in New Issue
Block a user