mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-01 12:02:27 +00:00
validate-scenario: only use valid position/duration
Position/duration query may fail, or yield unknown values (eg, unknown duration for live streams). In these cases, we must ensure we do not use those invalid values. https://bugzilla.gnome.org/show_bug.cgi?id=715160
This commit is contained in:
parent
71cd2a8ce7
commit
4dc3f5171e
1 changed files with 18 additions and 10 deletions
|
@ -649,7 +649,7 @@ get_position (GstValidateScenario * scenario)
|
|||
GstValidateAction *act = NULL;
|
||||
gint64 start_with_tolerance, stop_with_tolerance;
|
||||
gint64 position, duration;
|
||||
GstFormat format = GST_FORMAT_TIME;
|
||||
gboolean has_pos, has_dur;
|
||||
GstValidateScenarioPrivate *priv = scenario->priv;
|
||||
GstElement *pipeline = scenario->pipeline;
|
||||
|
||||
|
@ -671,20 +671,28 @@ get_position (GstValidateScenario * scenario)
|
|||
gst_query_unref (query);
|
||||
if (scenario->priv->actions)
|
||||
act = scenario->priv->actions->data;
|
||||
gst_element_query_position (pipeline, format, &position);
|
||||
|
||||
format = GST_FORMAT_TIME;
|
||||
gst_element_query_duration (pipeline, format, &duration);
|
||||
|
||||
if (position > duration) {
|
||||
GST_VALIDATE_REPORT (scenario,
|
||||
QUERY_POSITION_SUPERIOR_DURATION,
|
||||
"Reported position %" GST_TIME_FORMAT " > reported duration %"
|
||||
GST_TIME_FORMAT, GST_TIME_ARGS (position), GST_TIME_ARGS (duration));
|
||||
has_pos = gst_element_query_position (pipeline, GST_FORMAT_TIME, &position)
|
||||
&& GST_CLOCK_TIME_IS_VALID (position);
|
||||
has_dur = gst_element_query_duration (pipeline, GST_FORMAT_TIME, &duration)
|
||||
&& GST_CLOCK_TIME_IS_VALID (duration);
|
||||
|
||||
if (!has_pos) {
|
||||
GST_LOG ("Unknown position");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (has_pos && has_dur) {
|
||||
if (position > duration) {
|
||||
GST_VALIDATE_REPORT (scenario,
|
||||
QUERY_POSITION_SUPERIOR_DURATION,
|
||||
"Reported position %" GST_TIME_FORMAT " > reported duration %"
|
||||
GST_TIME_FORMAT, GST_TIME_ARGS (position), GST_TIME_ARGS (duration));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
GST_LOG ("Current position: %" GST_TIME_FORMAT, GST_TIME_ARGS (position));
|
||||
|
||||
/* Check if playback is within seek segment */
|
||||
|
|
Loading…
Reference in a new issue