validate: Add a 'check' field to waits to allow running check actions after it get executed

Adding the notion of 'check' action types

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3007>
This commit is contained in:
Thibault Saunier 2022-09-07 15:19:05 -04:00 committed by GStreamer Marge Bot
parent 29aec57ef6
commit 15e76aa7d6
2 changed files with 44 additions and 4 deletions

View file

@ -150,6 +150,9 @@ _fill_action (GstValidateScenario * scenario, GstValidateAction * action,
static gboolean _action_set_done (GstValidateAction * action); static gboolean _action_set_done (GstValidateAction * action);
static GList *_find_elements_defined_in_action (GstValidateScenario * scenario, static GList *_find_elements_defined_in_action (GstValidateScenario * scenario,
GstValidateAction * action); GstValidateAction * action);
static GstValidateAction *gst_validate_create_subaction (GstValidateScenario *
scenario, GstStructure * lvariables, GstValidateAction * action,
GstStructure * nstruct, gint it, gint max);
/* GstValidateSinkInformation tracks information for all sinks in the pipeline */ /* GstValidateSinkInformation tracks information for all sinks in the pipeline */
typedef struct typedef struct
@ -2782,6 +2785,7 @@ stop_waiting_signal (GstStructure * data)
{ {
guint sigid = 0; guint sigid = 0;
GstElement *target; GstElement *target;
GstStructure *check = NULL;
GstValidateAction *action; GstValidateAction *action;
GstValidateScenario *scenario; GstValidateScenario *scenario;
@ -2800,6 +2804,21 @@ stop_waiting_signal (GstStructure * data)
scenario->priv->signal_handler_id = 0; scenario->priv->signal_handler_id = 0;
SCENARIO_UNLOCK (scenario); SCENARIO_UNLOCK (scenario);
if (gst_structure_get (action->structure, "check", GST_TYPE_STRUCTURE,
&check, NULL)) {
GstValidateAction *subact =
gst_validate_create_subaction (scenario, NULL, action,
check, 0, 0);
GstValidateActionType *subact_type = _find_action_type (subact->type);
if (!(subact_type->flags & GST_VALIDATE_ACTION_TYPE_CHECK)) {
gst_validate_error_structure (action,
"`check` action %s is not marked as 'check'", subact->type);
}
gst_validate_execute_action (subact_type, subact);
gst_validate_action_unref (subact);
}
gst_validate_action_set_done (action); gst_validate_action_set_done (action);
gst_validate_action_unref (action); gst_validate_action_unref (action);
_add_execute_actions_gsource (scenario); _add_execute_actions_gsource (scenario);
@ -6832,6 +6851,13 @@ register_action_types (void)
.types = "boolean", .types = "boolean",
NULL NULL
}, },
{
.name = "check",
.description = "The check action to execute when non blocking signal is received",
.mandatory = FALSE,
.types = "structure",
NULL
},
{NULL} {NULL}
}), }),
"Waits for signal 'signal-name', message 'message-type', or during 'duration' seconds", "Waits for signal 'signal-name', message 'message-type', or during 'duration' seconds",
@ -6971,7 +6997,7 @@ register_action_types (void)
"The properties values to check will be defined as:\n\n" "The properties values to check will be defined as:\n\n"
" element-name.padname::property-name\n\n" " element-name.padname::property-name\n\n"
"> NOTE: `.padname` is not needed if checking an element property\n\n", "> NOTE: `.padname` is not needed if checking an element property\n\n",
GST_VALIDATE_ACTION_TYPE_NONE); GST_VALIDATE_ACTION_TYPE_CHECK);
REGISTER_ACTION_TYPE ("set-properties", _execute_set_or_check_properties, REGISTER_ACTION_TYPE ("set-properties", _execute_set_or_check_properties,
((GstValidateActionParameter []) { ((GstValidateActionParameter []) {
@ -7069,7 +7095,7 @@ register_action_types (void)
"Check the value of property of an element or klass of elements in the pipeline.\n" "Check the value of property of an element or klass of elements in the pipeline.\n"
"Besides property-name and value, either 'target-element-name' or\n" "Besides property-name and value, either 'target-element-name' or\n"
"'target-element-klass' needs to be defined", "'target-element-klass' needs to be defined",
GST_VALIDATE_ACTION_TYPE_NONE); GST_VALIDATE_ACTION_TYPE_CHECK);
REGISTER_ACTION_TYPE ("set-debug-threshold", REGISTER_ACTION_TYPE ("set-debug-threshold",
_execute_set_debug_threshold, _execute_set_debug_threshold,
@ -7254,7 +7280,7 @@ register_action_types (void)
" This allows checking the checksum of a buffer after a 'seek' or after a" " This allows checking the checksum of a buffer after a 'seek' or after a"
" GESTimeline 'commit'" " GESTimeline 'commit'"
" for example", " for example",
GST_VALIDATE_ACTION_TYPE_NON_BLOCKING); GST_VALIDATE_ACTION_TYPE_NON_BLOCKING | GST_VALIDATE_ACTION_TYPE_CHECK);
REGISTER_ACTION_TYPE ("crank-clock", _execute_crank_clock, REGISTER_ACTION_TYPE ("crank-clock", _execute_crank_clock,
((GstValidateActionParameter []) { ((GstValidateActionParameter []) {
@ -7368,7 +7394,10 @@ register_action_types (void)
NULL }, NULL },
{NULL} {NULL}
}), }),
"Check current pipeline position.\n", GST_VALIDATE_ACTION_TYPE_NONE); "Check current pipeline position.\n",
/* FIXME: Make MT safe so it can be marked as GST_VALIDATE_ACTION_TYPE_CHECK */
GST_VALIDATE_ACTION_TYPE_NONE);
REGISTER_ACTION_TYPE("run-command", _run_command, REGISTER_ACTION_TYPE("run-command", _run_command,
((GstValidateActionParameter[]) { ((GstValidateActionParameter[]) {

View file

@ -228,6 +228,17 @@ typedef enum
GST_VALIDATE_ACTION_TYPE_CAN_BE_OPTIONAL = 1 << 7, GST_VALIDATE_ACTION_TYPE_CAN_BE_OPTIONAL = 1 << 7,
GST_VALIDATE_ACTION_TYPE_DOESNT_NEED_PIPELINE = 1 << 8, GST_VALIDATE_ACTION_TYPE_DOESNT_NEED_PIPELINE = 1 << 8,
GST_VALIDATE_ACTION_TYPE_HANDLED_IN_CONFIG = 1 << 9, GST_VALIDATE_ACTION_TYPE_HANDLED_IN_CONFIG = 1 << 9,
/**
* GST_VALIDATE_ACTION_TYPE_CHECK:
*
* The action is checking some state from objects in the pipeline. It means that it can
* be used as 'check' in different action which have a `check` "sub action", such as the 'wait' action type.
* This implies that the action can be executed from any thread and not only from the scenario thread as other
* types.
*
* Since: 1.22
*/
GST_VALIDATE_ACTION_TYPE_CHECK = 1 << 10,
} GstValidateActionTypeFlags; } GstValidateActionTypeFlags;
typedef struct _GstValidateActionTypePrivate GstValidateActionTypePrivate; typedef struct _GstValidateActionTypePrivate GstValidateActionTypePrivate;