From 5360ba56f7fa552865a42ed12845e748663ae6db Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 18 Jul 2012 11:17:23 +0200 Subject: [PATCH] basesink: handle -1 step amounts Define a 0 and -1 step amount. They used to almost do the same thing but now, 0 cancels/stops the current step and -1 keeps on stepping until the end of the segment. See https://bugzilla.gnome.org/show_bug.cgi?id=679378 --- docs/design/part-framestep.txt | 6 ++++-- gst/gstsegment.c | 3 +-- libs/gst/base/gstbasesink.c | 27 +++++++++++++++++++++------ 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/docs/design/part-framestep.txt b/docs/design/part-framestep.txt index 22d8895..7e5ecb8 100644 --- a/docs/design/part-framestep.txt +++ b/docs/design/part-framestep.txt @@ -101,8 +101,10 @@ The step event is created with the following fields in the structure: The format of the step units "amount", G_TYPE_UINT64 - The amount of units to step. -1 resumes normal non-stepping behaviour to - the end of the segment. + The amount of units to step. A 0 amount immediately completes and can be + used to cancel the current step and resume normal non-stepping behaviour + to the end of the segment. + A -1 amount steps until the end of the segment. "rate", G_TYPE_DOUBLE The rate at which the frames should be stepped in PLAYING mode. 1.0 is diff --git a/gst/gstsegment.c b/gst/gstsegment.c index d0f1622..7ae8e60 100644 --- a/gst/gstsegment.c +++ b/gst/gstsegment.c @@ -440,8 +440,7 @@ gst_segment_to_stream_time (const GstSegment * segment, GstFormat format, * @position: the position in the segment * * Translate @position to the total running time using the currently configured - * and previously accumulated segments. Position is a value between @segment - * start and stop time. + * segment. Position is a value between @segment start and stop time. * * This function is typically used by elements that need to synchronize to the * global clock in a pipeline. The runnning time is a constantly increasing value diff --git a/libs/gst/base/gstbasesink.c b/libs/gst/base/gstbasesink.c index 8bced47..a96fa04 100644 --- a/libs/gst/base/gstbasesink.c +++ b/libs/gst/base/gstbasesink.c @@ -1496,16 +1496,30 @@ start_stepping (GstBaseSink * sink, GstSegment * segment, current->start_start = segment->start; if (current->format == GST_FORMAT_TIME) { - end = current->start + current->amount; + /* calculate the running-time when the step operation should stop */ + if (current->amount != -1) + end = current->start + current->amount; + else + end = -1; + if (!current->flush) { + gint64 position; + /* update the segment clipping regions for non-flushing seeks */ if (segment->rate > 0.0) { - segment->stop = gst_segment_to_position (segment, GST_FORMAT_TIME, end); - segment->position = segment->stop; + if (end != -1) + position = gst_segment_to_position (segment, GST_FORMAT_TIME, end); + else + position = segment->stop; + + segment->stop = position; + segment->position = position; } else { - gint64 position; + if (end != -1) + position = gst_segment_to_position (segment, GST_FORMAT_TIME, end); + else + position = segment->start; - position = gst_segment_to_position (segment, GST_FORMAT_TIME, end); segment->time = position; segment->start = position; segment->position = position; @@ -1590,8 +1604,9 @@ handle_stepping (GstBaseSink * sink, GstSegment * segment, { gboolean step_end = FALSE; + /* stepping never stops */ if (current->amount == -1) - return TRUE; + return FALSE; /* see if we need to skip this buffer because of stepping */ switch (current->format) { -- 2.7.4