summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeungha Yang <sh.yang@lge.com>2016-04-15 20:54:42 +0900
committerEdward Hervey <bilboed@bilboed.com>2017-01-31 15:55:12 +0100
commit15f2898e872d3b7ce74ea5fbd35fac9f1f47b4a5 (patch)
tree055660244859a6742ab4a33634b7771101358adf
parent94da8f5d8dbc9308abaec5b1c450c4c39d452e21 (diff)
segment: Modifiy inside segment condition
There is a special case that segment_start == segment_stop == start. It's inside of segment https://bugzilla.gnome.org/show_bug.cgi?id=764707
-rw-r--r--gst/gstsegment.c7
-rw-r--r--tests/check/gst/gstsegment.c56
2 files changed, 61 insertions, 2 deletions
diff --git a/gst/gstsegment.c b/gst/gstsegment.c
index 8d4183ea44..8db09df3b1 100644
--- a/gst/gstsegment.c
+++ b/gst/gstsegment.c
@@ -884,8 +884,11 @@ gst_segment_clip (const GstSegment * segment, GstFormat format, guint64 start,
g_return_val_if_fail (segment->format == format, FALSE);
/* if we have a stop position and a valid start and start is bigger,
- * we're outside of the segment */
- if (G_UNLIKELY (segment->stop != -1 && start != -1 && start >= segment->stop))
+ * we're outside of the segment. (Special case) segment start and
+ * segment stop can be identical. In this case, if start is also identical,
+ * it's inside of segment */
+ if (G_UNLIKELY (segment->stop != -1 && start != -1 && (start > segment->stop
+ || (segment->start != segment->stop && start == segment->stop))))
return FALSE;
/* if a stop position is given and is before the segment start,
diff --git a/tests/check/gst/gstsegment.c b/tests/check/gst/gstsegment.c
index f3433e8083..60a0d6f516 100644
--- a/tests/check/gst/gstsegment.c
+++ b/tests/check/gst/gstsegment.c
@@ -345,6 +345,62 @@ GST_START_TEST (segment_seek_size)
fail_unless (update == FALSE);
check_times (&segment, 200, 200, 0);
+ /* special case, segment's start and stop are identical */
+ /* completely outside */
+ res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 50, 100, &cstart, &cstop);
+ fail_unless (res == FALSE);
+
+ /* completely outside also */
+ res = gst_segment_clip (&segment, GST_FORMAT_BYTES,
+ 250, 300, &cstart, &cstop);
+ fail_unless (res == FALSE);
+
+ /* stop at boundary point. it's outside because stop is exclusive */
+ res = gst_segment_clip (&segment, GST_FORMAT_BYTES,
+ 100, 200, &cstart, &cstop);
+ fail_unless (res == FALSE);
+
+ /* touching boundary point. it's inside because start at segment start */
+ res = gst_segment_clip (&segment, GST_FORMAT_BYTES,
+ 200, 300, &cstart, &cstop);
+ fail_unless (res == TRUE);
+ fail_unless (cstart == 200);
+ fail_unless (cstop == 200);
+
+ /* completely inside */
+ res = gst_segment_clip (&segment, GST_FORMAT_BYTES,
+ 200, 200, &cstart, &cstop);
+ fail_unless (res == TRUE);
+ fail_unless (cstart == 200);
+ fail_unless (cstop == 200);
+
+ /* exclusively cover boundary point */
+ res = gst_segment_clip (&segment, GST_FORMAT_BYTES,
+ 150, 250, &cstart, &cstop);
+ fail_unless (res == TRUE);
+ fail_unless (cstart == 200);
+ fail_unless (cstop == 200);
+
+ /* invalid start */
+ res = gst_segment_clip (&segment, GST_FORMAT_BYTES, -1, 200, &cstart, &cstop);
+ fail_unless (res == FALSE);
+
+ /* start outside */
+ res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 50, -1, &cstart, &cstop);
+ fail_unless (res == TRUE);
+ fail_unless (cstart == 200);
+ fail_unless (cstop == 200);
+
+ /* start on boundary point */
+ res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 200, -1, &cstart, &cstop);
+ fail_unless (res == TRUE);
+ fail_unless (cstart == 200);
+ fail_unless (cstop == 200);
+
+ /* start completely outside */
+ res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 250, -1, &cstart, &cstop);
+ fail_unless (res == FALSE);
+
/* seek relative to end */
gst_segment_do_seek (&segment, 1.0,
GST_FORMAT_BYTES,