diff --git a/docs/design/part-framestep.txt b/docs/design/part-framestep.txt index 22d8895362..7e5ecb887f 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 d0f1622308..7ae8e6080a 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 8bced47ab4..a96fa04354 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; - } else { - gint64 position; + if (end != -1) + position = gst_segment_to_position (segment, GST_FORMAT_TIME, end); + else + position = segment->stop; + + segment->stop = position; + segment->position = position; + } else { + 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) {