From: Thiago Santos Date: Wed, 17 Dec 2014 18:21:16 +0000 (-0300) Subject: audiodecoder: expose getcaps virtual function X-Git-Tag: 1.19.3~511^2~4024 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=36a99922e4e2ac549ed2b933ccacebf208149b48;p=platform%2Fupstream%2Fgstreamer.git audiodecoder: expose getcaps virtual function Allows subclasses to do custom caps query replies. Also exposes the standard caps query handler so subclasses can just extend on top of it instead of reimplementing the caps query proxying. --- diff --git a/gst-libs/gst/audio/gstaudiodecoder.c b/gst-libs/gst/audio/gstaudiodecoder.c index efd979b..dc4cedd 100644 --- a/gst-libs/gst/audio/gstaudiodecoder.c +++ b/gst-libs/gst/audio/gstaudiodecoder.c @@ -2422,6 +2422,48 @@ exit: return res; } +/** + * gst_audio_decoder_proxy_getcaps: + * @decoder: a #GstAudioDecoder + * @caps: (allow-none): initial caps + * @filter: (allow-none): filter caps + * + * Returns caps that express @caps (or sink template caps if @caps == NULL) + * restricted to rate/channels/... combinations supported by downstream + * elements. + * + * Returns: (transfer-full): a #GstCaps owned by caller + * + * @Since: 1.6 + */ +GstCaps * +gst_audio_decoder_proxy_getcaps (GstAudioDecoder * decoder, GstCaps * caps, + GstCaps * filter) +{ + return __gst_audio_element_proxy_getcaps (GST_ELEMENT_CAST (decoder), + GST_AUDIO_DECODER_SINK_PAD (decoder), + GST_AUDIO_DECODER_SRC_PAD (decoder), caps, filter); +} + +static GstCaps * +gst_audio_decoder_sink_getcaps (GstAudioDecoder * decoder, GstCaps * filter) +{ + GstAudioDecoderClass *klass; + GstCaps *caps; + + klass = GST_AUDIO_DECODER_GET_CLASS (decoder); + + if (klass->getcaps) + caps = klass->getcaps (decoder, filter); + else + caps = gst_audio_decoder_proxy_getcaps (decoder, NULL, filter); + + GST_LOG_OBJECT (decoder, "Returning caps %" GST_PTR_FORMAT, caps); + + return caps; +} + + static gboolean gst_audio_decoder_sink_query (GstPad * pad, GstObject * parent, GstQuery * query) @@ -2462,15 +2504,12 @@ gst_audio_decoder_sink_query (GstPad * pad, GstObject * parent, break; } case GST_QUERY_CAPS:{ - GstCaps *filter; - GstCaps *result; + GstCaps *filter, *caps; gst_query_parse_caps (query, &filter); - result = __gst_audio_element_proxy_getcaps (GST_ELEMENT_CAST (dec), - GST_AUDIO_DECODER_SINK_PAD (dec), - GST_AUDIO_DECODER_SRC_PAD (dec), NULL, filter); - gst_query_set_caps_result (query, result); - gst_caps_unref (result); + caps = gst_audio_decoder_sink_getcaps (dec, filter); + gst_query_set_caps_result (query, caps); + gst_caps_unref (caps); res = TRUE; break; } diff --git a/gst-libs/gst/audio/gstaudiodecoder.h b/gst-libs/gst/audio/gstaudiodecoder.h index 8f97fe8..6febb91 100644 --- a/gst-libs/gst/audio/gstaudiodecoder.h +++ b/gst-libs/gst/audio/gstaudiodecoder.h @@ -231,6 +231,11 @@ struct _GstAudioDecoder * Propose buffer allocation parameters for upstream elements. * Subclasses should chain up to the parent implementation to * invoke the default handler. + * @getcaps: Optional. + * Allows for a custom sink getcaps implementation. + * If not implemented, + * default returns gst_audio_decoder_proxy_getcaps + * applied to sink template caps. * * Subclasses can override any of the available virtual methods or not, as * needed. At minimum @handle_frame (and likely @set_format) needs to be @@ -278,8 +283,11 @@ struct _GstAudioDecoderClass gboolean (*propose_allocation) (GstAudioDecoder *dec, GstQuery * query); + GstCaps * (*getcaps) (GstAudioDecoder * dec, + GstCaps * filter); + /*< private >*/ - gpointer _gst_reserved[GST_PADDING_LARGE]; + gpointer _gst_reserved[GST_PADDING_LARGE - 1]; }; GType gst_audio_decoder_get_type (void); @@ -287,6 +295,9 @@ GType gst_audio_decoder_get_type (void); gboolean gst_audio_decoder_set_output_format (GstAudioDecoder * dec, const GstAudioInfo * info); +GstCaps * gst_audio_decoder_proxy_getcaps (GstAudioDecoder * dec, + GstCaps * caps, + GstCaps * filter); gboolean gst_audio_decoder_negotiate (GstAudioDecoder * dec); GstFlowReturn gst_audio_decoder_finish_frame (GstAudioDecoder * dec, diff --git a/win32/common/libgstaudio.def b/win32/common/libgstaudio.def index be4d23a..2144723 100644 --- a/win32/common/libgstaudio.def +++ b/win32/common/libgstaudio.def @@ -54,6 +54,7 @@ EXPORTS gst_audio_decoder_get_type gst_audio_decoder_merge_tags gst_audio_decoder_negotiate + gst_audio_decoder_proxy_getcaps gst_audio_decoder_set_drainable gst_audio_decoder_set_estimate_rate gst_audio_decoder_set_latency