From 75d30ae2d36b2cac25a52a7fd4dd8f17fe2501cb Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Fri, 24 Apr 2020 23:33:16 -0400 Subject: [PATCH] validate: Add a check-position action type Part-of: --- validate/gst/validate/gst-validate-scenario.c | 47 +++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/validate/gst/validate/gst-validate-scenario.c b/validate/gst/validate/gst-validate-scenario.c index 0e0dba2..c6a64bb 100644 --- a/validate/gst/validate/gst-validate-scenario.c +++ b/validate/gst/validate/gst-validate-scenario.c @@ -2611,6 +2611,43 @@ _find_elements_defined_in_action (GstValidateScenario * scenario, } static GstValidateExecuteActionReturn +_execute_check_position (GstValidateScenario * scenario, + GstValidateAction * action) +{ + GstClockTime expected_pos, pos; + + if (!gst_validate_action_get_clocktime (scenario, action, + "expected-position", &expected_pos)) { + GST_VALIDATE_REPORT_ACTION (scenario, action, + SCENARIO_ACTION_EXECUTION_ERROR, + "Could not retrieve expected position in: %" GST_PTR_FORMAT, + action->structure); + + return GST_VALIDATE_EXECUTE_ACTION_ERROR_REPORTED; + } + + if (!_get_position (scenario, NULL, &pos)) { + GST_VALIDATE_REPORT_ACTION (scenario, action, + SCENARIO_ACTION_EXECUTION_ERROR, "Could not get pipeline position"); + + return GST_VALIDATE_EXECUTE_ACTION_ERROR_REPORTED; + } + + if (pos != expected_pos) { + GST_VALIDATE_REPORT_ACTION (scenario, action, + SCENARIO_ACTION_EXECUTION_ERROR, + "Pipeline position doesn't match expectations" + " got %" GST_TIME_FORMAT " instead of %" GST_TIME_FORMAT, + GST_TIME_ARGS (pos), GST_TIME_ARGS (expected_pos)); + + return GST_VALIDATE_EXECUTE_ACTION_ERROR_REPORTED; + } + + return GST_VALIDATE_EXECUTE_ACTION_OK; + +} + +static GstValidateExecuteActionReturn _execute_set_or_check_property (GstValidateScenario * scenario, GstValidateAction * action) { @@ -6020,6 +6057,16 @@ register_action_types (void) {NULL} }), "Request a video key unit", FALSE); + + REGISTER_ACTION_TYPE("check-position", _execute_check_position, + ((GstValidateActionParameter[]) { + { .name = "expected-position", + .description = "The expected pipeline position", + .mandatory = TRUE, + .types = "GstClockTime", + NULL }, + }), + "Check current pipeline position.\n", GST_VALIDATE_ACTION_TYPE_NONE); /* *INDENT-ON* */ } -- 2.7.4