--- asterisk-1.4.4-orig/utils/Makefile 2007-03-23 01:10:53.000000000 +1030 +++ asterisk-1.4.4/utils/Makefile 2008-03-22 10:21:27.000000000 +1030 @@ -16,7 +16,7 @@ .PHONY: clean all uninstall # to get check_expr, add it to the ALL_UTILS list -ALL_UTILS:=astman smsq stereorize streamplayer aelparse muted +ALL_UTILS:=astman smsq stereorize streamplayer aelparse UTILS:=$(ALL_UTILS) include $(ASTTOPDIR)/Makefile.rules --- asterisk-1.4.4-orig/main/config.c 2007-04-26 10:57:18.000000000 +0930 +++ asterisk-1.4.4/main/config.c 2008-03-22 10:21:27.000000000 +1030 @@ -37,7 +37,6 @@ #include #include #include -#define AST_INCLUDE_GLOB 1 #ifdef AST_INCLUDE_GLOB #if defined(__Darwin__) || defined(__CYGWIN__) #define GLOB_ABORTED GLOB_ABEND --- asterisk-1.4.4-orig/configure 2007-04-07 06:28:43.000000000 +0930 +++ asterisk-1.4.4/configure 2008-03-22 10:21:27.000000000 +1030 @@ -12577,7 +12577,7 @@ fi if test "x$ac_cv_func_fork_works" = xcross; then case $host in - *-*-amigaos* | *-*-msdosdjgpp* | *-*-uclinux* | *-*-linux-uclibc* ) + *-*-amigaos* | *-*-msdosdjgpp* | *-*-uclinux* | *-*-linux-uclibc* | bfin-*-* ) # Override, as these systems have only a dummy fork() stub ac_cv_func_fork_works=no ;; --- asterisk-1.4.4-orig/main/frame.c 2007-01-20 04:19:38.000000000 +1030 +++ asterisk-1.4.4/main/frame.c 2008-03-22 10:21:27.000000000 +1030 @@ -113,7 +113,7 @@ { 1, AST_FORMAT_SLINEAR, "slin", "16 bit Signed Linear PCM", 160, 10, 70, 10, 20, AST_SMOOTHER_FLAG_BE }, /*!< 7 */ { 1, AST_FORMAT_LPC10, "lpc10", "LPC10", 7, 20, 20, 20, 20 }, /*!< 8: codec_lpc10.c */ { 1, AST_FORMAT_G729A, "g729", "G.729A", 10, 10, 230, 10, 20, AST_SMOOTHER_FLAG_G729 }, /*!< 9: Binary commercial distribution */ - { 1, AST_FORMAT_SPEEX, "speex", "SpeeX", 10, 10, 60, 10, 20 }, /*!< 10: codec_speex.c */ + { 1, AST_FORMAT_SPEEX, "speex", "SpeeX", 38, 20, 300, 20, 20 }, /*!< 10: codec_speex.c */ { 1, AST_FORMAT_ILBC, "ilbc", "iLBC", 50, 30, 30, 30, 30 }, /*!< 11: codec_ilbc.c */ /* inc=30ms - workaround */ { 1, AST_FORMAT_G726_AAL2, "g726aal2", "G.726 AAL2", 40, 10, 300, 10, 20 }, /*!< 12: codec_g726.c */ { 1, AST_FORMAT_G722, "g722", "G722"}, /*!< 13 */ @@ -1467,7 +1467,11 @@ int samples=0; switch(f->subclass) { case AST_FORMAT_SPEEX: - samples = speex_samples(f->data, f->datalen); + //samples = speex_samples(f->data, f->datalen); + /* DR: hard coded for quality=8 mode. + 300 bits (38 bytes) converted to 160 samples */ + samples = 160 * (f->datalen / 38); + //ast_log(LOG_WARNING, "f->datalen: %d samples: %d\n", f->datalen, samples); break; case AST_FORMAT_G723_1: samples = g723_samples(f->data, f->datalen); --- asterisk-1.4.4-orig/configs/modules.conf.sample 2006-08-25 23:44:27.000000000 +0930 +++ asterisk-1.4.4//configs/modules.conf.sample 2008-03-22 10:21:27.000000000 +1030 @@ -36,3 +36,5 @@ ; noload => chan_alsa.so ;noload => chan_oss.so + +noload => codec_g729.so --- asterisk-1.4.4-orig/main/callerid.c 2007-01-24 05:28:27.000000000 +1030 +++ asterisk-1.4.4/main/callerid.c 2008-03-22 10:21:27.000000000 +1030 @@ -45,7 +45,32 @@ #include "asterisk/options.h" #include "asterisk/utils.h" +#ifdef USE_SPANDSP_CALLERID +#include +#include +#include "spandsp/telephony.h" +#include "spandsp/logging.h" +#include "spandsp/complex.h" +#include "spandsp/dds.h" +#include "spandsp/power_meter.h" +#include "spandsp/async.h" +#include "spandsp/crc.h" +#include "spandsp/fsk.h" +#include "spandsp/tone_detect.h" +#include "spandsp/tone_generate.h" +#include "spandsp/super_tone_rx.h" +#include "spandsp/queue.h" +#include "spandsp/dtmf.h" +#include "spandsp/adsi.h" +#endif + + struct callerid_state { +#ifdef USE_SPANDSP_CALLERID + adsi_rx_state_t adsi; + char adsi_output[256]; + int adsi_len; +#endif fsk_data fskd; char rawdata[256]; short oldstuff[160]; @@ -61,6 +86,8 @@ int skipflag; unsigned short crc; + /*jfk: debug*/ + FILE* fpdebug; }; @@ -77,6 +104,29 @@ #define AST_CALLERID_UNKNOWN "" +#ifdef USE_SPANDSP_CALLERID +void cid_put_msg_func_t(void *user_data, const uint8_t *msg, int len) +{ + /*given the nature of calling adsi_rx for each sample, we'll always + * only have one byte at a time here */ + struct callerid_state *cid = (struct callerid_state *)user_data; + cid->adsi_len = len; + memcpy(cid->adsi_output,msg,len > sizeof(cid->adsi_output) ? sizeof(cid->adsi_output) : len); +} + +int fsk_serie_spandsp(struct callerid_state *cid, short *buffer, int *len) +{ + + cid->adsi_len = 0; + adsi_rx(&cid->adsi,buffer,*len); + *len = 0; + if (cid->adsi_len >= 0) { + return 1; + } + return 0; +} +#endif + static inline void gen_tones(unsigned char *buf, int len, int codec, float ddr1, float ddi1, float ddr2, float ddi2, float *cr1, float *ci1, float *cr2, float *ci2) { int x; @@ -134,6 +184,12 @@ struct callerid_state *cid; if ((cid = ast_calloc(1, sizeof(*cid)))) { +#ifdef USE_SPANDSP_CALLERID + adsi_rx_init(&cid->adsi, + (cid_signalling == 2) ? ADSI_STANDARD_CLIP : ADSI_STANDARD_CLASS, + cid_put_msg_func_t, + cid); +#endif cid->fskd.spb = 7.0; /* 1200 baud */ /* cid->fskd.hdlc = 0; */ /* Async */ cid->fskd.nbit = 8; /* 8 bits */ @@ -153,6 +209,9 @@ /* cid->fskd.state = 0; */ cid->flags = CID_UNKNOWN_NAME | CID_UNKNOWN_NUMBER; /* cid->pos = 0; */ + + /*jfk: debug, open a temp file*/ + /*cid->fpdebug = fopen("/tmp/audio.raw","wb");*/ } return cid; @@ -550,6 +609,11 @@ if (!(buf = ast_calloc(1, 2 * len + cid->oldlen))) { return -1; } + /*jfk: debug: write out to a temp file*/ + /* + if (cid->fpdebug) { + fwrite(ubuf,1,len,cid->fpdebug); + }*/ obuf = buf; memcpy(buf, cid->oldstuff, cid->oldlen); @@ -559,7 +623,11 @@ buf[x+cid->oldlen/2] = AST_XLAW(ubuf[x]); while(mylen >= 160) { olen = mylen; +#ifdef USE_SPANDSP_CALLERID + res = fsk_serie_spandsp(cid, buf, &mylen); +#else res = fsk_serie(&cid->fskd, buf, &mylen, &b); +#endif if (mylen < 0) { ast_log(LOG_ERROR, "fsk_serie made mylen < 0 (%d)\n", mylen); free(obuf); @@ -572,6 +640,13 @@ return -1; } if (res == 1) { +#ifdef USE_SPANDSP_CALLERID + int index; + cid->sawflag = 2; + for (index = 0;index < cid->adsi_len;index++) + { + b = cid->adsi_output[index] & 0x00ff; +#endif /* Ignore invalid bytes */ if (b > 0xff) continue; @@ -606,6 +681,7 @@ if (!cid->len) { cid->rawdata[cid->pos] = '\0'; cid->sawflag = 5; +#ifndef USE_SPANDSP_CALLERID } break; case 5: /* Check checksum */ @@ -615,6 +691,7 @@ cid->sawflag = 0; break; } +#endif cid->number[0] = '\0'; cid->name[0] = '\0'; @@ -685,10 +762,16 @@ } free(obuf); return 1; +#ifdef USE_SPANDSP_CALLERID + } +#endif break; default: ast_log(LOG_ERROR, "Dunno what to do with a digit in sawflag %d\n", cid->sawflag); } +#ifdef USE_SPANDSP_CALLERID + } /*for*/ +#endif } } if (mylen) { @@ -702,6 +785,11 @@ void callerid_free(struct callerid_state *cid) { + /*jfk + if (cid->fpdebug) { + fclose(cid->fpdebug); + cid->fpdebug = 0; + }*/ free(cid); } --- asterisk-1.4.4-orig/res/res_agi.c 2007-02-16 22:09:55.000000000 +1030 +++ asterisk-1.4.4/res/res_agi.c 2008-03-22 10:25:14.000000000 +1030 @@ -286,7 +286,7 @@ /* Block SIGHUP during the fork - prevents a race */ sigfillset(&signal_set); pthread_sigmask(SIG_BLOCK, &signal_set, &old_set); - pid = fork(); + pid = vfork(); if (pid < 0) { ast_log(LOG_WARNING, "Failed to fork(): %s\n", strerror(errno)); pthread_sigmask(SIG_SETMASK, &old_set, NULL);