mpegdemux: Set duration on seeking query if possible

Set duration on seeking query in the same way as duration query handler.
Otherwise application might get confused as if the duration is unknown.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1791>
This commit is contained in:
Seungha Yang 2020-11-11 18:21:25 +09:00 committed by GStreamer Merge Bot
parent 6d300ce785
commit 7cec64499d

View file

@ -1557,10 +1557,14 @@ gst_ps_demux_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
if (demux->random_access) { if (demux->random_access) {
/* In pull mode we can seek in TIME format if we have the SCR */ /* In pull mode we can seek in TIME format if we have the SCR */
if (fmt != GST_FORMAT_TIME || demux->scr_rate_n == G_MAXUINT64 if (fmt != GST_FORMAT_TIME || demux->scr_rate_n == G_MAXUINT64
|| demux->scr_rate_d == G_MAXUINT64) || demux->scr_rate_d == G_MAXUINT64) {
gst_query_set_seeking (query, fmt, FALSE, -1, -1); gst_query_set_seeking (query, fmt, FALSE, -1, -1);
else } else {
gst_query_set_seeking (query, fmt, TRUE, 0, -1); gint64 dur = -1;
if (GST_CLOCK_TIME_IS_VALID (demux->src_segment.duration))
dur = demux->src_segment.duration;
gst_query_set_seeking (query, fmt, TRUE, 0, dur);
}
} else { } else {
if (fmt == GST_FORMAT_BYTES) { if (fmt == GST_FORMAT_BYTES) {
/* Seeking in BYTES format not supported at all */ /* Seeking in BYTES format not supported at all */