From dbd43c7dd3818c5c244348ffe8c1d97c6808c8a5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 1 Feb 2012 15:59:57 +0100 Subject: [PATCH] audiodecoder: Rename set_outcaps() to set_output_format() and take a GstAudioInfo as parameter --- gst-libs/gst/audio/gstaudiodecoder.c | 30 +++++++++++++++++------------- gst-libs/gst/audio/gstaudiodecoder.h | 4 ++-- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/gst-libs/gst/audio/gstaudiodecoder.c b/gst-libs/gst/audio/gstaudiodecoder.c index 3b1de16..c28af8b 100644 --- a/gst-libs/gst/audio/gstaudiodecoder.c +++ b/gst-libs/gst/audio/gstaudiodecoder.c @@ -488,28 +488,30 @@ gst_audio_decoder_finalize (GObject * object) } /** - * gst_audio_decoder_set_outcaps: + * gst_audio_decoder_set_output_format: * @dec: a #GstAudioDecoder - * @caps: #GstCaps + * @info: #GstAudioInfo * - * Configure output @caps on the srcpad of @dec. Also perform - * sanity checking of @caps and extracts output data format + * Configure output info on the srcpad of @dec. * * Returns: %TRUE on success. **/ gboolean -gst_audio_decoder_set_outcaps (GstAudioDecoder * dec, GstCaps * caps) +gst_audio_decoder_set_output_format (GstAudioDecoder * dec, + const GstAudioInfo * info) { gboolean res = TRUE; guint old_rate; + GstCaps *caps; - GST_DEBUG_OBJECT (dec, "setting src caps %" GST_PTR_FORMAT, caps); + GST_DEBUG_OBJECT (dec, "Setting output format"); GST_AUDIO_DECODER_STREAM_LOCK (dec); - /* parse caps here to check subclass; - * also makes us aware of output format */ - if (!gst_caps_is_fixed (caps)) + /* If the audio info can't be converted to caps, + * it was invalid */ + caps = gst_audio_info_to_caps (info); + if (!caps) goto refuse_caps; /* adjust ts tracking to new sample rate */ @@ -520,20 +522,22 @@ gst_audio_decoder_set_outcaps (GstAudioDecoder * dec, GstCaps * caps) dec->priv->samples = 0; } - if (!gst_audio_info_from_caps (&dec->priv->ctx.info, caps)) - goto refuse_caps; + /* copy the GstAudioInfo */ + dec->priv->ctx.info = *info; + + GST_DEBUG_OBJECT (dec, "setting src caps %" GST_PTR_FORMAT, caps); -done: GST_AUDIO_DECODER_STREAM_UNLOCK (dec); res = gst_pad_set_caps (dec->srcpad, caps); +done: return res; /* ERRORS */ refuse_caps: { - GST_WARNING_OBJECT (dec, "rejected caps %" GST_PTR_FORMAT, caps); + GST_WARNING_OBJECT (dec, "invalid output format"); res = FALSE; goto done; } diff --git a/gst-libs/gst/audio/gstaudiodecoder.h b/gst-libs/gst/audio/gstaudiodecoder.h index 77a8219..3d74b9d 100644 --- a/gst-libs/gst/audio/gstaudiodecoder.h +++ b/gst-libs/gst/audio/gstaudiodecoder.h @@ -242,8 +242,8 @@ struct _GstAudioDecoderClass GType gst_audio_decoder_get_type (void); -gboolean gst_audio_decoder_set_outcaps (GstAudioDecoder * dec, - GstCaps * caps); +gboolean gst_audio_decoder_set_output_format (GstAudioDecoder * dec, + const GstAudioInfo * info); GstFlowReturn gst_audio_decoder_finish_frame (GstAudioDecoder * dec, GstBuffer * buf, gint frames); -- 2.7.4