mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-13 10:55:34 +00:00
audiodecoder: add option to use default pad accept-caps handling
Add gst_audio_decoder_set_use_default_pad_acceptcaps() to allow subclasses to make videodecoder use the default pad acceptcaps handling instead of resorting to the caps query that is, usually, less efficient and unecessary API: gst_audio_decoder_set_use_default_pad_acceptcaps
This commit is contained in:
parent
4982188cf7
commit
33b1da7b80
3 changed files with 50 additions and 16 deletions
|
@ -279,6 +279,9 @@ struct _GstAudioDecoderPrivate
|
||||||
|
|
||||||
/* pending serialized sink events, will be sent from finish_frame() */
|
/* pending serialized sink events, will be sent from finish_frame() */
|
||||||
GList *pending_events;
|
GList *pending_events;
|
||||||
|
|
||||||
|
/* flags */
|
||||||
|
gboolean use_default_pad_acceptcaps;
|
||||||
};
|
};
|
||||||
|
|
||||||
//* Default channel layouts taken from audioconvert */
|
//* Default channel layouts taken from audioconvert */
|
||||||
|
@ -2691,28 +2694,34 @@ gst_audio_decoder_sink_query_default (GstAudioDecoder * dec, GstQuery * query)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GST_QUERY_ACCEPT_CAPS:{
|
case GST_QUERY_ACCEPT_CAPS:{
|
||||||
GstCaps *caps;
|
if (dec->priv->use_default_pad_acceptcaps) {
|
||||||
GstCaps *allowed_caps;
|
res =
|
||||||
GstCaps *template_caps;
|
gst_pad_query_default (GST_AUDIO_DECODER_SINK_PAD (dec),
|
||||||
gboolean accept;
|
GST_OBJECT_CAST (dec), query);
|
||||||
|
} else {
|
||||||
|
GstCaps *caps;
|
||||||
|
GstCaps *allowed_caps;
|
||||||
|
GstCaps *template_caps;
|
||||||
|
gboolean accept;
|
||||||
|
|
||||||
gst_query_parse_accept_caps (query, &caps);
|
gst_query_parse_accept_caps (query, &caps);
|
||||||
|
|
||||||
template_caps = gst_pad_get_pad_template_caps (pad);
|
template_caps = gst_pad_get_pad_template_caps (pad);
|
||||||
accept = gst_caps_is_subset (caps, template_caps);
|
accept = gst_caps_is_subset (caps, template_caps);
|
||||||
gst_caps_unref (template_caps);
|
gst_caps_unref (template_caps);
|
||||||
|
|
||||||
if (accept) {
|
if (accept) {
|
||||||
allowed_caps = gst_pad_query_caps (GST_AUDIO_DECODER_SINK_PAD (dec),
|
allowed_caps = gst_pad_query_caps (GST_AUDIO_DECODER_SINK_PAD (dec),
|
||||||
caps);
|
caps);
|
||||||
|
|
||||||
accept = gst_caps_can_intersect (caps, allowed_caps);
|
accept = gst_caps_can_intersect (caps, allowed_caps);
|
||||||
|
|
||||||
gst_caps_unref (allowed_caps);
|
gst_caps_unref (allowed_caps);
|
||||||
|
}
|
||||||
|
|
||||||
|
gst_query_set_accept_caps_result (query, accept);
|
||||||
|
res = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_query_set_accept_caps_result (query, accept);
|
|
||||||
res = TRUE;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GST_QUERY_SEEKING:
|
case GST_QUERY_SEEKING:
|
||||||
|
@ -3611,3 +3620,24 @@ gst_audio_decoder_get_allocator (GstAudioDecoder * dec,
|
||||||
if (params)
|
if (params)
|
||||||
*params = dec->priv->ctx.params;
|
*params = dec->priv->ctx.params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_audio_decoder_set_use_default_pad_acceptcaps:
|
||||||
|
* @decoder: a #GstAudioDecoder
|
||||||
|
* @use: if the default pad accept-caps query handling should be used
|
||||||
|
*
|
||||||
|
* Lets #GstAudioDecoder sub-classes decide if they want the sink pad
|
||||||
|
* to use the default pad query handler to reply to accept-caps queries.
|
||||||
|
*
|
||||||
|
* By setting this to true it is possible to further customize the default
|
||||||
|
* handler with %GST_PAD_SET_ACCEPT_INTERSECT and
|
||||||
|
* %GST_PAD_SET_ACCEPT_TEMPLATE
|
||||||
|
*
|
||||||
|
* Since: 1.6
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gst_audio_decoder_set_use_default_pad_acceptcaps (GstAudioDecoder * decoder,
|
||||||
|
gboolean use)
|
||||||
|
{
|
||||||
|
decoder->priv->use_default_pad_acceptcaps = use;
|
||||||
|
}
|
||||||
|
|
|
@ -397,6 +397,9 @@ void gst_audio_decoder_merge_tags (GstAudioDecoder * dec,
|
||||||
gboolean gst_audio_decoder_sink_query_default (GstAudioDecoder * dec,
|
gboolean gst_audio_decoder_sink_query_default (GstAudioDecoder * dec,
|
||||||
GstQuery * query);
|
GstQuery * query);
|
||||||
|
|
||||||
|
void gst_audio_decoder_set_use_default_pad_acceptcaps (GstAudioDecoder * decoder,
|
||||||
|
gboolean use);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* _GST_AUDIO_DECODER_H_ */
|
#endif /* _GST_AUDIO_DECODER_H_ */
|
||||||
|
|
|
@ -67,6 +67,7 @@ EXPORTS
|
||||||
gst_audio_decoder_set_plc
|
gst_audio_decoder_set_plc
|
||||||
gst_audio_decoder_set_plc_aware
|
gst_audio_decoder_set_plc_aware
|
||||||
gst_audio_decoder_set_tolerance
|
gst_audio_decoder_set_tolerance
|
||||||
|
gst_audio_decoder_set_use_default_pad_acceptcaps
|
||||||
gst_audio_decoder_sink_query_default
|
gst_audio_decoder_sink_query_default
|
||||||
gst_audio_downmix_meta_api_get_type
|
gst_audio_downmix_meta_api_get_type
|
||||||
gst_audio_downmix_meta_get_info
|
gst_audio_downmix_meta_get_info
|
||||||
|
|
Loading…
Reference in a new issue