validate: allow scenarios to define a max nb of dropped buffers

The 'max-dropped' description field can now be used to specify the max
number of buffers than can be dropped by the QoS system.
This commit is contained in:
Guillaume Desmottes 2019-02-06 18:24:19 +01:00 committed by Thibault Saunier
parent e8162cc957
commit 921a073bdf
3 changed files with 60 additions and 4 deletions

View file

@ -400,6 +400,10 @@ gst_validate_report_load_issues (void)
_
("The pipeline latency is higher than the maximum allowed by the scenario"),
NULL);
REGISTER_VALIDATE_ISSUE (CRITICAL, SCENARIO_ACTION_TOO_MANY_BUFFERS_DROPPED,
_
("The number of dropped buffers is higher than the maximum allowed by the scenario"),
NULL);
REGISTER_VALIDATE_ISSUE (WARNING, G_LOG_WARNING, _("We got a g_log warning"),
NULL);
REGISTER_VALIDATE_ISSUE (CRITICAL, G_LOG_CRITICAL,

View file

@ -121,6 +121,7 @@ typedef enum {
#define SCENARIO_ACTION_TIMEOUT _QUARK("scenario::action-timeout")
#define SCENARIO_ACTION_EXECUTION_ISSUE _QUARK("scenario::execution-issue")
#define SCENARIO_ACTION_LATENCY_TOO_HIGH _QUARK("scenario::latency-too-high")
#define SCENARIO_ACTION_TOO_MANY_BUFFERS_DROPPED _QUARK("scenario::too-many-buffers-dropped")
#define G_LOG_ISSUE _QUARK("g-log::issue")
#define G_LOG_WARNING _QUARK("g-log::warning")

View file

@ -158,6 +158,8 @@ struct _GstValidateScenarioPrivate
gchar *pipeline_name;
GstClockTime max_latency;
gint dropped;
gint max_dropped;
/* 'switch-track action' currently waiting for
* GST_MESSAGE_STREAMS_SELECTED to be completed. */
@ -822,6 +824,27 @@ _action_sets_state (GstValidateAction * action)
}
static void
gst_validate_scenario_check_dropped (GstValidateScenario * scenario)
{
GstValidateScenarioPrivate *priv = scenario->priv;
guint dropped;
dropped = g_atomic_int_get (&priv->dropped);
if (priv->max_dropped == -1 || dropped != -1)
return;
GST_DEBUG_OBJECT (scenario, "Number of dropped buffers: %d (max allowed: %d)",
dropped, priv->max_dropped);
if (dropped > priv->max_dropped) {
GST_VALIDATE_REPORT (scenario, SCENARIO_ACTION_TOO_MANY_BUFFERS_DROPPED,
"Too many buffers have been dropped: %d (max allowed: %d)",
dropped, priv->max_dropped);
}
}
static GstValidateExecuteActionReturn
_execute_stop (GstValidateScenario * scenario, GstValidateAction * action)
{
@ -838,6 +861,8 @@ _execute_stop (GstValidateScenario * scenario, GstValidateAction * action)
}
SCENARIO_UNLOCK (scenario);
gst_validate_scenario_check_dropped (scenario);
gst_bus_post (bus,
gst_message_new_request_state (GST_OBJECT_CAST (scenario),
GST_STATE_NULL));
@ -2898,6 +2923,18 @@ message_cb (GstBus * bus, GstMessage * message, GstValidateScenario * scenario)
gst_validate_scenario_check_latency (scenario, pipeline);
break;
case GST_MESSAGE_QOS:
{
guint64 dropped;
/* Check the maximum allowed when scenario is terminating so the report
* will include the actual number of dropped buffers. */
gst_message_parse_qos_stats (message, NULL, NULL, &dropped);
if (dropped != -1)
g_atomic_int_set (&priv->dropped, dropped);
break;
}
default:
break;
}
@ -2965,6 +3002,8 @@ _load_scenario_file (GstValidateScenario * scenario,
gst_validate_utils_get_clocktime (structure, "max-latency",
&priv->max_latency);
gst_structure_get_int (structure, "max-dropped", &priv->max_dropped);
continue;
} else if (!g_strcmp0 (type, "include")) {
const gchar *location = gst_structure_get_string (structure, "location");
@ -3016,12 +3055,13 @@ _load_scenario_file (GstValidateScenario * scenario,
action->action_number = priv->num_actions++;
}
/* max latency can be overriden using config */
/* max-latency and max-dropped can be overriden using config */
for (config = gst_validate_plugin_get_config (NULL); config;
config = g_list_next (config)) {
if (gst_validate_utils_get_clocktime (config->data, "max-latency",
&priv->max_latency))
break;
gst_validate_utils_get_clocktime (config->data, "max-latency",
&priv->max_latency);
gst_structure_get_int (config->data, "max-dropped", &priv->max_dropped);
}
done:
@ -3268,6 +3308,7 @@ gst_validate_scenario_init (GstValidateScenario * scenario)
priv->vars = gst_structure_new_empty ("vars");
g_weak_ref_init (&scenario->priv->ref_pipeline, NULL);
priv->max_latency = GST_CLOCK_TIME_NONE;
priv->max_dropped = -1;
g_mutex_init (&priv->lock);
}
@ -4306,6 +4347,16 @@ init_scenarios (void)
.possible_variables = NULL,
.def = "infinite (GST_CLOCK_TIME_NONE)"
},
{
.name = "max-dropped",
.description = "The maximum number of buffers which can be dropped by the QoS system allowed for this pipeline.\n"
"It can be overriden using core configuration, like for example by defining the "
"env variable GST_VALIDATE_CONFIG=core,max-dropped=100",
.mandatory = FALSE,
.types = "int",
.possible_variables = NULL,
.def = "infinite (-1)"
},
{NULL}
}),
"Allows to describe the scenario in various ways",