[asterisk-commits] res agi: Allow configuration of audio format of EAGI pipe (asterisk[13])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu May 25 19:01:19 CDT 2017


George Joseph has submitted this change and it was merged. ( https://gerrit.asterisk.org/5706 )

Change subject: res_agi: Allow configuration of audio format of EAGI pipe
......................................................................


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
---
M CHANGES
M res/res_agi.c
2 files changed, 30 insertions(+), 3 deletions(-)

Approvals:
  George Joseph: Looks good to me, but someone else must approve; Approved for Submit
  Joshua Colp: Looks good to me, approved



diff --git a/CHANGES b/CHANGES
index 7ae196c..94405bf 100644
--- a/CHANGES
+++ b/CHANGES
@@ -9,6 +9,17 @@
 ==============================================================================
 
 ------------------------------------------------------------------------------
+--- Functionality changes from Asterisk 13.16.0 to Asterisk 13.17.0 ----------
+------------------------------------------------------------------------------
+
+res_agi
+------------------
+ * The EAGI() application will now look for a dialplan variable named
+   EAGI_AUDIO_FORMAT and use that format with the 'enhanced' audio pipe that
+   EAGI provides. If not specified, it will continue to use the default signed
+   linear (slin).
+
+------------------------------------------------------------------------------
 --- Functionality changes from Asterisk 13.15.0 to Asterisk 13.16.0 ----------
 ------------------------------------------------------------------------------
 
diff --git a/res/res_agi.c b/res/res_agi.c
index cd0d621..aace243 100644
--- a/res/res_agi.c
+++ b/res/res_agi.c
@@ -4554,15 +4554,30 @@
 {
 	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 @@
 				ast_format_get_name(readformat));
 		}
 	}
-	ao2_ref(readformat, -1);
+	ao2_cleanup(requested_format);
+	ao2_cleanup(readformat);
 	return res;
 }
 

-- 
To view, visit https://gerrit.asterisk.org/5706
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I7a10fad401ad2a21c68c2e7246fa357d5cee5bbd
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>



More information about the asterisk-commits mailing list