Asterisk EAGI: Difference between revisions
Jump to navigation
Jump to search
Line 43: | Line 43: | ||
Patch: | Patch: | ||
<pre> | <pre>--- res/res_agi.c.original 2016-06-19 17:39:06.554220638 +0200 | ||
+++ res/res_agi.c 2016-06-19 20:48:41.901887183 +0200 | |||
@@ -4194,13 +4194,27 @@ | |||
{ | |||
int res; | |||
struct ast_format *readformat; | |||
+ struct ast_format *requested_format; | |||
+ char *ret; | |||
+ char tempstr[1024] = ""; | |||
if (ast_check_hangup(chan)) { | |||
ast_log(LOG_ERROR, "EAGI cannot be run on a dead/hungup channel, please use AGI.\n"); | |||
return 0; | |||
} | |||
readformat = ao2_bump(ast_channel_readformat(chan)); | |||
- if (ast_set_read_format(chan, ast_format_slin)) { | |||
+ | |||
+ // set format according to EAGI_AUDIO_FORMAT variable else use sln | |||
+ pbx_retrieve_variable(chan, "EAGI_AUDIO_FORMAT", &ret, tempstr, sizeof(tempstr), NULL); | |||
+ ast_verb(3, "EAGI_AUDIO_FORMAT = %s\n", tempstr); | |||
+ requested_format = __ast_format_cache_get(tempstr); | |||
+ if (requested_format == NULL) { | |||
+ requested_format = ast_format_slin; | |||
+ ast_verb(3, "Setting EAGI audio format to default slin\n"); | |||
+ } else { | |||
+ ast_verb(3, "Setting EAGI audio format to requested %s\n",tempstr); | |||
+ } | |||
+ if (ast_set_read_format(chan, requested_format)) { | |||
ast_log(LOG_WARNING, "Unable to set channel '%s' to linear mode\n", ast_channel_name(chan)); | |||
ao2_ref(readformat, -1); | |||
return -1; | |||
</pre> | |||
Values for the format are: | Values for the format are: |
Revision as of 19:59, 19 June 2016
FreePBX Patch needed to be able to use EAGI
--- extensions.class.original.php 2016-06-18 19:23:14.009320154 +0200 +++ extensions.class.php 2016-06-18 15:54:11.273444005 +0200 @@ -1251,6 +1251,11 @@ return "AGI(".$this->data.")"; } } +class ext_eagi extends extension { + function output() { + return "EAGI(".$this->data.")"; + } +} class ext_deadagi extends extension { function output() { return "DeadAGI(".$this->data.")";
PHPAGI patch to the version distributed in FreePBX to be able to open EAGI audio stream
--- phpagi.dist.php 2016-06-19 09:07:55.475372158 +0200 +++ phpagi.php 2016-06-19 09:46:12.734317454 +0200 @@ -173,10 +173,10 @@ // open audio if eagi detected if($this->request['agi_enhanced'] == '1.0') { - if(file_exists('/proc/' . getmypid() . '/fd/3')) + if (array_search('php',stream_get_wrappers())!==FALSE) { // this should work on linux - $this->audio = fopen('/proc/' . getmypid() . '/fd/3', 'r'); + $this->audio = fopen('php://fd/' . AUDIO_FILENO, 'r'); } elseif(file_exists('/dev/fd/3')) {
Asterisk patch to configure EAGI audio stream format
With this patch, use the following in the dialplan prior to calling an EAGI script. The following example shows how to set 48kHz LPCM single channel 16 bit signed audio:
set(EAGI_AUDIO_FORMAT=slin48)
Note slin48 not sln48
Patch:
--- res/res_agi.c.original 2016-06-19 17:39:06.554220638 +0200 +++ res/res_agi.c 2016-06-19 20:48:41.901887183 +0200 @@ -4194,13 +4194,27 @@ { int res; struct ast_format *readformat; + struct ast_format *requested_format; + char *ret; + char tempstr[1024] = ""; if (ast_check_hangup(chan)) { ast_log(LOG_ERROR, "EAGI cannot be run on a dead/hungup channel, please use AGI.\n"); return 0; } readformat = ao2_bump(ast_channel_readformat(chan)); - if (ast_set_read_format(chan, ast_format_slin)) { + + // set format according to EAGI_AUDIO_FORMAT variable else use sln + pbx_retrieve_variable(chan, "EAGI_AUDIO_FORMAT", &ret, tempstr, sizeof(tempstr), NULL); + ast_verb(3, "EAGI_AUDIO_FORMAT = %s\n", tempstr); + requested_format = __ast_format_cache_get(tempstr); + if (requested_format == NULL) { + requested_format = ast_format_slin; + ast_verb(3, "Setting EAGI audio format to default slin\n"); + } else { + ast_verb(3, "Setting EAGI audio format to requested %s\n",tempstr); + } + if (ast_set_read_format(chan, requested_format)) { ast_log(LOG_WARNING, "Unable to set channel '%s' to linear mode\n", ast_channel_name(chan)); ao2_ref(readformat, -1); return -1;
Values for the format are:
- g723
- ulaw
- alaw
- gsm
- g726
- g726aal2
- adpcm
- slin
- slin12
- slin16
- slin24
- slin32
- slin44
- slin48
- slin96
- slin192
- lpc10
- g729
- speex
- speex16
- speex32
- ilbc
- g722
- siren7
- siren14
- testlaw
- g719
- opus
- jpeg ??? (seems unlikely)
- png ??? (seems unlikely)
- h261
- h263
- h263p
- h264
- mpeg4
- vp8
- red
- t140