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: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
This commit is contained in:
Sreerenj Balachandran 2011-12-08 11:54:59 +01:00 committed by Gwenole Beauchesne
parent dc08d1eae0
commit 809e087cca
2 changed files with 16 additions and 0 deletions

View file

@ -455,6 +455,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:
@ -472,6 +475,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;
}
@ -570,6 +581,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();
@ -660,6 +674,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(

View file

@ -72,6 +72,7 @@ struct _GstVaapiDecode {
GstCaps *decoder_caps;
GstCaps *allowed_caps;
unsigned int use_ffmpeg : 1;
unsigned int is_ready : 1;
};
struct _GstVaapiDecodeClass {