gstreamer/tests/check/gst/gstsegment.c

637 lines
20 KiB
C
Raw Normal View History

/* GStreamer
* Copyright (C) 2005 Jan Schmidt <thaytan@mad.scientist.com>
* 2009 Wim Taymans <wim.taymans@gmail.com>
*
* gstsegment.c: Unit test for segments
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include <gst/check/gstcheck.h>
2012-07-27 10:24:03 +00:00
static void
check_times (GstSegment * segment, guint64 position, guint64 stream_time,
guint64 running_time)
{
guint64 st, rt;
st = gst_segment_to_stream_time (segment, segment->format, position);
rt = gst_segment_to_running_time (segment, segment->format, position);
fail_unless_equals_int64 (st, stream_time);
fail_unless_equals_int64 (rt, running_time);
2012-07-27 10:24:03 +00:00
}
/* mess with the segment structure in the bytes format */
GST_START_TEST (segment_seek_nosize)
{
GstSegment segment;
gboolean res;
guint64 cstart, cstop;
gboolean update;
gst_segment_init (&segment, GST_FORMAT_BYTES);
/* configure segment to start 100 */
gst_segment_do_seek (&segment, 1.0,
GST_FORMAT_BYTES,
GST_SEEK_FLAG_NONE,
GST_SEEK_TYPE_SET, 100, GST_SEEK_TYPE_NONE, -1, &update);
fail_unless (segment.start == 100);
2012-07-27 10:24:03 +00:00
fail_unless (segment.position == 100);
fail_unless (segment.stop == -1);
fail_unless (update == TRUE);
2012-07-27 10:24:03 +00:00
/* appended after current position 0 */
check_times (&segment, 100, 100, 0);
/* do some clipping on the open range */
/* completely outside */
res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 0, 50, &cstart, &cstop);
fail_unless (res == FALSE);
docs/design/part-overview.txt: Make upsteam/downstream concepts more clear. Original commit message from CVS: * docs/design/part-overview.txt: Make upsteam/downstream concepts more clear. Give an example of serialized/non-serialized events. * docs/design/part-events.txt: * docs/design/part-streams.txt: Mention applied_rate. * docs/design/part-trickmodes.txt: Mention applied rate, flesh out some more use cases. * gst/gstevent.c: (gst_event_new_new_segment), (gst_event_parse_new_segment), (gst_event_new_new_segment_full), (gst_event_parse_new_segment_full), (gst_event_new_tag), (gst_event_parse_tag), (gst_event_new_buffer_size), (gst_event_parse_buffer_size), (gst_event_new_qos), (gst_event_parse_qos), (gst_event_parse_seek), (gst_event_new_navigation): * gst/gstevent.h: Add applied_rate field to NEWSEGMENT event. API: gst_event_new_new_segment_full() API: gst_event_parse_new_segment_full() * gst/gstsegment.c: (gst_segment_init), (gst_segment_set_seek), (gst_segment_set_newsegment), (gst_segment_set_newsegment_full), (gst_segment_to_stream_time), (gst_segment_to_running_time): * gst/gstsegment.h: Add applied_rate to GstSegment structure. Make calculation of stream_time and running_time more correct wrt rate/applied_rate. Add some more docs. API: GstSegment::applied_rate field API: gst_segment_set_newsegment_full(); * libs/gst/base/gstbasesink.c: (gst_base_sink_configure_segment), (gst_base_sink_get_sync_times), (gst_base_sink_get_position): * libs/gst/base/gstbasetransform.c: (gst_base_transform_sink_eventfunc), (gst_base_transform_handle_buffer): Parse and use applied_rate in the GstSegment field. * tests/check/gst/gstevent.c: (GST_START_TEST): Add check for applied_rate field. * tests/check/gst/gstsegment.c: (GST_START_TEST), (gstsegments_suite): Add more checks for various GstSegment operations.
2006-05-08 09:52:33 +00:00
/* touching lower bound, still outside of the segment */
res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 50, 100, &cstart, &cstop);
fail_unless (res == FALSE);
/* partially inside */
res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 50, 150, &cstart, &cstop);
fail_unless (res == TRUE);
fail_unless (cstart == 100);
fail_unless (cstop == 150);
/* inside, touching lower bound */
res = gst_segment_clip (&segment, GST_FORMAT_BYTES,
100, 150, &cstart, &cstop);
fail_unless (res == TRUE);
fail_unless (cstart == 100);
fail_unless (cstop == 150);
/* special case, 0 duration and outside segment */
res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 90, 90, &cstart, &cstop);
fail_unless (res == FALSE);
/* special case, 0 duration and touching lower bound, i.e. inside segment */
res = gst_segment_clip (&segment, GST_FORMAT_BYTES,
100, 100, &cstart, &cstop);
fail_unless (res == TRUE);
fail_unless (cstart == 100);
fail_unless (cstop == 100);
/* special case, 0 duration and inside the segment */
res = gst_segment_clip (&segment, GST_FORMAT_BYTES,
120, 120, &cstart, &cstop);
fail_unless (res == TRUE);
fail_unless (cstart == 120);
fail_unless (cstop == 120);
/* completely inside */
res = gst_segment_clip (&segment, GST_FORMAT_BYTES,
150, 200, &cstart, &cstop);
fail_unless (res == TRUE);
fail_unless (cstart == 150);
fail_unless (cstop == 200);
/* invalid start */
res = gst_segment_clip (&segment, GST_FORMAT_BYTES, -1, 100, &cstart, &cstop);
fail_unless (res == FALSE);
docs/design/part-overview.txt: Make upsteam/downstream concepts more clear. Original commit message from CVS: * docs/design/part-overview.txt: Make upsteam/downstream concepts more clear. Give an example of serialized/non-serialized events. * docs/design/part-events.txt: * docs/design/part-streams.txt: Mention applied_rate. * docs/design/part-trickmodes.txt: Mention applied rate, flesh out some more use cases. * gst/gstevent.c: (gst_event_new_new_segment), (gst_event_parse_new_segment), (gst_event_new_new_segment_full), (gst_event_parse_new_segment_full), (gst_event_new_tag), (gst_event_parse_tag), (gst_event_new_buffer_size), (gst_event_parse_buffer_size), (gst_event_new_qos), (gst_event_parse_qos), (gst_event_parse_seek), (gst_event_new_navigation): * gst/gstevent.h: Add applied_rate field to NEWSEGMENT event. API: gst_event_new_new_segment_full() API: gst_event_parse_new_segment_full() * gst/gstsegment.c: (gst_segment_init), (gst_segment_set_seek), (gst_segment_set_newsegment), (gst_segment_set_newsegment_full), (gst_segment_to_stream_time), (gst_segment_to_running_time): * gst/gstsegment.h: Add applied_rate to GstSegment structure. Make calculation of stream_time and running_time more correct wrt rate/applied_rate. Add some more docs. API: GstSegment::applied_rate field API: gst_segment_set_newsegment_full(); * libs/gst/base/gstbasesink.c: (gst_base_sink_configure_segment), (gst_base_sink_get_sync_times), (gst_base_sink_get_position): * libs/gst/base/gstbasetransform.c: (gst_base_transform_sink_eventfunc), (gst_base_transform_handle_buffer): Parse and use applied_rate in the GstSegment field. * tests/check/gst/gstevent.c: (GST_START_TEST): Add check for applied_rate field. * tests/check/gst/gstsegment.c: (GST_START_TEST), (gstsegments_suite): Add more checks for various GstSegment operations.
2006-05-08 09:52:33 +00:00
/* start outside, we don't know the stop */
res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 50, -1, &cstart, &cstop);
fail_unless (res == TRUE);
fail_unless (cstart == 100);
fail_unless (cstop == -1);
/* start on lower bound */
res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 100, -1, &cstart, &cstop);
fail_unless (res == TRUE);
fail_unless (cstart == 100);
fail_unless (cstop == -1);
/* start inside */
res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 150, -1, &cstart, &cstop);
fail_unless (res == TRUE);
fail_unless (cstart == 150);
fail_unless (cstop == -1);
2012-07-27 10:24:03 +00:00
/* move to 150, this is a running_time of 50 */
segment.position = 150;
check_times (&segment, 150, 150, 50);
/* add 100 to start, set stop to 300 */
gst_segment_do_seek (&segment, 1.0,
GST_FORMAT_BYTES,
GST_SEEK_FLAG_NONE,
2011-10-28 14:08:37 +00:00
GST_SEEK_TYPE_SET, 100 + 100, GST_SEEK_TYPE_SET, 300, &update);
fail_unless (segment.start == 200);
2012-07-27 10:24:03 +00:00
fail_unless (segment.position == 200);
fail_unless (segment.stop == 300);
fail_unless (segment.base == 50);
fail_unless (update == TRUE);
2012-07-27 10:24:03 +00:00
check_times (&segment, 200, 200, 50);
check_times (&segment, 250, 250, 100);
update = FALSE;
/* add 100 to start (to 300), set stop to 200, this is not allowed.
docs/design/part-overview.txt: Make upsteam/downstream concepts more clear. Original commit message from CVS: * docs/design/part-overview.txt: Make upsteam/downstream concepts more clear. Give an example of serialized/non-serialized events. * docs/design/part-events.txt: * docs/design/part-streams.txt: Mention applied_rate. * docs/design/part-trickmodes.txt: Mention applied rate, flesh out some more use cases. * gst/gstevent.c: (gst_event_new_new_segment), (gst_event_parse_new_segment), (gst_event_new_new_segment_full), (gst_event_parse_new_segment_full), (gst_event_new_tag), (gst_event_parse_tag), (gst_event_new_buffer_size), (gst_event_parse_buffer_size), (gst_event_new_qos), (gst_event_parse_qos), (gst_event_parse_seek), (gst_event_new_navigation): * gst/gstevent.h: Add applied_rate field to NEWSEGMENT event. API: gst_event_new_new_segment_full() API: gst_event_parse_new_segment_full() * gst/gstsegment.c: (gst_segment_init), (gst_segment_set_seek), (gst_segment_set_newsegment), (gst_segment_set_newsegment_full), (gst_segment_to_stream_time), (gst_segment_to_running_time): * gst/gstsegment.h: Add applied_rate to GstSegment structure. Make calculation of stream_time and running_time more correct wrt rate/applied_rate. Add some more docs. API: GstSegment::applied_rate field API: gst_segment_set_newsegment_full(); * libs/gst/base/gstbasesink.c: (gst_base_sink_configure_segment), (gst_base_sink_get_sync_times), (gst_base_sink_get_position): * libs/gst/base/gstbasetransform.c: (gst_base_transform_sink_eventfunc), (gst_base_transform_handle_buffer): Parse and use applied_rate in the GstSegment field. * tests/check/gst/gstevent.c: (GST_START_TEST): Add check for applied_rate field. * tests/check/gst/gstsegment.c: (GST_START_TEST), (gstsegments_suite): Add more checks for various GstSegment operations.
2006-05-08 09:52:33 +00:00
* nothing should be updated in the segment. A g_warning is
* emited. */
ASSERT_CRITICAL (gst_segment_do_seek (&segment, 1.0,
GST_FORMAT_BYTES,
GST_SEEK_FLAG_NONE,
2011-10-28 14:08:37 +00:00
GST_SEEK_TYPE_SET, 200 + 100, GST_SEEK_TYPE_SET, 200, &update));
fail_unless (segment.start == 200);
2012-07-27 10:24:03 +00:00
fail_unless (segment.position == 200);
fail_unless (segment.stop == 300);
fail_unless (segment.base == 50);
/* update didn't change */
fail_unless (update == FALSE);
check_times (&segment, 200, 200, 50);
2012-07-27 10:24:03 +00:00
check_times (&segment, 250, 250, 100);
update = TRUE;
/* seek relative to end, should not do anything since size is
* unknown. */
gst_segment_do_seek (&segment, 1.0,
GST_FORMAT_BYTES,
GST_SEEK_FLAG_NONE,
GST_SEEK_TYPE_END, -300, GST_SEEK_TYPE_END, -100, &update);
fail_unless (segment.start == 200);
2012-07-27 10:24:03 +00:00
fail_unless (segment.position == 200);
fail_unless (segment.stop == 300);
fail_unless (segment.base == 50);
fail_unless (update == FALSE);
2012-07-27 10:24:03 +00:00
check_times (&segment, 250, 250, 100);
/* completely outside */
res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 0, 50, &cstart, &cstop);
fail_unless (res == FALSE);
/* touching lower bound */
res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 50, 200, &cstart, &cstop);
fail_unless (res == FALSE);
/* partially inside */
res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 50, 250, &cstart, &cstop);
fail_unless (res == TRUE);
fail_unless (cstart == 200);
fail_unless (cstop == 250);
/* inside, touching lower bound */
res = gst_segment_clip (&segment, GST_FORMAT_BYTES,
200, 250, &cstart, &cstop);
fail_unless (res == TRUE);
fail_unless (cstart == 200);
fail_unless (cstop == 250);
/* completely inside */
res = gst_segment_clip (&segment, GST_FORMAT_BYTES,
250, 290, &cstart, &cstop);
fail_unless (res == TRUE);
fail_unless (cstart == 250);
fail_unless (cstop == 290);
/* partially inside */
res = gst_segment_clip (&segment, GST_FORMAT_BYTES,
250, 350, &cstart, &cstop);
fail_unless (res == TRUE);
fail_unless (cstart == 250);
fail_unless (cstop == 300);
/* invalid start */
res = gst_segment_clip (&segment, GST_FORMAT_BYTES, -1, 100, &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 == 300);
/* start on lower bound */
res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 200, -1, &cstart, &cstop);
fail_unless (res == TRUE);
fail_unless (cstart == 200);
fail_unless (cstop == 300);
/* start inside */
res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 250, -1, &cstart, &cstop);
fail_unless (res == TRUE);
fail_unless (cstart == 250);
fail_unless (cstop == 300);
/* start outside on boundary */
res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 300, -1, &cstart, &cstop);
fail_unless (res == FALSE);
/* start completely outside */
res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 350, -1, &cstart, &cstop);
fail_unless (res == FALSE);
}
GST_END_TEST;
/* mess with the segment structure in the bytes format */
GST_START_TEST (segment_seek_size)
{
GstSegment segment;
gboolean res;
guint64 cstart, cstop;
gboolean update;
gst_segment_init (&segment, GST_FORMAT_BYTES);
segment.duration = 200;
/* configure segment to start 100 */
gst_segment_do_seek (&segment, 1.0,
GST_FORMAT_BYTES,
GST_SEEK_FLAG_NONE,
GST_SEEK_TYPE_SET, 100, GST_SEEK_TYPE_NONE, -1, &update);
fail_unless (segment.start == 100);
2012-07-27 10:24:03 +00:00
fail_unless (segment.position == 100);
fail_unless (segment.stop == -1);
fail_unless (update == TRUE);
2012-07-27 10:24:03 +00:00
check_times (&segment, 100, 100, 0);
/* do some clipping on the open range */
/* completely outside */
res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 0, 50, &cstart, &cstop);
fail_unless (res == FALSE);
/* touching lower bound */
res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 50, 100, &cstart, &cstop);
fail_unless (res == FALSE);
/* partially inside */
res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 50, 150, &cstart, &cstop);
fail_unless (res == TRUE);
fail_unless (cstart == 100);
fail_unless (cstop == 150);
/* inside, touching lower bound */
res = gst_segment_clip (&segment, GST_FORMAT_BYTES,
100, 150, &cstart, &cstop);
fail_unless (res == TRUE);
fail_unless (cstart == 100);
fail_unless (cstop == 150);
/* completely inside */
res = gst_segment_clip (&segment, GST_FORMAT_BYTES,
150, 200, &cstart, &cstop);
fail_unless (res == TRUE);
fail_unless (cstart == 150);
fail_unless (cstop == 200);
/* invalid start */
res = gst_segment_clip (&segment, GST_FORMAT_BYTES, -1, 100, &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 == 100);
fail_unless (cstop == -1);
/* start on lower bound */
res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 100, -1, &cstart, &cstop);
fail_unless (res == TRUE);
fail_unless (cstart == 100);
fail_unless (cstop == -1);
/* start inside */
res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 150, -1, &cstart, &cstop);
fail_unless (res == TRUE);
fail_unless (cstart == 150);
fail_unless (cstop == -1);
/* add 100 to start, set stop to 300, stop clips to 200 */
gst_segment_do_seek (&segment, 1.0,
GST_FORMAT_BYTES,
GST_SEEK_FLAG_NONE,
2011-10-28 14:08:37 +00:00
GST_SEEK_TYPE_SET, 100 + 100, GST_SEEK_TYPE_SET, 300, &update);
fail_unless (segment.start == 200);
2012-07-27 10:24:03 +00:00
fail_unless (segment.position == 200);
fail_unless (segment.stop == 200);
2012-07-27 10:24:03 +00:00
check_times (&segment, 200, 200, 0);
/* add 100 to start (to 300), set stop to 200, this clips start
* to duration */
gst_segment_do_seek (&segment, 1.0,
GST_FORMAT_BYTES,
GST_SEEK_FLAG_NONE,
2011-10-28 14:08:37 +00:00
GST_SEEK_TYPE_SET, 200 + 100, GST_SEEK_TYPE_SET, 200, &update);
fail_unless (segment.start == 200);
2012-07-27 10:24:03 +00:00
fail_unless (segment.position == 200);
fail_unless (segment.stop == 200);
fail_unless (update == FALSE);
2012-07-27 10:24:03 +00:00
check_times (&segment, 200, 200, 0);
/* seek relative to end */
gst_segment_do_seek (&segment, 1.0,
GST_FORMAT_BYTES,
GST_SEEK_FLAG_NONE,
GST_SEEK_TYPE_END, -100, GST_SEEK_TYPE_END, -20, &update);
fail_unless (segment.start == 100);
2012-07-27 10:24:03 +00:00
fail_unless (segment.position == 100);
fail_unless (segment.stop == 180);
fail_unless (update == TRUE);
2012-07-27 10:24:03 +00:00
check_times (&segment, 150, 150, 50);
/* completely outside */
res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 0, 50, &cstart, &cstop);
fail_unless (res == FALSE);
/* touching lower bound */
res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 50, 100, &cstart, &cstop);
fail_unless (res == FALSE);
/* partially inside */
res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 50, 150, &cstart, &cstop);
fail_unless (res == TRUE);
fail_unless (cstart == 100);
fail_unless (cstop == 150);
/* inside, touching lower bound */
res = gst_segment_clip (&segment, GST_FORMAT_BYTES,
100, 150, &cstart, &cstop);
fail_unless (res == TRUE);
fail_unless (cstart == 100);
fail_unless (cstop == 150);
/* completely inside */
res = gst_segment_clip (&segment, GST_FORMAT_BYTES,
150, 170, &cstart, &cstop);
fail_unless (res == TRUE);
fail_unless (cstart == 150);
fail_unless (cstop == 170);
/* partially inside */
res = gst_segment_clip (&segment, GST_FORMAT_BYTES,
150, 250, &cstart, &cstop);
fail_unless (res == TRUE);
fail_unless (cstart == 150);
fail_unless (cstop == 180);
/* invalid start */
res = gst_segment_clip (&segment, GST_FORMAT_BYTES, -1, 100, &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 == 100);
fail_unless (cstop == 180);
/* start on lower bound */
res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 100, -1, &cstart, &cstop);
fail_unless (res == TRUE);
fail_unless (cstart == 100);
fail_unless (cstop == 180);
/* start inside */
res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 150, -1, &cstart, &cstop);
fail_unless (res == TRUE);
fail_unless (cstart == 150);
fail_unless (cstop == 180);
/* start outside on boundary */
res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 180, -1, &cstart, &cstop);
fail_unless (res == FALSE);
/* start completely outside */
res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 250, -1, &cstart, &cstop);
fail_unless (res == FALSE);
}
GST_END_TEST;
GST_START_TEST (segment_seek_reverse)
{
GstSegment segment;
gboolean update;
gst_segment_init (&segment, GST_FORMAT_BYTES);
segment.duration = 200;
/* configure segment to stop 100 */
gst_segment_do_seek (&segment, -1.0,
GST_FORMAT_BYTES,
GST_SEEK_FLAG_NONE,
GST_SEEK_TYPE_SET, 0, GST_SEEK_TYPE_SET, 100, &update);
fail_unless (segment.start == 0);
fail_unless (segment.stop == 100);
fail_unless (segment.time == 0);
fail_unless (segment.position == 100);
fail_unless (update == TRUE);
2012-07-27 10:24:03 +00:00
check_times (&segment, 100, 100, 0);
check_times (&segment, 50, 50, 50);
check_times (&segment, 0, 0, 100);
/* update */
gst_segment_do_seek (&segment, -1.0,
GST_FORMAT_BYTES,
GST_SEEK_FLAG_NONE,
2011-10-28 14:08:37 +00:00
GST_SEEK_TYPE_SET, 10, GST_SEEK_TYPE_SET, 100 - 20, &update);
fail_unless (segment.start == 10);
fail_unless (segment.stop == 80);
fail_unless (segment.time == 10);
fail_unless (segment.position == 80);
fail_unless (update == TRUE);
2012-07-27 10:24:03 +00:00
check_times (&segment, 80, 80, 0);
check_times (&segment, 40, 40, 40);
check_times (&segment, 10, 10, 70);
gst_segment_do_seek (&segment, -1.0,
GST_FORMAT_BYTES,
GST_SEEK_FLAG_NONE,
GST_SEEK_TYPE_SET, 20, GST_SEEK_TYPE_NONE, 0, &update);
fail_unless (segment.start == 20);
fail_unless (segment.stop == 80);
fail_unless (segment.time == 20);
fail_unless (segment.position == 80);
fail_unless (update == FALSE);
2012-07-27 10:24:03 +00:00
check_times (&segment, 80, 80, 0);
check_times (&segment, 20, 20, 60);
}
GST_END_TEST;
/* mess with the segment structure in the bytes format */
GST_START_TEST (segment_seek_rate)
{
GstSegment segment;
gboolean update;
gst_segment_init (&segment, GST_FORMAT_BYTES);
/* configure segment to rate 2.0 */
gst_segment_do_seek (&segment, 2.0,
GST_FORMAT_BYTES,
GST_SEEK_FLAG_NONE,
GST_SEEK_TYPE_NONE, -1, GST_SEEK_TYPE_NONE, -1, &update);
fail_unless (segment.format == GST_FORMAT_BYTES);
fail_unless (segment.start == 0);
fail_unless (segment.position == 0);
fail_unless (segment.stop == -1);
fail_unless (segment.rate == 2.0);
fail_unless (update == FALSE);
check_times (&segment, 50, 50, 25);
/* set a real stop position, this must happen in bytes */
gst_segment_do_seek (&segment, 3.0,
GST_FORMAT_BYTES,
GST_SEEK_FLAG_NONE,
GST_SEEK_TYPE_NONE, -1, GST_SEEK_TYPE_SET, 100, &update);
fail_unless (segment.format == GST_FORMAT_BYTES);
fail_unless (segment.start == 0);
fail_unless (segment.stop == 100);
fail_unless (segment.rate == 3.0);
/* no seek should happen, we just updated the stop position in forward
* playback mode.*/
fail_unless (update == FALSE);
check_times (&segment, 60, 60, 20);
/* set some duration, stop -1 END seeks will now work with the
* duration, if the formats match */
segment.duration = 200;
fail_unless (segment.duration == 200);
/* seek to end with 0 should set the stop to the duration */
gst_segment_do_seek (&segment, 2.0,
GST_FORMAT_BYTES, GST_SEEK_FLAG_NONE,
GST_SEEK_TYPE_NONE, -1, GST_SEEK_TYPE_END, 0, &update);
fail_unless (segment.stop == 200);
fail_unless (segment.duration == 200);
/* subtract 100 from the end */
gst_segment_do_seek (&segment, 2.0,
GST_FORMAT_BYTES, GST_SEEK_FLAG_NONE,
GST_SEEK_TYPE_NONE, -1, GST_SEEK_TYPE_END, -100, &update);
fail_unless (segment.stop == 100);
fail_unless (segment.duration == 200);
/* add 100 to the duration, this should be clamped to the duration */
gst_segment_do_seek (&segment, 2.0,
GST_FORMAT_BYTES, GST_SEEK_FLAG_NONE,
GST_SEEK_TYPE_NONE, -1, GST_SEEK_TYPE_END, 100, &update);
fail_unless (segment.stop == 200);
fail_unless (segment.duration == 200);
}
GST_END_TEST;
GST_START_TEST (segment_copy)
{
GstSegment *copy;
GstSegment segment = { 0.0, };
/* this is a boxed type copy function, we support copying NULL */
fail_unless (gst_segment_copy (NULL) == NULL);
gst_segment_init (&segment, GST_FORMAT_TIME);
segment.rate = -1.0;
segment.applied_rate = 1.0;
segment.start = 0;
segment.stop = 200;
segment.time = 0;
copy = gst_segment_copy (&segment);
fail_unless (copy != NULL);
/* we inited the struct on the stack to zeroes, so direct comparison should
* be ok here despite the padding field and regardless of implementation */
fail_unless (memcmp (copy, &segment, sizeof (GstSegment)) == 0);
gst_segment_free (copy);
}
GST_END_TEST;
/* mess with the segment structure in the bytes format */
GST_START_TEST (segment_seek_noupdate)
{
GstSegment segment;
gboolean update;
gst_segment_init (&segment, GST_FORMAT_TIME);
segment.start = 0;
segment.position = 50;
segment.stop = 200;
segment.time = 0;
/* doesn't change anything */
gst_segment_do_seek (&segment, 1.0,
GST_FORMAT_TIME,
GST_SEEK_FLAG_NONE,
GST_SEEK_TYPE_NONE, 0, GST_SEEK_TYPE_NONE, 0, &update);
fail_unless (update == FALSE);
fail_unless (segment.format == GST_FORMAT_TIME);
fail_unless (segment.start == 0);
fail_unless (segment.stop == 200);
fail_unless (segment.time == 0);
fail_unless (segment.position == 50);
fail_unless (segment.base == 50);
fail_unless (segment.offset == 50);
gst_segment_do_seek (&segment, 2.0,
GST_FORMAT_TIME,
GST_SEEK_FLAG_NONE,
GST_SEEK_TYPE_NONE, 0, GST_SEEK_TYPE_NONE, 0, &update);
fail_unless (update == FALSE);
fail_unless (segment.format == GST_FORMAT_TIME);
fail_unless (segment.start == 0);
fail_unless (segment.stop == 200);
fail_unless (segment.time == 0);
fail_unless (segment.position == 50);
fail_unless (segment.base == 50);
fail_unless_equals_int (segment.offset, 50);
gst_segment_do_seek (&segment, 1.0,
GST_FORMAT_TIME,
GST_SEEK_FLAG_FLUSH,
GST_SEEK_TYPE_NONE, 0, GST_SEEK_TYPE_NONE, 0, &update);
fail_unless (update == FALSE);
fail_unless (segment.format == GST_FORMAT_TIME);
fail_unless (segment.start == 0);
fail_unless (segment.stop == 200);
fail_unless (segment.time == 0);
fail_unless (segment.position == 50);
fail_unless (segment.base == 0);
fail_unless (segment.offset == 50);
}
GST_END_TEST;
And correct even more valid sparse warnings. Original commit message from CVS: * gst/gstelementfactory.h: * tests/check/elements/fakesink.c: * tests/check/elements/fakesrc.c: (setup_fakesrc): * tests/check/elements/fdsrc.c: (setup_fdsrc): * tests/check/elements/filesink.c: (setup_filesink): * tests/check/elements/filesrc.c: (setup_filesrc): * tests/check/elements/identity.c: (setup_identity): * tests/check/elements/tee.c: * tests/check/generic/sinks.c: * tests/check/generic/states.c: (setup), (teardown): * tests/check/gst/gst.c: * tests/check/gst/gstabi.c: * tests/check/gst/gstbin.c: * tests/check/gst/gstbus.c: (pull_messages): * tests/check/gst/gstcaps.c: * tests/check/gst/gstelement.c: * tests/check/gst/gstevent.c: * tests/check/gst/gstghostpad.c: * tests/check/gst/gstiterator.c: * tests/check/gst/gstmessage.c: * tests/check/gst/gstminiobject.c: (my_foo_init): * tests/check/gst/gstobject.c: (thread_name_object), (gst_object_suite): * tests/check/gst/gstpad.c: * tests/check/gst/gstplugin.c: * tests/check/gst/gstpoll.c: * tests/check/gst/gstquery.c: * tests/check/gst/gstsegment.c: * tests/check/gst/gststructure.c: * tests/check/gst/gstsystemclock.c: * tests/check/gst/gsttask.c: * tests/check/gst/gstutils.c: * tests/check/gst/gstvalue.c: * tests/check/gst/struct_hppa.h: * tests/check/gst/struct_i386.h: * tests/check/gst/struct_ppc32.h: * tests/check/gst/struct_ppc64.h: * tests/check/gst/struct_x86_64.h: * tests/check/libs/adapter.c: (create_and_fill_adapter): * tests/check/libs/basesrc.c: * tests/check/libs/controller.c: (GST_START_TEST): * tests/check/libs/gdp.c: * tests/check/libs/gstnetclientclock.c: * tests/check/libs/gstnettimeprovider.c: * tests/check/libs/libsabi.c: * tests/check/libs/struct_hppa.h: * tests/check/libs/struct_i386.h: * tests/check/libs/struct_ppc32.h: * tests/check/libs/struct_ppc64.h: * tests/check/libs/struct_x86_64.h: * tests/check/pipelines/cleanup.c: * tests/check/pipelines/simple-launch-lines.c: * tests/check/pipelines/stress.c: And correct even more valid sparse warnings. * win32/common/libgstreamer.def: Add gst_poll_fd_init to the list of symbols.
2008-02-29 13:59:24 +00:00
static Suite *
tests/check/: use the new macro Original commit message from CVS: * tests/check/elements/fakesink.c: * tests/check/elements/fakesrc.c: * tests/check/elements/fdsrc.c: * tests/check/elements/identity.c: * tests/check/generic/sinks.c: (gst_sinks_suite): * tests/check/generic/states.c: * tests/check/gst/gst.c: * tests/check/gst/gstabi.c: * tests/check/gst/gstbin.c: * tests/check/gst/gstbuffer.c: (gst_buffer_suite): * tests/check/gst/gstbus.c: (gst_bus_suite): * tests/check/gst/gstcaps.c: (GST_START_TEST): * tests/check/gst/gstelement.c: * tests/check/gst/gstevent.c: (gst_event_suite): * tests/check/gst/gstghostpad.c: * tests/check/gst/gstiterator.c: (gst_iterator_suite): * tests/check/gst/gstmessage.c: (gst_message_suite): * tests/check/gst/gstminiobject.c: * tests/check/gst/gstobject.c: * tests/check/gst/gstpad.c: * tests/check/gst/gstpipeline.c: * tests/check/gst/gstplugin.c: * tests/check/gst/gstquery.c: (gst_query_suite): * tests/check/gst/gstsegment.c: (gst_segment_suite): * tests/check/gst/gststructure.c: * tests/check/gst/gstsystemclock.c: * tests/check/gst/gsttag.c: * tests/check/gst/gsttask.c: (gst_task_suite): * tests/check/gst/gstutils.c: * tests/check/gst/gstvalue.c: * tests/check/libs/adapter.c: * tests/check/libs/basesrc.c: * tests/check/libs/collectpads.c: * tests/check/libs/controller.c: * tests/check/libs/gdp.c: (gst_dp_suite): * tests/check/libs/gstnetclientclock.c: * tests/check/libs/gstnettimeprovider.c: * tests/check/libs/libsabi.c: (libsabi_suite): * tests/check/libs/typefindhelper.c: * tests/check/pipelines/cleanup.c: * tests/check/pipelines/parse-launch.c: * tests/check/pipelines/simple-launch-lines.c: * tests/check/pipelines/stress.c: (stress_suite): use the new macro
2006-07-01 20:56:56 +00:00
gst_segment_suite (void)
{
Suite *s = suite_create ("GstSegment");
TCase *tc_chain = tcase_create ("segments");
tcase_set_timeout (tc_chain, 20);
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, segment_seek_nosize);
tcase_add_test (tc_chain, segment_seek_size);
tcase_add_test (tc_chain, segment_seek_reverse);
tcase_add_test (tc_chain, segment_seek_rate);
tcase_add_test (tc_chain, segment_copy);
tcase_add_test (tc_chain, segment_seek_noupdate);
docs/design/part-overview.txt: Make upsteam/downstream concepts more clear. Original commit message from CVS: * docs/design/part-overview.txt: Make upsteam/downstream concepts more clear. Give an example of serialized/non-serialized events. * docs/design/part-events.txt: * docs/design/part-streams.txt: Mention applied_rate. * docs/design/part-trickmodes.txt: Mention applied rate, flesh out some more use cases. * gst/gstevent.c: (gst_event_new_new_segment), (gst_event_parse_new_segment), (gst_event_new_new_segment_full), (gst_event_parse_new_segment_full), (gst_event_new_tag), (gst_event_parse_tag), (gst_event_new_buffer_size), (gst_event_parse_buffer_size), (gst_event_new_qos), (gst_event_parse_qos), (gst_event_parse_seek), (gst_event_new_navigation): * gst/gstevent.h: Add applied_rate field to NEWSEGMENT event. API: gst_event_new_new_segment_full() API: gst_event_parse_new_segment_full() * gst/gstsegment.c: (gst_segment_init), (gst_segment_set_seek), (gst_segment_set_newsegment), (gst_segment_set_newsegment_full), (gst_segment_to_stream_time), (gst_segment_to_running_time): * gst/gstsegment.h: Add applied_rate to GstSegment structure. Make calculation of stream_time and running_time more correct wrt rate/applied_rate. Add some more docs. API: GstSegment::applied_rate field API: gst_segment_set_newsegment_full(); * libs/gst/base/gstbasesink.c: (gst_base_sink_configure_segment), (gst_base_sink_get_sync_times), (gst_base_sink_get_position): * libs/gst/base/gstbasetransform.c: (gst_base_transform_sink_eventfunc), (gst_base_transform_handle_buffer): Parse and use applied_rate in the GstSegment field. * tests/check/gst/gstevent.c: (GST_START_TEST): Add check for applied_rate field. * tests/check/gst/gstsegment.c: (GST_START_TEST), (gstsegments_suite): Add more checks for various GstSegment operations.
2006-05-08 09:52:33 +00:00
return s;
}
tests/check/: use the new macro Original commit message from CVS: * tests/check/elements/fakesink.c: * tests/check/elements/fakesrc.c: * tests/check/elements/fdsrc.c: * tests/check/elements/identity.c: * tests/check/generic/sinks.c: (gst_sinks_suite): * tests/check/generic/states.c: * tests/check/gst/gst.c: * tests/check/gst/gstabi.c: * tests/check/gst/gstbin.c: * tests/check/gst/gstbuffer.c: (gst_buffer_suite): * tests/check/gst/gstbus.c: (gst_bus_suite): * tests/check/gst/gstcaps.c: (GST_START_TEST): * tests/check/gst/gstelement.c: * tests/check/gst/gstevent.c: (gst_event_suite): * tests/check/gst/gstghostpad.c: * tests/check/gst/gstiterator.c: (gst_iterator_suite): * tests/check/gst/gstmessage.c: (gst_message_suite): * tests/check/gst/gstminiobject.c: * tests/check/gst/gstobject.c: * tests/check/gst/gstpad.c: * tests/check/gst/gstpipeline.c: * tests/check/gst/gstplugin.c: * tests/check/gst/gstquery.c: (gst_query_suite): * tests/check/gst/gstsegment.c: (gst_segment_suite): * tests/check/gst/gststructure.c: * tests/check/gst/gstsystemclock.c: * tests/check/gst/gsttag.c: * tests/check/gst/gsttask.c: (gst_task_suite): * tests/check/gst/gstutils.c: * tests/check/gst/gstvalue.c: * tests/check/libs/adapter.c: * tests/check/libs/basesrc.c: * tests/check/libs/collectpads.c: * tests/check/libs/controller.c: * tests/check/libs/gdp.c: (gst_dp_suite): * tests/check/libs/gstnetclientclock.c: * tests/check/libs/gstnettimeprovider.c: * tests/check/libs/libsabi.c: (libsabi_suite): * tests/check/libs/typefindhelper.c: * tests/check/pipelines/cleanup.c: * tests/check/pipelines/parse-launch.c: * tests/check/pipelines/simple-launch-lines.c: * tests/check/pipelines/stress.c: (stress_suite): use the new macro
2006-07-01 20:56:56 +00:00
GST_CHECK_MAIN (gst_segment);