Commit 2b6759d3 authored by Sreerenj Balachandran's avatar Sreerenj Balachandran Committed by Gwenole Beauchesne

vaapidecode: return sink caps template if decoder is in NULL state.

Otherwise, the decoder would always create its own X display instead
of probing it from the downstream element, which is not reliable.
e.g. DISPLAY is not :0 or when running on Wayland.
Signed-off-by: default avatarGwenole Beauchesne <gwenole.beauchesne@intel.com>
parent dc057ab6
......@@ -436,6 +436,9 @@ gst_vaapidecode_change_state(GstElement *element, GstStateChange transition)
GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
switch (transition) {
case GST_STATE_CHANGE_NULL_TO_READY:
decode->is_ready = TRUE;
break;
case GST_STATE_CHANGE_READY_TO_PAUSED:
break;
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
......@@ -453,6 +456,14 @@ gst_vaapidecode_change_state(GstElement *element, GstStateChange transition)
break;
case GST_STATE_CHANGE_PAUSED_TO_READY:
break;
case GST_STATE_CHANGE_READY_TO_NULL:
gst_vaapidecode_destroy(decode);
if (decode->display) {
g_object_unref(decode->display);
decode->display = NULL;
}
decode->is_ready = FALSE;
break;
default:
break;
}
......@@ -559,6 +570,9 @@ gst_vaapidecode_get_caps(GstPad *pad)
{
GstVaapiDecode * const decode = GST_VAAPIDECODE(GST_OBJECT_PARENT(pad));
if (!decode->is_ready)
return gst_static_pad_template_get_caps(&gst_vaapidecode_sink_factory);
if (!gst_vaapidecode_ensure_allowed_caps(decode))
return gst_caps_new_empty();
......@@ -633,6 +647,7 @@ gst_vaapidecode_init(GstVaapiDecode *decode, GstVaapiDecodeClass *klass)
decode->decoder_caps = NULL;
decode->allowed_caps = NULL;
decode->use_ffmpeg = TRUE;
decode->is_ready = FALSE;
/* Pad through which data comes in to the element */
decode->sinkpad = gst_pad_new_from_template(
......
......@@ -72,6 +72,7 @@ struct _GstVaapiDecode {
GstCaps *decoder_caps;
GstCaps *allowed_caps;
unsigned int use_ffmpeg : 1;
unsigned int is_ready : 1;
};
struct _GstVaapiDecodeClass {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment