Commit 6c21dd4d authored by Vivia Nikolaidou's avatar Vivia Nikolaidou 🦆
Browse files

identity: Fix crash when receiving a gap event outside the current segment

We were checking if the start time of the gap event was
GST_CLOCK_TIME_NONE, which is superfluous because that cannot happen,
and then not checking if it was NONE after gst_segment_to_running_time,
which caused a crash if an identity received a gap event fully or
partially outside the current segment.

This patch was done in cooperation with:
Jan Alexander Steffens (heftig) <jan.steffens@ltnglobal.com>

Part-of: <gstreamer/gstreamer!1269>
parent c414f956
Pipeline #435376 passed with stages
in 108 minutes and 5 seconds
......@@ -480,19 +480,34 @@ gst_identity_sink_event (GstBaseTransform * trans, GstEvent * event)
if (GST_EVENT_TYPE (event) == GST_EVENT_GAP &&
trans->have_segment && trans->segment.format == GST_FORMAT_TIME) {
GstClockTime start, dur;
GstClockTime start, dur, old_start;
gst_event_parse_gap (event, &start, &dur);
if (GST_CLOCK_TIME_IS_VALID (start)) {
start = gst_segment_to_running_time (&trans->segment,
GST_FORMAT_TIME, start);
gst_event_parse_gap (event, &old_start, &dur);
gst_identity_do_sync (identity, start);
start = gst_segment_to_running_time (&trans->segment,
GST_FORMAT_TIME, old_start);
/* also transform GAP timestamp similar to buffer timestamps */
if (identity->single_segment) {
gst_identity_do_sync (identity,
GST_CLOCK_TIME_IS_VALID (start) ? start : 0);
/* also transform GAP timestamp similar to buffer timestamps */
if (identity->single_segment) {
guint64 clip_start, clip_stop;
if (GST_CLOCK_TIME_IS_VALID (start)) {
gst_event_unref (event);
event = gst_event_new_gap (start, dur);
} else if (GST_CLOCK_TIME_IS_VALID (dur) &&
gst_segment_clip (&trans->segment, GST_FORMAT_TIME, old_start,
old_start + dur, &clip_start, &clip_stop)) {
gst_event_unref (event);
event = gst_event_new_gap (clip_start, clip_stop - clip_start);
} else {
/* Gap event is completely outside the segment, drop it */
GST_DEBUG_OBJECT (identity,
"Dropping GAP event outside segment: %" GST_PTR_FORMAT, event);
gst_event_unref (event);
ret = TRUE;
goto done;
}
}
}
......
Supports Markdown
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