mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 01:00:37 +00:00
gst/gstsegment.c: Fix boundary checking in to_running_time() and to_stream_time().
Original commit message from CVS: * gst/gstsegment.c: (gst_segment_set_seek), (gst_segment_set_newsegment_full), (gst_segment_to_stream_time), (gst_segment_to_running_time): Fix boundary checking in to_running_time() and to_stream_time(). Fixes #377183. * tests/check/gst/gstsegment.c: (GST_START_TEST): stream and running time can now be calculated for the complete clipped segment.
This commit is contained in:
parent
c0ce620980
commit
f830f6f4ac
3 changed files with 52 additions and 39 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
||||||
|
2006-11-20 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
|
* gst/gstsegment.c: (gst_segment_set_seek),
|
||||||
|
(gst_segment_set_newsegment_full), (gst_segment_to_stream_time),
|
||||||
|
(gst_segment_to_running_time):
|
||||||
|
Fix boundary checking in to_running_time() and to_stream_time().
|
||||||
|
Fixes #377183.
|
||||||
|
|
||||||
|
* tests/check/gst/gstsegment.c: (GST_START_TEST):
|
||||||
|
stream and running time can now be calculated for the complete
|
||||||
|
clipped segment.
|
||||||
|
|
||||||
2006-11-15 Tim-Philipp Müller <tim at centricular dot net>
|
2006-11-15 Tim-Philipp Müller <tim at centricular dot net>
|
||||||
|
|
||||||
* gst/gstpad.c: (gst_pad_push_event):
|
* gst/gstpad.c: (gst_pad_push_event):
|
||||||
|
|
|
@ -512,7 +512,7 @@ gst_segment_to_stream_time (GstSegment * segment, GstFormat format,
|
||||||
g_return_val_if_fail (segment->format == format, -1);
|
g_return_val_if_fail (segment->format == format, -1);
|
||||||
|
|
||||||
/* outside of the segment boundary stop */
|
/* outside of the segment boundary stop */
|
||||||
if (G_UNLIKELY (segment->stop != -1 && position >= segment->stop))
|
if (G_UNLIKELY (segment->stop != -1 && position > segment->stop))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* before the segment boundary */
|
/* before the segment boundary */
|
||||||
|
@ -589,7 +589,7 @@ gst_segment_to_running_time (GstSegment * segment, GstFormat format,
|
||||||
|
|
||||||
if (segment->rate > 0.0) {
|
if (segment->rate > 0.0) {
|
||||||
/* outside of the segment boundary stop */
|
/* outside of the segment boundary stop */
|
||||||
if (G_UNLIKELY (segment->stop != -1 && position >= segment->stop))
|
if (G_UNLIKELY (segment->stop != -1 && position > segment->stop))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* bring to uncorrected position in segment */
|
/* bring to uncorrected position in segment */
|
||||||
|
@ -597,7 +597,7 @@ gst_segment_to_running_time (GstSegment * segment, GstFormat format,
|
||||||
} else {
|
} else {
|
||||||
/* cannot continue if no stop position set or outside of
|
/* cannot continue if no stop position set or outside of
|
||||||
* the segment. */
|
* the segment. */
|
||||||
if (G_UNLIKELY (segment->stop == -1 || position >= segment->stop))
|
if (G_UNLIKELY (segment->stop == -1 || position > segment->stop))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* bring to uncorrected position in segment */
|
/* bring to uncorrected position in segment */
|
||||||
|
|
|
@ -581,10 +581,10 @@ GST_START_TEST (segment_newsegment_streamtime)
|
||||||
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 100);
|
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 100);
|
||||||
fail_unless (result == 100);
|
fail_unless (result == 100);
|
||||||
|
|
||||||
/* outside of the segment */
|
|
||||||
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200);
|
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200);
|
||||||
fail_unless (result == -1);
|
fail_unless (result == 200);
|
||||||
|
|
||||||
|
/* outside of the segment */
|
||||||
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300);
|
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300);
|
||||||
fail_unless (result == -1);
|
fail_unless (result == -1);
|
||||||
|
|
||||||
|
@ -635,10 +635,10 @@ GST_START_TEST (segment_newsegment_streamtime)
|
||||||
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 600);
|
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 600);
|
||||||
fail_unless (result == 100);
|
fail_unless (result == 100);
|
||||||
|
|
||||||
/* outside of the segment */
|
|
||||||
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 700);
|
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 700);
|
||||||
fail_unless (result == -1);
|
fail_unless (result == 200);
|
||||||
|
|
||||||
|
/* outside of the segment */
|
||||||
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 800);
|
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 800);
|
||||||
fail_unless (result == -1);
|
fail_unless (result == -1);
|
||||||
|
|
||||||
|
@ -664,10 +664,10 @@ GST_START_TEST (segment_newsegment_streamtime)
|
||||||
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 600);
|
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 600);
|
||||||
fail_unless (result == 300);
|
fail_unless (result == 300);
|
||||||
|
|
||||||
/* outside of the segment */
|
|
||||||
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 700);
|
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 700);
|
||||||
fail_unless (result == -1);
|
fail_unless (result == 400);
|
||||||
|
|
||||||
|
/* outside of the segment */
|
||||||
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 800);
|
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 800);
|
||||||
fail_unless (result == -1);
|
fail_unless (result == -1);
|
||||||
}
|
}
|
||||||
|
@ -712,10 +712,10 @@ GST_START_TEST (segment_newsegment_streamtime_rate)
|
||||||
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 150);
|
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 150);
|
||||||
fail_unless (result == 150);
|
fail_unless (result == 150);
|
||||||
|
|
||||||
/* outside of the segment */
|
|
||||||
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200);
|
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200);
|
||||||
fail_unless (result == -1);
|
fail_unless (result == 200);
|
||||||
|
|
||||||
|
/* outside of the segment */
|
||||||
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300);
|
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300);
|
||||||
fail_unless (result == -1);
|
fail_unless (result == -1);
|
||||||
|
|
||||||
|
@ -740,10 +740,10 @@ GST_START_TEST (segment_newsegment_streamtime_rate)
|
||||||
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 250);
|
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 250);
|
||||||
fail_unless (result == 150);
|
fail_unless (result == 150);
|
||||||
|
|
||||||
/* outside of the segment */
|
|
||||||
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300);
|
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300);
|
||||||
fail_unless (result == -1);
|
fail_unless (result == 200);
|
||||||
|
|
||||||
|
/* outside of the segment */
|
||||||
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 400);
|
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 400);
|
||||||
fail_unless (result == -1);
|
fail_unless (result == -1);
|
||||||
|
|
||||||
|
@ -784,10 +784,10 @@ GST_START_TEST (segment_newsegment_streamtime_rate)
|
||||||
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200);
|
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200);
|
||||||
fail_unless (result == 300);
|
fail_unless (result == 300);
|
||||||
|
|
||||||
/* outside of the segment */
|
|
||||||
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300);
|
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300);
|
||||||
fail_unless (result == -1);
|
fail_unless (result == 400);
|
||||||
|
|
||||||
|
/* outside of the segment */
|
||||||
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 400);
|
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 400);
|
||||||
fail_unless (result == -1);
|
fail_unless (result == -1);
|
||||||
}
|
}
|
||||||
|
@ -835,10 +835,10 @@ GST_START_TEST (segment_newsegment_streamtime_applied_rate)
|
||||||
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 150);
|
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 150);
|
||||||
fail_unless (result == 50);
|
fail_unless (result == 50);
|
||||||
|
|
||||||
/* outside of the segment */
|
|
||||||
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200);
|
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200);
|
||||||
fail_unless (result == -1);
|
fail_unless (result == 0);
|
||||||
|
|
||||||
|
/* outside of the segment */
|
||||||
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300);
|
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300);
|
||||||
fail_unless (result == -1);
|
fail_unless (result == -1);
|
||||||
|
|
||||||
|
@ -876,10 +876,10 @@ GST_START_TEST (segment_newsegment_streamtime_applied_rate)
|
||||||
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 150);
|
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 150);
|
||||||
fail_unless (result == 300);
|
fail_unless (result == 300);
|
||||||
|
|
||||||
/* outside of the segment */
|
|
||||||
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200);
|
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200);
|
||||||
fail_unless (result == -1);
|
fail_unless (result == 400);
|
||||||
|
|
||||||
|
/* outside of the segment */
|
||||||
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300);
|
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300);
|
||||||
fail_unless (result == -1);
|
fail_unless (result == -1);
|
||||||
|
|
||||||
|
@ -917,10 +917,10 @@ GST_START_TEST (segment_newsegment_streamtime_applied_rate)
|
||||||
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 150);
|
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 150);
|
||||||
fail_unless (result == 100);
|
fail_unless (result == 100);
|
||||||
|
|
||||||
/* outside of the segment */
|
|
||||||
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200);
|
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200);
|
||||||
fail_unless (result == -1);
|
fail_unless (result == 0);
|
||||||
|
|
||||||
|
/* outside of the segment */
|
||||||
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300);
|
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300);
|
||||||
fail_unless (result == -1);
|
fail_unless (result == -1);
|
||||||
|
|
||||||
|
@ -959,10 +959,10 @@ GST_START_TEST (segment_newsegment_streamtime_applied_rate)
|
||||||
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 150);
|
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 150);
|
||||||
fail_unless (result == 0);
|
fail_unless (result == 0);
|
||||||
|
|
||||||
/* outside of the segment */
|
|
||||||
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200);
|
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200);
|
||||||
fail_unless (result == -1);
|
fail_unless (result == 0);
|
||||||
|
|
||||||
|
/* outside of the segment */
|
||||||
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300);
|
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300);
|
||||||
fail_unless (result == -1);
|
fail_unless (result == -1);
|
||||||
}
|
}
|
||||||
|
@ -1011,10 +1011,10 @@ GST_START_TEST (segment_newsegment_streamtime_applied_rate_rate)
|
||||||
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 150);
|
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 150);
|
||||||
fail_unless (result == 300);
|
fail_unless (result == 300);
|
||||||
|
|
||||||
/* outside of the segment */
|
|
||||||
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200);
|
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200);
|
||||||
fail_unless (result == -1);
|
fail_unless (result == 400);
|
||||||
|
|
||||||
|
/* outside of the segment */
|
||||||
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300);
|
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300);
|
||||||
fail_unless (result == -1);
|
fail_unless (result == -1);
|
||||||
|
|
||||||
|
@ -1052,10 +1052,10 @@ GST_START_TEST (segment_newsegment_streamtime_applied_rate_rate)
|
||||||
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 150);
|
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 150);
|
||||||
fail_unless (result == 50);
|
fail_unless (result == 50);
|
||||||
|
|
||||||
/* outside of the segment */
|
|
||||||
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200);
|
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200);
|
||||||
fail_unless (result == -1);
|
fail_unless (result == 0);
|
||||||
|
|
||||||
|
/* outside of the segment */
|
||||||
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300);
|
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300);
|
||||||
fail_unless (result == -1);
|
fail_unless (result == -1);
|
||||||
|
|
||||||
|
@ -1093,10 +1093,10 @@ GST_START_TEST (segment_newsegment_streamtime_applied_rate_rate)
|
||||||
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 150);
|
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 150);
|
||||||
fail_unless (result == 50);
|
fail_unless (result == 50);
|
||||||
|
|
||||||
/* outside of the segment */
|
|
||||||
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200);
|
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200);
|
||||||
fail_unless (result == -1);
|
fail_unless (result == 0);
|
||||||
|
|
||||||
|
/* outside of the segment */
|
||||||
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300);
|
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300);
|
||||||
fail_unless (result == -1);
|
fail_unless (result == -1);
|
||||||
|
|
||||||
|
@ -1133,10 +1133,10 @@ GST_START_TEST (segment_newsegment_streamtime_applied_rate_rate)
|
||||||
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 150);
|
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 150);
|
||||||
fail_unless (result == 300);
|
fail_unless (result == 300);
|
||||||
|
|
||||||
/* outside of the segment */
|
|
||||||
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200);
|
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200);
|
||||||
fail_unless (result == -1);
|
fail_unless (result == 400);
|
||||||
|
|
||||||
|
/* outside of the segment */
|
||||||
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300);
|
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300);
|
||||||
fail_unless (result == -1);
|
fail_unless (result == -1);
|
||||||
}
|
}
|
||||||
|
@ -1178,10 +1178,11 @@ GST_START_TEST (segment_newsegment_runningtime)
|
||||||
result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 100);
|
result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 100);
|
||||||
fail_unless (result == 100);
|
fail_unless (result == 100);
|
||||||
|
|
||||||
/* outside of the segment */
|
/* at edge is exactly the segment duration */
|
||||||
result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 200);
|
result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 200);
|
||||||
fail_unless (result == -1);
|
fail_unless (result == 200);
|
||||||
|
|
||||||
|
/* outside of the segment */
|
||||||
result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 300);
|
result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 300);
|
||||||
fail_unless (result == -1);
|
fail_unless (result == -1);
|
||||||
|
|
||||||
|
@ -1236,10 +1237,10 @@ GST_START_TEST (segment_newsegment_runningtime)
|
||||||
result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 600);
|
result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 600);
|
||||||
fail_unless (result == 400);
|
fail_unless (result == 400);
|
||||||
|
|
||||||
/* outside of the segment */
|
|
||||||
result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 700);
|
result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 700);
|
||||||
fail_unless (result == -1);
|
fail_unless (result == 500);
|
||||||
|
|
||||||
|
/* outside of the segment */
|
||||||
result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 800);
|
result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 800);
|
||||||
fail_unless (result == -1);
|
fail_unless (result == -1);
|
||||||
|
|
||||||
|
@ -1268,10 +1269,10 @@ GST_START_TEST (segment_newsegment_runningtime)
|
||||||
result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 600);
|
result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 600);
|
||||||
fail_unless (result == 600);
|
fail_unless (result == 600);
|
||||||
|
|
||||||
/* outside of the segment */
|
|
||||||
result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 700);
|
result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 700);
|
||||||
fail_unless (result == -1);
|
fail_unless (result == 500);
|
||||||
|
|
||||||
|
/* outside of the segment */
|
||||||
result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 800);
|
result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 800);
|
||||||
fail_unless (result == -1);
|
fail_unless (result == -1);
|
||||||
|
|
||||||
|
@ -1301,10 +1302,10 @@ GST_START_TEST (segment_newsegment_runningtime)
|
||||||
result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 600);
|
result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 600);
|
||||||
fail_unless (result == 750);
|
fail_unless (result == 750);
|
||||||
|
|
||||||
/* outside of the segment */
|
|
||||||
result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 700);
|
result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 700);
|
||||||
fail_unless (result == -1);
|
fail_unless (result == 700);
|
||||||
|
|
||||||
|
/* outside of the segment */
|
||||||
result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 800);
|
result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 800);
|
||||||
fail_unless (result == -1);
|
fail_unless (result == -1);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue