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
This commit is contained in:
Wim Taymans 2012-07-18 11:17:23 +02:00
parent 8e946d5d16
commit 5360ba56f7
3 changed files with 27 additions and 11 deletions

View file

@ -101,8 +101,10 @@ The step event is created with the following fields in the structure:
The format of the step units The format of the step units
"amount", G_TYPE_UINT64 "amount", G_TYPE_UINT64
The amount of units to step. -1 resumes normal non-stepping behaviour to The amount of units to step. A 0 amount immediately completes and can be
the end of the segment. 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 "rate", G_TYPE_DOUBLE
The rate at which the frames should be stepped in PLAYING mode. 1.0 is The rate at which the frames should be stepped in PLAYING mode. 1.0 is

View file

@ -440,8 +440,7 @@ gst_segment_to_stream_time (const GstSegment * segment, GstFormat format,
* @position: the position in the segment * @position: the position in the segment
* *
* Translate @position to the total running time using the currently configured * Translate @position to the total running time using the currently configured
* and previously accumulated segments. Position is a value between @segment * segment. Position is a value between @segment start and stop time.
* start and stop time.
* *
* This function is typically used by elements that need to synchronize to the * 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 * global clock in a pipeline. The runnning time is a constantly increasing value

View file

@ -1496,16 +1496,30 @@ start_stepping (GstBaseSink * sink, GstSegment * segment,
current->start_start = segment->start; current->start_start = segment->start;
if (current->format == GST_FORMAT_TIME) { if (current->format == GST_FORMAT_TIME) {
/* calculate the running-time when the step operation should stop */
if (current->amount != -1)
end = current->start + current->amount; end = current->start + current->amount;
else
end = -1;
if (!current->flush) { if (!current->flush) {
/* 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; gint64 position;
/* update the segment clipping regions for non-flushing seeks */
if (segment->rate > 0.0) {
if (end != -1)
position = gst_segment_to_position (segment, GST_FORMAT_TIME, end); 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;
segment->time = position; segment->time = position;
segment->start = position; segment->start = position;
segment->position = position; segment->position = position;
@ -1590,8 +1604,9 @@ handle_stepping (GstBaseSink * sink, GstSegment * segment,
{ {
gboolean step_end = FALSE; gboolean step_end = FALSE;
/* stepping never stops */
if (current->amount == -1) if (current->amount == -1)
return TRUE; return FALSE;
/* see if we need to skip this buffer because of stepping */ /* see if we need to skip this buffer because of stepping */
switch (current->format) { switch (current->format) {