int res = 0;
int ms;
- struct ast_dsp *sildet; /* silence detector dsp */
+ struct ast_dsp *sildet=NULL; /* silence detector dsp */
int totalsilence = 0;
int dspsilence = 0;
int silence = 0; /* amount of silence to allow */
int gotsilence = 0; /* did we timeout for silence? */
- char *silencestr;
- int rfmt;
+ char *silencestr=NULL;
+ int rfmt=0;
/* XXX EAGI FIXME XXX */
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
+#include <ctype.h>
#include <pthread.h>
static char *descrip =
" Festival(text[|intkeys]): Connect to Festival, send the argument, get back the waveform,"
"play it to the user, allowing any given interrupt keys to immediately terminate and return\n"
-"the value.\n";
+"the value, or 'any' to allow any number back (useful in dialplan)\n";
STANDARD_LOCAL_USER;
}
-static int send_waveform_to_channel(struct ast_channel *chan, char *waveform, int length) {
+static int send_waveform_to_channel(struct ast_channel *chan, char *waveform, int length, char *intkeys) {
int res=0;
int fds[2];
int ms = -1;
}
if (f->frametype == AST_FRAME_DTMF) {
ast_log(LOG_DEBUG, "User pressed a key\n");
- ast_frfree(f);
- res = 0;
- break;
+ if (strchr(intkeys, f->subclass)) {
+ res = f->subclass;
+ ast_frfree(f);
+ break;
+ }
}
if (f->frametype == AST_FRAME_VOICE) {
/* Treat as a generator */
-static int festival_exec(struct ast_channel *chan, void *data)
+static int festival_exec(struct ast_channel *chan, void *vdata)
{
int usecache;
int res=0;
int readcache=0;
int writecache=0;
int strln;
- int fdesc;
+ int fdesc = -1;
char buffer[16384];
- int seekpos;
+ int seekpos = 0;
+ char data[256] = "";
+ char *intstr;
struct ast_config *cfg;
cfg = ast_load(FESTIVAL_CONFIG);
- if (!data) {
+ if (!vdata || !strlen(vdata)) {
ast_log(LOG_WARNING, "festival requires an argument (text)\n");
return -1;
}
+ strncpy(data, vdata, sizeof(data) - 1);
+ if ((intstr = strchr(data, '|'))) {
+ *intstr = '\0';
+ intstr++;
+ if (!strcasecmp(intstr, "any"))
+ intstr = AST_DIGIT_ANY;
+ }
LOCAL_USER_ADD(u);
ast_log(LOG_WARNING, "Text passed to festival server : %s\n",(char *)data);
/* Connect to local festival server */
if (strcmp(ack,"WV\n") == 0) { /* receive a waveform */
ast_log(LOG_WARNING,"Festival WV command");
waveform = socket_receive_file_to_buff(fd,&filesize);
- send_waveform_to_channel(chan,waveform,filesize);
+ send_waveform_to_channel(chan,waveform,filesize, intstr);
free(waveform);
res=0;
break;
char loc[256]; /* Location */
int penalty; /* Are we a last resort? */
int calls;
+ int dynamic; /* Are we dynamically added? */
time_t lastcall; /* When last successful call was hungup */
struct member *next; /* Next member */
};
static void free_members(struct ast_call_queue *q)
{
- struct member *curm, *next;
+ /* Free non-dynamic members */
+ struct member *curm, *next, *prev;
curm = q->members;
+ prev = NULL;
while(curm) {
next = curm->next;
- free(curm);
+ if (!curm->dynamic) {
+ if (prev)
+ prev->next = next;
+ else
+ q->members = next;
+ free(curm);
+ } else
+ prev = curm;
curm = next;
}
- q->members = NULL;
}
static void destroy_queue(struct ast_call_queue *q)
save = q->members ;
q->members = create_queue_node( interface ) ;
- if( q->members != NULL )
+ if( q->members != NULL ) {
+ q->members->dynamic = 1;
q->members->next = save ;
- else
+ } else
q->members = save ;
ast_log(LOG_NOTICE, "Added interface '%s' to queue '%s'\n", interface, queuename);
/* Mark all queues as dead for the moment */
q = queues;
while(q) {
- q->dead = 1;
q = q->next;
}
/* Chug through config file */
ast_cli(fd, " Members: \n");
for (mem = q->members; mem; mem = mem->next) {
if (mem->penalty)
- snprintf(max, sizeof(max), " with penalty %d", mem->penalty);
+ snprintf(max, sizeof(max) - 20, " with penalty %d", mem->penalty);
else
strcpy(max, "");
+ if (mem->dynamic)
+ strcat(max, " (dynamic)");
if (mem->calls) {
snprintf(calls, sizeof(calls), " has taken %d calls (last was %ld secs ago)",
mem->calls, time(NULL) - mem->lastcall);
if ((res = ast_readstring(chan, username, sizeof(username) - 1, 2000, 10000, "#") < 0))
break;
if ((receiver = find_user(&srec, context, username))) {
- printf("Got %d\n", atoi(username));
/* if (play_and_wait(chan, "vm-savedto"))
break;
*/
strncpy(p->peername, r->username, sizeof(p->peername)-1);
strncpy(p->username, r->username, sizeof(p->username)-1);
strncpy(p->exten, r->contact, sizeof(p->exten) - 1);
+ /* Always bind to our IP if specified */
+ if (bindaddr.sin_addr.s_addr)
+ memcpy(&p->ourip, &bindaddr.sin_addr, sizeof(p->ourip));
build_contact(p);
}
}
} else {
/* Check for callerid, digits, etc */
- chan = zt_new(i, AST_STATE_DOWN, 0, SUB_REAL, 0);
+ chan = zt_new(i, AST_STATE_RESERVED, 0, SUB_REAL, 0);
if (chan) {
if (has_voicemail(i))
#ifdef ZT_TONE_STUTTER
if (last->msgstate != res) {
int x;
ast_log(LOG_DEBUG, "Message status for %s changed from %d to %d on %d\n", last->mailbox, last->msgstate, res, last->channel);
- x = ZT_FLUSH_WRITE;
+ x = ZT_FLUSH_BOTH;
res2 = ioctl(last->subs[SUB_REAL].zfd, ZT_FLUSH, &x);
if (res2)
ast_log(LOG_WARNING, "Unable to flush input on channel %d\n", last->channel);
******************************************************************/
#include "iLBC_define.h"
+#include "FrameClassify.h"
/*----------------------------------------------------------------*
* Classification of subframes to localize start state
#include "lsf.h"
#include "iLBC_define.h"
#include "constants.h"
+#include "LPCdecode.h"
/*----------------------------------------------------------------*
* interpolation of lsf coefficients for the decoder
#include "helpfun.h"
#include "lsf.h"
#include "constants.h"
+#include "LPCencode.h"
/*----------------------------------------------------------------*
* lpc analysis (subrutine to LPCencode)
*---------------------------------------------------------------*/
-void SimpleAnalysis(
+static void SimpleAnalysis(
float *lsf, /* (o) lsf coefficients */
float *data, /* (i) new data vector */
float *lpc_buffer /* (i) buffer containing old data */
* (subrutine to SimpleInterpolateLSF)
*---------------------------------------------------------------*/
-void LSFinterpolate2a_enc(
+static void LSFinterpolate2a_enc(
float *a, /* (o) lpc coefficients */
float *lsf1,/* (i) first set of lsf coefficients */
float *lsf2,/* (i) second set of lsf coefficients */
* lsf interpolator (subrutine to LPCencode)
*---------------------------------------------------------------*/
-void SimpleInterpolateLSF(
+static void SimpleInterpolateLSF(
float *syntdenum, /* (o) the synthesis filter denominator
resulting from the quantized
interpolated lsf */
* lsf quantizer (subrutine to LPCencode)
*---------------------------------------------------------------*/
-void SimplelsfQ(
+static void SimplelsfQ(
float *lsfdeq, /* (o) dequantized lsf coefficients
(dimension FILTERORDER) */
int *index, /* (o) quantization index */
#include "iLBC_define.h"
#include "constants.h"
#include "filter.h"
+#include "StateConstructW.h"
/*----------------------------------------------------------------*
* decoding of the start state
#include "constants.h"
#include "filter.h"
#include "helpfun.h"
+#include "StateSearchW.h"
/*----------------------------------------------------------------*
* predictive noise shaping encoding of scaled start state
#include <string.h>
#include "iLBC_define.h"
+#include "anaFilter.h"
/*----------------------------------------------------------------*
* LP analysis filter.
#include "iLBC_define.h"
#include "constants.h"
+#include "createCB.h"
#include <string.h>
#include <math.h>
#include <string.h>
#include "iLBC_define.h"
+#include "doCPLC.h"
/*----------------------------------------------------------------*
* Compute cross correlation and pitch gain for pitch prediction
* of last subframe at given lag.
*---------------------------------------------------------------*/
-void compCorr(
+static void compCorr(
float *cc, /* (o) cross correlation coefficient */
float *gc, /* (o) gain */
float *buffer, /* (i) signal buffer */
#include "iLBC_define.h"
#include "constants.h"
#include "filter.h"
+#include "enhancer.h"
/*----------------------------------------------------------------*
* Find index in array such that the array element with said
* according to the squared-error criterion
*---------------------------------------------------------------*/
-void NearestNeighbor(
+static void NearestNeighbor(
int *index, /* (o) index of array element closest to value */
float *array, /* (i) data array */
float value,/* (i) value */
* compute cross correlation between sequences
*---------------------------------------------------------------*/
-void mycorr1(
+static void mycorr1(
float* corr, /* (o) correlation of seq1 and seq2 */
float* seq1, /* (i) first sequence */
int dim1, /* (i) dimension first seq1 */
* upsample finite array assuming zeros outside bounds
*---------------------------------------------------------------*/
-void enh_upsample(
+static void enh_upsample(
float* useq1, /* (o) upsampled output sequence */
float* seq1,/* (i) unupsampled sequence */
int dim1, /* (i) dimension seq1 */
* sampling rate
*---------------------------------------------------------------*/
-void refiner(
+static void refiner(
float *seg, /* (o) segment array */
float *updStartPos, /* (o) updated start point */
float* idata, /* (i) original data buffer */
* find the smoothed output data
*---------------------------------------------------------------*/
-void smath(
+static void smath(
float *odata, /* (o) smoothed output */
float *sseq,/* (i) said second sequence of waveforms */
int hl, /* (i) 2*hl+1 is sseq dimension */
* get the pitch-synchronous sample sequence
*---------------------------------------------------------------*/
-void getsseq(
+static void getsseq(
float *sseq, /* (o) the pitch-synchronous sequence */
float *idata, /* (i) original data */
int idatal, /* (i) dimension of data */
* idata+centerStartPos+ENH_BLOCKL-1
*---------------------------------------------------------------*/
-void enhancer(
+static void enhancer(
float *odata, /* (o) smoothed block, dimension blockl */
float *idata, /* (i) data buffer used for enhancing */
int idatal, /* (i) dimension idata */
******************************************************************/
#include "iLBC_define.h"
-
+#include "filter.h"
+
/*----------------------------------------------------------------*
* all-pole filter
*---------------------------------------------------------------*/
#include <math.h>
#include "constants.h"
#include "filter.h"
+#include "gainquant.h"
/*----------------------------------------------------------------*
* quantizer for the gain in the gain-shape coding of residual
#include "iLBC_define.h"
#include "constants.h"
+#include "getCBvec.h"
#include <string.h>
/*----------------------------------------------------------------*
#include <math.h>
#include "iLBC_define.h"
+#include "helpfun.h"
#include "constants.h"
/*----------------------------------------------------------------*
******************************************************************/
#include "constants.h"
+#include "hpInput.h"
/*----------------------------------------------------------------*
* Input high-pass filter
******************************************************************/
#include "constants.h"
+#include "hpOutput.h"
/*----------------------------------------------------------------*
* Output high-pass filter
#include "iLBC_define.h"
#include "gainquant.h"
#include "getCBvec.h"
+#include "iCBConstruct.h"
/*----------------------------------------------------------------*
* Convert the codebook indexes to make the search easier
#include <string.h>
#include "iLBC_define.h"
+#include "iCBSearch.h"
#include "gainquant.h"
#include "createCB.h"
#include "filter.h"
#include "helpfun.h"
#include "constants.h"
#include "packing.h"
+#include "iLBC_decode.h"
#include "string.h"
#include "enhancer.h"
#include "hpOutput.h"
* frame residual decoder function (subrutine to iLBC_decode)
*---------------------------------------------------------------*/
-void Decode(
+static void Decode(
float *decresidual, /* (o) decoded residual frame */
int start, /* (i) location of start state */
int idxForMax, /* (i) codebook index for the maximum
#include "helpfun.h"
#include "constants.h"
#include "packing.h"
+#include "iLBC_encode.h"
#include "iCBSearch.h"
#include "iCBConstruct.h"
#include "hpInput.h"
#include <math.h>
#include "iLBC_define.h"
+#include "lsf.h"
/*----------------------------------------------------------------*
* conversion from lpc coefficients to lsf coefficients
#include "constants.h"
#include "helpfun.h"
#include "string.h"
+#include "packing.h"
/*----------------------------------------------------------------*
* splitting an integer into first most significant bits and
******************************************************************/
#include "iLBC_define.h"
+#include "syntFilter.h"
/*----------------------------------------------------------------*
* LP synthesis filter.
}
-static void __verboser(char *stuff, int opos, int replacelast, int complete)
+static void __verboser(const char *stuff, int opos, int replacelast, int complete)
{
char *s2[2];
struct timeval tv;
}
}
-static void verboser(char *stuff, int opos, int replacelast, int complete)
+static void verboser(const char *stuff, int opos, int replacelast, int complete)
{
ast_mutex_lock(&verb_lock);
/* Lock appropriately if we're really being called in verbose mode */