summaryrefslogtreecommitdiff
path: root/main/codec_builtin.c
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2016-11-15 16:23:35 -0600
committerRichard Mudgett <rmudgett@digium.com>2016-11-16 14:56:18 -0500
commited9ced0531108b056b89c789df5c40b8b53db5ae (patch)
tree40848f46ad1f70475e5f3ad32a9c6c5c3983b691 /main/codec_builtin.c
parent1c26117dff1292fea8c3b15b1892c6bc751b83b6 (diff)
codec_opus: Fix warning when Opus negotiated but codec_opus not loaded.
When Opus is negotiated but not loaded, the log is spammed with messages because the system does not know how to calculate the number of samples in a frame. * Suppress the warning by supplying a function that assumes 20ms of samples in the frame. For pass through support it doesn't really seem to matter what number of samples is returned anyway. ASTERISK-26605 #close Change-Id: Icf2273692f040dc2c45b01e72a790d11092f9e0f
Diffstat (limited to 'main/codec_builtin.c')
-rw-r--r--main/codec_builtin.c16
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,
};