|
|
|
@ -47,10 +47,10 @@ int covert_flac( );
|
|
|
|
|
struct b_audio * get_audio_bytes( ); |
|
|
|
|
struct response_google *send_network( s_agi_parameter *param_agi, struct b_audio *b_flac ); |
|
|
|
|
int copy_to_struct( struct b_audio *b_flac, char *str, size_t p ); |
|
|
|
|
char *http_content(CURL *curl, s_agi_parameter *param_agi, struct b_audio *b_flac); |
|
|
|
|
char *http_content(CURL *curl, struct b_audio *b_flac); |
|
|
|
|
size_t response_curl(void *contents, size_t size, size_t nmemb, void *userp); |
|
|
|
|
|
|
|
|
|
int main(int argc, char **argv){ |
|
|
|
|
int main(){ |
|
|
|
|
s_agi_parameter *param_agi = NULL; |
|
|
|
|
s_agi_return *response = NULL; |
|
|
|
|
|
|
|
|
@ -114,6 +114,11 @@ int main(int argc, char **argv){
|
|
|
|
|
|
|
|
|
|
struct response_google *p = send_network( param_agi, b_flac ); |
|
|
|
|
|
|
|
|
|
if(!p){ |
|
|
|
|
AGI_NORESPONSE( "VERBOSE \"erro libcurl\"\n" ); |
|
|
|
|
exit(-1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
json_t *j = json_loads(p->response, 0, NULL); |
|
|
|
|
if(!j){ |
|
|
|
|
AGI_NORESPONSE( "VERBOSE \"erro json_loads\"\n" ); |
|
|
|
@ -258,14 +263,14 @@ int verify_param_asterisk( s_agi_parameter *param ){
|
|
|
|
|
value = get_param_n( param, 3 ); |
|
|
|
|
if( value ){ |
|
|
|
|
if( !strcmp( value, "NOBEEP" )){ |
|
|
|
|
strncpy( beep, " ", 1); |
|
|
|
|
beep[0] = '\0'; |
|
|
|
|
} |
|
|
|
|
else{ |
|
|
|
|
strncpy( beep, "BEEP", 4); /* BEEP default */ |
|
|
|
|
strncpy( beep, "BEEP", 5); /* BEEP default */ |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else{ |
|
|
|
|
strncpy( beep, "BEEP", 4); |
|
|
|
|
strncpy( beep, "BEEP", 5); |
|
|
|
|
} |
|
|
|
|
// AGI_NORESPONSE( "VERBOSE \"beep %s\" \n", beep);
|
|
|
|
|
|
|
|
|
@ -275,17 +280,17 @@ int verify_param_asterisk( s_agi_parameter *param ){
|
|
|
|
|
if( value ){ |
|
|
|
|
int abtime = atoi(value); |
|
|
|
|
if( abtime == 0 ){ |
|
|
|
|
strncpy( abs_timeout, "5000", 4 );/* valor default */ |
|
|
|
|
strncpy( abs_timeout, "5000", 5 );/* valor default */ |
|
|
|
|
} |
|
|
|
|
else if(abtime == -1){ |
|
|
|
|
strncpy( abs_timeout, "-1", 2 ); |
|
|
|
|
strncpy( abs_timeout, "-1", 3 ); |
|
|
|
|
} |
|
|
|
|
else{ |
|
|
|
|
snprintf( abs_timeout, sizeof abs_timeout, "%d", abs_timeout ); |
|
|
|
|
snprintf( abs_timeout, sizeof abs_timeout, "%d", abtime ); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else{ |
|
|
|
|
strncpy( abs_timeout, "5000", 4 );/* valor default */ |
|
|
|
|
strncpy( abs_timeout, "5000", 5 );/* valor default */ |
|
|
|
|
} |
|
|
|
|
// AGI_NORESPONSE("VERBOSE \"abs_timeout %s\" \n", abs_timeout);
|
|
|
|
|
|
|
|
|
@ -310,13 +315,13 @@ int create_temporary_file(){
|
|
|
|
|
|
|
|
|
|
/* Converter o audio sln -> flac */ |
|
|
|
|
int covert_flac( ){ |
|
|
|
|
char str_convert[512]; |
|
|
|
|
char str_convert[4500]; |
|
|
|
|
/* line perl
|
|
|
|
|
* system($flac, $comp_level, "--totally-silent", "--channels=1", "--endian=$endian", |
|
|
|
|
* "--sign=signed", "--bps=16", "--force-raw-format", "--sample-rate=$samplerate", |
|
|
|
|
* "$tmpname.$format") == 0 or die "$name $flac failed: $?\n"; |
|
|
|
|
*/ |
|
|
|
|
snprintf( str_convert, 512, "%s -8 --totally-silent --channels=1 --endian=little \
|
|
|
|
|
snprintf( str_convert, 4500, "%s -8 --totally-silent --channels=1 --endian=little \
|
|
|
|
|
--sign=signed --bps=16 --force-raw-format --sample-rate=8000 \
|
|
|
|
|
\"%s.sln\"", flac, name_audio ); |
|
|
|
|
return system( str_convert ); |
|
|
|
@ -435,7 +440,7 @@ struct response_google *send_network( s_agi_parameter *param_agi, struct b_audi
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); |
|
|
|
|
|
|
|
|
|
char *content = NULL; |
|
|
|
|
content = http_content(curl, param_agi, b_flac); |
|
|
|
|
content = http_content(curl, b_flac); |
|
|
|
|
if(!content){ |
|
|
|
|
AGI_NORESPONSE("VERBOSE \"content NULL. Programa terminado \"\n"); |
|
|
|
|
} |
|
|
|
@ -453,6 +458,8 @@ struct response_google *send_network( s_agi_parameter *param_agi, struct b_audi
|
|
|
|
|
AGI_NORESPONSE("VERBOSE \"curl != CURLE_OK \"\n"); |
|
|
|
|
exit(-1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return http_response; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -503,12 +510,13 @@ int copy_to_struct( struct b_audio *b_flac, char *str, size_t p ){
|
|
|
|
|
if(final == 1){ |
|
|
|
|
b_flac->bytes_encode[b_flac->nmemb_encode] = '\0'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* post da variável com base64 */ |
|
|
|
|
char *http_content(CURL *curl, s_agi_parameter *param_agi, struct b_audio *b_flac){ |
|
|
|
|
char *http_content(CURL *curl, struct b_audio *b_flac){ |
|
|
|
|
/* my %config = (
|
|
|
|
|
"encoding" => "FLAC", |
|
|
|
|
"sampleRateHertz" => $samplerate, |