validate: Add a reference to the pipeline from each monitor

That will allow us to add more flexibility regarding the way
we report thing to the user and will allow us to properly make
reports per pipeline.
This commit is contained in:
Thibault Saunier 2016-09-21 15:48:57 -03:00
parent 41be7bb2a9
commit e247122051
8 changed files with 86 additions and 14 deletions

View file

@ -39,6 +39,7 @@ enum
{
PROP_0,
PROP_OBJECT,
PROP_PIPELINE,
PROP_RUNNER,
PROP_VALIDATE_PARENT,
PROP_LAST
@ -69,11 +70,26 @@ _get_reporting_level (GstValidateReporter * monitor)
return GST_VALIDATE_MONITOR (monitor)->level;
}
static GstPipeline *
_get_pipeline (GstValidateReporter * monitor)
{
GstPipeline *pipeline;
GST_OBJECT_LOCK (monitor);
pipeline = GST_VALIDATE_MONITOR (monitor)->pipeline;
if (pipeline)
gst_object_ref (pipeline);
GST_OBJECT_UNLOCK (monitor);
return pipeline;
}
static void
_reporter_iface_init (GstValidateReporterInterface * iface)
{
iface->intercept_report = gst_validate_monitor_intercept_report;
iface->get_reporting_level = _get_reporting_level;
iface->get_pipeline = _get_pipeline;
}
#define gst_validate_monitor_parent_class parent_class
@ -85,6 +101,19 @@ _target_freed_cb (GstValidateMonitor * monitor, GObject * where_the_object_was)
{
GST_DEBUG_OBJECT (monitor, "Target was freed");
monitor->target = NULL;
GST_OBJECT_LOCK (monitor);
monitor->pipeline = NULL;
GST_OBJECT_UNLOCK (monitor);
}
static void
_pipeline_freed_cb (GstValidateMonitor * monitor,
GObject * where_the_object_was)
{
GST_DEBUG_OBJECT (monitor, "Pipeline was freed");
GST_OBJECT_LOCK (monitor);
monitor->pipeline = NULL;
GST_OBJECT_UNLOCK (monitor);
}
static void
@ -133,9 +162,14 @@ gst_validate_monitor_class_init (GstValidateMonitorClass * klass)
g_param_spec_object ("object", "Object", "The object to be monitored",
G_TYPE_OBJECT, G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_PIPELINE,
g_param_spec_object ("pipeline", "Pipeline", "The pipeline in which the"
"monitored object is", GST_TYPE_PIPELINE,
G_PARAM_CONSTRUCT | G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_RUNNER,
g_param_spec_object ("validate-runner", "VALIDATE Runner",
"The Validate runner to " "report errors to",
"The Validate runner to report errors to",
GST_TYPE_VALIDATE_RUNNER,
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
@ -159,8 +193,15 @@ gst_validate_monitor_constructor (GType type, guint n_construct_params,
if (monitor->parent) {
gst_validate_monitor_set_media_descriptor (monitor,
monitor->parent->media_descriptor);
}
GST_OBJECT_LOCK (monitor);
if (monitor->parent->pipeline) {
g_object_weak_ref (G_OBJECT (monitor->parent->pipeline),
(GWeakNotify) _pipeline_freed_cb, monitor);
monitor->pipeline = monitor->parent->pipeline;
}
GST_OBJECT_UNLOCK (monitor);
}
gst_validate_monitor_setup (monitor);
return (GObject *) monitor;
@ -339,6 +380,13 @@ gst_validate_monitor_set_property (GObject * object, guint prop_id,
gst_validate_reporter_set_name (GST_VALIDATE_REPORTER (monitor),
g_strdup (GST_OBJECT_NAME (monitor->target)));
break;
case PROP_PIPELINE:
GST_OBJECT_LOCK (monitor);
monitor->pipeline = g_value_get_object (value);
if (monitor->pipeline)
g_object_weak_ref (G_OBJECT (monitor->pipeline),
(GWeakNotify) _pipeline_freed_cb, monitor);
GST_OBJECT_UNLOCK (monitor);
case PROP_RUNNER:
gst_validate_reporter_set_runner (GST_VALIDATE_REPORTER (monitor),
g_value_get_object (value));
@ -364,6 +412,9 @@ gst_validate_monitor_get_property (GObject * object, guint prop_id,
case PROP_OBJECT:
g_value_set_object (value, GST_VALIDATE_MONITOR_GET_OBJECT (monitor));
break;
case PROP_PIPELINE:
g_value_set_object (value, monitor->pipeline);
break;
case PROP_RUNNER:
g_value_set_object (value, GST_VALIDATE_MONITOR_GET_RUNNER (monitor));
break;

View file

@ -84,6 +84,7 @@ struct _GstValidateMonitor {
GstObject object;
GstObject *target;
GstPipeline *pipeline;
GMutex mutex;
gchar *target_name;

View file

@ -599,7 +599,8 @@ gst_validate_pipeline_monitor_new (GstPipeline * pipeline,
GstBus *bus;
GstValidatePipelineMonitor *monitor =
g_object_new (GST_TYPE_VALIDATE_PIPELINE_MONITOR, "object",
pipeline, "validate-runner", runner, "validate-parent", parent, NULL);
pipeline, "validate-runner", runner, "validate-parent", parent,
"pipeline", pipeline, NULL);
if (GST_VALIDATE_MONITOR_GET_OBJECT (monitor) == NULL) {
g_object_unref (monitor);

View file

@ -719,18 +719,18 @@ gst_validate_report_level_get_name (GstValidateReportLevel level)
}
GstValidateReportLevel
gst_validate_report_level_from_name (const gchar * issue_name)
gst_validate_report_level_from_name (const gchar * level_name)
{
if (g_strcmp0 (issue_name, "critical") == 0)
if (g_strcmp0 (level_name, "critical") == 0)
return GST_VALIDATE_REPORT_LEVEL_CRITICAL;
else if (g_strcmp0 (issue_name, "warning") == 0)
else if (g_strcmp0 (level_name, "warning") == 0)
return GST_VALIDATE_REPORT_LEVEL_WARNING;
else if (g_strcmp0 (issue_name, "issue") == 0)
else if (g_strcmp0 (level_name, "issue") == 0)
return GST_VALIDATE_REPORT_LEVEL_ISSUE;
else if (g_strcmp0 (issue_name, "ignore") == 0)
else if (g_strcmp0 (level_name, "ignore") == 0)
return GST_VALIDATE_REPORT_LEVEL_IGNORE;
return GST_VALIDATE_REPORT_LEVEL_UNKNOWN;

View file

@ -239,7 +239,7 @@ gboolean gst_validate_report_should_print (GstValidateReport * report);
gboolean gst_validate_report_set_master_report(GstValidateReport *report, GstValidateReport *master_report);
void gst_validate_report_set_reporting_level (GstValidateReport *report, GstValidateReportingDetails level);
void gst_validate_report_add_repeated_report (GstValidateReport *report, GstValidateReport *repeated_report);
GstValidateReportLevel gst_validate_report_level_from_name (const gchar *issue_name);
GstValidateReportLevel gst_validate_report_level_from_name (const gchar *level_name);
G_END_DECLS

View file

@ -135,6 +135,18 @@ gst_validate_reporter_get_reporting_level (GstValidateReporter * reporter)
return ret;
}
GstPipeline *
gst_validate_reporter_get_pipeline (GstValidateReporter * reporter)
{
GstValidateReporterInterface *iface =
GST_VALIDATE_REPORTER_GET_INTERFACE (reporter);
if (iface->get_pipeline)
return iface->get_pipeline (reporter);
return NULL;
}
GstValidateReport *
gst_validate_reporter_get_report (GstValidateReporter * reporter,
GstValidateIssueId issue_id)

View file

@ -88,10 +88,10 @@ struct _GstValidateReporterInterface
{
GTypeInterface parent;
GstValidateInterceptionReturn (*intercept_report) (GstValidateReporter *
reporter, GstValidateReport * report);
GstValidateReportingDetails (*get_reporting_level) (GstValidateReporter *
reporter);
GstValidateInterceptionReturn (*intercept_report) (GstValidateReporter * reporter,
GstValidateReport * report);
GstValidateReportingDetails (*get_reporting_level) (GstValidateReporter * reporter);
GstPipeline * (*get_pipeline) (GstValidateReporter *reporter);
};
void gst_validate_reporter_set_name (GstValidateReporter * reporter,
@ -116,6 +116,7 @@ gint gst_validate_reporter_get_reports_count (GstValidateReporter *reporter);
GstValidateReportingDetails gst_validate_reporter_get_reporting_level (GstValidateReporter *reporter);
void gst_validate_reporter_purge_reports (GstValidateReporter * reporter);
GstPipeline * gst_validate_reporter_get_pipeline (GstValidateReporter * reporter);
G_END_DECLS
#endif /* _GST_VALIDATE_REPORTER_ */

View file

@ -177,10 +177,17 @@ gst_validate_scenario_intercept_report (GstValidateReporter * reporter,
return GST_VALIDATE_REPORTER_REPORT;
}
static GstPipeline *
_get_pipeline (GstValidateReporter * scenario)
{
return gst_object_ref (GST_VALIDATE_SCENARIO (scenario)->pipeline);
}
static void
_reporter_iface_init (GstValidateReporterInterface * iface)
{
iface->intercept_report = gst_validate_scenario_intercept_report;
iface->get_pipeline = _get_pipeline;
}
G_DEFINE_TYPE_WITH_CODE (GstValidateScenario, gst_validate_scenario,
@ -629,7 +636,6 @@ _pause_action_restore_playing (GstValidateScenario * scenario)
{
GstElement *pipeline = scenario->pipeline;
gst_validate_printf (scenario, "Back to playing\n");
if (gst_element_set_state (pipeline, GST_STATE_PLAYING) ==