Version 0.3.0 from FTP

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@556 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Mark Spencer
2002-11-29 02:14:13 +00:00
parent 55dc769bc3
commit d4cce257b2
15 changed files with 124 additions and 86 deletions

View File

@@ -116,12 +116,13 @@ static int disa_exec(struct ast_channel *chan, void *data)
int i,j,k,x; int i,j,k,x;
struct localuser *u; struct localuser *u;
char tmp[256],arg2[256],exten[AST_MAX_EXTENSION],acctcode[20]; char tmp[256],arg2[256],exten[AST_MAX_EXTENSION],acctcode[20];
unsigned char tone_block[640],sil_block[640]; unsigned char tone_block[640];
char *ourcontext,*ourcallerid; char *ourcontext,*ourcallerid;
struct ast_frame *f,wf; struct ast_frame *f,wf;
struct timeval lastout, now, lastdigittime; struct timeval lastout, now, lastdigittime;
int res; int res;
FILE *fp; FILE *fp;
char *stringp=NULL;
if (ast_set_write_format(chan,AST_FORMAT_ULAW)) if (ast_set_write_format(chan,AST_FORMAT_ULAW))
{ {
@@ -134,19 +135,18 @@ static int disa_exec(struct ast_channel *chan, void *data)
return -1; return -1;
} }
lastout.tv_sec = lastout.tv_usec = 0; lastout.tv_sec = lastout.tv_usec = 0;
/* make block of silence */
memset(sil_block,0x7f,sizeof(sil_block));
if (!data || !strlen((char *)data)) { if (!data || !strlen((char *)data)) {
ast_log(LOG_WARNING, "disa requires an argument (passcode/passcode file)\n"); ast_log(LOG_WARNING, "disa requires an argument (passcode/passcode file)\n");
return -1; return -1;
} }
strncpy(tmp, (char *)data, sizeof(tmp)-1); strncpy(tmp, (char *)data, sizeof(tmp)-1);
strtok(tmp, "|"); stringp=tmp;
ourcontext = strtok(NULL, "|"); strsep(&stringp, "|");
ourcontext = strsep(&stringp, "|");
/* if context specified, save 2nd arg and parse third */ /* if context specified, save 2nd arg and parse third */
if (ourcontext) { if (ourcontext) {
strcpy(arg2,ourcontext); strcpy(arg2,ourcontext);
ourcallerid = strtok(NULL,"|"); ourcallerid = strsep(&stringp,"|");
} }
/* if context not specified, use "disa" */ /* if context not specified, use "disa" */
else { else {
@@ -162,6 +162,7 @@ static int disa_exec(struct ast_channel *chan, void *data)
} }
i = k = x = 0; /* k is 0 for pswd entry, 1 for ext entry */ i = k = x = 0; /* k is 0 for pswd entry, 1 for ext entry */
exten[0] = 0; exten[0] = 0;
acctcode[0] = 0;
/* can we access DISA without password? */ /* can we access DISA without password? */
if (!strcasecmp(tmp, "no-password")) if (!strcasecmp(tmp, "no-password"))
{ {
@@ -207,7 +208,7 @@ static int disa_exec(struct ast_channel *chan, void *data)
wf.data = tone_block; wf.data = tone_block;
wf.datalen = f->datalen; wf.datalen = f->datalen;
make_tone_block(tone_block, 350, 440, f->datalen, &x); make_tone_block(tone_block, 350, 440, f->datalen, &x);
wf.timelen = wf.datalen / 8; wf.samples = wf.datalen;
ast_frfree(f); ast_frfree(f);
if (ast_write(chan, &wf)) if (ast_write(chan, &wf))
{ {
@@ -250,6 +251,7 @@ static int disa_exec(struct ast_channel *chan, void *data)
tmp[0] = 0; tmp[0] = 0;
while(fgets(tmp,sizeof(tmp) - 1,fp)) while(fgets(tmp,sizeof(tmp) - 1,fp))
{ {
char *stringp=NULL;
if (!tmp[0]) continue; if (!tmp[0]) continue;
if (tmp[strlen(tmp) - 1] == '\n') if (tmp[strlen(tmp) - 1] == '\n')
tmp[strlen(tmp) - 1] = 0; tmp[strlen(tmp) - 1] = 0;
@@ -257,10 +259,11 @@ static int disa_exec(struct ast_channel *chan, void *data)
/* skip comments */ /* skip comments */
if (tmp[0] == '#') continue; if (tmp[0] == '#') continue;
if (tmp[0] == ';') continue; if (tmp[0] == ';') continue;
strtok(tmp, "|"); stringp=tmp;
strsep(&stringp, "|");
/* save 2nd arg as clid */ /* save 2nd arg as clid */
ourcallerid = arg2; ourcallerid = arg2;
ourcontext = strtok(NULL, "|"); ourcontext = strsep(&stringp, "|");
/* password must be in valid format (numeric) */ /* password must be in valid format (numeric) */
if (sscanf(tmp,"%d",&j) < 1) continue; if (sscanf(tmp,"%d",&j) < 1) continue;
/* if we got it */ /* if we got it */
@@ -328,7 +331,7 @@ reorder:
wf.mallocd = 0; wf.mallocd = 0;
wf.data = tone_block; wf.data = tone_block;
wf.datalen = f->datalen; wf.datalen = f->datalen;
wf.timelen = wf.datalen / 8; wf.samples = wf.datalen;
if (k) if (k)
memset(tone_block, 0x7f, wf.datalen); memset(tone_block, 0x7f, wf.datalen);
else else

View File

@@ -211,7 +211,7 @@ static int send_waveform_to_channel(struct ast_channel *chan, char *waveform, in
myf.f.frametype = AST_FRAME_VOICE; myf.f.frametype = AST_FRAME_VOICE;
myf.f.subclass = AST_FORMAT_SLINEAR; myf.f.subclass = AST_FORMAT_SLINEAR;
myf.f.datalen = res; myf.f.datalen = res;
myf.f.timelen = res / 16; myf.f.samples = res / 2;
myf.f.mallocd = 0; myf.f.mallocd = 0;
myf.f.offset = AST_FRIENDLY_OFFSET; myf.f.offset = AST_FRIENDLY_OFFSET;
myf.f.src = __PRETTY_FUNCTION__; myf.f.src = __PRETTY_FUNCTION__;

View File

@@ -164,7 +164,7 @@ static int mp3_exec(struct ast_channel *chan, void *data)
myf.f.frametype = AST_FRAME_VOICE; myf.f.frametype = AST_FRAME_VOICE;
myf.f.subclass = AST_FORMAT_SLINEAR; myf.f.subclass = AST_FORMAT_SLINEAR;
myf.f.datalen = res; myf.f.datalen = res;
myf.f.timelen = res / 16; myf.f.samples = res / 2;
myf.f.mallocd = 0; myf.f.mallocd = 0;
myf.f.offset = AST_FRIENDLY_OFFSET; myf.f.offset = AST_FRIENDLY_OFFSET;
myf.f.src = __PRETTY_FUNCTION__; myf.f.src = __PRETTY_FUNCTION__;

View File

@@ -646,7 +646,7 @@ static struct ast_frame *alsa_read(struct ast_channel *chan)
f.frametype = AST_FRAME_NULL; f.frametype = AST_FRAME_NULL;
f.subclass = 0; f.subclass = 0;
f.timelen = 0; f.samples = 0;
f.datalen = 0; f.datalen = 0;
f.data = NULL; f.data = NULL;
f.offset = 0; f.offset = 0;
@@ -728,7 +728,7 @@ static struct ast_frame *alsa_read(struct ast_channel *chan)
} }
f.frametype = AST_FRAME_VOICE; f.frametype = AST_FRAME_VOICE;
f.subclass = AST_FORMAT_SLINEAR; f.subclass = AST_FORMAT_SLINEAR;
f.timelen = FRAME_SIZE / 8; f.samples = FRAME_SIZE;
f.datalen = FRAME_SIZE * 2; f.datalen = FRAME_SIZE * 2;
f.data = buf; f.data = buf;
f.offset = AST_FRIENDLY_OFFSET; f.offset = AST_FRIENDLY_OFFSET;
@@ -905,8 +905,8 @@ static char sendtext_usage[] =
static int console_sendtext(int fd, int argc, char *argv[]) static int console_sendtext(int fd, int argc, char *argv[])
{ {
int tmparg = 1; int tmparg = 2;
if (argc < 1) if (argc < 2)
return RESULT_SHOWUSAGE; return RESULT_SHOWUSAGE;
if (!alsa.owner) { if (!alsa.owner) {
ast_cli(fd, "No one is calling us\n"); ast_cli(fd, "No one is calling us\n");
@@ -968,9 +968,11 @@ static int console_dial(int fd, int argc, char *argv[])
mye = exten; mye = exten;
myc = context; myc = context;
if (argc == 2) { if (argc == 2) {
char *stringp=NULL;
strncpy(tmp, argv[1], sizeof(tmp)-1); strncpy(tmp, argv[1], sizeof(tmp)-1);
strtok(tmp, "@"); stringp=tmp;
tmp2 = strtok(NULL, "@"); strsep(&stringp, "@");
tmp2 = strsep(&stringp, "@");
if (strlen(tmp)) if (strlen(tmp))
mye = tmp; mye = tmp;
if (tmp2 && strlen(tmp2)) if (tmp2 && strlen(tmp2))
@@ -995,7 +997,7 @@ static struct ast_cli_entry myclis[] = {
{ { "answer", NULL }, console_answer, "Answer an incoming console call", answer_usage }, { { "answer", NULL }, console_answer, "Answer an incoming console call", answer_usage },
{ { "hangup", NULL }, console_hangup, "Hangup a call on the console", hangup_usage }, { { "hangup", NULL }, console_hangup, "Hangup a call on the console", hangup_usage },
{ { "dial", NULL }, console_dial, "Dial an extension on the console", dial_usage }, { { "dial", NULL }, console_dial, "Dial an extension on the console", dial_usage },
{ { "send text", NULL }, console_sendtext, "Send text to the remote device", sendtext_usage }, { { "send", "text", NULL }, console_sendtext, "Send text to the remote device", sendtext_usage },
{ { "autoanswer", NULL }, console_autoanswer, "Sets/displays autoanswer", autoanswer_usage, autoanswer_complete } { { "autoanswer", NULL }, console_autoanswer, "Sets/displays autoanswer", autoanswer_usage, autoanswer_complete }
}; };

View File

@@ -187,7 +187,7 @@ static struct ast_frame *aopen_handle_escape(struct ast_modem_pvt *p, char esc)
p->fr.subclass = 0; p->fr.subclass = 0;
p->fr.data = NULL; p->fr.data = NULL;
p->fr.datalen = 0; p->fr.datalen = 0;
p->fr.timelen = 0; p->fr.samples = 0;
p->fr.offset = 0; p->fr.offset = 0;
p->fr.mallocd = 0; p->fr.mallocd = 0;
if (esc) if (esc)
@@ -315,7 +315,7 @@ static struct ast_frame *aopen_read(struct ast_modem_pvt *p)
/* If we get here, we have a complete voice frame */ /* If we get here, we have a complete voice frame */
p->fr.frametype = AST_FRAME_VOICE; p->fr.frametype = AST_FRAME_VOICE;
p->fr.subclass = AST_FORMAT_SLINEAR; p->fr.subclass = AST_FORMAT_SLINEAR;
p->fr.timelen = 30; p->fr.samples = 240;
p->fr.data = p->obuf; p->fr.data = p->obuf;
p->fr.datalen = p->obuflen; p->fr.datalen = p->obuflen;
p->fr.mallocd = 0; p->fr.mallocd = 0;

View File

@@ -160,7 +160,7 @@ static struct ast_frame *bestdata_handle_escape(struct ast_modem_pvt *p, char es
p->fr.subclass = 0; p->fr.subclass = 0;
p->fr.data = NULL; p->fr.data = NULL;
p->fr.datalen = 0; p->fr.datalen = 0;
p->fr.timelen = 0; p->fr.samples = 0;
p->fr.offset = 0; p->fr.offset = 0;
p->fr.mallocd = 0; p->fr.mallocd = 0;
if (esc) if (esc)
@@ -364,7 +364,7 @@ static struct ast_frame *bestdata_read(struct ast_modem_pvt *p)
/* If we get here, we have a complete voice frame */ /* If we get here, we have a complete voice frame */
p->fr.frametype = AST_FRAME_VOICE; p->fr.frametype = AST_FRAME_VOICE;
p->fr.subclass = AST_FORMAT_SLINEAR; p->fr.subclass = AST_FORMAT_SLINEAR;
p->fr.timelen = 30; p->fr.samples = 240;
p->fr.data = p->obuf; p->fr.data = p->obuf;
p->fr.datalen = p->obuflen; p->fr.datalen = p->obuflen;
p->fr.mallocd = 0; p->fr.mallocd = 0;

View File

@@ -17,6 +17,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
#include <unistd.h> #include <unistd.h>
#include <sys/ioctl.h>
#include <asterisk/lock.h> #include <asterisk/lock.h>
#include <asterisk/vmodem.h> #include <asterisk/vmodem.h>
#include <asterisk/module.h> #include <asterisk/module.h>
@@ -151,11 +152,37 @@ static int i4l_init(struct ast_modem_pvt *p)
return -1; return -1;
} }
} }
if (strlen(p->incomingmsn)) {
char *q;
snprintf(cmd, sizeof(cmd), "AT&L%s", p->incomingmsn);
// translate , into ; since that is the seperator I4L uses, but can't be directly
// put in the config file because it will interpret the rest of the line as comment.
q = cmd+4;
while (*q) {
if (*q == ',') *q = ';';
++q;
}
if (ast_modem_send(p, cmd, 0) ||
ast_modem_expect(p, "OK", 5)) {
ast_log(LOG_WARNING, "Unable to set Listen to %s\n", p->msn);
return -1;
}
}
if (ast_modem_send(p, "AT&D2", 0) ||
ast_modem_expect(p, "OK", 5)) {
ast_log(LOG_WARNING, "Unable to set to DTR disconnect mode\n");
return -1;
}
if (ast_modem_send(p, "ATS18=1", 0) || if (ast_modem_send(p, "ATS18=1", 0) ||
ast_modem_expect(p, "OK", 5)) { ast_modem_expect(p, "OK", 5)) {
ast_log(LOG_WARNING, "Unable to set to audio only mode\n"); ast_log(LOG_WARNING, "Unable to set to audio only mode\n");
return -1; return -1;
} }
if (ast_modem_send(p, "ATS13.6=1", 0) ||
ast_modem_expect(p, "OK", 5)) {
ast_log(LOG_WARNING, "Unable to set to RUNG indication\n");
return -1;
}
if (ast_modem_send(p, "ATS14=4", 0) || if (ast_modem_send(p, "ATS14=4", 0) ||
ast_modem_expect(p, "OK", 5)) { ast_modem_expect(p, "OK", 5)) {
ast_log(LOG_WARNING, "Unable to set to transparent mode\n"); ast_log(LOG_WARNING, "Unable to set to transparent mode\n");
@@ -189,7 +216,7 @@ static struct ast_frame *i4l_handle_escape(struct ast_modem_pvt *p, char esc)
p->fr.subclass = 0; p->fr.subclass = 0;
p->fr.data = NULL; p->fr.data = NULL;
p->fr.datalen = 0; p->fr.datalen = 0;
p->fr.timelen = 0; p->fr.samples = 0;
p->fr.offset = 0; p->fr.offset = 0;
p->fr.mallocd = 0; p->fr.mallocd = 0;
if (esc && option_debug) if (esc && option_debug)
@@ -271,7 +298,15 @@ static struct ast_frame *i4l_read(struct ast_modem_pvt *p)
int x; int x;
if (p->ministate == STATE_COMMAND) { if (p->ministate == STATE_COMMAND) {
/* Read the first two bytes, first, in case it's a control message */ /* Read the first two bytes, first, in case it's a control message */
read(p->fd, result, 2); res = read(p->fd, result, 2);
if (res < 2) {
// short read, means there was a hangup?
// (or is this also possible without hangup?)
// Anyway, reading from unitialized buffers is a bad idea anytime.
if (errno == EAGAIN)
return i4l_handle_escape(p, 0);
return NULL;
}
if (result[0] == CHAR_DLE) { if (result[0] == CHAR_DLE) {
return i4l_handle_escape(p, result[1]); return i4l_handle_escape(p, result[1]);
@@ -283,7 +318,7 @@ static struct ast_frame *i4l_read(struct ast_modem_pvt *p)
ast_modem_trim(result); ast_modem_trim(result);
if (!strcasecmp(result, "VCON")) { if (!strcasecmp(result, "VCON")) {
/* If we're in immediate mode, reply now */ /* If we're in immediate mode, reply now */
if (p->mode == MODEM_MODE_IMMEDIATE) // if (p->mode == MODEM_MODE_IMMEDIATE)
return i4l_handle_escape(p, 'X'); return i4l_handle_escape(p, 'X');
} else } else
if (!strcasecmp(result, "BUSY")) { if (!strcasecmp(result, "BUSY")) {
@@ -292,16 +327,22 @@ static struct ast_frame *i4l_read(struct ast_modem_pvt *p)
} else } else
if (!strncasecmp(result, "CALLER NUMBER: ", 15 )) { if (!strncasecmp(result, "CALLER NUMBER: ", 15 )) {
strncpy(p->cid, result + 15, sizeof(p->cid)-1); strncpy(p->cid, result + 15, sizeof(p->cid)-1);
return i4l_handle_escape(p, 'R'); return i4l_handle_escape(p, 0);
} else } else
if (!strcasecmp(result, "RINGING")) { if (!strcasecmp(result, "RINGING")) {
if (option_verbose > 2) if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "%s is ringing...\n", p->dev); ast_verbose(VERBOSE_PREFIX_3 "%s is ringing...\n", p->dev);
return i4l_handle_escape(p, 'I'); return i4l_handle_escape(p, 'I');
} else } else
if (!strncasecmp(result, "RUNG", 4)) {
/* PM2002: the line was hung up before we picked it up, bye bye */
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "%s was hung up on before we answered\n", p->dev);
return NULL;
} else
if (!strncasecmp(result, "RING", 4)) { if (!strncasecmp(result, "RING", 4)) {
if (result[4]=='/') if (result[4]=='/')
strncpy(p->dnid, result + 4, sizeof(p->dnid)-1); strncpy(p->dnid, result + 5, sizeof(p->dnid)-1);
return i4l_handle_escape(p, 'R'); return i4l_handle_escape(p, 'R');
} else } else
if (!strcasecmp(result, "NO CARRIER")) { if (!strcasecmp(result, "NO CARRIER")) {
@@ -329,6 +370,7 @@ static struct ast_frame *i4l_read(struct ast_modem_pvt *p)
if (errno == EAGAIN) if (errno == EAGAIN)
return i4l_handle_escape(p, 0); return i4l_handle_escape(p, 0);
ast_log(LOG_WARNING, "Read failed: %s\n", strerror(errno)); ast_log(LOG_WARNING, "Read failed: %s\n", strerror(errno));
return NULL;
} }
for (x=0;x<res;x++) { for (x=0;x<res;x++) {
@@ -372,7 +414,7 @@ static struct ast_frame *i4l_read(struct ast_modem_pvt *p)
/* If we get here, we have a complete voice frame */ /* If we get here, we have a complete voice frame */
p->fr.frametype = AST_FRAME_VOICE; p->fr.frametype = AST_FRAME_VOICE;
p->fr.subclass = AST_FORMAT_SLINEAR; p->fr.subclass = AST_FORMAT_SLINEAR;
p->fr.timelen = 30; p->fr.samples = 240;
p->fr.data = p->obuf; p->fr.data = p->obuf;
p->fr.datalen = p->obuflen; p->fr.datalen = p->obuflen;
p->fr.mallocd = 0; p->fr.mallocd = 0;
@@ -497,32 +539,24 @@ static int i4l_dial(struct ast_modem_pvt *p, char *stuff)
static int i4l_hangup(struct ast_modem_pvt *p) static int i4l_hangup(struct ast_modem_pvt *p)
{ {
char dummy[50]; char dummy[50];
sprintf(dummy, "%c%c", 0x10, 0x3); int dtr = TIOCM_DTR;
if (write(p->fd, dummy, 2) < 0) {
ast_log(LOG_WARNING, "Failed to break\n"); /* down DTR to hangup modem */
return -1; ioctl(p->fd, TIOCMBIC, &dtr);
}
/* Read anything outstanding */ /* Read anything outstanding */
while(read(p->fd, dummy, sizeof(dummy)) > 0); while(read(p->fd, dummy, sizeof(dummy)) > 0);
sprintf(dummy, "%c%c", 0x10, 0x14); /* rise DTR to re-enable line */
if (write(p->fd, dummy, 2) < 0) { ioctl(p->fd, TIOCMBIS, &dtr);
ast_log(LOG_WARNING, "Failed to break\n");
return -1; /* Read anything outstanding */
} while(read(p->fd, dummy, sizeof(dummy)) > 0);
ast_modem_expect(p, "VCON", 1);
#if 0 /* basically we're done, just to be sure */
if (ast_modem_expect(p, "VCON", 8)) {
ast_log(LOG_WARNING, "Didn't get expected VCON\n");
return -1;
}
#endif
write(p->fd, "\n\n", 2); write(p->fd, "\n\n", 2);
read(p->fd, dummy, sizeof(dummy)); read(p->fd, dummy, sizeof(dummy));
/* Hangup by switching to data, then back to voice */ if (ast_modem_send(p, "ATH", 0)) {
if (ast_modem_send(p, "ATH", 0) ||
ast_modem_expect(p, "NO CARRIER", 8)) {
ast_log(LOG_WARNING, "Unable to hang up\n"); ast_log(LOG_WARNING, "Unable to hang up\n");
return -1; return -1;
} }
@@ -530,6 +564,7 @@ static int i4l_hangup(struct ast_modem_pvt *p)
ast_log(LOG_WARNING, "Final 'OK' not received\n"); ast_log(LOG_WARNING, "Final 'OK' not received\n");
return -1; return -1;
} }
return 0; return 0;
} }

View File

@@ -320,7 +320,7 @@ static struct ast_frame *phone_exception(struct ast_channel *ast)
/* Some nice norms */ /* Some nice norms */
p->fr.datalen = 0; p->fr.datalen = 0;
p->fr.timelen = 0; p->fr.samples = 0;
p->fr.data = NULL; p->fr.data = NULL;
p->fr.src = type; p->fr.src = type;
p->fr.offset = 0; p->fr.offset = 0;
@@ -381,7 +381,7 @@ static struct ast_frame *phone_read(struct ast_channel *ast)
/* Some nice norms */ /* Some nice norms */
p->fr.datalen = 0; p->fr.datalen = 0;
p->fr.timelen = 0; p->fr.samples = 0;
p->fr.data = NULL; p->fr.data = NULL;
p->fr.src = type; p->fr.src = type;
p->fr.offset = 0; p->fr.offset = 0;
@@ -415,6 +415,7 @@ static struct ast_frame *phone_read(struct ast_channel *ast)
res = 4; res = 4;
break; break;
} }
p->fr.samples = 240;
p->fr.datalen = res; p->fr.datalen = res;
p->fr.frametype = AST_FRAME_VOICE; p->fr.frametype = AST_FRAME_VOICE;
p->fr.subclass = p->lastinput; p->fr.subclass = p->lastinput;
@@ -630,6 +631,8 @@ static struct ast_channel *phone_new(struct phone_pvt *i, int state, char *conte
strncpy(tmp->context, context, sizeof(tmp->context)-1); strncpy(tmp->context, context, sizeof(tmp->context)-1);
if (strlen(i->ext)) if (strlen(i->ext))
strncpy(tmp->exten, i->ext, sizeof(tmp->exten)-1); strncpy(tmp->exten, i->ext, sizeof(tmp->exten)-1);
else
strncpy(tmp->exten, "s", sizeof(tmp->exten) - 1);
if (strlen(i->language)) if (strlen(i->language))
strncpy(tmp->language, i->language, sizeof(tmp->language)-1); strncpy(tmp->language, i->language, sizeof(tmp->language)-1);
if (strlen(i->callerid)) if (strlen(i->callerid))

View File

@@ -125,7 +125,7 @@ alawtoulaw_frameout (struct ast_translator_pvt *pvt)
tmp->f.frametype = AST_FRAME_VOICE; tmp->f.frametype = AST_FRAME_VOICE;
tmp->f.subclass = AST_FORMAT_ULAW; tmp->f.subclass = AST_FORMAT_ULAW;
tmp->f.datalen = tmp->tail; tmp->f.datalen = tmp->tail;
tmp->f.timelen = tmp->tail / 8; tmp->f.samples = tmp->tail;
tmp->f.mallocd = 0; tmp->f.mallocd = 0;
tmp->f.offset = AST_FRIENDLY_OFFSET; tmp->f.offset = AST_FRIENDLY_OFFSET;
tmp->f.src = __PRETTY_FUNCTION__; tmp->f.src = __PRETTY_FUNCTION__;
@@ -172,7 +172,7 @@ ulawtoalaw_frameout (struct ast_translator_pvt *pvt)
if (tmp->tail) { if (tmp->tail) {
tmp->f.frametype = AST_FRAME_VOICE; tmp->f.frametype = AST_FRAME_VOICE;
tmp->f.subclass = AST_FORMAT_ALAW; tmp->f.subclass = AST_FORMAT_ALAW;
tmp->f.timelen = tmp->tail / 8; tmp->f.samples = tmp->tail;
tmp->f.mallocd = 0; tmp->f.mallocd = 0;
tmp->f.offset = AST_FRIENDLY_OFFSET; tmp->f.offset = AST_FRIENDLY_OFFSET;
tmp->f.src = __PRETTY_FUNCTION__; tmp->f.src = __PRETTY_FUNCTION__;
@@ -195,7 +195,7 @@ alawtoulaw_sample ()
f.frametype = AST_FRAME_VOICE; f.frametype = AST_FRAME_VOICE;
f.subclass = AST_FORMAT_ALAW; f.subclass = AST_FORMAT_ALAW;
f.datalen = sizeof (ulaw_slin_ex); f.datalen = sizeof (ulaw_slin_ex);
f.timelen = sizeof(ulaw_slin_ex) / 8; f.samples = sizeof(ulaw_slin_ex);
f.mallocd = 0; f.mallocd = 0;
f.offset = 0; f.offset = 0;
f.src = __PRETTY_FUNCTION__; f.src = __PRETTY_FUNCTION__;
@@ -210,7 +210,7 @@ ulawtoalaw_sample ()
f.frametype = AST_FRAME_VOICE; f.frametype = AST_FRAME_VOICE;
f.subclass = AST_FORMAT_ULAW; f.subclass = AST_FORMAT_ULAW;
f.datalen = sizeof (ulaw_slin_ex); f.datalen = sizeof (ulaw_slin_ex);
f.timelen = sizeof(ulaw_slin_ex) / 8; f.samples = sizeof(ulaw_slin_ex);
f.mallocd = 0; f.mallocd = 0;
f.offset = 0; f.offset = 0;
f.src = __PRETTY_FUNCTION__; f.src = __PRETTY_FUNCTION__;

View File

@@ -290,7 +290,7 @@ adpcmtolin_framein (struct ast_translator_pvt *pvt, struct ast_frame *f)
* *
* Results: * Results:
* Converted signals are placed in tmp->f.data, tmp->f.datalen * Converted signals are placed in tmp->f.data, tmp->f.datalen
* and tmp->f.timelen are calculated. * and tmp->f.samples are calculated.
* *
* Side effects: * Side effects:
* None. * None.
@@ -307,7 +307,7 @@ adpcmtolin_frameout (struct ast_translator_pvt *pvt)
tmp->f.frametype = AST_FRAME_VOICE; tmp->f.frametype = AST_FRAME_VOICE;
tmp->f.subclass = AST_FORMAT_SLINEAR; tmp->f.subclass = AST_FORMAT_SLINEAR;
tmp->f.datalen = tmp->tail *2; tmp->f.datalen = tmp->tail *2;
tmp->f.timelen = tmp->tail / 8; tmp->f.samples = tmp->tail;
tmp->f.mallocd = 0; tmp->f.mallocd = 0;
tmp->f.offset = AST_FRIENDLY_OFFSET; tmp->f.offset = AST_FRIENDLY_OFFSET;
tmp->f.src = __PRETTY_FUNCTION__; tmp->f.src = __PRETTY_FUNCTION__;
@@ -383,7 +383,7 @@ lintoadpcm_frameout (struct ast_translator_pvt *pvt)
tmp->f.frametype = AST_FRAME_VOICE; tmp->f.frametype = AST_FRAME_VOICE;
tmp->f.subclass = AST_FORMAT_ADPCM; tmp->f.subclass = AST_FORMAT_ADPCM;
tmp->f.timelen = i_max / 8; tmp->f.samples = i_max;
tmp->f.mallocd = 0; tmp->f.mallocd = 0;
tmp->f.offset = AST_FRIENDLY_OFFSET; tmp->f.offset = AST_FRIENDLY_OFFSET;
tmp->f.src = __PRETTY_FUNCTION__; tmp->f.src = __PRETTY_FUNCTION__;
@@ -417,7 +417,7 @@ adpcmtolin_sample ()
f.frametype = AST_FRAME_VOICE; f.frametype = AST_FRAME_VOICE;
f.subclass = AST_FORMAT_ADPCM; f.subclass = AST_FORMAT_ADPCM;
f.datalen = sizeof (adpcm_slin_ex); f.datalen = sizeof (adpcm_slin_ex);
f.timelen = sizeof(adpcm_slin_ex) / 4; f.samples = sizeof(adpcm_slin_ex) * 2;
f.mallocd = 0; f.mallocd = 0;
f.offset = 0; f.offset = 0;
f.src = __PRETTY_FUNCTION__; f.src = __PRETTY_FUNCTION__;
@@ -437,7 +437,7 @@ lintoadpcm_sample ()
f.subclass = AST_FORMAT_SLINEAR; f.subclass = AST_FORMAT_SLINEAR;
f.datalen = sizeof (slin_adpcm_ex); f.datalen = sizeof (slin_adpcm_ex);
/* Assume 8000 Hz */ /* Assume 8000 Hz */
f.timelen = sizeof (slin_adpcm_ex) / 16; f.samples = sizeof (slin_adpcm_ex) / 2;
f.mallocd = 0; f.mallocd = 0;
f.offset = 0; f.offset = 0;
f.src = __PRETTY_FUNCTION__; f.src = __PRETTY_FUNCTION__;

View File

@@ -151,7 +151,7 @@ alawtolin_framein (struct ast_translator_pvt *pvt, struct ast_frame *f)
* *
* Results: * Results:
* Converted signals are placed in tmp->f.data, tmp->f.datalen * Converted signals are placed in tmp->f.data, tmp->f.datalen
* and tmp->f.timelen are calculated. * and tmp->f.samples are calculated.
* *
* Side effects: * Side effects:
* None. * None.
@@ -168,7 +168,7 @@ alawtolin_frameout (struct ast_translator_pvt *pvt)
tmp->f.frametype = AST_FRAME_VOICE; tmp->f.frametype = AST_FRAME_VOICE;
tmp->f.subclass = AST_FORMAT_SLINEAR; tmp->f.subclass = AST_FORMAT_SLINEAR;
tmp->f.datalen = tmp->tail *2; tmp->f.datalen = tmp->tail *2;
tmp->f.timelen = tmp->tail / 8; tmp->f.samples = tmp->tail;
tmp->f.mallocd = 0; tmp->f.mallocd = 0;
tmp->f.offset = AST_FRIENDLY_OFFSET; tmp->f.offset = AST_FRIENDLY_OFFSET;
tmp->f.src = __PRETTY_FUNCTION__; tmp->f.src = __PRETTY_FUNCTION__;
@@ -226,7 +226,7 @@ lintoalaw_frameout (struct ast_translator_pvt *pvt)
if (tmp->tail) { if (tmp->tail) {
tmp->f.frametype = AST_FRAME_VOICE; tmp->f.frametype = AST_FRAME_VOICE;
tmp->f.subclass = AST_FORMAT_ALAW; tmp->f.subclass = AST_FORMAT_ALAW;
tmp->f.timelen = tmp->tail / 8; tmp->f.samples = tmp->tail;
tmp->f.mallocd = 0; tmp->f.mallocd = 0;
tmp->f.offset = AST_FRIENDLY_OFFSET; tmp->f.offset = AST_FRIENDLY_OFFSET;
tmp->f.src = __PRETTY_FUNCTION__; tmp->f.src = __PRETTY_FUNCTION__;
@@ -249,7 +249,7 @@ alawtolin_sample ()
f.frametype = AST_FRAME_VOICE; f.frametype = AST_FRAME_VOICE;
f.subclass = AST_FORMAT_ALAW; f.subclass = AST_FORMAT_ALAW;
f.datalen = sizeof (ulaw_slin_ex); f.datalen = sizeof (ulaw_slin_ex);
f.timelen = sizeof(ulaw_slin_ex) / 8; f.samples = sizeof(ulaw_slin_ex);
f.mallocd = 0; f.mallocd = 0;
f.offset = 0; f.offset = 0;
f.src = __PRETTY_FUNCTION__; f.src = __PRETTY_FUNCTION__;
@@ -269,7 +269,7 @@ lintoalaw_sample ()
f.subclass = AST_FORMAT_SLINEAR; f.subclass = AST_FORMAT_SLINEAR;
f.datalen = sizeof (slin_ulaw_ex); f.datalen = sizeof (slin_ulaw_ex);
/* Assume 8000 Hz */ /* Assume 8000 Hz */
f.timelen = sizeof (slin_ulaw_ex) / 16; f.samples = sizeof (slin_ulaw_ex) / 2;
f.mallocd = 0; f.mallocd = 0;
f.offset = 0; f.offset = 0;
f.src = __PRETTY_FUNCTION__; f.src = __PRETTY_FUNCTION__;

View File

@@ -79,7 +79,7 @@ static struct ast_frame *lintogsm_sample()
f.subclass = AST_FORMAT_SLINEAR; f.subclass = AST_FORMAT_SLINEAR;
f.datalen = sizeof(slin_gsm_ex); f.datalen = sizeof(slin_gsm_ex);
/* Assume 8000 Hz */ /* Assume 8000 Hz */
f.timelen = sizeof(slin_gsm_ex)/16; f.samples = sizeof(slin_gsm_ex)/2;
f.mallocd = 0; f.mallocd = 0;
f.offset = 0; f.offset = 0;
f.src = __PRETTY_FUNCTION__; f.src = __PRETTY_FUNCTION__;
@@ -94,7 +94,7 @@ static struct ast_frame *gsmtolin_sample()
f.subclass = AST_FORMAT_GSM; f.subclass = AST_FORMAT_GSM;
f.datalen = sizeof(gsm_slin_ex); f.datalen = sizeof(gsm_slin_ex);
/* All frames are 20 ms long */ /* All frames are 20 ms long */
f.timelen = 20; f.samples = 160;
f.mallocd = 0; f.mallocd = 0;
f.offset = 0; f.offset = 0;
f.src = __PRETTY_FUNCTION__; f.src = __PRETTY_FUNCTION__;
@@ -112,7 +112,7 @@ static struct ast_frame *gsmtolin_frameout(struct ast_translator_pvt *tmp)
tmp->f.subclass = AST_FORMAT_SLINEAR; tmp->f.subclass = AST_FORMAT_SLINEAR;
tmp->f.datalen = tmp->tail * 2; tmp->f.datalen = tmp->tail * 2;
/* Assume 8000 Hz */ /* Assume 8000 Hz */
tmp->f.timelen = tmp->tail / 8; tmp->f.samples = tmp->tail;
tmp->f.mallocd = 0; tmp->f.mallocd = 0;
tmp->f.offset = AST_FRIENDLY_OFFSET; tmp->f.offset = AST_FRIENDLY_OFFSET;
tmp->f.src = __PRETTY_FUNCTION__; tmp->f.src = __PRETTY_FUNCTION__;
@@ -190,7 +190,7 @@ static struct ast_frame *lintogsm_frameout(struct ast_translator_pvt *tmp)
x++; x++;
} }
tmp->f.datalen = x * 33; tmp->f.datalen = x * 33;
tmp->f.timelen = x * 20; tmp->f.samples = x * 160;
return &tmp->f; return &tmp->f;
} }

View File

@@ -100,14 +100,11 @@ static struct ast_translator_pvt *lpc10_dec_new()
static struct ast_frame *lintolpc10_sample() static struct ast_frame *lintolpc10_sample()
{ {
static struct ast_frame f; static struct ast_frame f;
static int longer = 0;
f.frametype = AST_FRAME_VOICE; f.frametype = AST_FRAME_VOICE;
f.subclass = AST_FORMAT_SLINEAR; f.subclass = AST_FORMAT_SLINEAR;
f.datalen = sizeof(slin_lpc10_ex); f.datalen = sizeof(slin_lpc10_ex);
/* Assume 8000 Hz */ /* Assume 8000 Hz */
f.timelen = LPC10_SAMPLES_PER_FRAME/8; f.samples = LPC10_SAMPLES_PER_FRAME;
f.timelen += longer;
longer = 1- longer;
f.mallocd = 0; f.mallocd = 0;
f.offset = 0; f.offset = 0;
f.src = __PRETTY_FUNCTION__; f.src = __PRETTY_FUNCTION__;
@@ -123,7 +120,7 @@ static struct ast_frame *lpc10tolin_sample()
f.datalen = sizeof(lpc10_slin_ex); f.datalen = sizeof(lpc10_slin_ex);
/* All frames are 22 ms long (maybe a little more -- why did he choose /* All frames are 22 ms long (maybe a little more -- why did he choose
LPC10_SAMPLES_PER_FRAME sample frames anyway?? */ LPC10_SAMPLES_PER_FRAME sample frames anyway?? */
f.timelen = LPC10_SAMPLES_PER_FRAME/8; f.samples = LPC10_SAMPLES_PER_FRAME;
f.mallocd = 0; f.mallocd = 0;
f.offset = 0; f.offset = 0;
f.src = __PRETTY_FUNCTION__; f.src = __PRETTY_FUNCTION__;
@@ -141,7 +138,7 @@ static struct ast_frame *lpc10tolin_frameout(struct ast_translator_pvt *tmp)
tmp->f.subclass = AST_FORMAT_SLINEAR; tmp->f.subclass = AST_FORMAT_SLINEAR;
tmp->f.datalen = tmp->tail * 2; tmp->f.datalen = tmp->tail * 2;
/* Assume 8000 Hz */ /* Assume 8000 Hz */
tmp->f.timelen = tmp->tail / 8; tmp->f.samples = tmp->tail;
tmp->f.mallocd = 0; tmp->f.mallocd = 0;
tmp->f.offset = AST_FRIENDLY_OFFSET; tmp->f.offset = AST_FRIENDLY_OFFSET;
tmp->f.src = __PRETTY_FUNCTION__; tmp->f.src = __PRETTY_FUNCTION__;
@@ -254,7 +251,7 @@ static struct ast_frame *lintolpc10_frameout(struct ast_translator_pvt *tmp)
if (tmp->tail < LPC10_SAMPLES_PER_FRAME) if (tmp->tail < LPC10_SAMPLES_PER_FRAME)
return NULL; return NULL;
/* Start with an empty frame */ /* Start with an empty frame */
tmp->f.timelen = 0; tmp->f.samples = 0;
tmp->f.datalen = 0; tmp->f.datalen = 0;
tmp->f.frametype = AST_FRAME_VOICE; tmp->f.frametype = AST_FRAME_VOICE;
tmp->f.subclass = AST_FORMAT_LPC10; tmp->f.subclass = AST_FORMAT_LPC10;
@@ -270,9 +267,7 @@ static struct ast_frame *lintolpc10_frameout(struct ast_translator_pvt *tmp)
lpc10_encode(tmpbuf, bits, tmp->lpc10.enc); lpc10_encode(tmpbuf, bits, tmp->lpc10.enc);
build_bits(((unsigned char *)tmp->outbuf) + tmp->f.datalen, bits); build_bits(((unsigned char *)tmp->outbuf) + tmp->f.datalen, bits);
tmp->f.datalen += LPC10_BYTES_IN_COMPRESSED_FRAME; tmp->f.datalen += LPC10_BYTES_IN_COMPRESSED_FRAME;
tmp->f.timelen += 22; tmp->f.samples += LPC10_SAMPLES_PER_FRAME;
/* We alternate between 22 and 23 ms to simulate 22.5 ms */
tmp->f.timelen += tmp->longer;
/* Use one of the two left over bits to record if this is a 22 or 23 ms frame... /* Use one of the two left over bits to record if this is a 22 or 23 ms frame...
important for IAX use */ important for IAX use */
tmp->longer = 1 - tmp->longer; tmp->longer = 1 - tmp->longer;

View File

@@ -101,7 +101,7 @@ static struct ast_frame *mp3tolin_sample()
f.data = mp3_slin_ex; f.data = mp3_slin_ex;
f.datalen = sizeof(mp3_slin_ex); f.datalen = sizeof(mp3_slin_ex);
/* Dunno how long an mp3 frame is -- kinda irrelevant anyway */ /* Dunno how long an mp3 frame is -- kinda irrelevant anyway */
f.timelen = 30; f.samples = 240;
f.mallocd = 0; f.mallocd = 0;
f.offset = 0; f.offset = 0;
f.src = __PRETTY_FUNCTION__; f.src = __PRETTY_FUNCTION__;
@@ -118,7 +118,7 @@ static struct ast_frame *mp3tolin_frameout(struct ast_translator_pvt *tmp)
tmp->f.subclass = AST_FORMAT_SLINEAR; tmp->f.subclass = AST_FORMAT_SLINEAR;
tmp->f.datalen = tmp->tail * 2; tmp->f.datalen = tmp->tail * 2;
/* Assume 8000 Hz */ /* Assume 8000 Hz */
tmp->f.timelen = tmp->tail / 8; tmp->f.samples = tmp->tail;
tmp->f.mallocd = 0; tmp->f.mallocd = 0;
tmp->f.offset = AST_FRIENDLY_OFFSET; tmp->f.offset = AST_FRIENDLY_OFFSET;
tmp->f.src = __PRETTY_FUNCTION__; tmp->f.src = __PRETTY_FUNCTION__;

View File

@@ -151,7 +151,7 @@ ulawtolin_framein (struct ast_translator_pvt *pvt, struct ast_frame *f)
* *
* Results: * Results:
* Converted signals are placed in tmp->f.data, tmp->f.datalen * Converted signals are placed in tmp->f.data, tmp->f.datalen
* and tmp->f.timelen are calculated. * and tmp->f.samples are calculated.
* *
* Side effects: * Side effects:
* None. * None.
@@ -168,7 +168,7 @@ ulawtolin_frameout (struct ast_translator_pvt *pvt)
tmp->f.frametype = AST_FRAME_VOICE; tmp->f.frametype = AST_FRAME_VOICE;
tmp->f.subclass = AST_FORMAT_SLINEAR; tmp->f.subclass = AST_FORMAT_SLINEAR;
tmp->f.datalen = tmp->tail *2; tmp->f.datalen = tmp->tail *2;
tmp->f.timelen = tmp->tail / 8; tmp->f.samples = tmp->tail;
tmp->f.mallocd = 0; tmp->f.mallocd = 0;
tmp->f.offset = AST_FRIENDLY_OFFSET; tmp->f.offset = AST_FRIENDLY_OFFSET;
tmp->f.src = __PRETTY_FUNCTION__; tmp->f.src = __PRETTY_FUNCTION__;
@@ -226,7 +226,7 @@ lintoulaw_frameout (struct ast_translator_pvt *pvt)
if (tmp->tail) { if (tmp->tail) {
tmp->f.frametype = AST_FRAME_VOICE; tmp->f.frametype = AST_FRAME_VOICE;
tmp->f.subclass = AST_FORMAT_ULAW; tmp->f.subclass = AST_FORMAT_ULAW;
tmp->f.timelen = tmp->tail / 8; tmp->f.samples = tmp->tail;
tmp->f.mallocd = 0; tmp->f.mallocd = 0;
tmp->f.offset = AST_FRIENDLY_OFFSET; tmp->f.offset = AST_FRIENDLY_OFFSET;
tmp->f.src = __PRETTY_FUNCTION__; tmp->f.src = __PRETTY_FUNCTION__;
@@ -249,7 +249,7 @@ ulawtolin_sample ()
f.frametype = AST_FRAME_VOICE; f.frametype = AST_FRAME_VOICE;
f.subclass = AST_FORMAT_ULAW; f.subclass = AST_FORMAT_ULAW;
f.datalen = sizeof (ulaw_slin_ex); f.datalen = sizeof (ulaw_slin_ex);
f.timelen = sizeof(ulaw_slin_ex) / 8; f.samples = sizeof(ulaw_slin_ex);
f.mallocd = 0; f.mallocd = 0;
f.offset = 0; f.offset = 0;
f.src = __PRETTY_FUNCTION__; f.src = __PRETTY_FUNCTION__;
@@ -269,7 +269,7 @@ lintoulaw_sample ()
f.subclass = AST_FORMAT_SLINEAR; f.subclass = AST_FORMAT_SLINEAR;
f.datalen = sizeof (slin_ulaw_ex); f.datalen = sizeof (slin_ulaw_ex);
/* Assume 8000 Hz */ /* Assume 8000 Hz */
f.timelen = sizeof (slin_ulaw_ex) / 16; f.samples = sizeof (slin_ulaw_ex) / 2;
f.mallocd = 0; f.mallocd = 0;
f.offset = 0; f.offset = 0;
f.src = __PRETTY_FUNCTION__; f.src = __PRETTY_FUNCTION__;