Commit 4429e10e authored by Wind Yuan's avatar Wind Yuan Committed by Gwenole Beauchesne

decode: delay NEWSEGMENT event if vaapidecode element was not linked.

Rationale: playbin2 links all elements at run-time. Once vaapidecode
is created and a NEWSEGMENT event arrives, downstream element may not
be ready yet. So, delay this event until next element is chained in,
otherwise basesink could output "Received buffer without a new-segment.
Assuming timestamps start from 0".
Signed-off-by: default avatarGwenole Beauchesne <gwenole.beauchesne@intel.com>
parent 92a29c44
......@@ -385,6 +385,11 @@ gst_vaapidecode_finalize(GObject *object)
decode->allowed_caps = NULL;
}
if (decode->delayed_new_seg) {
gst_event_unref(decode->delayed_new_seg);
decode->delayed_new_seg = NULL;
}
G_OBJECT_CLASS(parent_class)->finalize(object);
}
......@@ -589,7 +594,16 @@ gst_vaapidecode_set_caps(GstPad *pad, GstCaps *caps)
return FALSE;
if (!gst_vaapidecode_update_src_caps(decode, caps))
return FALSE;
return gst_vaapidecode_reset(decode, decode->sinkpad_caps);
if (!gst_vaapidecode_reset(decode, decode->sinkpad_caps))
return FALSE;
/* Propagate NEWSEGMENT event downstream, now that pads are linked */
if (decode->delayed_new_seg) {
if (gst_pad_push_event(decode->srcpad, decode->delayed_new_seg))
gst_event_unref(decode->delayed_new_seg);
decode->delayed_new_seg = NULL;
}
return TRUE;
}
static GstFlowReturn
......@@ -620,6 +634,20 @@ gst_vaapidecode_sink_event(GstPad *pad, GstEvent *event)
GST_DEBUG("handle sink event '%s'", GST_EVENT_TYPE_NAME(event));
/* Propagate event downstream */
switch (GST_EVENT_TYPE(event)) {
case GST_EVENT_NEWSEGMENT:
if (decode->delayed_new_seg) {
gst_event_unref(decode->delayed_new_seg);
decode->delayed_new_seg = NULL;
}
if (!GST_PAD_PEER(decode->srcpad)) {
decode->delayed_new_seg = gst_event_ref(event);
return TRUE;
}
break;
default:
break;
}
return gst_pad_push_event(decode->srcpad, event);
}
......@@ -645,6 +673,7 @@ gst_vaapidecode_init(GstVaapiDecode *decode, GstVaapiDecodeClass *klass)
decode->decoder_ready = NULL;
decode->decoder_caps = NULL;
decode->allowed_caps = NULL;
decode->delayed_new_seg = NULL;
decode->use_ffmpeg = TRUE;
decode->is_ready = FALSE;
......
......@@ -71,6 +71,7 @@ struct _GstVaapiDecode {
GCond *decoder_ready;
GstCaps *decoder_caps;
GstCaps *allowed_caps;
GstEvent *delayed_new_seg;
unsigned int use_ffmpeg : 1;
unsigned int is_ready : 1;
};
......
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