diff options
author | anthm <anthm@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-07-02 22:40:09 +0000 |
---|---|---|
committer | anthm <anthm@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-07-02 22:40:09 +0000 |
commit | a5d644afc81be27f8fd17d3bdc93eb7774ddf915 (patch) | |
tree | 7aaa890e04411db065f6eff94d9611787c69d30a | |
parent | c2a463a19ac227bd26a3e09a90c0cf4b7f6f1e15 (diff) |
autodial update
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@3377 f38db490-d61c-443f-a65b-d21fe96a405b
-rwxr-xr-x | Makefile | 12 | ||||
-rwxr-xr-x | codecs/Makefile | 40 | ||||
-rwxr-xr-x | include/asterisk/cdr.h | 4 | ||||
-rwxr-xr-x | include/asterisk/manager.h | 3 | ||||
-rwxr-xr-x | res/res_musiconhold.c | 194 |
5 files changed, 187 insertions, 66 deletions
@@ -194,6 +194,13 @@ endif CC=gcc INSTALL=install + +####### res_perl +LIBS += $(shell /usr/local/bin/perl -MExtUtils::Embed -e ldopts) $(shell perl -MConfig -e 'print $$Config{libs}') +PERLCFLAGS += $(shell /usr/local/bin/perl -MExtUtils::Embed -e ccopts) +OBJS += perlxsi.o +####### /res_perl + _all: all @echo " +--------- Asterisk Build Complete ---------+" @echo " + Asterisk has successfully been built, but +" @@ -205,6 +212,11 @@ _all: all all: depend asterisk subdirs +####### res_perl +perlxsi.o: + $(CC) -c perlxsi.c $(PERLCFLAGS) -o perlxsi.o +####### /res_perl + editline/config.h: cd editline && unset CFLAGS LIBS && ./configure ; \ diff --git a/codecs/Makefile b/codecs/Makefile index 43c4e13db..9a1d561e7 100755 --- a/codecs/Makefile +++ b/codecs/Makefile @@ -16,9 +16,12 @@ # and have placed it in the g723.1 directory and/or the Annex-B code in # g723.1b) # -#MODG723=codec_g723_1.so codec_g723_1b.so +MODG723=codec_g723_1.so codec_g723_1b.so MODG723=$(shell [ -f g723.1/coder.c ] && echo "codec_g723_1.so") MODG723+=$(shell [ -f g723.1b/coder2.c ] && echo "codec_g723_1b.so") +MODG729=$(shell [ -f g729cp/codld8cp.c ] && echo "codec_g729.so") +MODG729+=$(shell [ -f g729abc/cod_ld8a.c ] && echo "codec_g729ab.so") +MODG729+=$(shell [ -f g729bc/cod_ld8c.c ] && echo "codec_g729b.so") MODSPEEX=$(shell [ -f /usr/include/speex.h ] || [ -f /usr/local/include/speex.h ] && echo "codec_speex.so") MODILBC=$(shell [ -f ilbc/iLBC_decode.h ] && echo "codec_ilbc.so") CFLAGS+=-fPIC @@ -26,6 +29,9 @@ CFLAGS+=$(shell [ -f /usr/local/include/speex.h ] && echo "-I/usr/local/include" LIBG723=g723.1/libg723.a LIBG723B=g723.1b/libg723b.a +LIBG729=g729cp/libg729.a +LIBG729AB=g729abc/libg729ab.a +LIBG729B=g729bc/libg729b.a LIBGSM=gsm/lib/libgsm.a LIBGSMT=gsm/lib/libgsm.a LIBLPC10=lpc10/liblpc10.a @@ -33,7 +39,7 @@ LIBSPEEX=$(shell [ -f /usr/local/lib/libspeex.a ] && echo "-L/usr/local/lib") LIBSPEEX+=-lspeex -lm LIBILBC=ilbc/libilbc.a -CODECS+=$(MODG723) $(MODSPEEX) $(MODILBC) codec_gsm.so codec_lpc10.so \ +CODECS+=$(MODG723) $(MODSPEEX) $(MODILBC) $(MODG729) codec_gsm.so codec_lpc10.so \ codec_adpcm.so codec_ulaw.so codec_alaw.so codec_a_mu.so \ codec_g726.so @@ -43,6 +49,9 @@ clean: rm -f *.so *.o .depend ! [ -d g723.1 ] || $(MAKE) -C g723.1 clean ! [ -d g723.1b ] || $(MAKE) -C g723.1b clean + ! [ -d g729abc ] || $(MAKE) -C g729abc clean + ! [ -d g729bc ] || $(MAKE) -C g729bc clean + ! [ -d g729cp ] || $(MAKE) -C g729cp clean $(MAKE) -C gsm clean $(MAKE) -C lpc10 clean $(MAKE) -C ilbc clean @@ -50,6 +59,15 @@ clean: $(LIBG723): $(MAKE) -C g723.1 all +$(LIBG729): + $(MAKE) -C g729cp all + +$(LIBG729B): + $(MAKE) -C g729bc all + +$(LIBG729AB): + $(MAKE) -C g729abc all + gsm/lib/libgsm.a: $(MAKE) -C gsm lib/libgsm.a @@ -74,6 +92,24 @@ codec_g723_1b.o : codec_g723_1.c codec_g723_1b.so : codec_g723_1b.o $(LIBG723B) $(CC) $(SOLINK) -o $@ $< $(LIBG723B) -lm +codec_g729.so : codec_g729.o $(LIBG729) + $(CC) $(SOLINK) -o $@ $< $(LIBG729) + +codec_g729.o : codec_g729.c + $(CC) -c -o $@ $(CFLAGS) -Dsingle -DANNEX_ALL $< + +codec_g729ab.so : codec_g729ab.o $(LIBG729AB) + $(CC) $(SOLINK) -o $@ $< $(LIBG729AB) + +codec_g729ab.o : codec_g729.c + $(CC) -c -o $@ $(CFLAGS) -Dsingle -DANNEX_A -DANNEX_B $< + +codec_g729b.so : codec_g729b.o $(LIBG729B) + $(CC) $(SOLINK) -o $@ $< $(LIBG729B) + +codec_g729b.o : codec_g729.c + $(CC) -c -o $@ $(CFLAGS) -Dsingle -DANNEX_B $< + codec_gsm.so: codec_gsm.o $(LIBGSMT) $(CC) $(SOLINK) -o $@ $< $(LIBGSM) diff --git a/include/asterisk/cdr.h b/include/asterisk/cdr.h index 05d50664d..2da5b95dc 100755 --- a/include/asterisk/cdr.h +++ b/include/asterisk/cdr.h @@ -63,9 +63,9 @@ struct ast_cdr { struct timeval end; /*! Total time in system, in seconds */ - int duration; + int duration; /*! Total time call is up, in seconds */ - int billsec; + int billsec; /*! What happened to the call */ int disposition; /*! What flags to use */ diff --git a/include/asterisk/manager.h b/include/asterisk/manager.h index d25e150d8..7e3f8d3b7 100755 --- a/include/asterisk/manager.h +++ b/include/asterisk/manager.h @@ -48,6 +48,9 @@ #define EVENT_FLAG_COMMAND (1 << 4) /* Ability to read/set commands */ #define EVENT_FLAG_AGENT (1 << 5) /* Ability to read/set agent info */ #define EVENT_FLAG_USER (1 << 6) /* Ability to read/set user info */ +#define EVENT_FLAG_CUSTOM1 (1 << 7) /* Ability to read/set user info */ +#define EVENT_FLAG_CUSTOM2 (1 << 8) /* Ability to read/set user info */ +#define EVENT_FLAG_CUSTOM3 (1 << 9) /* Ability to read/set user info */ /* Export manager structures */ #define MAX_HEADERS 80 diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c index 311cb4046..dc14467c2 100755 --- a/res/res_musiconhold.c +++ b/res/res_musiconhold.c @@ -75,10 +75,10 @@ struct mohclass { char class[80]; char dir[256]; char miscargs[256]; + char customexec[256]; int destroyme; int pid; /* PID of mpg123 */ int quiet; - int single; pthread_t thread; struct mohdata *members; /* Source of audio */ @@ -106,64 +106,82 @@ AST_MUTEX_DEFINE_STATIC(moh_lock); static int spawn_mp3(struct mohclass *class) { int fds[2]; - int files; + int files=0; char fns[MAX_MP3S][80]; char *argv[MAX_MP3S + 50]; char xargs[256]; char *argptr; - int argc = 0; + int argc; DIR *dir; struct dirent *de; - dir = opendir(class->dir); - if (!dir) { - ast_log(LOG_WARNING, "%s is not a valid directory\n", class->dir); - return -1; - } - argv[argc++] = "mpg123"; - argv[argc++] = "-q"; - argv[argc++] = "-s"; - argv[argc++] = "--mono"; - argv[argc++] = "-r"; - argv[argc++] = "8000"; - - if (!class->single) { - argv[argc++] = "-b"; - argv[argc++] = "2048"; - } - argv[argc++] = "-f"; - - if (class->quiet) { - argv[argc++] = "4096"; - } else - argv[argc++] = "8192"; - - /* Look for extra arguments and add them to the list */ - strncpy(xargs, class->miscargs, sizeof(xargs) - 1); - argptr = xargs; - while(argptr && !ast_strlen_zero(argptr)) { - argv[argc++] = argptr; - argptr = strchr(argptr, ','); - if (argptr) { - *argptr = '\0'; - argptr++; - } - } - - files = 0; - while((de = readdir(dir)) && (files < MAX_MP3S)) { - if ((strlen(de->d_name) > 3) && !strcasecmp(de->d_name + strlen(de->d_name) - 4, ".mp3")) { - strncpy(fns[files], de->d_name, sizeof(fns[files])); - argv[argc++] = fns[files]; - files++; + if(class->customexec && strlen(class->customexec)) { + argc = 0; + strncpy(xargs, class->customexec, sizeof(xargs) - 1); + argptr = xargs; + while(argptr && strlen(argptr)) { + argv[argc] = argptr; + argptr = strchr(argptr, ','); + if (argptr) { + *argptr = '\0'; + argptr++; + } + argc++; } } - argv[argc] = NULL; - closedir(dir); - if (pipe(fds)) { - ast_log(LOG_WARNING, "Pipe failed\n"); - return -1; + else { + dir = opendir(class->dir); + if (!dir) { + ast_log(LOG_WARNING, "%s is not a valid directory\n", class->dir); + return -1; + } + argv[0] = "mpg123"; + argv[1] = "-q"; + argv[2] = "-s"; + argv[3] = "--mono"; + argv[4] = "-r"; + argv[5] = "8000"; + argv[6] = "-b"; + argv[7] = "2048"; + argc = 8; + if (class->quiet) { + argv[argc++] = "-f"; + argv[argc++] = "8192"; + } + + /* Look for extra arguments and add them to the list */ + strncpy(xargs, class->miscargs, sizeof(xargs) - 1); + argptr = xargs; + while(argptr && strlen(argptr)) { + argv[argc++] = argptr; + argptr = strchr(argptr, ','); + if (argptr) { + *argptr = '\0'; + argptr++; + } + } + + + + + files = 0; + while((de = readdir(dir)) && (files < MAX_MP3S)) { + if ((strlen(de->d_name) > 3) && !strcasecmp(de->d_name + strlen(de->d_name) - 4, ".mp3")) { + strncpy(fns[files], de->d_name, sizeof(fns[files])); + argv[argc++] = fns[files]; + files++; + } + } + argv[argc] = NULL; + closedir(dir); } + + + + if (pipe(fds)) { + ast_log(LOG_WARNING, "Pipe failed\n"); + return -1; + } #if 0 printf("%d files total, %d args total\n", files, argc); { @@ -172,28 +190,47 @@ static int spawn_mp3(struct mohclass *class) printf("arg%d: %s\n", x, argv[x]); } #endif - if (!files) { + if (!files && class->customexec && ! strlen(class->customexec)) { ast_log(LOG_WARNING, "Found no files in '%s'\n", class->dir); close(fds[0]); close(fds[1]); return -1; } + + + class->pid = fork(); + if (class->pid < 0) { close(fds[0]); close(fds[1]); ast_log(LOG_WARNING, "Fork failed: %s\n", strerror(errno)); return -1; } + + + + + if (!class->pid) { int x; close(fds[0]); /* Stdout goes to pipe */ + dup2(fds[1], STDOUT_FILENO); - /* Close unused file descriptors */ - for (x=3;x<8192;x++) - close(x); - /* Child */ + + + + + + /* Close unused file descriptors */ + for (x=3;x<8192;x++) + close(x); + /* Child */ + + + /* try custom */ + execv(argv[0], argv); chdir(class->dir); /* Default install is /usr/local/bin */ execv(LOCAL_MPG_123, argv); @@ -485,9 +522,11 @@ static struct ast_generator mohgen = generate: moh_generate, }; -static int moh_register(char *classname, char *mode, char *param, char *miscargs) +static int moh_register(char *classname, char *mode, char *param, char *miscargs,char *customexec) { struct mohclass *moh; + char custmode[7] = "custom"; + custmode[7]= (char) NULL; #ifdef ZAPATA_MOH int x; #endif @@ -504,14 +543,32 @@ static int moh_register(char *classname, char *mode, char *param, char *miscargs memset(moh, 0, sizeof(struct mohclass)); strncpy(moh->class, classname, sizeof(moh->class) - 1); + + if(customexec && strlen(customexec)) { + strncpy(moh->customexec, customexec, sizeof(moh->customexec) - 1); + mode=custmode; + + } + if (miscargs) - strncpy(moh->miscargs, miscargs, sizeof(moh->miscargs) - 1); - if (!strcasecmp(mode, "mp3") || !strcasecmp(mode, "mp3nb") || !strcasecmp(mode, "quietmp3") || !strcasecmp(mode, "quietmp3nb") || !strcasecmp(mode, "httpmp3")) { - if (!strcasecmp(mode, "mp3nb") || !strcasecmp(mode, "quietmp3nb")) - moh->single = 1; - if (!strcasecmp(mode, "quietmp3") || !strcasecmp(mode, "quietmp3nb")) + strncpy(moh->miscargs, miscargs, sizeof(moh->miscargs) - 1); + + + + + + + + + + if (!strcasecmp(mode, "mp3") || !strcasecmp(mode, "quietmp3") || !strcasecmp(mode, "httpmp3") || !strcasecmp(mode, "custom")) { + + + if(! customexec || (customexec && ! strlen(customexec))) { + if (!strcasecmp(mode, "quietmp3")) moh->quiet = 1; strncpy(moh->dir, param, sizeof(moh->dir) - 1); + } moh->srcfd = -1; #ifdef ZAPATA_MOH /* It's an MP3 Moh -- Open /dev/zap/pseudo for timing... Is @@ -526,6 +583,9 @@ static int moh_register(char *classname, char *mode, char *param, char *miscargs #else moh->pseudofd = -1; #endif + + + if (pthread_create(&moh->thread, NULL, monmp3thread, moh)) { ast_log(LOG_WARNING, "Unable to create moh...\n"); if (moh->pseudofd > -1) @@ -578,10 +638,20 @@ static void load_moh_classes(void) *args = '\0'; args++; } - moh_register(var->name, var->value, data,args); + moh_register(var->name, var->value, data,args,NULL); } var = var->next; } + + + var = ast_variable_browse(cfg, "custom_exec"); + while(var) { + + moh_register(var->name,NULL,NULL,NULL,var->value); + var = var->next; + } + + ast_destroy(cfg); } } @@ -606,7 +676,7 @@ static void ast_moh_destroy(void) ast_log(LOG_DEBUG, "mpg123 pid %d and child died after %d bytes read\n", moh->pid, tbytes); close(moh->srcfd); moh->pid = 0; - } + } moh = moh->next; } ast_mutex_unlock(&moh_lock); |