diff options
author | Alexander Traud <pabstraud@compuserve.com> | 2016-07-19 20:39:38 +0200 |
---|---|---|
committer | Alexander Traud <pabstraud@compuserve.com> | 2016-07-22 10:09:08 +0200 |
commit | 8fb807009f2e19349be778fc78be110f72ccc2f8 (patch) | |
tree | 46c2a4a11d15b7c4702a241e36fd32921a8fa2fa /main/codec_builtin.c | |
parent | 943bb48b59435e00131cbd56b075f73f57d10e87 (diff) |
codecs: Add iLBC 20.
Asterisk already supported iLBC 30. This change adds iLBC 20. Now, Asterisk
defaults to iLBC 20 but falls back to iLBC 30, when the remote party requests
this.
ASTERISK-26218 #close
ASTERISK-26221 #close
Reported by: Aaron Meriwether
Change-Id: I07f523a3aa1338bb5217a1bf69c1eeb92adedffa
Diffstat (limited to 'main/codec_builtin.c')
-rw-r--r-- | main/codec_builtin.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/main/codec_builtin.c b/main/codec_builtin.c index 50fbf555c..15147980d 100644 --- a/main/codec_builtin.c +++ b/main/codec_builtin.c @@ -31,6 +31,7 @@ ASTERISK_REGISTER_FILE() +#include "asterisk/ilbc.h" #include "asterisk/logger.h" #include "asterisk/astobj2.h" #include "asterisk/codec.h" @@ -588,7 +589,12 @@ static struct ast_codec speex32 = { static int ilbc_samples(struct ast_frame *frame) { - return 240 * (frame->datalen / 50); + struct ilbc_attr *attr = ast_format_get_attribute_data(frame->subclass.format); + const unsigned int mode = attr ? attr->mode : 30; + const unsigned int samples_per_frame = mode * ast_format_get_sample_rate(frame->subclass.format) / 1000; + const unsigned int octets_per_frame = (mode == 20) ? 38 : 50; + + return samples_per_frame * frame->datalen / octets_per_frame; } static struct ast_codec ilbc = { @@ -596,12 +602,12 @@ static struct ast_codec ilbc = { .description = "iLBC", .type = AST_MEDIA_TYPE_AUDIO, .sample_rate = 8000, - .minimum_ms = 30, + .minimum_ms = 20, .maximum_ms = 300, - .default_ms = 30, - .minimum_bytes = 50, + .default_ms = 20, + .minimum_bytes = 38, .samples_count = ilbc_samples, - .smooth = 1, + .smooth = 0, }; static struct ast_codec g722 = { |