From 2e79f52d7116e5529ab78972cee8081b6ffe6878 Mon Sep 17 00:00:00 2001 From: Alexander Traud Date: Tue, 19 Jul 2016 20:14:21 +0200 Subject: codecs: Add Codec 2 mode 2400. ASTERISK-26217 #close Change-Id: I1e45d8084683fab5f2b272bf35f4a149cea8b8d6 --- main/codec_builtin.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'main/codec_builtin.c') diff --git a/main/codec_builtin.c b/main/codec_builtin.c index 50fbf555c..6fc0fd896 100644 --- a/main/codec_builtin.c +++ b/main/codec_builtin.c @@ -107,6 +107,30 @@ static struct ast_codec g723 = { .get_length = g723_length, }; +static int codec2_samples(struct ast_frame *frame) +{ + return 160 * (frame->datalen / 6); +} + +static int codec2_length(unsigned int samples) +{ + return (samples / 160) * 6; +} + +static struct ast_codec codec2 = { + .name = "codec2", + .description = "Codec 2", + .type = AST_MEDIA_TYPE_AUDIO, + .sample_rate = 8000, + .minimum_ms = 20, + .maximum_ms = 300, + .default_ms = 20, + .minimum_bytes = 6, + .samples_count = codec2_samples, + .get_length = codec2_length, + .smooth = 1, +}; + static int none_samples(struct ast_frame *frame) { return frame->datalen; @@ -863,6 +887,7 @@ int ast_codec_builtin_init(void) { int res = 0; + res |= CODEC_REGISTER_AND_CACHE(codec2); res |= CODEC_REGISTER_AND_CACHE(g723); res |= CODEC_REGISTER_AND_CACHE(ulaw); res |= CODEC_REGISTER_AND_CACHE(alaw); -- cgit v1.2.3