validate: Add an API to get the bin monitor scenario
authorThibault Saunier <tsaunier@igalia.com>
Tue, 15 Dec 2020 20:58:51 +0000 (17:58 -0300)
committerThibault Saunier <tsaunier@igalia.com>
Tue, 15 Dec 2020 20:58:51 +0000 (17:58 -0300)
This is useful for applications that use Validate directly.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-devtools/-/merge_requests/233>

validate/gst/validate/gst-validate-bin-monitor.c
validate/gst/validate/gst-validate-bin-monitor.h

index 2264fa2..ab2c82c 100644 (file)
@@ -150,7 +150,7 @@ gst_validate_bin_monitor_dispose (GObject * object)
   if (monitor->scenario) {
     gst_validate_reporter_purge_reports (GST_VALIDATE_REPORTER
         (monitor->scenario));
-    gst_object_unref (monitor->scenario);
+    gst_clear_object (&monitor->scenario);
   }
 
   g_list_free_full (monitor->element_monitors, purge_and_unref_reporter);
@@ -350,3 +350,21 @@ _validate_bin_element_removed (GstBin * bin, GstElement * element,
         GST_ELEMENT_NAME (element),
         gst_validate_reporter_get_name (GST_VALIDATE_REPORTER (monitor)));
 }
+
+/**
+ * gst_validate_bin_monitor_get_scenario:
+ * @monitor: A #GstValidateBinMonitor
+ *
+ * Returns: (transfer full) (nullable): The #GstValidateScenario being executed
+ * under @monitor watch
+ *
+ * Since: 1.20
+ */
+GstValidateScenario *
+gst_validate_bin_monitor_get_scenario (GstValidateBinMonitor * monitor)
+{
+  if (monitor->scenario)
+    return gst_object_ref (monitor->scenario);
+
+  return NULL;
+}
index 184b5e2..300161d 100644 (file)
@@ -77,8 +77,13 @@ struct _GstValidateBinMonitorClass {
 GST_VALIDATE_API
 GType          gst_validate_bin_monitor_get_type               (void);
 
-GST_VALIDATE_API
-GstValidateBinMonitor *   gst_validate_bin_monitor_new      (GstBin * bin, GstValidateRunner * runner, GstValidateMonitor * parent);
+GST_VALIDATE_API GstValidateBinMonitor *
+gst_validate_bin_monitor_new                (GstBin * bin,
+                                             GstValidateRunner * runner,
+                                             GstValidateMonitor * parent);
+
+GST_VALIDATE_API GstValidateScenario *
+gst_validate_bin_monitor_get_scenario       (GstValidateBinMonitor * monitor);
 
 G_END_DECLS