2005-11-20 19:11:09 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2005 Jan Schmidt <thaytan@mad.scientist.com>
|
2009-06-04 10:48:51 +00:00
|
|
|
* 2009 Wim Taymans <wim.taymans@gmail.com>
|
2005-11-20 19:11:09 +00:00
|
|
|
*
|
|
|
|
* 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
|
2012-11-03 20:44:48 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2005-11-20 19:11:09 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#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);
|
|
|
|
|
2012-07-27 15:09:45 +00:00
|
|
|
fail_unless_equals_int64 (st, stream_time);
|
|
|
|
fail_unless_equals_int64 (rt, running_time);
|
2012-07-27 10:24:03 +00:00
|
|
|
}
|
|
|
|
|
2005-11-20 19:11:09 +00:00
|
|
|
/* mess with the segment structure in the bytes format */
|
|
|
|
GST_START_TEST (segment_seek_nosize)
|
|
|
|
{
|
|
|
|
GstSegment segment;
|
|
|
|
gboolean res;
|
2011-05-13 16:07:24 +00:00
|
|
|
guint64 cstart, cstop;
|
More segment updates, replace code in plugins with segment helper functions.
Original commit message from CVS:
* check/gst/gstsegment.c: (GST_START_TEST):
* docs/design/part-TODO.txt:
* gst/base/gstbasesink.c: (gst_base_sink_handle_object),
(gst_base_sink_event), (gst_base_sink_do_sync),
(gst_base_sink_activate_pull), (gst_base_sink_get_position),
(gst_base_sink_query), (gst_base_sink_change_state):
* gst/base/gstbasesink.h:
* gst/base/gstbasesrc.c: (gst_base_src_init), (gst_base_src_query),
(gst_base_src_default_newsegment),
(gst_base_src_configure_segment), (gst_base_src_do_seek),
(gst_base_src_get_range), (gst_base_src_loop),
(gst_base_src_change_state):
* gst/base/gstbasesrc.h:
* gst/base/gstbasetransform.c:
(gst_base_transform_prepare_output_buf),
(gst_base_transform_event), (gst_base_transform_change_state):
* gst/base/gstbasetransform.h:
* gst/base/gstcollectpads.c: (gst_collect_pads_add_pad),
(gst_collect_pads_event):
* gst/base/gstcollectpads.h:
* gst/elements/gstfakesrc.c: (gst_fake_src_init),
(gst_fake_src_create):
* gst/elements/gstfakesrc.h:
* gst/elements/gstidentity.c: (gst_identity_transform_ip):
* gst/gstsegment.c: (gst_segment_init), (gst_segment_set_duration),
(gst_segment_set_last_stop), (gst_segment_set_seek),
(gst_segment_set_newsegment), (gst_segment_to_stream_time),
(gst_segment_to_running_time), (gst_segment_clip):
* gst/gstsegment.h:
More segment updates, replace code in plugins with segment
helper functions.
2005-11-21 17:09:45 +00:00
|
|
|
gboolean update;
|
2005-11-20 19:11:09 +00:00
|
|
|
|
|
|
|
gst_segment_init (&segment, GST_FORMAT_BYTES);
|
|
|
|
|
|
|
|
/* configure segment to start 100 */
|
2011-05-13 16:07:24 +00:00
|
|
|
gst_segment_do_seek (&segment, 1.0,
|
2005-11-20 19:11:09 +00:00
|
|
|
GST_FORMAT_BYTES,
|
More segment updates, replace code in plugins with segment helper functions.
Original commit message from CVS:
* check/gst/gstsegment.c: (GST_START_TEST):
* docs/design/part-TODO.txt:
* gst/base/gstbasesink.c: (gst_base_sink_handle_object),
(gst_base_sink_event), (gst_base_sink_do_sync),
(gst_base_sink_activate_pull), (gst_base_sink_get_position),
(gst_base_sink_query), (gst_base_sink_change_state):
* gst/base/gstbasesink.h:
* gst/base/gstbasesrc.c: (gst_base_src_init), (gst_base_src_query),
(gst_base_src_default_newsegment),
(gst_base_src_configure_segment), (gst_base_src_do_seek),
(gst_base_src_get_range), (gst_base_src_loop),
(gst_base_src_change_state):
* gst/base/gstbasesrc.h:
* gst/base/gstbasetransform.c:
(gst_base_transform_prepare_output_buf),
(gst_base_transform_event), (gst_base_transform_change_state):
* gst/base/gstbasetransform.h:
* gst/base/gstcollectpads.c: (gst_collect_pads_add_pad),
(gst_collect_pads_event):
* gst/base/gstcollectpads.h:
* gst/elements/gstfakesrc.c: (gst_fake_src_init),
(gst_fake_src_create):
* gst/elements/gstfakesrc.h:
* gst/elements/gstidentity.c: (gst_identity_transform_ip):
* gst/gstsegment.c: (gst_segment_init), (gst_segment_set_duration),
(gst_segment_set_last_stop), (gst_segment_set_seek),
(gst_segment_set_newsegment), (gst_segment_to_stream_time),
(gst_segment_to_running_time), (gst_segment_clip):
* gst/gstsegment.h:
More segment updates, replace code in plugins with segment
helper functions.
2005-11-21 17:09:45 +00:00
|
|
|
GST_SEEK_FLAG_NONE,
|
|
|
|
GST_SEEK_TYPE_SET, 100, GST_SEEK_TYPE_NONE, -1, &update);
|
2005-11-20 19:11:09 +00:00
|
|
|
fail_unless (segment.start == 100);
|
2012-07-27 10:24:03 +00:00
|
|
|
fail_unless (segment.position == 100);
|
2005-11-20 19:11:09 +00:00
|
|
|
fail_unless (segment.stop == -1);
|
2006-12-19 12:38:00 +00:00
|
|
|
fail_unless (update == TRUE);
|
2012-07-27 10:24:03 +00:00
|
|
|
/* appended after current position 0 */
|
|
|
|
check_times (&segment, 100, 100, 0);
|
2005-11-20 19:11:09 +00:00
|
|
|
|
|
|
|
/* 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 */
|
2005-11-20 19:11:09 +00:00
|
|
|
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);
|
|
|
|
|
2009-08-11 11:21:35 +00:00
|
|
|
/* 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 */
|
2006-09-15 08:43:44 +00:00
|
|
|
res = gst_segment_clip (&segment, GST_FORMAT_BYTES,
|
|
|
|
100, 100, &cstart, &cstop);
|
2009-08-11 11:21:35 +00:00
|
|
|
fail_unless (res == TRUE);
|
|
|
|
fail_unless (cstart == 100);
|
|
|
|
fail_unless (cstop == 100);
|
2009-08-11 11:03:03 +00:00
|
|
|
|
|
|
|
/* special case, 0 duration and inside the segment */
|
|
|
|
res = gst_segment_clip (&segment, GST_FORMAT_BYTES,
|
|
|
|
120, 120, &cstart, &cstop);
|
2006-09-15 08:43:44 +00:00
|
|
|
fail_unless (res == TRUE);
|
2009-08-11 11:03:03 +00:00
|
|
|
fail_unless (cstart == 120);
|
|
|
|
fail_unless (cstop == 120);
|
2006-09-15 08:43:44 +00:00
|
|
|
|
2005-11-20 19:11:09 +00:00
|
|
|
/* 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 */
|
2005-11-20 19:11:09 +00:00
|
|
|
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);
|
|
|
|
|
2005-11-20 19:11:09 +00:00
|
|
|
/* add 100 to start, set stop to 300 */
|
2011-05-13 16:07:24 +00:00
|
|
|
gst_segment_do_seek (&segment, 1.0,
|
2005-11-20 19:11:09 +00:00
|
|
|
GST_FORMAT_BYTES,
|
More segment updates, replace code in plugins with segment helper functions.
Original commit message from CVS:
* check/gst/gstsegment.c: (GST_START_TEST):
* docs/design/part-TODO.txt:
* gst/base/gstbasesink.c: (gst_base_sink_handle_object),
(gst_base_sink_event), (gst_base_sink_do_sync),
(gst_base_sink_activate_pull), (gst_base_sink_get_position),
(gst_base_sink_query), (gst_base_sink_change_state):
* gst/base/gstbasesink.h:
* gst/base/gstbasesrc.c: (gst_base_src_init), (gst_base_src_query),
(gst_base_src_default_newsegment),
(gst_base_src_configure_segment), (gst_base_src_do_seek),
(gst_base_src_get_range), (gst_base_src_loop),
(gst_base_src_change_state):
* gst/base/gstbasesrc.h:
* gst/base/gstbasetransform.c:
(gst_base_transform_prepare_output_buf),
(gst_base_transform_event), (gst_base_transform_change_state):
* gst/base/gstbasetransform.h:
* gst/base/gstcollectpads.c: (gst_collect_pads_add_pad),
(gst_collect_pads_event):
* gst/base/gstcollectpads.h:
* gst/elements/gstfakesrc.c: (gst_fake_src_init),
(gst_fake_src_create):
* gst/elements/gstfakesrc.h:
* gst/elements/gstidentity.c: (gst_identity_transform_ip):
* gst/gstsegment.c: (gst_segment_init), (gst_segment_set_duration),
(gst_segment_set_last_stop), (gst_segment_set_seek),
(gst_segment_set_newsegment), (gst_segment_to_stream_time),
(gst_segment_to_running_time), (gst_segment_clip):
* gst/gstsegment.h:
More segment updates, replace code in plugins with segment
helper functions.
2005-11-21 17:09:45 +00:00
|
|
|
GST_SEEK_FLAG_NONE,
|
2011-10-28 14:08:37 +00:00
|
|
|
GST_SEEK_TYPE_SET, 100 + 100, GST_SEEK_TYPE_SET, 300, &update);
|
2005-11-20 19:11:09 +00:00
|
|
|
fail_unless (segment.start == 200);
|
2012-07-27 10:24:03 +00:00
|
|
|
fail_unless (segment.position == 200);
|
2005-11-20 19:11:09 +00:00
|
|
|
fail_unless (segment.stop == 300);
|
2012-07-27 15:09:45 +00:00
|
|
|
fail_unless (segment.base == 50);
|
2006-12-19 12:38:00 +00:00
|
|
|
fail_unless (update == TRUE);
|
2012-07-27 10:24:03 +00:00
|
|
|
check_times (&segment, 200, 200, 50);
|
2012-07-27 15:09:45 +00:00
|
|
|
check_times (&segment, 250, 250, 100);
|
2005-11-20 19:11:09 +00:00
|
|
|
|
2006-12-19 12:38:00 +00:00
|
|
|
update = FALSE;
|
2011-05-13 16:07:24 +00:00
|
|
|
/* 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. */
|
2011-05-13 16:07:24 +00:00
|
|
|
ASSERT_CRITICAL (gst_segment_do_seek (&segment, 1.0,
|
2005-11-20 19:11:09 +00:00
|
|
|
GST_FORMAT_BYTES,
|
More segment updates, replace code in plugins with segment helper functions.
Original commit message from CVS:
* check/gst/gstsegment.c: (GST_START_TEST):
* docs/design/part-TODO.txt:
* gst/base/gstbasesink.c: (gst_base_sink_handle_object),
(gst_base_sink_event), (gst_base_sink_do_sync),
(gst_base_sink_activate_pull), (gst_base_sink_get_position),
(gst_base_sink_query), (gst_base_sink_change_state):
* gst/base/gstbasesink.h:
* gst/base/gstbasesrc.c: (gst_base_src_init), (gst_base_src_query),
(gst_base_src_default_newsegment),
(gst_base_src_configure_segment), (gst_base_src_do_seek),
(gst_base_src_get_range), (gst_base_src_loop),
(gst_base_src_change_state):
* gst/base/gstbasesrc.h:
* gst/base/gstbasetransform.c:
(gst_base_transform_prepare_output_buf),
(gst_base_transform_event), (gst_base_transform_change_state):
* gst/base/gstbasetransform.h:
* gst/base/gstcollectpads.c: (gst_collect_pads_add_pad),
(gst_collect_pads_event):
* gst/base/gstcollectpads.h:
* gst/elements/gstfakesrc.c: (gst_fake_src_init),
(gst_fake_src_create):
* gst/elements/gstfakesrc.h:
* gst/elements/gstidentity.c: (gst_identity_transform_ip):
* gst/gstsegment.c: (gst_segment_init), (gst_segment_set_duration),
(gst_segment_set_last_stop), (gst_segment_set_seek),
(gst_segment_set_newsegment), (gst_segment_to_stream_time),
(gst_segment_to_running_time), (gst_segment_clip):
* gst/gstsegment.h:
More segment updates, replace code in plugins with segment
helper functions.
2005-11-21 17:09:45 +00:00
|
|
|
GST_SEEK_FLAG_NONE,
|
2011-10-28 14:08:37 +00:00
|
|
|
GST_SEEK_TYPE_SET, 200 + 100, GST_SEEK_TYPE_SET, 200, &update));
|
2005-11-20 19:11:09 +00:00
|
|
|
fail_unless (segment.start == 200);
|
2012-07-27 10:24:03 +00:00
|
|
|
fail_unless (segment.position == 200);
|
2005-11-20 19:11:09 +00:00
|
|
|
fail_unless (segment.stop == 300);
|
2012-07-27 15:09:45 +00:00
|
|
|
fail_unless (segment.base == 50);
|
2006-12-19 12:38:00 +00:00
|
|
|
/* update didn't change */
|
|
|
|
fail_unless (update == FALSE);
|
2012-07-27 15:09:45 +00:00
|
|
|
check_times (&segment, 200, 200, 50);
|
2012-07-27 10:24:03 +00:00
|
|
|
check_times (&segment, 250, 250, 100);
|
2005-11-20 19:11:09 +00:00
|
|
|
|
2006-12-19 12:38:00 +00:00
|
|
|
update = TRUE;
|
2005-11-20 19:11:09 +00:00
|
|
|
/* seek relative to end, should not do anything since size is
|
|
|
|
* unknown. */
|
2011-05-13 16:07:24 +00:00
|
|
|
gst_segment_do_seek (&segment, 1.0,
|
2005-11-20 19:11:09 +00:00
|
|
|
GST_FORMAT_BYTES,
|
More segment updates, replace code in plugins with segment helper functions.
Original commit message from CVS:
* check/gst/gstsegment.c: (GST_START_TEST):
* docs/design/part-TODO.txt:
* gst/base/gstbasesink.c: (gst_base_sink_handle_object),
(gst_base_sink_event), (gst_base_sink_do_sync),
(gst_base_sink_activate_pull), (gst_base_sink_get_position),
(gst_base_sink_query), (gst_base_sink_change_state):
* gst/base/gstbasesink.h:
* gst/base/gstbasesrc.c: (gst_base_src_init), (gst_base_src_query),
(gst_base_src_default_newsegment),
(gst_base_src_configure_segment), (gst_base_src_do_seek),
(gst_base_src_get_range), (gst_base_src_loop),
(gst_base_src_change_state):
* gst/base/gstbasesrc.h:
* gst/base/gstbasetransform.c:
(gst_base_transform_prepare_output_buf),
(gst_base_transform_event), (gst_base_transform_change_state):
* gst/base/gstbasetransform.h:
* gst/base/gstcollectpads.c: (gst_collect_pads_add_pad),
(gst_collect_pads_event):
* gst/base/gstcollectpads.h:
* gst/elements/gstfakesrc.c: (gst_fake_src_init),
(gst_fake_src_create):
* gst/elements/gstfakesrc.h:
* gst/elements/gstidentity.c: (gst_identity_transform_ip):
* gst/gstsegment.c: (gst_segment_init), (gst_segment_set_duration),
(gst_segment_set_last_stop), (gst_segment_set_seek),
(gst_segment_set_newsegment), (gst_segment_to_stream_time),
(gst_segment_to_running_time), (gst_segment_clip):
* gst/gstsegment.h:
More segment updates, replace code in plugins with segment
helper functions.
2005-11-21 17:09:45 +00:00
|
|
|
GST_SEEK_FLAG_NONE,
|
|
|
|
GST_SEEK_TYPE_END, -300, GST_SEEK_TYPE_END, -100, &update);
|
2005-11-20 19:11:09 +00:00
|
|
|
fail_unless (segment.start == 200);
|
2012-07-27 10:24:03 +00:00
|
|
|
fail_unless (segment.position == 200);
|
2005-11-20 19:11:09 +00:00
|
|
|
fail_unless (segment.stop == 300);
|
2012-07-27 15:09:45 +00:00
|
|
|
fail_unless (segment.base == 50);
|
2006-12-19 12:38:00 +00:00
|
|
|
fail_unless (update == FALSE);
|
2012-07-27 10:24:03 +00:00
|
|
|
check_times (&segment, 250, 250, 100);
|
2005-11-20 19:11:09 +00:00
|
|
|
|
|
|
|
/* 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;
|
2011-05-13 16:07:24 +00:00
|
|
|
guint64 cstart, cstop;
|
More segment updates, replace code in plugins with segment helper functions.
Original commit message from CVS:
* check/gst/gstsegment.c: (GST_START_TEST):
* docs/design/part-TODO.txt:
* gst/base/gstbasesink.c: (gst_base_sink_handle_object),
(gst_base_sink_event), (gst_base_sink_do_sync),
(gst_base_sink_activate_pull), (gst_base_sink_get_position),
(gst_base_sink_query), (gst_base_sink_change_state):
* gst/base/gstbasesink.h:
* gst/base/gstbasesrc.c: (gst_base_src_init), (gst_base_src_query),
(gst_base_src_default_newsegment),
(gst_base_src_configure_segment), (gst_base_src_do_seek),
(gst_base_src_get_range), (gst_base_src_loop),
(gst_base_src_change_state):
* gst/base/gstbasesrc.h:
* gst/base/gstbasetransform.c:
(gst_base_transform_prepare_output_buf),
(gst_base_transform_event), (gst_base_transform_change_state):
* gst/base/gstbasetransform.h:
* gst/base/gstcollectpads.c: (gst_collect_pads_add_pad),
(gst_collect_pads_event):
* gst/base/gstcollectpads.h:
* gst/elements/gstfakesrc.c: (gst_fake_src_init),
(gst_fake_src_create):
* gst/elements/gstfakesrc.h:
* gst/elements/gstidentity.c: (gst_identity_transform_ip):
* gst/gstsegment.c: (gst_segment_init), (gst_segment_set_duration),
(gst_segment_set_last_stop), (gst_segment_set_seek),
(gst_segment_set_newsegment), (gst_segment_to_stream_time),
(gst_segment_to_running_time), (gst_segment_clip):
* gst/gstsegment.h:
More segment updates, replace code in plugins with segment
helper functions.
2005-11-21 17:09:45 +00:00
|
|
|
gboolean update;
|
2005-11-20 19:11:09 +00:00
|
|
|
|
|
|
|
gst_segment_init (&segment, GST_FORMAT_BYTES);
|
2011-05-13 16:07:24 +00:00
|
|
|
segment.duration = 200;
|
2005-11-20 19:11:09 +00:00
|
|
|
|
|
|
|
/* configure segment to start 100 */
|
2011-05-13 16:07:24 +00:00
|
|
|
gst_segment_do_seek (&segment, 1.0,
|
2005-11-20 19:11:09 +00:00
|
|
|
GST_FORMAT_BYTES,
|
More segment updates, replace code in plugins with segment helper functions.
Original commit message from CVS:
* check/gst/gstsegment.c: (GST_START_TEST):
* docs/design/part-TODO.txt:
* gst/base/gstbasesink.c: (gst_base_sink_handle_object),
(gst_base_sink_event), (gst_base_sink_do_sync),
(gst_base_sink_activate_pull), (gst_base_sink_get_position),
(gst_base_sink_query), (gst_base_sink_change_state):
* gst/base/gstbasesink.h:
* gst/base/gstbasesrc.c: (gst_base_src_init), (gst_base_src_query),
(gst_base_src_default_newsegment),
(gst_base_src_configure_segment), (gst_base_src_do_seek),
(gst_base_src_get_range), (gst_base_src_loop),
(gst_base_src_change_state):
* gst/base/gstbasesrc.h:
* gst/base/gstbasetransform.c:
(gst_base_transform_prepare_output_buf),
(gst_base_transform_event), (gst_base_transform_change_state):
* gst/base/gstbasetransform.h:
* gst/base/gstcollectpads.c: (gst_collect_pads_add_pad),
(gst_collect_pads_event):
* gst/base/gstcollectpads.h:
* gst/elements/gstfakesrc.c: (gst_fake_src_init),
(gst_fake_src_create):
* gst/elements/gstfakesrc.h:
* gst/elements/gstidentity.c: (gst_identity_transform_ip):
* gst/gstsegment.c: (gst_segment_init), (gst_segment_set_duration),
(gst_segment_set_last_stop), (gst_segment_set_seek),
(gst_segment_set_newsegment), (gst_segment_to_stream_time),
(gst_segment_to_running_time), (gst_segment_clip):
* gst/gstsegment.h:
More segment updates, replace code in plugins with segment
helper functions.
2005-11-21 17:09:45 +00:00
|
|
|
GST_SEEK_FLAG_NONE,
|
|
|
|
GST_SEEK_TYPE_SET, 100, GST_SEEK_TYPE_NONE, -1, &update);
|
2005-11-20 19:11:09 +00:00
|
|
|
fail_unless (segment.start == 100);
|
2012-07-27 10:24:03 +00:00
|
|
|
fail_unless (segment.position == 100);
|
2005-11-20 19:11:09 +00:00
|
|
|
fail_unless (segment.stop == -1);
|
2006-12-19 12:38:00 +00:00
|
|
|
fail_unless (update == TRUE);
|
2012-07-27 10:24:03 +00:00
|
|
|
check_times (&segment, 100, 100, 0);
|
2005-11-20 19:11:09 +00:00
|
|
|
|
|
|
|
/* 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 */
|
2011-05-13 16:07:24 +00:00
|
|
|
gst_segment_do_seek (&segment, 1.0,
|
2005-11-20 19:11:09 +00:00
|
|
|
GST_FORMAT_BYTES,
|
More segment updates, replace code in plugins with segment helper functions.
Original commit message from CVS:
* check/gst/gstsegment.c: (GST_START_TEST):
* docs/design/part-TODO.txt:
* gst/base/gstbasesink.c: (gst_base_sink_handle_object),
(gst_base_sink_event), (gst_base_sink_do_sync),
(gst_base_sink_activate_pull), (gst_base_sink_get_position),
(gst_base_sink_query), (gst_base_sink_change_state):
* gst/base/gstbasesink.h:
* gst/base/gstbasesrc.c: (gst_base_src_init), (gst_base_src_query),
(gst_base_src_default_newsegment),
(gst_base_src_configure_segment), (gst_base_src_do_seek),
(gst_base_src_get_range), (gst_base_src_loop),
(gst_base_src_change_state):
* gst/base/gstbasesrc.h:
* gst/base/gstbasetransform.c:
(gst_base_transform_prepare_output_buf),
(gst_base_transform_event), (gst_base_transform_change_state):
* gst/base/gstbasetransform.h:
* gst/base/gstcollectpads.c: (gst_collect_pads_add_pad),
(gst_collect_pads_event):
* gst/base/gstcollectpads.h:
* gst/elements/gstfakesrc.c: (gst_fake_src_init),
(gst_fake_src_create):
* gst/elements/gstfakesrc.h:
* gst/elements/gstidentity.c: (gst_identity_transform_ip):
* gst/gstsegment.c: (gst_segment_init), (gst_segment_set_duration),
(gst_segment_set_last_stop), (gst_segment_set_seek),
(gst_segment_set_newsegment), (gst_segment_to_stream_time),
(gst_segment_to_running_time), (gst_segment_clip):
* gst/gstsegment.h:
More segment updates, replace code in plugins with segment
helper functions.
2005-11-21 17:09:45 +00:00
|
|
|
GST_SEEK_FLAG_NONE,
|
2011-10-28 14:08:37 +00:00
|
|
|
GST_SEEK_TYPE_SET, 100 + 100, GST_SEEK_TYPE_SET, 300, &update);
|
2005-11-20 19:11:09 +00:00
|
|
|
fail_unless (segment.start == 200);
|
2012-07-27 10:24:03 +00:00
|
|
|
fail_unless (segment.position == 200);
|
2005-11-20 19:11:09 +00:00
|
|
|
fail_unless (segment.stop == 200);
|
2012-07-27 10:24:03 +00:00
|
|
|
check_times (&segment, 200, 200, 0);
|
2005-11-20 19:11:09 +00:00
|
|
|
|
|
|
|
/* add 100 to start (to 300), set stop to 200, this clips start
|
|
|
|
* to duration */
|
2011-05-13 16:07:24 +00:00
|
|
|
gst_segment_do_seek (&segment, 1.0,
|
2005-11-20 19:11:09 +00:00
|
|
|
GST_FORMAT_BYTES,
|
More segment updates, replace code in plugins with segment helper functions.
Original commit message from CVS:
* check/gst/gstsegment.c: (GST_START_TEST):
* docs/design/part-TODO.txt:
* gst/base/gstbasesink.c: (gst_base_sink_handle_object),
(gst_base_sink_event), (gst_base_sink_do_sync),
(gst_base_sink_activate_pull), (gst_base_sink_get_position),
(gst_base_sink_query), (gst_base_sink_change_state):
* gst/base/gstbasesink.h:
* gst/base/gstbasesrc.c: (gst_base_src_init), (gst_base_src_query),
(gst_base_src_default_newsegment),
(gst_base_src_configure_segment), (gst_base_src_do_seek),
(gst_base_src_get_range), (gst_base_src_loop),
(gst_base_src_change_state):
* gst/base/gstbasesrc.h:
* gst/base/gstbasetransform.c:
(gst_base_transform_prepare_output_buf),
(gst_base_transform_event), (gst_base_transform_change_state):
* gst/base/gstbasetransform.h:
* gst/base/gstcollectpads.c: (gst_collect_pads_add_pad),
(gst_collect_pads_event):
* gst/base/gstcollectpads.h:
* gst/elements/gstfakesrc.c: (gst_fake_src_init),
(gst_fake_src_create):
* gst/elements/gstfakesrc.h:
* gst/elements/gstidentity.c: (gst_identity_transform_ip):
* gst/gstsegment.c: (gst_segment_init), (gst_segment_set_duration),
(gst_segment_set_last_stop), (gst_segment_set_seek),
(gst_segment_set_newsegment), (gst_segment_to_stream_time),
(gst_segment_to_running_time), (gst_segment_clip):
* gst/gstsegment.h:
More segment updates, replace code in plugins with segment
helper functions.
2005-11-21 17:09:45 +00:00
|
|
|
GST_SEEK_FLAG_NONE,
|
2011-10-28 14:08:37 +00:00
|
|
|
GST_SEEK_TYPE_SET, 200 + 100, GST_SEEK_TYPE_SET, 200, &update);
|
2005-11-20 19:11:09 +00:00
|
|
|
fail_unless (segment.start == 200);
|
2012-07-27 10:24:03 +00:00
|
|
|
fail_unless (segment.position == 200);
|
2005-11-20 19:11:09 +00:00
|
|
|
fail_unless (segment.stop == 200);
|
2007-02-13 15:51:00 +00:00
|
|
|
fail_unless (update == FALSE);
|
2012-07-27 10:24:03 +00:00
|
|
|
check_times (&segment, 200, 200, 0);
|
2005-11-20 19:11:09 +00:00
|
|
|
|
|
|
|
/* seek relative to end */
|
2011-05-13 16:07:24 +00:00
|
|
|
gst_segment_do_seek (&segment, 1.0,
|
2005-11-20 19:11:09 +00:00
|
|
|
GST_FORMAT_BYTES,
|
More segment updates, replace code in plugins with segment helper functions.
Original commit message from CVS:
* check/gst/gstsegment.c: (GST_START_TEST):
* docs/design/part-TODO.txt:
* gst/base/gstbasesink.c: (gst_base_sink_handle_object),
(gst_base_sink_event), (gst_base_sink_do_sync),
(gst_base_sink_activate_pull), (gst_base_sink_get_position),
(gst_base_sink_query), (gst_base_sink_change_state):
* gst/base/gstbasesink.h:
* gst/base/gstbasesrc.c: (gst_base_src_init), (gst_base_src_query),
(gst_base_src_default_newsegment),
(gst_base_src_configure_segment), (gst_base_src_do_seek),
(gst_base_src_get_range), (gst_base_src_loop),
(gst_base_src_change_state):
* gst/base/gstbasesrc.h:
* gst/base/gstbasetransform.c:
(gst_base_transform_prepare_output_buf),
(gst_base_transform_event), (gst_base_transform_change_state):
* gst/base/gstbasetransform.h:
* gst/base/gstcollectpads.c: (gst_collect_pads_add_pad),
(gst_collect_pads_event):
* gst/base/gstcollectpads.h:
* gst/elements/gstfakesrc.c: (gst_fake_src_init),
(gst_fake_src_create):
* gst/elements/gstfakesrc.h:
* gst/elements/gstidentity.c: (gst_identity_transform_ip):
* gst/gstsegment.c: (gst_segment_init), (gst_segment_set_duration),
(gst_segment_set_last_stop), (gst_segment_set_seek),
(gst_segment_set_newsegment), (gst_segment_to_stream_time),
(gst_segment_to_running_time), (gst_segment_clip):
* gst/gstsegment.h:
More segment updates, replace code in plugins with segment
helper functions.
2005-11-21 17:09:45 +00:00
|
|
|
GST_SEEK_FLAG_NONE,
|
|
|
|
GST_SEEK_TYPE_END, -100, GST_SEEK_TYPE_END, -20, &update);
|
2005-11-20 19:11:09 +00:00
|
|
|
fail_unless (segment.start == 100);
|
2012-07-27 10:24:03 +00:00
|
|
|
fail_unless (segment.position == 100);
|
2005-11-20 19:11:09 +00:00
|
|
|
fail_unless (segment.stop == 180);
|
2006-12-19 12:38:00 +00:00
|
|
|
fail_unless (update == TRUE);
|
2012-07-27 10:24:03 +00:00
|
|
|
check_times (&segment, 150, 150, 50);
|
2005-11-20 19:11:09 +00:00
|
|
|
|
|
|
|
/* 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;
|
2005-11-21 13:26:51 +00:00
|
|
|
|
2006-10-09 16:33:29 +00:00
|
|
|
GST_START_TEST (segment_seek_reverse)
|
|
|
|
{
|
|
|
|
GstSegment segment;
|
|
|
|
gboolean update;
|
|
|
|
|
|
|
|
gst_segment_init (&segment, GST_FORMAT_BYTES);
|
2011-05-13 16:07:24 +00:00
|
|
|
segment.duration = 200;
|
2006-10-09 16:33:29 +00:00
|
|
|
|
|
|
|
/* configure segment to stop 100 */
|
2011-05-13 16:07:24 +00:00
|
|
|
gst_segment_do_seek (&segment, -1.0,
|
2006-10-09 16:33:29 +00:00
|
|
|
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);
|
2006-10-09 17:15:39 +00:00
|
|
|
fail_unless (segment.time == 0);
|
2011-05-13 16:07:24 +00:00
|
|
|
fail_unless (segment.position == 100);
|
2006-12-19 12:38:00 +00:00
|
|
|
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);
|
2006-10-09 16:33:29 +00:00
|
|
|
|
|
|
|
/* update */
|
2011-05-13 16:07:24 +00:00
|
|
|
gst_segment_do_seek (&segment, -1.0,
|
2006-10-09 16:33:29 +00:00
|
|
|
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);
|
2006-10-09 16:33:29 +00:00
|
|
|
fail_unless (segment.start == 10);
|
|
|
|
fail_unless (segment.stop == 80);
|
2006-10-09 17:15:39 +00:00
|
|
|
fail_unless (segment.time == 10);
|
2011-05-13 16:07:24 +00:00
|
|
|
fail_unless (segment.position == 80);
|
2006-12-19 12:38:00 +00:00
|
|
|
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);
|
2006-10-09 16:33:29 +00:00
|
|
|
|
2011-05-13 16:07:24 +00:00
|
|
|
gst_segment_do_seek (&segment, -1.0,
|
2006-10-09 16:33:29 +00:00
|
|
|
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);
|
2006-10-09 17:15:39 +00:00
|
|
|
fail_unless (segment.time == 20);
|
2011-05-13 16:07:24 +00:00
|
|
|
fail_unless (segment.position == 80);
|
2007-02-13 15:51:00 +00:00
|
|
|
fail_unless (update == FALSE);
|
2012-07-27 10:24:03 +00:00
|
|
|
check_times (&segment, 80, 80, 0);
|
|
|
|
check_times (&segment, 20, 20, 60);
|
2006-10-09 16:33:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2007-12-19 12:48:18 +00:00
|
|
|
/* 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);
|
|
|
|
|
2011-05-17 15:53:00 +00:00
|
|
|
/* configure segment to rate 2.0 */
|
2011-05-13 16:07:24 +00:00
|
|
|
gst_segment_do_seek (&segment, 2.0,
|
2011-05-17 15:53:00 +00:00
|
|
|
GST_FORMAT_BYTES,
|
2007-12-19 12:48:18 +00:00
|
|
|
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);
|
2012-07-27 15:09:45 +00:00
|
|
|
fail_unless (segment.position == 0);
|
2007-12-19 12:48:18 +00:00
|
|
|
fail_unless (segment.stop == -1);
|
|
|
|
fail_unless (segment.rate == 2.0);
|
|
|
|
fail_unless (update == FALSE);
|
2012-07-27 15:09:45 +00:00
|
|
|
check_times (&segment, 50, 50, 25);
|
2007-12-19 12:48:18 +00:00
|
|
|
|
|
|
|
/* set a real stop position, this must happen in bytes */
|
2011-05-13 16:07:24 +00:00
|
|
|
gst_segment_do_seek (&segment, 3.0,
|
2007-12-19 12:48:18 +00:00
|
|
|
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);
|
2012-07-27 15:09:45 +00:00
|
|
|
check_times (&segment, 60, 60, 20);
|
2007-12-19 12:48:18 +00:00
|
|
|
|
|
|
|
/* set some duration, stop -1 END seeks will now work with the
|
|
|
|
* duration, if the formats match */
|
2011-05-13 16:07:24 +00:00
|
|
|
segment.duration = 200;
|
2007-12-19 12:48:18 +00:00
|
|
|
fail_unless (segment.duration == 200);
|
|
|
|
|
2011-05-17 15:53:00 +00:00
|
|
|
/* seek to end with 0 should set the stop to the duration */
|
2011-05-13 16:07:24 +00:00
|
|
|
gst_segment_do_seek (&segment, 2.0,
|
2011-05-17 15:53:00 +00:00
|
|
|
GST_FORMAT_BYTES, GST_SEEK_FLAG_NONE,
|
2007-12-19 12:48:18 +00:00
|
|
|
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 */
|
2011-05-13 16:07:24 +00:00
|
|
|
gst_segment_do_seek (&segment, 2.0,
|
2007-12-19 12:48:18 +00:00
|
|
|
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 */
|
2011-05-13 16:07:24 +00:00
|
|
|
gst_segment_do_seek (&segment, 2.0,
|
2007-12-19 12:48:18 +00:00
|
|
|
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);
|
2007-11-09 11:56:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2008-05-09 20:48:24 +00:00
|
|
|
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);
|
|
|
|
|
2011-05-13 16:07:24 +00:00
|
|
|
segment.rate = -1.0;
|
|
|
|
segment.applied_rate = 1.0;
|
|
|
|
segment.start = 0;
|
|
|
|
segment.stop = 200;
|
|
|
|
segment.time = 0;
|
2008-05-09 20:48:24 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2012-07-27 15:09:45 +00:00
|
|
|
/* 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;
|
|
|
|
|
|
|
|
|
2008-02-29 13:59:24 +00:00
|
|
|
static Suite *
|
2006-07-01 20:56:56 +00:00
|
|
|
gst_segment_suite (void)
|
2005-11-20 19:11:09 +00:00
|
|
|
{
|
|
|
|
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);
|
2006-10-09 16:33:29 +00:00
|
|
|
tcase_add_test (tc_chain, segment_seek_reverse);
|
2007-12-19 12:48:18 +00:00
|
|
|
tcase_add_test (tc_chain, segment_seek_rate);
|
2008-05-09 20:48:24 +00:00
|
|
|
tcase_add_test (tc_chain, segment_copy);
|
2012-07-27 15:09:45 +00:00
|
|
|
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
|
|
|
|
2005-11-20 19:11:09 +00:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2006-07-01 20:56:56 +00:00
|
|
|
GST_CHECK_MAIN (gst_segment);
|