mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
videodecoder: add option to use default pad accept-caps handling
Add gst_video_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_video_decoder_set_use_default_pad_acceptcaps
This commit is contained in:
parent
95eb641821
commit
4982188cf7
3 changed files with 50 additions and 16 deletions
|
@ -421,6 +421,9 @@ struct _GstVideoDecoderPrivate
|
||||||
|
|
||||||
GstTagList *tags;
|
GstTagList *tags;
|
||||||
gboolean tags_changed;
|
gboolean tags_changed;
|
||||||
|
|
||||||
|
/* flags */
|
||||||
|
gboolean use_default_pad_acceptcaps;
|
||||||
};
|
};
|
||||||
|
|
||||||
static GstElementClass *parent_class = NULL;
|
static GstElementClass *parent_class = NULL;
|
||||||
|
@ -1862,28 +1865,34 @@ gst_video_decoder_sink_query_default (GstVideoDecoder * decoder,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GST_QUERY_ACCEPT_CAPS:{
|
case GST_QUERY_ACCEPT_CAPS:{
|
||||||
GstCaps *caps;
|
if (decoder->priv->use_default_pad_acceptcaps) {
|
||||||
GstCaps *allowed_caps;
|
res =
|
||||||
GstCaps *template_caps;
|
gst_pad_query_default (GST_VIDEO_DECODER_SINK_PAD (decoder),
|
||||||
gboolean accept;
|
GST_OBJECT_CAST (decoder), 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_VIDEO_DECODER_SINK_PAD (decoder),
|
allowed_caps =
|
||||||
caps);
|
gst_pad_query_caps (GST_VIDEO_DECODER_SINK_PAD (decoder), 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;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -4293,3 +4302,24 @@ gst_video_decoder_get_allocator (GstVideoDecoder * decoder,
|
||||||
if (params)
|
if (params)
|
||||||
*params = decoder->priv->params;
|
*params = decoder->priv->params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_video_decoder_set_use_default_pad_acceptcaps:
|
||||||
|
* @decoder: a #GstVideoDecoder
|
||||||
|
* @use: if the default pad accept-caps query handling should be used
|
||||||
|
*
|
||||||
|
* Lets #GstVideoDecoder 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_video_decoder_set_use_default_pad_acceptcaps (GstVideoDecoder * decoder,
|
||||||
|
gboolean use)
|
||||||
|
{
|
||||||
|
decoder->priv->use_default_pad_acceptcaps = use;
|
||||||
|
}
|
||||||
|
|
|
@ -427,6 +427,9 @@ GstCaps * gst_video_decoder_proxy_getcaps (GstVideoDecoder * decoder,
|
||||||
gboolean gst_video_decoder_sink_query_default (GstVideoDecoder * decoder,
|
gboolean gst_video_decoder_sink_query_default (GstVideoDecoder * decoder,
|
||||||
GstQuery * query);
|
GstQuery * query);
|
||||||
|
|
||||||
|
void gst_video_decoder_set_use_default_pad_acceptcaps (GstVideoDecoder * decoder,
|
||||||
|
gboolean use);
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
|
@ -129,6 +129,7 @@ EXPORTS
|
||||||
gst_video_decoder_set_needs_format
|
gst_video_decoder_set_needs_format
|
||||||
gst_video_decoder_set_output_state
|
gst_video_decoder_set_output_state
|
||||||
gst_video_decoder_set_packetized
|
gst_video_decoder_set_packetized
|
||||||
|
gst_video_decoder_set_use_default_pad_acceptcaps
|
||||||
gst_video_decoder_sink_query_default
|
gst_video_decoder_sink_query_default
|
||||||
gst_video_dither_flags_get_type
|
gst_video_dither_flags_get_type
|
||||||
gst_video_dither_free
|
gst_video_dither_free
|
||||||
|
|
Loading…
Reference in a new issue