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
This commit is contained in:
Mathieu Duponchelle 2014-05-06 15:34:08 +02:00
parent 1332e9fc4f
commit 7d4abf31e7
3 changed files with 83 additions and 5 deletions

View file

@ -38,11 +38,24 @@
* TODO * TODO
*/ */
enum
{
PROP_0,
PROP_STATELESS,
PROP_LAST
};
#define gst_validate_bin_monitor_parent_class parent_class #define gst_validate_bin_monitor_parent_class parent_class
G_DEFINE_TYPE (GstValidateBinMonitor, gst_validate_bin_monitor, G_DEFINE_TYPE (GstValidateBinMonitor, gst_validate_bin_monitor,
GST_TYPE_VALIDATE_ELEMENT_MONITOR); GST_TYPE_VALIDATE_ELEMENT_MONITOR);
static void 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, gst_validate_bin_monitor_wrap_element (GstValidateBinMonitor * monitor,
GstElement * element); GstElement * element);
static gboolean gst_validate_bin_monitor_setup (GstValidateMonitor * monitor); static gboolean gst_validate_bin_monitor_setup (GstValidateMonitor * monitor);
@ -51,6 +64,44 @@ static void
_validate_bin_element_added (GstBin * bin, GstElement * pad, _validate_bin_element_added (GstBin * bin, GstElement * pad,
GstValidateBinMonitor * monitor); 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 static void
gst_validate_bin_monitor_dispose (GObject * object) gst_validate_bin_monitor_dispose (GObject * object)
{ {
@ -83,8 +134,15 @@ gst_validate_bin_monitor_class_init (GstValidateBinMonitorClass * klass)
gobject_class = G_OBJECT_CLASS (klass); gobject_class = G_OBJECT_CLASS (klass);
validatemonitor_class = GST_VALIDATE_MONITOR_CLASS_CAST (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; 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; validatemonitor_class->setup = gst_validate_bin_monitor_setup;
} }

View file

@ -61,6 +61,7 @@ struct _GstValidateBinMonitor {
/*< private >*/ /*< private >*/
gulong element_added_id; gulong element_added_id;
guint print_pos_srcid; guint print_pos_srcid;
gboolean stateless;
}; };
/** /**

View file

@ -47,6 +47,7 @@ enum
{ {
PROP_0, PROP_0,
PROP_RUNNER, PROP_RUNNER,
PROP_STATELESS,
PROP_LAST PROP_LAST
}; };
@ -83,6 +84,8 @@ struct _GstValidateScenarioPrivate
guint num_actions; guint num_actions;
gboolean stateless;
guint get_pos_id; guint get_pos_id;
guint wait_id; guint wait_id;
@ -874,13 +877,12 @@ message_cb (GstBus * bus, GstMessage * message, GstValidateScenario * scenario)
gst_message_parse_state_changed (message, gst_message_parse_state_changed (message,
&pstate, &nstate, NULL); &pstate, &nstate, NULL);
if (scenario->priv->target_state == nstate)
scenario->priv->changing_state = FALSE;
if (pstate == GST_STATE_READY && nstate == GST_STATE_PAUSED) if (pstate == GST_STATE_READY && nstate == GST_STATE_PAUSED)
_add_get_position_source (scenario); _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; break;
} }
@ -1276,6 +1278,8 @@ static void
gst_validate_scenario_set_property (GObject * object, guint prop_id, gst_validate_scenario_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec) const GValue * value, GParamSpec * pspec)
{ {
GstValidateScenario *self = GST_VALIDATE_SCENARIO (object);
switch (prop_id) { switch (prop_id) {
case PROP_RUNNER: case PROP_RUNNER:
/* we assume the runner is valid as long as this scenario is, /* 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), gst_validate_reporter_set_runner (GST_VALIDATE_REPORTER (object),
g_value_get_object (value)); g_value_get_object (value));
break; break;
case PROP_STATELESS:
self->priv->stateless = g_value_get_boolean (value);
if (self->priv->stateless)
_add_get_position_source (self);
break;
default: default:
break; break;
} }
@ -1292,6 +1301,8 @@ static void
gst_validate_scenario_get_property (GObject * object, guint prop_id, gst_validate_scenario_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec) GValue * value, GParamSpec * pspec)
{ {
GstValidateScenario *self = GST_VALIDATE_SCENARIO (object);
switch (prop_id) { switch (prop_id) {
case PROP_RUNNER: case PROP_RUNNER:
/* we assume the runner is valid as long as this scenario is, /* 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, g_value_set_object (value,
gst_validate_reporter_get_runner (GST_VALIDATE_REPORTER (object))); gst_validate_reporter_get_runner (GST_VALIDATE_REPORTER (object)));
break; break;
case PROP_STATELESS:
g_value_set_boolean(value, self->priv->stateless);
break;
default: default:
break; break;
} }
@ -1322,6 +1336,11 @@ gst_validate_scenario_class_init (GstValidateScenarioClass * klass)
"The Validate runner to " "report errors to", "The Validate runner to " "report errors to",
GST_TYPE_VALIDATE_RUNNER, GST_TYPE_VALIDATE_RUNNER,
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)); 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 static void