validate:scenario: Execute actions without playback time without a valid position

If the user did not specify any playback time we should be able to
execute actions even if the pipeline can't answer the position query

+ Make simpler to read the conditions of an action execution
This commit is contained in:
Thibault Saunier 2014-11-16 23:05:45 +01:00
parent cdfa1ee61b
commit 11c49a7db8

View file

@ -833,6 +833,41 @@ _check_position (GstValidateScenario * scenario, gdouble rate,
}
static gboolean
_should_execute_action (GstValidateScenario * scenario, GstValidateAction * act,
GstClockTime position, gdouble rate)
{
if (!act) {
GST_DEBUG_OBJECT (scenario, "No action to execute");
return FALSE;
} else if (GST_STATE (scenario->pipeline) < GST_STATE_PAUSED) {
GST_DEBUG_OBJECT (scenario, "Pipeline not even in paused, "
"just executing actions");
return TRUE;
} else if (act->playback_time == GST_CLOCK_TIME_NONE) {
GST_DEBUG_OBJECT (scenario, "No timing info, executing action");
return TRUE;
} else if ((rate > 0 && (GstClockTime) position < act->playback_time)) {
GST_DEBUG_OBJECT (scenario, "positive rate and position %" GST_TIME_FORMAT
" < playback_time %" GST_TIME_FORMAT, GST_TIME_ARGS (position),
GST_TIME_ARGS (act->playback_time));
return FALSE;
} else if (rate < 0 && (GstClockTime) position > act->playback_time) {
GST_DEBUG_OBJECT (scenario, "negativ rate and position %" GST_TIME_FORMAT
" < playback_time %" GST_TIME_FORMAT, GST_TIME_ARGS (position),
GST_TIME_ARGS (act->playback_time));
return FALSE;
}
return TRUE;
}
static gboolean
get_position (GstValidateScenario * scenario)
{
@ -842,6 +877,7 @@ get_position (GstValidateScenario * scenario)
GstValidateAction *act = NULL;
gint64 position, duration;
gboolean has_pos, has_dur;
GstValidateActionType *type;
GstValidateScenarioPrivate *priv = scenario->priv;
GstElement *pipeline = scenario->pipeline;
@ -900,8 +936,10 @@ get_position (GstValidateScenario * scenario)
has_dur = gst_element_query_duration (pipeline, GST_FORMAT_TIME, &duration)
&& GST_CLOCK_TIME_IS_VALID (duration);
if (!has_pos && GST_STATE (pipeline) >= GST_STATE_PAUSED) {
GST_LOG ("Unknown position: %" GST_TIME_FORMAT, GST_TIME_ARGS (position));
if (!has_pos && GST_STATE (pipeline) >= GST_STATE_PAUSED &&
act && GST_CLOCK_TIME_IS_VALID (act->playback_time)) {
GST_INFO_OBJECT (scenario, "Unknown position: %" GST_TIME_FORMAT,
GST_TIME_ARGS (position));
return TRUE;
}
@ -916,15 +954,13 @@ get_position (GstValidateScenario * scenario)
}
}
GST_LOG ("Current position: %" GST_TIME_FORMAT, GST_TIME_ARGS (position));
GST_DEBUG_OBJECT (scenario, "Current position: %" GST_TIME_FORMAT,
GST_TIME_ARGS (position));
_check_position (scenario, rate, position);
if (act && (((rate > 0 && (GstClockTime) position >= act->playback_time) ||
(rate < 0 && (GstClockTime) position <= act->playback_time) ||
(act->playback_time == GST_CLOCK_TIME_NONE)) ||
(GST_STATE (pipeline) < GST_STATE_PAUSED))) {
GstValidateActionType *type;
if (!_should_execute_action (scenario, act, position, rate))
return TRUE;
type = _find_action_type (act->type);
@ -959,11 +995,11 @@ get_position (GstValidateScenario * scenario)
} else if (act->state != GST_VALIDATE_EXECUTE_ACTION_ASYNC) {
tmp = priv->actions;
priv->actions = g_list_remove_link (priv->actions, tmp);
GST_ERROR ("NEXT! %p", priv->actions);
gst_mini_object_unref (GST_MINI_OBJECT (act));
g_list_free (tmp);
}
}
return TRUE;
}