From fbf478b3f50281803cb1514a69d8e75f602be6c3 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Tue, 12 Dec 2023 10:42:32 -0300 Subject: [PATCH] validate: scenario: Add a way to set pipeline base-time, start-time and force using the system clock Part-of: --- .../docs/gst-validate-test-file.md | 13 +++++++ .../gst/validate/gst-validate-scenario.c | 35 +++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/subprojects/gst-devtools/docs/gst-validate-test-file.md b/subprojects/gst-devtools/docs/gst-validate-test-file.md index c743618583..9e6a5c3625 100644 --- a/subprojects/gst-devtools/docs/gst-validate-test-file.md +++ b/subprojects/gst-devtools/docs/gst-validate-test-file.md @@ -58,6 +58,19 @@ configs = { Note: Since this is GstStructure synthax, we need to have the structures in the array as strings/within quotes. +## `base-time` + +The `base-time` fields lets you set the Pipeline base-time as defined in [gst_element_set_base_time](gst_element_set_base_time). + +## `use-system-clock` + +The `use-system-clock` fields lets you set force the Pipeline to use the +[`GstSystemClock`](GstSystemClock) + +## `start-time` + +The `start-time` fields lets you set the Pipeline start-time as defined in [gst_element_set_start_time](gst_element_set_start_time). + ## expected-issues The `expected-issues` field is an array of `expected-issue` structures containing diff --git a/subprojects/gst-devtools/validate/gst/validate/gst-validate-scenario.c b/subprojects/gst-devtools/validate/gst/validate/gst-validate-scenario.c index 9fc52fdcda..6663e0603c 100644 --- a/subprojects/gst-devtools/validate/gst/validate/gst-validate-scenario.c +++ b/subprojects/gst-devtools/validate/gst/validate/gst-validate-scenario.c @@ -5924,11 +5924,46 @@ gst_validate_scenario_new (GstValidateRunner * GST_OBJECT_NAME (pipeline)); g_weak_ref_init (&scenario->priv->ref_pipeline, pipeline); + + GstClockTime base_time, start_time; + gboolean use_system_clock = FALSE; + + if (gst_validate_utils_get_clocktime (scenario->description, "base-time", + &base_time)) { + gst_validate_printf (NULL, + "**-> Setting %" GST_PTR_FORMAT " base time to %" GST_TIMEP_FORMAT + "**\n", pipeline, &base_time); + gst_element_set_base_time (GST_ELEMENT (pipeline), base_time); + } + + if (gst_validate_utils_get_clocktime (scenario->description, "start-time", + &start_time)) { + gst_validate_printf (NULL, + "**-> Setting %" GST_PTR_FORMAT " start time to %" GST_TIMEP_FORMAT + "**\n", pipeline, &base_time); + gst_element_set_start_time (GST_ELEMENT (pipeline), start_time); + } + + gst_structure_get_boolean (scenario->description, "use-system-clock", + &use_system_clock); if (scenario->priv->clock) { + if (use_system_clock) + gst_validate_abort + ("Requested to use system clock and test clock at the same time"); gst_element_set_clock (pipeline, GST_CLOCK_CAST (scenario->priv->clock)); gst_pipeline_use_clock (GST_PIPELINE (pipeline), GST_CLOCK_CAST (scenario->priv->clock)); } + if (use_system_clock) { + GstClock *system_clock = gst_system_clock_obtain (); + gst_element_set_clock (pipeline, system_clock); + gst_pipeline_use_clock (GST_PIPELINE (pipeline), system_clock); + + gst_validate_printf (NULL, + "**-> Using clock %" GST_PTR_FORMAT " on %" GST_PTR_FORMAT "**\n", + system_clock, pipeline); + } + gst_validate_reporter_set_name (GST_VALIDATE_REPORTER (scenario), g_filename_display_basename (scenario_name));