mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-03 14:08:56 +00:00
gst/rawparse/gstrawparse.c: Add simple reverse playback.
Original commit message from CVS: * gst/rawparse/gstrawparse.c: (gst_raw_parse_push_buffer), (gst_raw_parse_loop), (gst_raw_parse_handle_seek_push), (gst_raw_parse_handle_seek_pull): Add simple reverse playback.
This commit is contained in:
parent
409526e5e7
commit
5e88627e2b
2 changed files with 48 additions and 21 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2008-06-09 Wim Taymans <wim.taymans@collabora.co.uk>
|
||||||
|
|
||||||
|
* gst/rawparse/gstrawparse.c: (gst_raw_parse_push_buffer),
|
||||||
|
(gst_raw_parse_loop), (gst_raw_parse_handle_seek_push),
|
||||||
|
(gst_raw_parse_handle_seek_pull):
|
||||||
|
Add simple reverse playback.
|
||||||
|
|
||||||
2008-06-09 Wim Taymans <wim.taymans@collabora.co.uk>
|
2008-06-09 Wim Taymans <wim.taymans@collabora.co.uk>
|
||||||
|
|
||||||
* gst/rawparse/gstrawparse.c: (gst_raw_parse_reset),
|
* gst/rawparse/gstrawparse.c: (gst_raw_parse_reset),
|
||||||
|
|
|
@ -216,6 +216,11 @@ gst_raw_parse_push_buffer (GstRawParse * rp, GstBuffer * buffer)
|
||||||
|
|
||||||
nframes = GST_BUFFER_SIZE (buffer) / rp->framesize;
|
nframes = GST_BUFFER_SIZE (buffer) / rp->framesize;
|
||||||
|
|
||||||
|
if (rp->segment.rate < 0) {
|
||||||
|
rp->n_frames -= nframes;
|
||||||
|
rp->discont = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
GST_BUFFER_OFFSET (buffer) = rp->n_frames;
|
GST_BUFFER_OFFSET (buffer) = rp->n_frames;
|
||||||
GST_BUFFER_OFFSET_END (buffer) = rp->n_frames + nframes;
|
GST_BUFFER_OFFSET_END (buffer) = rp->n_frames + nframes;
|
||||||
|
|
||||||
|
@ -236,8 +241,10 @@ gst_raw_parse_push_buffer (GstRawParse * rp, GstBuffer * buffer)
|
||||||
rp->discont = FALSE;
|
rp->discont = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
rp->offset += GST_BUFFER_SIZE (buffer);
|
if (rp->segment.rate >= 0) {
|
||||||
rp->n_frames += nframes;
|
rp->offset += GST_BUFFER_SIZE (buffer);
|
||||||
|
rp->n_frames += nframes;
|
||||||
|
}
|
||||||
|
|
||||||
rp->segment.last_stop = GST_BUFFER_TIMESTAMP (buffer);
|
rp->segment.last_stop = GST_BUFFER_TIMESTAMP (buffer);
|
||||||
|
|
||||||
|
@ -324,20 +331,31 @@ gst_raw_parse_loop (GstElement * element)
|
||||||
else
|
else
|
||||||
size = rp->framesize;
|
size = rp->framesize;
|
||||||
|
|
||||||
if (rp->offset + size > rp->upstream_length) {
|
if (rp->segment.rate >= 0) {
|
||||||
GstFormat fmt = GST_FORMAT_BYTES;
|
if (rp->offset + size > rp->upstream_length) {
|
||||||
|
GstFormat fmt = GST_FORMAT_BYTES;
|
||||||
|
|
||||||
if (!gst_pad_query_peer_duration (rp->sinkpad, &fmt, &rp->upstream_length)) {
|
if (!gst_pad_query_peer_duration (rp->sinkpad, &fmt,
|
||||||
GST_WARNING_OBJECT (rp,
|
&rp->upstream_length)) {
|
||||||
"Could not get upstream duration, trying to pull frame by frame");
|
GST_WARNING_OBJECT (rp,
|
||||||
size = rp->framesize;
|
"Could not get upstream duration, trying to pull frame by frame");
|
||||||
} else if (rp->upstream_length < rp->offset + rp->framesize) {
|
size = rp->framesize;
|
||||||
|
} else if (rp->upstream_length < rp->offset + rp->framesize) {
|
||||||
|
ret = GST_FLOW_UNEXPECTED;
|
||||||
|
goto pause;
|
||||||
|
} else if (rp->offset + size > rp->upstream_length) {
|
||||||
|
size = rp->upstream_length - rp->offset;
|
||||||
|
size -= size % rp->framesize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (rp->offset == 0) {
|
||||||
ret = GST_FLOW_UNEXPECTED;
|
ret = GST_FLOW_UNEXPECTED;
|
||||||
goto pause;
|
goto pause;
|
||||||
} else if (rp->offset + size > rp->upstream_length) {
|
} else if (rp->offset < size) {
|
||||||
size = rp->upstream_length - rp->offset;
|
size -= rp->offset;
|
||||||
size -= size % rp->framesize;
|
|
||||||
}
|
}
|
||||||
|
rp->offset -= size;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = gst_pad_pull_range (rp->sinkpad, rp->offset, size, &buffer);
|
ret = gst_pad_pull_range (rp->sinkpad, rp->offset, size, &buffer);
|
||||||
|
@ -666,6 +684,10 @@ gst_raw_parse_handle_seek_push (GstRawParse * rp, GstEvent * event)
|
||||||
gst_event_parse_seek (event, &rate, &format, &flags, &start_type, &start,
|
gst_event_parse_seek (event, &rate, &format, &flags, &start_type, &start,
|
||||||
&stop_type, &stop);
|
&stop_type, &stop);
|
||||||
|
|
||||||
|
/* can't seek backwards yet */
|
||||||
|
if (rate <= 0.0)
|
||||||
|
goto wrong_rate;
|
||||||
|
|
||||||
/* First try if upstream handles the seek */
|
/* First try if upstream handles the seek */
|
||||||
ret = gst_pad_push_event (rp->sinkpad, event);
|
ret = gst_pad_push_event (rp->sinkpad, event);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
@ -695,6 +717,13 @@ gst_raw_parse_handle_seek_push (GstRawParse * rp, GstEvent * event)
|
||||||
"seeking is only supported in TIME or DEFAULT format");
|
"seeking is only supported in TIME or DEFAULT format");
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
/* ERRORS */
|
||||||
|
wrong_rate:
|
||||||
|
{
|
||||||
|
GST_DEBUG_OBJECT (rp, "Seek failed: negative rates not supported yet");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -714,10 +743,6 @@ gst_raw_parse_handle_seek_pull (GstRawParse * rp, GstEvent * event)
|
||||||
gst_event_parse_seek (event, &rate, &format, &flags, &start_type, &start,
|
gst_event_parse_seek (event, &rate, &format, &flags, &start_type, &start,
|
||||||
&stop_type, &stop);
|
&stop_type, &stop);
|
||||||
|
|
||||||
/* can't seek backwards yet */
|
|
||||||
if (rate <= 0.0)
|
|
||||||
goto wrong_rate;
|
|
||||||
|
|
||||||
/* convert input offsets to time */
|
/* convert input offsets to time */
|
||||||
ret = gst_raw_parse_convert (rp, format, start, GST_FORMAT_TIME, &start);
|
ret = gst_raw_parse_convert (rp, format, start, GST_FORMAT_TIME, &start);
|
||||||
ret &= gst_raw_parse_convert (rp, format, stop, GST_FORMAT_TIME, &stop);
|
ret &= gst_raw_parse_convert (rp, format, stop, GST_FORMAT_TIME, &stop);
|
||||||
|
@ -845,11 +870,6 @@ gst_raw_parse_handle_seek_pull (GstRawParse * rp, GstEvent * event)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
/* ERRORS */
|
/* ERRORS */
|
||||||
wrong_rate:
|
|
||||||
{
|
|
||||||
GST_DEBUG_OBJECT (rp, "Seek failed: negative rates not supported yet");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
convert_failed:
|
convert_failed:
|
||||||
{
|
{
|
||||||
GST_DEBUG_OBJECT (rp, "Seek failed: couldn't convert to byte positions");
|
GST_DEBUG_OBJECT (rp, "Seek failed: couldn't convert to byte positions");
|
||||||
|
|
Loading…
Reference in a new issue