validate: scenario: Allow scenario to define the pipeline state target

Some user might want to start executing actions from the start.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4164>
This commit is contained in:
Thibault Saunier 2023-03-13 11:37:45 -03:00 committed by GStreamer Marge Bot
parent ac6a457614
commit 734263617b

View file

@ -4415,7 +4415,8 @@ handle_bus_message (MessageData * d)
gst_validate_action_set_done (priv->actions->data); gst_validate_action_set_done (priv->actions->data);
} }
if (old_state == GST_STATE_READY && state == GST_STATE_PAUSED) if (old_state == scenario->priv->target_state - 1
&& state == scenario->priv->target_state)
_add_execute_actions_gsource (scenario); _add_execute_actions_gsource (scenario);
/* GstBin only send a new latency message when reaching PLAYING if /* GstBin only send a new latency message when reaching PLAYING if
@ -4702,14 +4703,17 @@ gst_validate_scenario_load_structures (GstValidateScenario * scenario,
gst_structure_get_boolean (structure, "is-config", is_config); gst_structure_get_boolean (structure, "is-config", is_config);
gst_structure_get_boolean (structure, "handles-states", gst_structure_get_boolean (structure, "handles-states",
&priv->handles_state); &priv->handles_state);
if (!gst_structure_get_enum (structure, "target-state", GST_TYPE_STATE,
(gint *) & priv->target_state) && !priv->handles_state) {
priv->target_state = GST_STATE_PLAYING;
}
gst_structure_get_boolean (structure, "ignore-eos", &priv->ignore_eos); gst_structure_get_boolean (structure, "ignore-eos", &priv->ignore_eos);
gst_structure_get_boolean (structure, "allow-errors", gst_structure_get_boolean (structure, "allow-errors",
&priv->allow_errors); &priv->allow_errors);
gst_structure_get_boolean (structure, "actions-on-idle", gst_structure_get_boolean (structure, "actions-on-idle",
&priv->execute_on_idle); &priv->execute_on_idle);
if (!priv->handles_state)
priv->target_state = GST_STATE_PLAYING;
pipeline_name = gst_structure_get_string (structure, "pipeline-name"); pipeline_name = gst_structure_get_string (structure, "pipeline-name");
if (pipeline_name) { if (pipeline_name) {
@ -5375,6 +5379,10 @@ gst_validate_scenario_new (GstValidateRunner *
GST_INFO_OBJECT (scenario, "Scenario handles state." GST_INFO_OBJECT (scenario, "Scenario handles state."
" Starting the get position source"); " Starting the get position source");
_add_execute_actions_gsource (scenario); _add_execute_actions_gsource (scenario);
} else if (scenario->priv->target_state == GST_STATE_NULL) {
GST_INFO_OBJECT (scenario,
"Target state is NULL, starting action execution");
_add_execute_actions_gsource (scenario);
} }
scenario->priv->overrides = scenario->priv->overrides =