[Asterisk-code-review] app chanspy: reduce audio loss on the spying channel. (asterisk[master])
Jean Aunis - Prescom
asteriskteam at digium.com
Fri Apr 1 07:52:53 CDT 2016
Jean Aunis - Prescom has uploaded a new change for review.
https://gerrit.asterisk.org/2520
Change subject: app_chanspy: reduce audio loss on the spying channel.
......................................................................
app_chanspy: reduce audio loss on the spying channel.
ChanSpy was creating its audiohook with the flags AST_AUDIOHOOK_TRIGGER_SYNC
and AST_AUDIOHOOK_SMALL_QUEUE, which caused audio frames to be lost in some
cases. Now these flags are set conditionally:
- AST_AUDIOHOOK_TRIGGER_SYNC is not set if the option "o" is set
- a new option "l" is created: if set, AST_AUDIOHOOK_SMALL_QUEUE will not
be set on the audiohook
ASTERISK-25866
Change-Id: I9c7652f41d9fa72c8691e4e70ec4fd16b047a4dd
---
M apps/app_chanspy.c
1 file changed, 24 insertions(+), 8 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/20/2520/1
diff --git a/apps/app_chanspy.c b/apps/app_chanspy.c
index 5dbb0b8..4212d4e 100644
--- a/apps/app_chanspy.c
+++ b/apps/app_chanspy.c
@@ -117,6 +117,10 @@
either a single group or a colon-delimited list of groups, such
as <literal>sales:support:accounting</literal>.</para></note>
</option>
+ <option name="l">
+ <para>Allow usage of a long queue to store audio frames.</para>
+ <note><para>This may introduce some delay in the received audio feed, but will improve the audio quality.</para></note>
+ </option>
<option name="n" argsep="@">
<para>Say the name of the person being spied on if that person has recorded
his/her name. If a context is specified, then that voicemail context will
@@ -262,6 +266,10 @@
either a single group or a colon-delimited list of groups, such
as <literal>sales:support:accounting</literal>.</para></note>
</option>
+ <option name="l">
+ <para>Allow usage of a long queue to store audio frames.</para>
+ <note><para>This may introduce some delay in the received audio feed, but will improve the audio quality.</para></note>
+ </option>
<option name="n" argsep="@">
<para>Say the name of the person being spied on if that person has recorded
his/her name. If a context is specified, then that voicemail context will
@@ -386,6 +394,7 @@
OPTION_STOP = (1 << 17),
OPTION_EXITONHANGUP = (1 << 18), /* Hang up when the spied-on channel hangs up. */
OPTION_UNIQUEID = (1 << 19), /* The chanprefix is a channel uniqueid or fully specified channel name. */
+ OPTION_LONG_QUEUE = (1 << 20), /* Allow usage of a long queue to store audio frames. */
};
enum {
@@ -407,6 +416,7 @@
AST_APP_OPTION_ARG('e', OPTION_ENFORCED, OPT_ARG_ENFORCED),
AST_APP_OPTION('E', OPTION_EXITONHANGUP),
AST_APP_OPTION_ARG('g', OPTION_GROUP, OPT_ARG_GROUP),
+ AST_APP_OPTION('l', OPTION_LONG_QUEUE),
AST_APP_OPTION_ARG('n', OPTION_NAME, OPT_ARG_NAME),
AST_APP_OPTION('o', OPTION_READONLY),
AST_APP_OPTION('q', OPTION_QUIET),
@@ -496,11 +506,17 @@
.generate = spy_generate,
};
-static int start_spying(struct ast_autochan *autochan, const char *spychan_name, struct ast_audiohook *audiohook)
+static int start_spying(struct ast_autochan *autochan, const char *spychan_name, struct ast_audiohook *audiohook, struct ast_flags *flags)
{
ast_log(LOG_NOTICE, "Attaching %s to %s\n", spychan_name, ast_channel_name(autochan->chan));
-
- ast_set_flag(audiohook, AST_AUDIOHOOK_TRIGGER_SYNC | AST_AUDIOHOOK_SMALL_QUEUE);
+ if(!ast_test_flag(flags, OPTION_READONLY)) {
+ ast_set_flag(audiohook, AST_AUDIOHOOK_TRIGGER_SYNC);
+ }
+ if(ast_test_flag(flags, OPTION_LONG_QUEUE)) {
+ ast_debug(9, "Using a long queue to store audio frames in spy audiohook\n");
+ } else {
+ ast_set_flag(audiohook, AST_AUDIOHOOK_SMALL_QUEUE);
+ }
return ast_audiohook_attach(autochan->chan, audiohook);
}
@@ -581,7 +597,7 @@
static int attach_barge(struct ast_autochan *spyee_autochan,
struct ast_autochan **spyee_bridge_autochan, struct ast_audiohook *bridge_whisper_audiohook,
- const char *spyer_name, const char *name)
+ const char *spyer_name, const char *name, struct ast_flags *flags)
{
int retval = 0;
struct ast_autochan *internal_bridge_autochan;
@@ -599,7 +615,7 @@
}
ast_autochan_channel_lock(internal_bridge_autochan);
- if (start_spying(internal_bridge_autochan, spyer_name, bridge_whisper_audiohook)) {
+ if (start_spying(internal_bridge_autochan, spyer_name, bridge_whisper_audiohook, flags)) {
ast_log(LOG_WARNING, "Unable to attach barge audiohook on spyee '%s'. Barge mode disabled.\n", name);
retval = -1;
}
@@ -647,7 +663,7 @@
*/
ast_audiohook_init(&csth.spy_audiohook, AST_AUDIOHOOK_TYPE_SPY, "ChanSpy", 0);
- if (start_spying(spyee_autochan, spyer_name, &csth.spy_audiohook)) {
+ if (start_spying(spyee_autochan, spyer_name, &csth.spy_audiohook, flags)) {
ast_audiohook_destroy(&csth.spy_audiohook);
return 0;
}
@@ -658,7 +674,7 @@
*/
ast_audiohook_init(&csth.whisper_audiohook, AST_AUDIOHOOK_TYPE_WHISPER, "ChanSpy", 0);
- if (start_spying(spyee_autochan, spyer_name, &csth.whisper_audiohook)) {
+ if (start_spying(spyee_autochan, spyer_name, &csth.whisper_audiohook, flags)) {
ast_log(LOG_WARNING, "Unable to attach whisper audiohook to spyee %s. Whisper mode disabled!\n", name);
}
}
@@ -710,7 +726,7 @@
* be attached and we'll need to continue attempting to attach the barge
* audio hook. */
if (!bridge_connected && attach_barge(spyee_autochan, &spyee_bridge_autochan,
- &csth.bridge_whisper_audiohook, spyer_name, name) == 0) {
+ &csth.bridge_whisper_audiohook, spyer_name, name, flags) == 0) {
bridge_connected = 1;
}
--
To view, visit https://gerrit.asterisk.org/2520
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9c7652f41d9fa72c8691e4e70ec4fd16b047a4dd
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Jean Aunis - Prescom <jean.aunis at prescom.fr>
More information about the asterisk-code-review
mailing list