segment->time = segment->start;
position = segment->position;
+ src->reverse = segment->rate < 0;
/* now move to the position indicated */
if (src->info.fps_n) {
if (G_UNLIKELY (src->info.fps_n == 0 && src->n_frames == 1))
goto eos;
+ if (G_UNLIKELY (src->n_frames == -1)) {
+ /* EOS for reverse playback */
+ goto eos;
+ }
+
GST_LOG_OBJECT (src,
"creating buffer from pool for frame %d", (gint) src->n_frames);
GST_TIME_ARGS (src->timestamp_offset), GST_TIME_ARGS (src->running_time));
GST_BUFFER_OFFSET (buffer) = src->accum_frames + src->n_frames;
- src->n_frames++;
+ if (src->reverse) {
+ src->n_frames--;
+ } else {
+ src->n_frames++;
+ }
GST_BUFFER_OFFSET_END (buffer) = GST_BUFFER_OFFSET (buffer) + 1;
if (src->info.fps_n) {
next_time = gst_util_uint64_scale_int (src->n_frames * GST_SECOND,
src->info.fps_d, src->info.fps_n);
- GST_BUFFER_DURATION (buffer) = next_time - src->running_time;
+ if (src->reverse) {
+ GST_BUFFER_DURATION (buffer) = src->running_time - next_time;
+ } else {
+ GST_BUFFER_DURATION (buffer) = next_time - src->running_time;
+ }
} else {
next_time = src->timestamp_offset;
/* NONE means forever */
/* running time and frames for current caps */
GstClockTime running_time; /* total running time */
gint64 n_frames; /* total frames sent */
+ gboolean reverse;
/* previous caps running time and frames */
GstClockTime accum_rtime; /* accumulated running_time */