diff options
author | Joshua Colp <jcolp@digium.com> | 2016-11-17 04:56:16 -0600 |
---|---|---|
committer | Gerrit Code Review <gerrit2@gerrit.digium.api> | 2016-11-17 04:56:16 -0600 |
commit | 09d195844812bb26bf3c644b219b2c41d2461a74 (patch) | |
tree | a5b9fc8c94ed33d1a8af243962cc85ab97d55fa8 | |
parent | 8fbdedb36efc570a84e77b4efdc82c8210bf7c86 (diff) | |
parent | ed9ced0531108b056b89c789df5c40b8b53db5ae (diff) |
Merge "codec_opus: Fix warning when Opus negotiated but codec_opus not loaded."
-rw-r--r-- | main/codec_builtin.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/main/codec_builtin.c b/main/codec_builtin.c index cc4edd239..f622c9105 100644 --- a/main/codec_builtin.c +++ b/main/codec_builtin.c @@ -729,6 +729,21 @@ static struct ast_codec g719 = { .get_length = g719_length, }; +static int opus_samples(struct ast_frame *frame) +{ + /* + * XXX This is likely not at all what's intended from this + * callback. If you have codec_opus.so loaded then this + * function is overridden anyway. However, since opus is + * variable bit rate and I cannot extract the calculation code + * from the opus library, I am going to punt and assume 20ms + * worth of samples. In testing, this has worked just fine. + * Pass through support doesn't seem to care about the value + * returned anyway. + */ + return ast_format_get_sample_rate(frame->subclass.format) / 50; +} + static struct ast_codec opus = { .name = "opus", .description = "Opus Codec", @@ -737,6 +752,7 @@ static struct ast_codec opus = { .minimum_ms = 20, .maximum_ms = 60, .default_ms = 20, + .samples_count = opus_samples, .minimum_bytes = 10, }; |