diff --git a/gst/gsttracer.h b/gst/gsttracer.h index 046ac229fc..751c1b385c 100644 --- a/gst/gsttracer.h +++ b/gst/gsttracer.h @@ -74,6 +74,9 @@ void gst_tracing_register_hook (GstTracer *tracer, const gchar *detail, GST_API gboolean gst_tracer_register (GstPlugin * plugin, const gchar * name, GType type); +GST_API +GList* gst_tracing_get_active_tracers (void); + #endif G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstTracer, gst_object_unref) diff --git a/gst/gsttracerutils.c b/gst/gsttracerutils.c index 2522cbf91c..d3a95b7fc3 100644 --- a/gst/gsttracerutils.c +++ b/gst/gsttracerutils.c @@ -205,3 +205,41 @@ gst_tracing_register_hook (GstTracer * tracer, const gchar * detail, } #endif /* GST_DISABLE_GST_TRACER_HOOKS */ + +/** + * gst_tracing_get_active_tracers: + * + * Get a list of all active tracer objects owned by the tracing framework for + * the entirety of the run-time of the process or till gst_deinit() is called. + * + * Returns: (transfer full) (element-type Gst.Tracer): A #GList of + * #GstTracer objects + * + * Since: 1.18 + */ +GList * +gst_tracing_get_active_tracers (void) +{ + GList *tracers, *h_list, *h_node, *t_node; + GstTracerHook *hook; + + if (!_priv_tracer_enabled || !_priv_tracers) + return NULL; + + tracers = NULL; + h_list = g_hash_table_get_values (_priv_tracers); + for (h_node = h_list; h_node; h_node = g_list_next (h_node)) { + for (t_node = h_node->data; t_node; t_node = g_list_next (t_node)) { + hook = (GstTracerHook *) t_node->data; + /* Skip duplicate tracers from different hooks. This function is O(n), but + * that should be fine since the number of tracers enabled on a process + * should be small. */ + if (g_list_index (tracers, hook->tracer) >= 0) + continue; + tracers = g_list_prepend (tracers, gst_object_ref (hook->tracer)); + } + } + g_list_free (h_list); + + return tracers; +}