baseparse: reverse playback in pull mode

right now reverse playback is disabled in pull mode.
enabling the code for the same and changing a bit of logic
to make reverse playback work.

https://bugzilla.gnome.org/show_bug.cgi?id=750783
This commit is contained in:
Vineeth TM 2015-07-06 09:26:58 +09:00 committed by Nicolas Dufresne
parent 9d57165c33
commit 274f4b784a

View file

@ -3322,8 +3322,6 @@ gst_base_parse_loop (GstPad * pad)
} }
ret = gst_base_parse_scan_frame (parse, klass); ret = gst_base_parse_scan_frame (parse, klass);
if (ret != GST_FLOW_OK)
goto done;
/* eat expected eos signalling past segment in reverse playback */ /* eat expected eos signalling past segment in reverse playback */
if (parse->segment.rate < 0.0 && ret == GST_FLOW_EOS && if (parse->segment.rate < 0.0 && ret == GST_FLOW_EOS &&
@ -3333,9 +3331,12 @@ gst_base_parse_loop (GstPad * pad)
gst_base_parse_finish_fragment (parse, FALSE); gst_base_parse_finish_fragment (parse, FALSE);
/* force previous fragment */ /* force previous fragment */
parse->priv->offset = -1; parse->priv->offset = -1;
ret = GST_FLOW_OK; goto eos;
} }
if (ret != GST_FLOW_OK)
goto done;
done: done:
if (ret == GST_FLOW_EOS) if (ret == GST_FLOW_EOS)
goto eos; goto eos;
@ -4289,9 +4290,6 @@ gst_base_parse_handle_seek (GstBaseParse * parse, GstEvent * event)
if (rate < 0.0 && parse->priv->pad_mode == GST_PAD_MODE_PUSH) if (rate < 0.0 && parse->priv->pad_mode == GST_PAD_MODE_PUSH)
goto negative_rate; goto negative_rate;
if (rate < 0.0 && parse->priv->pad_mode == GST_PAD_MODE_PULL)
goto negative_rate_pull_mode;
if (start_type != GST_SEEK_TYPE_SET || if (start_type != GST_SEEK_TYPE_SET ||
(stop_type != GST_SEEK_TYPE_SET && stop_type != GST_SEEK_TYPE_NONE)) (stop_type != GST_SEEK_TYPE_SET && stop_type != GST_SEEK_TYPE_NONE))
goto wrong_type; goto wrong_type;
@ -4317,25 +4315,41 @@ gst_base_parse_handle_seek (GstBaseParse * parse, GstEvent * event)
GST_DEBUG_OBJECT (parse, "accurate seek possible"); GST_DEBUG_OBJECT (parse, "accurate seek possible");
accurate = TRUE; accurate = TRUE;
} }
if (accurate) { if (accurate) {
GstClockTime startpos = seeksegment.position; GstClockTime startpos;
if (rate >= 0)
startpos = seeksegment.position;
else
startpos = start;
/* accurate requested, so ... seek a bit before target */ /* accurate requested, so ... seek a bit before target */
if (startpos < parse->priv->lead_in_ts) if (startpos < parse->priv->lead_in_ts)
startpos = 0; startpos = 0;
else else
startpos -= parse->priv->lead_in_ts; startpos -= parse->priv->lead_in_ts;
if (seeksegment.stop == -1)
seeksegment.stop = seeksegment.duration;
seekpos = gst_base_parse_find_offset (parse, startpos, TRUE, &start_ts); seekpos = gst_base_parse_find_offset (parse, startpos, TRUE, &start_ts);
seekstop = gst_base_parse_find_offset (parse, seeksegment.stop, FALSE, seekstop = gst_base_parse_find_offset (parse, seeksegment.stop, FALSE,
NULL); NULL);
seeksegment.start = seeksegment.time = seeksegment.position = start_ts;
} else { } else {
start_ts = seeksegment.position; if (rate >= 0)
if (!gst_base_parse_convert (parse, format, seeksegment.position, start_ts = seeksegment.position;
else
start_ts = start;
if (seeksegment.stop == -1)
seeksegment.stop = seeksegment.duration;
if (!gst_base_parse_convert (parse, format, start_ts,
GST_FORMAT_BYTES, &seekpos)) GST_FORMAT_BYTES, &seekpos))
goto convert_failed; goto convert_failed;
if (!gst_base_parse_convert (parse, format, seeksegment.stop, if (!gst_base_parse_convert (parse, format, seeksegment.stop,
GST_FORMAT_BYTES, &seekstop)) GST_FORMAT_BYTES, &seekstop))
goto convert_failed; goto convert_failed;
} }
GST_DEBUG_OBJECT (parse, GST_DEBUG_OBJECT (parse,
@ -4494,12 +4508,6 @@ done:
return res; return res;
/* ERRORS */ /* ERRORS */
negative_rate_pull_mode:
{
GST_FIXME_OBJECT (parse, "negative playback in pull mode needs fixing");
res = FALSE;
goto done;
}
negative_rate: negative_rate:
{ {
GST_DEBUG_OBJECT (parse, "negative playback rates delegated upstream."); GST_DEBUG_OBJECT (parse, "negative playback rates delegated upstream.");