diff --git a/apps/app_disa.c b/apps/app_disa.c index a105c9ed8c7677df6ed596451a0cc1ba4ddb1f1d..89d956deb6b07c3ee397987f7cbced6431fd92da 100755 --- a/apps/app_disa.c +++ b/apps/app_disa.c @@ -116,12 +116,13 @@ static int disa_exec(struct ast_channel *chan, void *data) int i,j,k,x; struct localuser *u; 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; struct ast_frame *f,wf; struct timeval lastout, now, lastdigittime; int res; FILE *fp; + char *stringp=NULL; 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; } lastout.tv_sec = lastout.tv_usec = 0; - /* make block of silence */ - memset(sil_block,0x7f,sizeof(sil_block)); if (!data || !strlen((char *)data)) { ast_log(LOG_WARNING, "disa requires an argument (passcode/passcode file)\n"); return -1; } strncpy(tmp, (char *)data, sizeof(tmp)-1); - strtok(tmp, "|"); - ourcontext = strtok(NULL, "|"); + stringp=tmp; + strsep(&stringp, "|"); + ourcontext = strsep(&stringp, "|"); /* if context specified, save 2nd arg and parse third */ if (ourcontext) { strcpy(arg2,ourcontext); - ourcallerid = strtok(NULL,"|"); + ourcallerid = strsep(&stringp,"|"); } /* if context not specified, use "disa" */ 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 */ exten[0] = 0; + acctcode[0] = 0; /* can we access DISA without 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.datalen = f->datalen; make_tone_block(tone_block, 350, 440, f->datalen, &x); - wf.timelen = wf.datalen / 8; + wf.samples = wf.datalen; ast_frfree(f); if (ast_write(chan, &wf)) { @@ -250,6 +251,7 @@ static int disa_exec(struct ast_channel *chan, void *data) tmp[0] = 0; while(fgets(tmp,sizeof(tmp) - 1,fp)) { + char *stringp=NULL; if (!tmp[0]) continue; if (tmp[strlen(tmp) - 1] == '\n') tmp[strlen(tmp) - 1] = 0; @@ -257,10 +259,11 @@ static int disa_exec(struct ast_channel *chan, void *data) /* skip comments */ if (tmp[0] == '#') continue; if (tmp[0] == ';') continue; - strtok(tmp, "|"); + stringp=tmp; + strsep(&stringp, "|"); /* save 2nd arg as clid */ ourcallerid = arg2; - ourcontext = strtok(NULL, "|"); + ourcontext = strsep(&stringp, "|"); /* password must be in valid format (numeric) */ if (sscanf(tmp,"%d",&j) < 1) continue; /* if we got it */ @@ -328,7 +331,7 @@ reorder: wf.mallocd = 0; wf.data = tone_block; wf.datalen = f->datalen; - wf.timelen = wf.datalen / 8; + wf.samples = wf.datalen; if (k) memset(tone_block, 0x7f, wf.datalen); else diff --git a/apps/app_festival.c b/apps/app_festival.c index d45988c991fc6417f4909e070a0cdf2cbfacfd65..1e88fff8e53914fb5533cd488a714d182539eb07 100755 --- a/apps/app_festival.c +++ b/apps/app_festival.c @@ -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.subclass = AST_FORMAT_SLINEAR; myf.f.datalen = res; - myf.f.timelen = res / 16; + myf.f.samples = res / 2; myf.f.mallocd = 0; myf.f.offset = AST_FRIENDLY_OFFSET; myf.f.src = __PRETTY_FUNCTION__; diff --git a/apps/app_mp3.c b/apps/app_mp3.c index 5ef5f9bb0d62e0b878de2aacca7a8513c7731fe6..e99415d53df602858c62f50cd3eea1cb509fbf49 100755 --- a/apps/app_mp3.c +++ b/apps/app_mp3.c @@ -164,7 +164,7 @@ static int mp3_exec(struct ast_channel *chan, void *data) myf.f.frametype = AST_FRAME_VOICE; myf.f.subclass = AST_FORMAT_SLINEAR; myf.f.datalen = res; - myf.f.timelen = res / 16; + myf.f.samples = res / 2; myf.f.mallocd = 0; myf.f.offset = AST_FRIENDLY_OFFSET; myf.f.src = __PRETTY_FUNCTION__; diff --git a/channels/chan_alsa.c b/channels/chan_alsa.c index 3e35a821fc538dd3c120db490d1f9696b515172e..225c8ba741b0710c351804e0590729e521aa5bdc 100755 --- a/channels/chan_alsa.c +++ b/channels/chan_alsa.c @@ -646,7 +646,7 @@ static struct ast_frame *alsa_read(struct ast_channel *chan) f.frametype = AST_FRAME_NULL; f.subclass = 0; - f.timelen = 0; + f.samples = 0; f.datalen = 0; f.data = NULL; f.offset = 0; @@ -728,7 +728,7 @@ static struct ast_frame *alsa_read(struct ast_channel *chan) } f.frametype = AST_FRAME_VOICE; f.subclass = AST_FORMAT_SLINEAR; - f.timelen = FRAME_SIZE / 8; + f.samples = FRAME_SIZE; f.datalen = FRAME_SIZE * 2; f.data = buf; f.offset = AST_FRIENDLY_OFFSET; @@ -905,8 +905,8 @@ static char sendtext_usage[] = static int console_sendtext(int fd, int argc, char *argv[]) { - int tmparg = 1; - if (argc < 1) + int tmparg = 2; + if (argc < 2) return RESULT_SHOWUSAGE; if (!alsa.owner) { 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; myc = context; if (argc == 2) { + char *stringp=NULL; strncpy(tmp, argv[1], sizeof(tmp)-1); - strtok(tmp, "@"); - tmp2 = strtok(NULL, "@"); + stringp=tmp; + strsep(&stringp, "@"); + tmp2 = strsep(&stringp, "@"); if (strlen(tmp)) mye = tmp; 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 }, { { "hangup", NULL }, console_hangup, "Hangup a call on the console", hangup_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 } }; diff --git a/channels/chan_modem_aopen.c b/channels/chan_modem_aopen.c index b33ce074c2c5729356a84cac42cf128cac113c0c..a838671de5d692304fc3c24546328977cf95304b 100755 --- a/channels/chan_modem_aopen.c +++ b/channels/chan_modem_aopen.c @@ -187,7 +187,7 @@ static struct ast_frame *aopen_handle_escape(struct ast_modem_pvt *p, char esc) p->fr.subclass = 0; p->fr.data = NULL; p->fr.datalen = 0; - p->fr.timelen = 0; + p->fr.samples = 0; p->fr.offset = 0; p->fr.mallocd = 0; 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 */ p->fr.frametype = AST_FRAME_VOICE; p->fr.subclass = AST_FORMAT_SLINEAR; - p->fr.timelen = 30; + p->fr.samples = 240; p->fr.data = p->obuf; p->fr.datalen = p->obuflen; p->fr.mallocd = 0; diff --git a/channels/chan_modem_bestdata.c b/channels/chan_modem_bestdata.c index 08a1c2e89fb5c6a59f938b85c2144eb8ab627be3..7ec76aa5ecddf71d4c40558778b4e655cfdab94f 100755 --- a/channels/chan_modem_bestdata.c +++ b/channels/chan_modem_bestdata.c @@ -160,7 +160,7 @@ static struct ast_frame *bestdata_handle_escape(struct ast_modem_pvt *p, char es p->fr.subclass = 0; p->fr.data = NULL; p->fr.datalen = 0; - p->fr.timelen = 0; + p->fr.samples = 0; p->fr.offset = 0; p->fr.mallocd = 0; 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 */ p->fr.frametype = AST_FRAME_VOICE; p->fr.subclass = AST_FORMAT_SLINEAR; - p->fr.timelen = 30; + p->fr.samples = 240; p->fr.data = p->obuf; p->fr.datalen = p->obuflen; p->fr.mallocd = 0; diff --git a/channels/chan_modem_i4l.c b/channels/chan_modem_i4l.c index 553f144ee5ffc0dd8dae1a32d57df4625ec33332..18b5a50399206b34164bc0f9dd8d4f8a4cc93da5 100755 --- a/channels/chan_modem_i4l.c +++ b/channels/chan_modem_i4l.c @@ -17,6 +17,7 @@ #include <stdlib.h> #include <errno.h> #include <unistd.h> +#include <sys/ioctl.h> #include <asterisk/lock.h> #include <asterisk/vmodem.h> #include <asterisk/module.h> @@ -151,11 +152,37 @@ static int i4l_init(struct ast_modem_pvt *p) 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) || ast_modem_expect(p, "OK", 5)) { ast_log(LOG_WARNING, "Unable to set to audio only mode\n"); 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) || ast_modem_expect(p, "OK", 5)) { 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.data = NULL; p->fr.datalen = 0; - p->fr.timelen = 0; + p->fr.samples = 0; p->fr.offset = 0; p->fr.mallocd = 0; if (esc && option_debug) @@ -271,7 +298,15 @@ static struct ast_frame *i4l_read(struct ast_modem_pvt *p) int x; if (p->ministate == STATE_COMMAND) { /* 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) { 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); if (!strcasecmp(result, "VCON")) { /* 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'); } else if (!strcasecmp(result, "BUSY")) { @@ -292,16 +327,22 @@ static struct ast_frame *i4l_read(struct ast_modem_pvt *p) } else if (!strncasecmp(result, "CALLER NUMBER: ", 15 )) { strncpy(p->cid, result + 15, sizeof(p->cid)-1); - return i4l_handle_escape(p, 'R'); + return i4l_handle_escape(p, 0); } else if (!strcasecmp(result, "RINGING")) { if (option_verbose > 2) ast_verbose(VERBOSE_PREFIX_3 "%s is ringing...\n", p->dev); return i4l_handle_escape(p, 'I'); } 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 (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'); } else if (!strcasecmp(result, "NO CARRIER")) { @@ -329,6 +370,7 @@ static struct ast_frame *i4l_read(struct ast_modem_pvt *p) if (errno == EAGAIN) return i4l_handle_escape(p, 0); ast_log(LOG_WARNING, "Read failed: %s\n", strerror(errno)); + return NULL; } 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 */ p->fr.frametype = AST_FRAME_VOICE; p->fr.subclass = AST_FORMAT_SLINEAR; - p->fr.timelen = 30; + p->fr.samples = 240; p->fr.data = p->obuf; p->fr.datalen = p->obuflen; 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) { char dummy[50]; - sprintf(dummy, "%c%c", 0x10, 0x3); - if (write(p->fd, dummy, 2) < 0) { - ast_log(LOG_WARNING, "Failed to break\n"); - return -1; - } + int dtr = TIOCM_DTR; + + /* down DTR to hangup modem */ + ioctl(p->fd, TIOCMBIC, &dtr); /* Read anything outstanding */ while(read(p->fd, dummy, sizeof(dummy)) > 0); - sprintf(dummy, "%c%c", 0x10, 0x14); - if (write(p->fd, dummy, 2) < 0) { - ast_log(LOG_WARNING, "Failed to break\n"); - return -1; - } - ast_modem_expect(p, "VCON", 1); -#if 0 - if (ast_modem_expect(p, "VCON", 8)) { - ast_log(LOG_WARNING, "Didn't get expected VCON\n"); - return -1; - } -#endif + /* rise DTR to re-enable line */ + ioctl(p->fd, TIOCMBIS, &dtr); + + /* Read anything outstanding */ + while(read(p->fd, dummy, sizeof(dummy)) > 0); + + /* basically we're done, just to be sure */ write(p->fd, "\n\n", 2); read(p->fd, dummy, sizeof(dummy)); - /* Hangup by switching to data, then back to voice */ - if (ast_modem_send(p, "ATH", 0) || - ast_modem_expect(p, "NO CARRIER", 8)) { + if (ast_modem_send(p, "ATH", 0)) { ast_log(LOG_WARNING, "Unable to hang up\n"); return -1; } @@ -530,6 +564,7 @@ static int i4l_hangup(struct ast_modem_pvt *p) ast_log(LOG_WARNING, "Final 'OK' not received\n"); return -1; } + return 0; } diff --git a/channels/chan_phone.c b/channels/chan_phone.c index 09f5b1b044163c580f1c876f4f1a1d97b7d80fb8..9a6bc9bcd5fa192c8d72265bc45c1222050b2f81 100755 --- a/channels/chan_phone.c +++ b/channels/chan_phone.c @@ -320,7 +320,7 @@ static struct ast_frame *phone_exception(struct ast_channel *ast) /* Some nice norms */ p->fr.datalen = 0; - p->fr.timelen = 0; + p->fr.samples = 0; p->fr.data = NULL; p->fr.src = type; p->fr.offset = 0; @@ -381,7 +381,7 @@ static struct ast_frame *phone_read(struct ast_channel *ast) /* Some nice norms */ p->fr.datalen = 0; - p->fr.timelen = 0; + p->fr.samples = 0; p->fr.data = NULL; p->fr.src = type; p->fr.offset = 0; @@ -415,6 +415,7 @@ static struct ast_frame *phone_read(struct ast_channel *ast) res = 4; break; } + p->fr.samples = 240; p->fr.datalen = res; p->fr.frametype = AST_FRAME_VOICE; 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); if (strlen(i->ext)) strncpy(tmp->exten, i->ext, sizeof(tmp->exten)-1); + else + strncpy(tmp->exten, "s", sizeof(tmp->exten) - 1); if (strlen(i->language)) strncpy(tmp->language, i->language, sizeof(tmp->language)-1); if (strlen(i->callerid)) diff --git a/codecs/codec_a_mu.c b/codecs/codec_a_mu.c index c7d52b447f7fb36f0deebc7a6a7f7a5cd623ce29..d7d6ff11e3878703981192d4507fbda8335c33c9 100755 --- a/codecs/codec_a_mu.c +++ b/codecs/codec_a_mu.c @@ -125,7 +125,7 @@ alawtoulaw_frameout (struct ast_translator_pvt *pvt) tmp->f.frametype = AST_FRAME_VOICE; tmp->f.subclass = AST_FORMAT_ULAW; tmp->f.datalen = tmp->tail; - tmp->f.timelen = tmp->tail / 8; + tmp->f.samples = tmp->tail; tmp->f.mallocd = 0; tmp->f.offset = AST_FRIENDLY_OFFSET; tmp->f.src = __PRETTY_FUNCTION__; @@ -172,7 +172,7 @@ ulawtoalaw_frameout (struct ast_translator_pvt *pvt) if (tmp->tail) { tmp->f.frametype = AST_FRAME_VOICE; tmp->f.subclass = AST_FORMAT_ALAW; - tmp->f.timelen = tmp->tail / 8; + tmp->f.samples = tmp->tail; tmp->f.mallocd = 0; tmp->f.offset = AST_FRIENDLY_OFFSET; tmp->f.src = __PRETTY_FUNCTION__; @@ -195,7 +195,7 @@ alawtoulaw_sample () f.frametype = AST_FRAME_VOICE; f.subclass = AST_FORMAT_ALAW; f.datalen = sizeof (ulaw_slin_ex); - f.timelen = sizeof(ulaw_slin_ex) / 8; + f.samples = sizeof(ulaw_slin_ex); f.mallocd = 0; f.offset = 0; f.src = __PRETTY_FUNCTION__; @@ -210,7 +210,7 @@ ulawtoalaw_sample () f.frametype = AST_FRAME_VOICE; f.subclass = AST_FORMAT_ULAW; f.datalen = sizeof (ulaw_slin_ex); - f.timelen = sizeof(ulaw_slin_ex) / 8; + f.samples = sizeof(ulaw_slin_ex); f.mallocd = 0; f.offset = 0; f.src = __PRETTY_FUNCTION__; diff --git a/codecs/codec_adpcm.c b/codecs/codec_adpcm.c index c07aba5381a894c6a762b8a49c960e817ad852a9..fdd03675e8b58904ec81f3cca17110464a0dda62 100755 --- a/codecs/codec_adpcm.c +++ b/codecs/codec_adpcm.c @@ -290,7 +290,7 @@ adpcmtolin_framein (struct ast_translator_pvt *pvt, struct ast_frame *f) * * Results: * 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: * None. @@ -307,7 +307,7 @@ adpcmtolin_frameout (struct ast_translator_pvt *pvt) tmp->f.frametype = AST_FRAME_VOICE; tmp->f.subclass = AST_FORMAT_SLINEAR; tmp->f.datalen = tmp->tail *2; - tmp->f.timelen = tmp->tail / 8; + tmp->f.samples = tmp->tail; tmp->f.mallocd = 0; tmp->f.offset = AST_FRIENDLY_OFFSET; tmp->f.src = __PRETTY_FUNCTION__; @@ -383,7 +383,7 @@ lintoadpcm_frameout (struct ast_translator_pvt *pvt) tmp->f.frametype = AST_FRAME_VOICE; tmp->f.subclass = AST_FORMAT_ADPCM; - tmp->f.timelen = i_max / 8; + tmp->f.samples = i_max; tmp->f.mallocd = 0; tmp->f.offset = AST_FRIENDLY_OFFSET; tmp->f.src = __PRETTY_FUNCTION__; @@ -417,7 +417,7 @@ adpcmtolin_sample () f.frametype = AST_FRAME_VOICE; f.subclass = AST_FORMAT_ADPCM; f.datalen = sizeof (adpcm_slin_ex); - f.timelen = sizeof(adpcm_slin_ex) / 4; + f.samples = sizeof(adpcm_slin_ex) * 2; f.mallocd = 0; f.offset = 0; f.src = __PRETTY_FUNCTION__; @@ -437,7 +437,7 @@ lintoadpcm_sample () f.subclass = AST_FORMAT_SLINEAR; f.datalen = sizeof (slin_adpcm_ex); /* Assume 8000 Hz */ - f.timelen = sizeof (slin_adpcm_ex) / 16; + f.samples = sizeof (slin_adpcm_ex) / 2; f.mallocd = 0; f.offset = 0; f.src = __PRETTY_FUNCTION__; diff --git a/codecs/codec_alaw.c b/codecs/codec_alaw.c index 833092365018021b84489387be890d11fdb8c24e..54a464cfc65ebf7f550eab52826b6513d928978a 100755 --- a/codecs/codec_alaw.c +++ b/codecs/codec_alaw.c @@ -151,7 +151,7 @@ alawtolin_framein (struct ast_translator_pvt *pvt, struct ast_frame *f) * * Results: * 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: * None. @@ -168,7 +168,7 @@ alawtolin_frameout (struct ast_translator_pvt *pvt) tmp->f.frametype = AST_FRAME_VOICE; tmp->f.subclass = AST_FORMAT_SLINEAR; tmp->f.datalen = tmp->tail *2; - tmp->f.timelen = tmp->tail / 8; + tmp->f.samples = tmp->tail; tmp->f.mallocd = 0; tmp->f.offset = AST_FRIENDLY_OFFSET; tmp->f.src = __PRETTY_FUNCTION__; @@ -226,7 +226,7 @@ lintoalaw_frameout (struct ast_translator_pvt *pvt) if (tmp->tail) { tmp->f.frametype = AST_FRAME_VOICE; tmp->f.subclass = AST_FORMAT_ALAW; - tmp->f.timelen = tmp->tail / 8; + tmp->f.samples = tmp->tail; tmp->f.mallocd = 0; tmp->f.offset = AST_FRIENDLY_OFFSET; tmp->f.src = __PRETTY_FUNCTION__; @@ -249,7 +249,7 @@ alawtolin_sample () f.frametype = AST_FRAME_VOICE; f.subclass = AST_FORMAT_ALAW; f.datalen = sizeof (ulaw_slin_ex); - f.timelen = sizeof(ulaw_slin_ex) / 8; + f.samples = sizeof(ulaw_slin_ex); f.mallocd = 0; f.offset = 0; f.src = __PRETTY_FUNCTION__; @@ -269,7 +269,7 @@ lintoalaw_sample () f.subclass = AST_FORMAT_SLINEAR; f.datalen = sizeof (slin_ulaw_ex); /* Assume 8000 Hz */ - f.timelen = sizeof (slin_ulaw_ex) / 16; + f.samples = sizeof (slin_ulaw_ex) / 2; f.mallocd = 0; f.offset = 0; f.src = __PRETTY_FUNCTION__; diff --git a/codecs/codec_gsm.c b/codecs/codec_gsm.c index c84ee28978fa51b91fc886637de88696a4828504..6a3ff8054b3cc4e8b8e614edef08c99859cf23ad 100755 --- a/codecs/codec_gsm.c +++ b/codecs/codec_gsm.c @@ -79,7 +79,7 @@ static struct ast_frame *lintogsm_sample() f.subclass = AST_FORMAT_SLINEAR; f.datalen = sizeof(slin_gsm_ex); /* Assume 8000 Hz */ - f.timelen = sizeof(slin_gsm_ex)/16; + f.samples = sizeof(slin_gsm_ex)/2; f.mallocd = 0; f.offset = 0; f.src = __PRETTY_FUNCTION__; @@ -94,7 +94,7 @@ static struct ast_frame *gsmtolin_sample() f.subclass = AST_FORMAT_GSM; f.datalen = sizeof(gsm_slin_ex); /* All frames are 20 ms long */ - f.timelen = 20; + f.samples = 160; f.mallocd = 0; f.offset = 0; 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.datalen = tmp->tail * 2; /* Assume 8000 Hz */ - tmp->f.timelen = tmp->tail / 8; + tmp->f.samples = tmp->tail; tmp->f.mallocd = 0; tmp->f.offset = AST_FRIENDLY_OFFSET; tmp->f.src = __PRETTY_FUNCTION__; @@ -190,7 +190,7 @@ static struct ast_frame *lintogsm_frameout(struct ast_translator_pvt *tmp) x++; } tmp->f.datalen = x * 33; - tmp->f.timelen = x * 20; + tmp->f.samples = x * 160; return &tmp->f; } diff --git a/codecs/codec_lpc10.c b/codecs/codec_lpc10.c index a2f6bd91115b1e90c259f97df2a44f5abd15cf1c..3ee94326c6509bea8ef83d7ae8b21a6759633e2d 100755 --- a/codecs/codec_lpc10.c +++ b/codecs/codec_lpc10.c @@ -100,14 +100,11 @@ static struct ast_translator_pvt *lpc10_dec_new() static struct ast_frame *lintolpc10_sample() { static struct ast_frame f; - static int longer = 0; f.frametype = AST_FRAME_VOICE; f.subclass = AST_FORMAT_SLINEAR; f.datalen = sizeof(slin_lpc10_ex); /* Assume 8000 Hz */ - f.timelen = LPC10_SAMPLES_PER_FRAME/8; - f.timelen += longer; - longer = 1- longer; + f.samples = LPC10_SAMPLES_PER_FRAME; f.mallocd = 0; f.offset = 0; f.src = __PRETTY_FUNCTION__; @@ -123,7 +120,7 @@ static struct ast_frame *lpc10tolin_sample() f.datalen = sizeof(lpc10_slin_ex); /* All frames are 22 ms long (maybe a little more -- why did he choose LPC10_SAMPLES_PER_FRAME sample frames anyway?? */ - f.timelen = LPC10_SAMPLES_PER_FRAME/8; + f.samples = LPC10_SAMPLES_PER_FRAME; f.mallocd = 0; f.offset = 0; 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.datalen = tmp->tail * 2; /* Assume 8000 Hz */ - tmp->f.timelen = tmp->tail / 8; + tmp->f.samples = tmp->tail; tmp->f.mallocd = 0; tmp->f.offset = AST_FRIENDLY_OFFSET; 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) return NULL; /* Start with an empty frame */ - tmp->f.timelen = 0; + tmp->f.samples = 0; tmp->f.datalen = 0; tmp->f.frametype = AST_FRAME_VOICE; 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); build_bits(((unsigned char *)tmp->outbuf) + tmp->f.datalen, bits); tmp->f.datalen += LPC10_BYTES_IN_COMPRESSED_FRAME; - tmp->f.timelen += 22; - /* We alternate between 22 and 23 ms to simulate 22.5 ms */ - tmp->f.timelen += tmp->longer; + tmp->f.samples += LPC10_SAMPLES_PER_FRAME; /* Use one of the two left over bits to record if this is a 22 or 23 ms frame... important for IAX use */ tmp->longer = 1 - tmp->longer; diff --git a/codecs/codec_mp3_d.c b/codecs/codec_mp3_d.c index f417453efee0a686b11b77d81fcd80fce270bf7d..c056e1102d3d41686d0787227926aed47a82f9ef 100755 --- a/codecs/codec_mp3_d.c +++ b/codecs/codec_mp3_d.c @@ -101,7 +101,7 @@ static struct ast_frame *mp3tolin_sample() f.data = mp3_slin_ex; f.datalen = sizeof(mp3_slin_ex); /* Dunno how long an mp3 frame is -- kinda irrelevant anyway */ - f.timelen = 30; + f.samples = 240; f.mallocd = 0; f.offset = 0; 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.datalen = tmp->tail * 2; /* Assume 8000 Hz */ - tmp->f.timelen = tmp->tail / 8; + tmp->f.samples = tmp->tail; tmp->f.mallocd = 0; tmp->f.offset = AST_FRIENDLY_OFFSET; tmp->f.src = __PRETTY_FUNCTION__; diff --git a/codecs/codec_ulaw.c b/codecs/codec_ulaw.c index 175da76f59962e01eca707fac0699bbbda61bb81..2d0a06155c1f06bad152f06ad881a8047511a4d6 100755 --- a/codecs/codec_ulaw.c +++ b/codecs/codec_ulaw.c @@ -151,7 +151,7 @@ ulawtolin_framein (struct ast_translator_pvt *pvt, struct ast_frame *f) * * Results: * 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: * None. @@ -168,7 +168,7 @@ ulawtolin_frameout (struct ast_translator_pvt *pvt) tmp->f.frametype = AST_FRAME_VOICE; tmp->f.subclass = AST_FORMAT_SLINEAR; tmp->f.datalen = tmp->tail *2; - tmp->f.timelen = tmp->tail / 8; + tmp->f.samples = tmp->tail; tmp->f.mallocd = 0; tmp->f.offset = AST_FRIENDLY_OFFSET; tmp->f.src = __PRETTY_FUNCTION__; @@ -226,7 +226,7 @@ lintoulaw_frameout (struct ast_translator_pvt *pvt) if (tmp->tail) { tmp->f.frametype = AST_FRAME_VOICE; tmp->f.subclass = AST_FORMAT_ULAW; - tmp->f.timelen = tmp->tail / 8; + tmp->f.samples = tmp->tail; tmp->f.mallocd = 0; tmp->f.offset = AST_FRIENDLY_OFFSET; tmp->f.src = __PRETTY_FUNCTION__; @@ -249,7 +249,7 @@ ulawtolin_sample () f.frametype = AST_FRAME_VOICE; f.subclass = AST_FORMAT_ULAW; f.datalen = sizeof (ulaw_slin_ex); - f.timelen = sizeof(ulaw_slin_ex) / 8; + f.samples = sizeof(ulaw_slin_ex); f.mallocd = 0; f.offset = 0; f.src = __PRETTY_FUNCTION__; @@ -269,7 +269,7 @@ lintoulaw_sample () f.subclass = AST_FORMAT_SLINEAR; f.datalen = sizeof (slin_ulaw_ex); /* Assume 8000 Hz */ - f.timelen = sizeof (slin_ulaw_ex) / 16; + f.samples = sizeof (slin_ulaw_ex) / 2; f.mallocd = 0; f.offset = 0; f.src = __PRETTY_FUNCTION__;