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.
This commit is contained in:
Thiago Santos 2014-12-17 15:21:16 -03:00
parent 160dce872b
commit 36a99922e4
3 changed files with 59 additions and 8 deletions

View file

@ -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;
}

View file

@ -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,

View file

@ -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