Version 0.3.0 from FTP
authorMark Spencer <markster@digium.com>
Fri, 29 Nov 2002 02:14:13 +0000 (02:14 +0000)
committerMark Spencer <markster@digium.com>
Fri, 29 Nov 2002 02:14:13 +0000 (02:14 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@556 65c4cc65-6c06-0410-ace0-fbb531ad65f3

15 files changed:
apps/app_disa.c
apps/app_festival.c
apps/app_mp3.c
channels/chan_alsa.c
channels/chan_modem_aopen.c
channels/chan_modem_bestdata.c
channels/chan_modem_i4l.c
channels/chan_phone.c
codecs/codec_a_mu.c
codecs/codec_adpcm.c
codecs/codec_alaw.c
codecs/codec_gsm.c
codecs/codec_lpc10.c
codecs/codec_mp3_d.c
codecs/codec_ulaw.c

index a105c9e..89d956d 100755 (executable)
@@ -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
index d45988c..1e88fff 100755 (executable)
@@ -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__;
index 5ef5f9b..e99415d 100755 (executable)
@@ -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__;
index 3e35a82..225c8ba 100755 (executable)
@@ -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 }
 };
 
index b33ce07..a838671 100755 (executable)
@@ -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;
index 08a1c2e..7ec76aa 100755 (executable)
@@ -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;
index 553f144..18b5a50 100755 (executable)
@@ -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;
 }
 
index 09f5b1b..9a6bc9b 100755 (executable)
@@ -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))
index c7d52b4..d7d6ff1 100755 (executable)
@@ -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__;
index c07aba5..fdd0367 100755 (executable)
@@ -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__;
index 8330923..54a464c 100755 (executable)
@@ -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__;
index c84ee28..6a3ff80 100755 (executable)
@@ -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; 
 }
 
index a2f6bd9..3ee9432 100755 (executable)
@@ -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;
index f417453..c056e11 100755 (executable)
@@ -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__;
index 175da76..2d0a061 100755 (executable)
@@ -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__;