mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 01:45:33 +00:00
videotestsrc: implement reverse playback
Decrement the n_frames counter when doing reverse playback to have timestamps and offsets reducing instead of increasing https://bugzilla.gnome.org/show_bug.cgi?id=701813
This commit is contained in:
parent
9269bee9bd
commit
866f132821
2 changed files with 17 additions and 2 deletions
|
@ -813,6 +813,7 @@ gst_video_test_src_do_seek (GstBaseSrc * bsrc, GstSegment * segment)
|
|||
|
||||
segment->time = segment->start;
|
||||
position = segment->position;
|
||||
src->reverse = segment->rate < 0;
|
||||
|
||||
/* now move to the position indicated */
|
||||
if (src->info.fps_n) {
|
||||
|
@ -862,6 +863,11 @@ gst_video_test_src_fill (GstPushSrc * psrc, GstBuffer * buffer)
|
|||
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);
|
||||
|
||||
|
@ -890,12 +896,20 @@ gst_video_test_src_fill (GstPushSrc * psrc, GstBuffer * buffer)
|
|||
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 */
|
||||
|
|
|
@ -139,6 +139,7 @@ struct _GstVideoTestSrc {
|
|||
/* 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 */
|
||||
|
|
Loading…
Reference in a new issue