Browse Source

deixar fonte pronto para compilar

remotes/origin/master
Rodgger 2 years ago
parent
commit
81d63f046b
  1. 1
      .gitignore
  2. 26
      Makefile
  3. 2
      agi.c
  4. 2
      base64.c
  5. BIN
      speech
  6. 34
      speech.c

1
.gitignore vendored

@ -1 +1,2 @@
a.out
*.o

26
Makefile

@ -0,0 +1,26 @@
## Compilar speech simplesip
##
##
##
##
CC=gcc
CFLAGS=-Wall -W
LIBS=-lcurl -ljansson
OBJ=\
speech.o\
agi.o\
base64.o
speech: $(OBJ)
$(CC) -o $@ $^ $(LIBS)
$(DIR_OBJ)%.o: $(DIR_SRC)%.c
$(CC) -c -o $@ $< $(CFLAGS)
clean:
rm *.o

2
agi.c

@ -3,7 +3,6 @@
#include <string.h>
#include "agi_c.h"
#include <stddef.h>
#include <regex.h>
#define STR_ARG_USER "agi_arg_"
@ -192,7 +191,6 @@ int agi_verbose_all_param(s_agi_parameter *param){
char str[300];
snprintf( str, 300, "VERBOSE \"DEBUG (%s: %s)\" \n", (param->key == NULL ? " " : param->key), (param->value == NULL ? "NULL" : param->value ) );
int n = 0;
agi_clear_response( agi_command(str) );
param = param->next;

2
base64.c

@ -12,7 +12,7 @@
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
/* Base64 encoder/decoder. Originally Apache file ap_base64.c
Base64 encoder/decoder. Originally Apache file ap_base64.c
*/
#include <string.h>

BIN
speech

Binary file not shown.

34
teste.c → speech.c

@ -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,
Loading…
Cancel
Save