Index: include/asterisk/frame.h =================================================================== --- include/asterisk/frame.h (revision 381060) +++ include/asterisk/frame.h (working copy) @@ -567,7 +567,7 @@ /*! \brief Gets duration in ms of interpolation frame for a format */ static inline int ast_codec_interp_len(struct ast_format *format) { - return (format->id == AST_FORMAT_ILBC) ? 30 : 20; + return 20; } /*! Index: main/frame.c =================================================================== --- main/frame.c (revision 381060) +++ main/frame.c (working copy) @@ -961,7 +961,7 @@ samples = g723_samples(f->data.ptr, f->datalen); break; case AST_FORMAT_ILBC: - samples = 240 * (f->datalen / 50); + samples = 160 * (f->datalen / 38); break; case AST_FORMAT_GSM: samples = 160 * (f->datalen / 33); @@ -1040,7 +1040,7 @@ len = (samples / 240) * 20; break; case AST_FORMAT_ILBC: - len = (samples / 240) * 50; + len = (samples / 160) * 38; break; case AST_FORMAT_GSM: len = (samples / 160) * 33; Index: main/format.c =================================================================== --- main/format.c (revision 381060) +++ main/format.c (working copy) @@ -1014,7 +1014,7 @@ format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_G729A, 0), "g729", 8000, "G.729A", 10, 10, 230, 10, 20, AST_SMOOTHER_FLAG_G729, 0); /*!< Binary commercial distribution */ format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_SPEEX, 0), "speex", 8000, "SpeeX", 10, 10, 60, 10, 20, 0, 0); /*!< codec_speex.c */ format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_SPEEX16, 0), "speex16", 16000, "SpeeX 16khz", 10, 10, 60, 10, 20, 0, 0); /*!< codec_speex.c */ - format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_ILBC, 0), "ilbc", 8000, "iLBC", 50, 30, 30, 30, 30, 0, 0); /*!< codec_ilbc.c */ /* inc=30ms - workaround */ + format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_ILBC, 0), "ilbc", 8000, "iLBC", 38, 20, 20, 20, 20, 0, 0); /*!< codec_ilbc.c */ /* inc=20 - workaround */ format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_G726_AAL2, 0), "g726aal2", 8000, "G.726 AAL2", 40, 10, 300, 10, 20, 0, 0); /*!< codec_g726.c */ format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_G722, 0), "g722", 16000, "G722", 80, 10, 150, 10, 20, 0, 0); /*!< codec_g722.c */ format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR16, 0), "slin16", 16000, "16 bit Signed Linear PCM (16kHz)", 320, 10, 70, 10, 20, AST_SMOOTHER_FLAG_BE, 0);/*!< Signed linear (16kHz) */ Index: codecs/codec_ilbc.c =================================================================== --- codecs/codec_ilbc.c (revision 381060) +++ codecs/codec_ilbc.c (working copy) @@ -41,11 +41,11 @@ #include "ilbc/iLBC_decode.h" #define USE_ILBC_ENHANCER 0 -#define ILBC_MS 30 -/* #define ILBC_MS 20 */ +/* #define ILBC_MS 30 */ +#define ILBC_MS 20 -#define ILBC_FRAME_LEN 50 /* apparently... */ -#define ILBC_SAMPLES 240 /* 30ms at 8000 hz */ +#define ILBC_FRAME_LEN 38 /* apparently... */ +#define ILBC_SAMPLES 160 /* 20ms at 8000 hz */ #define BUFFER_SAMPLES 8000 /* Sample frame data */ @@ -101,7 +101,7 @@ } if (f->datalen % ILBC_FRAME_LEN) { - ast_log(LOG_WARNING, "Huh? An ilbc frame that isn't a multiple of 50 bytes long from %s (%d)?\n", f->src, f->datalen); + ast_log(LOG_WARNING, "Huh? An ilbc frame that isn't a multiple of 38 bytes long from %s (%d)?\n", f->src, f->datalen); return -1; } Index: codecs/ex_ilbc.h =================================================================== --- codecs/ex_ilbc.h (revision 381060) +++ codecs/ex_ilbc.h (working copy) @@ -11,8 +11,7 @@ 0xff, 0xa0, 0xff, 0xfa, 0x0f, 0x60, 0x12, 0x11, 0xa2, 0x47, 0x22, 0x8c, 0x00, 0x00, 0x01, 0x02, 0x80, 0x43, 0xa0, 0x40, 0x33, 0xff, 0xcf, 0xc0, 0xf3, 0xf3, 0x3f, 0x8f, 0x3f, 0xff, - 0xff, 0xff, 0xff, 0xfc, 0xf9, 0xe5, 0x55, 0x78, 0x0b, 0xca, - 0xe1, 0x27, 0x94, 0x7b, 0xa8, 0x91, 0x2c, 0x36, 0x08, 0x56, + 0xff, 0xff, 0xff, 0xfc, 0xf9, 0xe5, 0x55, 0x78, }; static struct ast_frame *ilbc_sample(void) @@ -20,7 +19,7 @@ static struct ast_frame f = { .frametype = AST_FRAME_VOICE, .datalen = sizeof(ex_ilbc), - /* All frames are 30 ms long */ + /* All frames are 20 ms long */ .samples = ILBC_SAMPLES, .mallocd = 0, .offset = 0, Index: formats/format_ilbc.c =================================================================== --- formats/format_ilbc.c (revision 381060) +++ formats/format_ilbc.c (working copy) @@ -41,8 +41,8 @@ /* Portions of the conversion code are by guido@sienanet.it */ -#define ILBC_BUF_SIZE 50 /* One Real iLBC Frame */ -#define ILBC_SAMPLES 240 +#define ILBC_BUF_SIZE 38 /* One Real iLBC Frame */ +#define ILBC_SAMPLES 160 static struct ast_frame *ilbc_read(struct ast_filestream *s, int *whennext) { @@ -72,12 +72,12 @@ ast_log(LOG_WARNING, "Asked to write non-iLBC frame (%s)!\n", ast_getformatname(&f->subclass.format)); return -1; } - if (f->datalen % 50) { - ast_log(LOG_WARNING, "Invalid data length, %d, should be multiple of 50\n", f->datalen); + if (f->datalen % 38) { + ast_log(LOG_WARNING, "Invalid data length, %d, should be multiple of 38\n", f->datalen); return -1; } if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen) { - ast_log(LOG_WARNING, "Bad write (%d/50): %s\n", res, strerror(errno)); + ast_log(LOG_WARNING, "Bad write (%d/38): %s\n", res, strerror(errno)); return -1; } return 0;