From: Sebastian Dröge Date: Tue, 3 Nov 2015 18:33:10 +0000 (+0200) Subject: matroskademux: Use codecutils helpers for creating Opus caps X-Git-Tag: 1.10.4~782 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ed20b9ab90d9ff2be7b7ffb4ba1139fca01171f7;p=platform%2Fupstream%2Fgst-plugins-good.git matroskademux: Use codecutils helpers for creating Opus caps Also fix up codec data with values from the container. https://bugzilla.gnome.org/show_bug.cgi?id=757152 --- diff --git a/gst/matroska/matroska-demux.c b/gst/matroska/matroska-demux.c index e7ba5cd..85fd3ad 100644 --- a/gst/matroska/matroska-demux.c +++ b/gst/matroska/matroska-demux.c @@ -5507,13 +5507,28 @@ gst_matroska_demux_audio_caps (GstMatroskaTrackAudioContext * /* FIXME: mark stream as broken and skip if there are no stream headers */ context->send_stream_headers = TRUE; } else if (!strcmp (codec_id, GST_MATROSKA_CODEC_ID_AUDIO_OPUS)) { - caps = gst_caps_new_empty_simple ("audio/x-opus"); - *codec_name = g_strdup ("Opus"); - context->stream_headers = - gst_matroska_parse_opus_stream_headers (context->codec_priv, - context->codec_priv_size); - /* FIXME: mark stream as broken and skip if there are no stream headers */ - context->send_stream_headers = TRUE; + GstBuffer *tmp; + + if (context->codec_priv_size >= 19) { + if (audiocontext->samplerate) + GST_WRITE_UINT32_LE ((guint8 *) context->codec_priv + 12, + audiocontext->samplerate); + if (context->codec_delay) { + guint64 delay = + gst_util_uint64_scale_round (context->codec_delay, 48000, + GST_SECOND); + GST_WRITE_UINT16_LE ((guint8 *) context->codec_priv + 10, delay); + } + + tmp = + gst_buffer_new_wrapped (g_memdup (context->codec_priv, + context->codec_priv_size), context->codec_priv_size); + caps = gst_codec_utils_opus_create_caps_from_header (tmp, NULL); + gst_buffer_unref (tmp); + *codec_name = g_strdup ("Opus"); + } else { + GST_WARNING ("Invalid Opus codec data size"); + } } else if (!strcmp (codec_id, GST_MATROSKA_CODEC_ID_AUDIO_ACM)) { gst_riff_strf_auds auds;