diff options
author | Vincent Penquerc'h <vincent.penquerch@collabora.co.uk> | 2011-09-28 14:22:02 +0100 |
---|---|---|
committer | Sebastian Dröge <sebastian.droege@collabora.co.uk> | 2011-10-03 11:21:15 +0200 |
commit | 934144c352a5edd054e4ebdf5113630ccf963be9 (patch) | |
tree | e91948e901d0844074701fa5b94a1ca35e97c312 /ext/opus/gstopusdec.c | |
parent | 85de20b8a14834059b5a60f33ba4757ed55f1ed6 (diff) | |
download | gstreamer-plugins-bad-934144c352a5edd054e4ebdf5113630ccf963be9.tar.gz |
opus: properly setup caps and init state from caps
https://bugzilla.gnome.org/show_bug.cgi?id=660364
Diffstat (limited to 'ext/opus/gstopusdec.c')
-rw-r--r-- | ext/opus/gstopusdec.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/ext/opus/gstopusdec.c b/ext/opus/gstopusdec.c index 9cdc14457..ae0b0bc68 100644 --- a/ext/opus/gstopusdec.c +++ b/ext/opus/gstopusdec.c @@ -193,6 +193,8 @@ opus_dec_sink_setcaps (GstPad * pad, GstCaps * caps) GstStructure *s; const GValue *streamheader; + GST_DEBUG_OBJECT (pad, "Setting sink caps to %" GST_PTR_FORMAT, caps); + s = gst_caps_get_structure (caps, 0); if ((streamheader = gst_structure_get_value (s, "streamheader")) && G_VALUE_HOLDS (streamheader, GST_TYPE_ARRAY) && @@ -237,6 +239,47 @@ opus_dec_sink_setcaps (GstPad * pad, GstCaps * caps) } } + if (!gst_structure_get_int (s, "frame-size", &dec->frame_size)) { + GST_WARNING_OBJECT (dec, "Frame size not included in caps"); + } + if (!gst_structure_get_int (s, "channels", &dec->n_channels)) { + GST_WARNING_OBJECT (dec, "Number of channels not included in caps"); + } + if (!gst_structure_get_int (s, "rate", &dec->sample_rate)) { + GST_WARNING_OBJECT (dec, "Sample rate not included in caps"); + } + switch (dec->frame_size) { + case 2: + dec->frame_samples = dec->sample_rate / 400; + break; + case 5: + dec->frame_samples = dec->sample_rate / 200; + break; + case 10: + dec->frame_samples = dec->sample_rate / 100; + break; + case 20: + dec->frame_samples = dec->sample_rate / 50; + break; + case 40: + dec->frame_samples = dec->sample_rate / 25; + break; + case 60: + dec->frame_samples = 3 * dec->sample_rate / 50; + break; + default: + GST_WARNING_OBJECT (dec, "Unsupported frame size: %d", dec->frame_size); + break; + } + + dec->frame_duration = gst_util_uint64_scale_int (dec->frame_samples, + GST_SECOND, dec->sample_rate); + + GST_INFO_OBJECT (dec, + "Got frame size %d, %d channels, %d Hz, giving %d samples per frame, frame duration %" + GST_TIME_FORMAT, dec->frame_size, dec->n_channels, dec->sample_rate, + dec->frame_samples, GST_TIME_ARGS (dec->frame_duration)); + done: gst_object_unref (dec); return ret; @@ -788,6 +831,10 @@ opus_dec_chain (GstPad * pad, GstBuffer * buf) GstOpusDec *dec; dec = GST_OPUS_DEC (gst_pad_get_parent (pad)); + GST_LOG_OBJECT (pad, + "Got buffer ts %" GST_TIME_FORMAT ", duration %" GST_TIME_FORMAT, + GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)), + GST_TIME_ARGS (GST_BUFFER_DURATION (buf))); if (GST_BUFFER_IS_DISCONT (buf)) { dec->discont = TRUE; |