From 7d4abf31e7eacb7ff7d5445a7b71659f0c63f78b Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Tue, 6 May 2014 15:34:08 +0200 Subject: [PATCH] scenarios: add a stateless property. This property enables the user to have actions executed independently of the state of the pipeline. Conflicts: validate/gst/validate/gst-validate-scenario.c --- validate/gst/validate/gst-validate-bin-monitor.c | 58 ++++++++++++++++++++++++ validate/gst/validate/gst-validate-bin-monitor.h | 1 + validate/gst/validate/gst-validate-scenario.c | 29 ++++++++++-- 3 files changed, 83 insertions(+), 5 deletions(-) diff --git a/validate/gst/validate/gst-validate-bin-monitor.c b/validate/gst/validate/gst-validate-bin-monitor.c index ac51020..a09bb8b 100644 --- a/validate/gst/validate/gst-validate-bin-monitor.c +++ b/validate/gst/validate/gst-validate-bin-monitor.c @@ -38,11 +38,24 @@ * TODO */ +enum +{ + PROP_0, + PROP_STATELESS, + PROP_LAST +}; + #define gst_validate_bin_monitor_parent_class parent_class G_DEFINE_TYPE (GstValidateBinMonitor, gst_validate_bin_monitor, GST_TYPE_VALIDATE_ELEMENT_MONITOR); static void +gst_validate_bin_monitor_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); +static void +gst_validate_bin_monitor_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_validate_bin_monitor_wrap_element (GstValidateBinMonitor * monitor, GstElement * element); static gboolean gst_validate_bin_monitor_setup (GstValidateMonitor * monitor); @@ -52,6 +65,44 @@ _validate_bin_element_added (GstBin * bin, GstElement * pad, GstValidateBinMonitor * monitor); static void +gst_validate_bin_monitor_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) +{ + GstValidateBinMonitor *monitor; + + monitor = GST_VALIDATE_BIN_MONITOR_CAST (object); + + switch (prop_id) { + case PROP_STATELESS: + monitor->stateless = g_value_get_boolean(value); + if (monitor->scenario != NULL) + g_object_set(monitor->scenario, "stateless", monitor->stateless, NULL); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +gst_validate_bin_monitor_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec) +{ + GstValidateBinMonitor *monitor; + + monitor = GST_VALIDATE_BIN_MONITOR_CAST (object); + + switch (prop_id) { + case PROP_STATELESS: + g_value_set_boolean (value, monitor->stateless); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void gst_validate_bin_monitor_dispose (GObject * object) { GstValidateBinMonitor *monitor = GST_VALIDATE_BIN_MONITOR_CAST (object); @@ -83,8 +134,15 @@ gst_validate_bin_monitor_class_init (GstValidateBinMonitorClass * klass) gobject_class = G_OBJECT_CLASS (klass); validatemonitor_class = GST_VALIDATE_MONITOR_CLASS_CAST (klass); + gobject_class->get_property = gst_validate_bin_monitor_get_property; + gobject_class->set_property = gst_validate_bin_monitor_set_property; gobject_class->dispose = gst_validate_bin_monitor_dispose; + g_object_class_install_property (gobject_class, PROP_STATELESS, + g_param_spec_boolean ("stateless", "Stateless", "True to execute actions as soon as possible, regardless " + "of the initial state of the pipeline", + FALSE, G_PARAM_READWRITE)); + validatemonitor_class->setup = gst_validate_bin_monitor_setup; } diff --git a/validate/gst/validate/gst-validate-bin-monitor.h b/validate/gst/validate/gst-validate-bin-monitor.h index 42d2bbc..e8a1c19 100644 --- a/validate/gst/validate/gst-validate-bin-monitor.h +++ b/validate/gst/validate/gst-validate-bin-monitor.h @@ -61,6 +61,7 @@ struct _GstValidateBinMonitor { /*< private >*/ gulong element_added_id; guint print_pos_srcid; + gboolean stateless; }; /** diff --git a/validate/gst/validate/gst-validate-scenario.c b/validate/gst/validate/gst-validate-scenario.c index 2d10caa..be5ccc4 100644 --- a/validate/gst/validate/gst-validate-scenario.c +++ b/validate/gst/validate/gst-validate-scenario.c @@ -47,6 +47,7 @@ enum { PROP_0, PROP_RUNNER, + PROP_STATELESS, PROP_LAST }; @@ -83,6 +84,8 @@ struct _GstValidateScenarioPrivate guint num_actions; + gboolean stateless; + guint get_pos_id; guint wait_id; @@ -874,13 +877,12 @@ message_cb (GstBus * bus, GstMessage * message, GstValidateScenario * scenario) gst_message_parse_state_changed (message, &pstate, &nstate, NULL); + + if (scenario->priv->target_state == nstate) + scenario->priv->changing_state = FALSE; + if (pstate == GST_STATE_READY && nstate == GST_STATE_PAUSED) _add_get_position_source (scenario); - - if (GST_MESSAGE_SRC (message) == GST_OBJECT(scenario->pipeline)) { - if (scenario->priv->target_state == nstate) - scenario->priv->changing_state = FALSE; - } } break; } @@ -1276,6 +1278,8 @@ static void gst_validate_scenario_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { + GstValidateScenario *self = GST_VALIDATE_SCENARIO (object); + switch (prop_id) { case PROP_RUNNER: /* we assume the runner is valid as long as this scenario is, @@ -1283,6 +1287,11 @@ gst_validate_scenario_set_property (GObject * object, guint prop_id, gst_validate_reporter_set_runner (GST_VALIDATE_REPORTER (object), g_value_get_object (value)); break; + case PROP_STATELESS: + self->priv->stateless = g_value_get_boolean (value); + if (self->priv->stateless) + _add_get_position_source (self); + break; default: break; } @@ -1292,6 +1301,8 @@ static void gst_validate_scenario_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec) { + GstValidateScenario *self = GST_VALIDATE_SCENARIO (object); + switch (prop_id) { case PROP_RUNNER: /* we assume the runner is valid as long as this scenario is, @@ -1299,6 +1310,9 @@ gst_validate_scenario_get_property (GObject * object, guint prop_id, g_value_set_object (value, gst_validate_reporter_get_runner (GST_VALIDATE_REPORTER (object))); break; + case PROP_STATELESS: + g_value_set_boolean(value, self->priv->stateless); + break; default: break; } @@ -1322,6 +1336,11 @@ gst_validate_scenario_class_init (GstValidateScenarioClass * klass) "The Validate runner to " "report errors to", GST_TYPE_VALIDATE_RUNNER, G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)); + + g_object_class_install_property (object_class, PROP_STATELESS, + g_param_spec_boolean ("stateless", "Stateless", "True to execute actions as soon as possible, regardless " + "of the initial state of the pipeline", + FALSE, G_PARAM_READWRITE)); } static void -- 2.7.4