summaryrefslogtreecommitdiff
path: root/res
diff options
context:
space:
mode:
authorSean Bright <sean.bright@gmail.com>2017-05-23 16:42:04 -0400
committerSean Bright <sean.bright@gmail.com>2017-05-23 16:46:47 -0400
commit90237dca11d0adf129198cef4a6a0716a52618b5 (patch)
treeb467d72d5180f610b8e707e8e8420b56920508ba /res
parentd0a1239f5560810662c84f38ebc342a39072e093 (diff)
res_agi: Allow configuration of audio format of EAGI pipe
This change allows the format of the EAGI audio pipe to be changed by setting the dialplan variable 'EAGI_AUDIO_FORMAT' to the name of one of the loaded formats. ASTERISK-26124 #close Change-Id: I7a10fad401ad2a21c68c2e7246fa357d5cee5bbd
Diffstat (limited to 'res')
-rw-r--r--res/res_agi.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/res/res_agi.c b/res/res_agi.c
index cd0d621eb..aace243ca 100644
--- a/res/res_agi.c
+++ b/res/res_agi.c
@@ -4554,15 +4554,30 @@ static int eagi_exec(struct ast_channel *chan, const char *data)
{
int res;
struct ast_format *readformat;
+ struct ast_format *requested_format = NULL;
+ const char *requested_format_name;
if (ast_check_hangup(chan)) {
ast_log(LOG_ERROR, "EAGI cannot be run on a dead/hungup channel, please use AGI.\n");
return 0;
}
+
+ requested_format_name = pbx_builtin_getvar_helper(chan, "EAGI_AUDIO_FORMAT");
+ if (requested_format_name) {
+ requested_format = ast_format_cache_get(requested_format_name);
+ if (requested_format) {
+ ast_verb(3, "<%s> Setting EAGI audio pipe format to %s\n",
+ ast_channel_name(chan), ast_format_get_name(requested_format));
+ } else {
+ ast_log(LOG_ERROR, "Could not find requested format: %s\n", requested_format_name);
+ }
+ }
+
readformat = ao2_bump(ast_channel_readformat(chan));
- if (ast_set_read_format(chan, ast_format_slin)) {
+ if (ast_set_read_format(chan, requested_format ?: ast_format_slin)) {
ast_log(LOG_WARNING, "Unable to set channel '%s' to linear mode\n", ast_channel_name(chan));
- ao2_ref(readformat, -1);
+ ao2_cleanup(requested_format);
+ ao2_cleanup(readformat);
return -1;
}
res = agi_exec_full(chan, data, 1, 0);
@@ -4572,7 +4587,8 @@ static int eagi_exec(struct ast_channel *chan, const char *data)
ast_format_get_name(readformat));
}
}
- ao2_ref(readformat, -1);
+ ao2_cleanup(requested_format);
+ ao2_cleanup(readformat);
return res;
}