tracer: split into tracer and tracerutils

Keep tracer base class in tracer and move core support into the utils module.
Add a unstable-api guard to the tracer.h so that external modules would need to
acknowledge the status by setting GST_USE_UNSTABLE_API.
This commit is contained in:
Stefan Sauer 2014-07-18 07:49:38 +02:00
parent 6ea2b41364
commit 46ea9729df
17 changed files with 403 additions and 325 deletions

View file

@ -117,6 +117,7 @@ libgstreamer_@GST_API_VERSION@_la_SOURCES = \
$(GST_TRACE_SRC) \
gsttracer.c \
gsttracerfactory.c \
gsttracerutils.c \
gsttypefind.c \
gsttypefindfactory.c \
gsturi.c \
@ -222,6 +223,7 @@ gst_headers = \
gsttocsetter.h \
gsttracer.h \
gsttracerfactory.h \
gsttracerutils.h \
gsttypefind.h \
gsttypefindfactory.h \
gsturi.h \

View file

@ -77,7 +77,6 @@
#include <gst/gsttaskpool.h>
#include <gst/gsttoc.h>
#include <gst/gsttocsetter.h>
#include <gst/gsttracer.h>
#include <gst/gsttracerfactory.h>
#include <gst/gsttypefind.h>
#include <gst/gsttypefindfactory.h>

View file

@ -62,6 +62,8 @@ extern const char g_log_domain_gstreamer[];
#include "gstdatetime.h"
#include "gsttracerutils.h"
G_BEGIN_DECLS
/* used by gstparse.c and grammar.y */

View file

@ -90,7 +90,7 @@
#include "gstutils.h"
#include "gstinfo.h"
#include "gstquark.h"
#include "gsttracer.h"
#include "gsttracerutils.h"
#include "gstvalue.h"
#include "gst-i18n-lib.h"
#include "glib-compat-private.h"

View file

@ -94,7 +94,7 @@
#include "gstutils.h"
#include "gstinfo.h"
#include "gsterror.h"
#include "gsttracer.h"
#include "gsttracerutils.h"
#include "gstvalue.h"
#include "glib-compat-private.h"

View file

@ -31,7 +31,6 @@
#include <gst/gst_private.h>
#include <gst/gstconfig.h>
#include <gst/gstelement.h>
#include <gst/gsttracer.h>
#include <gst/gsttracerfactory.h>
#include <gst/gsttypefind.h>
#include <gst/gsttypefindfactory.h>

View file

@ -1,7 +1,7 @@
/* GStreamer
* Copyright (C) 2013 Stefan Sauer <ensonic@users.sf.net>
*
* gsttracer.h: tracing subsystem
* gsttracer.c: tracer base class
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@ -21,28 +21,20 @@
/**
* SECTION:gsttracer
* @short_description: Tracing subsystem
*
* The tracing subsystem provides hooks in the core library and API for modules
* to attach to them.
* @short_description: Tracing base class
*
* Tracing modules will subclass #GstTracer and register through
* gst_tracer_register(). Modules can attach to various hook-types - see
* #GstTracerHook. When invoked they receive hook specific contextual data,
* which they must not modify.
*
* The user can activate tracers by setting the environment variable GST_TRACE
* to a ';' separated list of tracers.
*/
#define GST_USE_UNSTABLE_API
#include "gst_private.h"
#include "gstenumtypes.h"
#include "gstregistry.h"
#include "gsttracer.h"
#include "gsttracerfactory.h"
#include "gstutils.h"
#ifndef GST_DISABLE_GST_DEBUG
GST_DEBUG_CATEGORY_EXTERN (tracer_debug);
#define GST_CAT_DEFAULT tracer_debug
@ -138,7 +130,7 @@ gst_tracer_get_property (GObject * object, guint prop_id,
}
}
static void
void
gst_tracer_invoke (GstTracer * self, GstTracerHookId hid,
GstTracerMessageId mid, va_list var_args)
{
@ -206,115 +198,6 @@ gst_tracer_register (GstPlugin * plugin, const gchar * name, GType type)
return TRUE;
}
/* tracing helpers */
gboolean _priv_tracer_enabled = FALSE;
/* TODO(ensonic): use GPtrArray ? */
GList *_priv_tracers[GST_TRACER_HOOK_ID_LAST] = { NULL, };
/* Initialize the debugging system */
void
_priv_gst_tracer_init (void)
{
const gchar *env = g_getenv ("GST_TRACE");
if (env != NULL && *env != '\0') {
GstRegistry *registry = gst_registry_get ();
GstPluginFeature *feature;
GstTracerFactory *factory;
GstTracerHook mask;
GstTracer *tracer;
gchar **t = g_strsplit_set (env, ";", 0);
gint i = 0, j;
gchar *params;
GST_INFO ("enabling tracers: '%s'", env);
while (t[i]) {
// check t[i] for params
if ((params = strchr (t[i], '('))) {
gchar *end = strchr (&params[1], ')');
*params = '\0';
params++;
if (end)
*end = '\0';
} else {
params = NULL;
}
GST_INFO ("checking tracer: '%s'", t[i]);
if ((feature = gst_registry_lookup_feature (registry, t[i]))) {
factory = GST_TRACER_FACTORY (gst_plugin_feature_load (feature));
if (factory) {
GST_INFO_OBJECT (factory, "creating tracer: type-id=%u",
(guint) factory->type);
tracer = g_object_new (factory->type, "params", params, NULL);
g_object_get (tracer, "mask", &mask, NULL);
if (mask) {
/* add to lists according to mask */
j = 0;
while (mask && (j < GST_TRACER_HOOK_ID_LAST)) {
if (mask & 1) {
_priv_tracers[j] = g_list_prepend (_priv_tracers[j],
gst_object_ref (tracer));
GST_WARNING_OBJECT (tracer, "added tracer to hook %d", j);
}
mask >>= 1;
j++;
}
_priv_tracer_enabled = TRUE;
} else {
GST_WARNING_OBJECT (tracer,
"tracer with zero mask won't have any effect");
}
gst_object_unref (tracer);
} else {
GST_WARNING_OBJECT (feature,
"loading plugin containing feature %s failed!", t[i]);
}
} else {
GST_WARNING ("no tracer named '%s'", t[i]);
}
i++;
}
g_strfreev (t);
}
}
void
_priv_gst_tracer_deinit (void)
{
gint i;
GList *node;
/* shutdown tracers for final reports */
for (i = 0; i < GST_TRACER_HOOK_ID_LAST; i++) {
for (node = _priv_tracers[i]; node; node = g_list_next (node)) {
gst_object_unref (node->data);
}
g_list_free (_priv_tracers[i]);
_priv_tracers[i] = NULL;
}
_priv_tracer_enabled = FALSE;
}
void
gst_tracer_dispatch (GstTracerHookId hid, GstTracerMessageId mid, ...)
{
va_list var_args;
GList *node;
for (node = _priv_tracers[hid]; node; node = g_list_next (node)) {
va_start (var_args, mid);
gst_tracer_invoke (node->data, hid, mid, var_args);
va_end (var_args);
}
}
/* tracing module helpers */
void
@ -328,5 +211,3 @@ gst_tracer_log_trace (GstStructure * s)
g_free (data);
gst_structure_free (s);
}
#endif /* GST_DISABLE_GST_DEBUG */

View file

@ -1,7 +1,7 @@
/* GStreamer
* Copyright (C) 2013 Stefan Sauer <ensonic@users.sf.net>
*
* gsttracer.h: tracing subsystem
* gsttracer.h: tracer base class
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@ -22,63 +22,18 @@
#ifndef __GST_TRACER_H__
#define __GST_TRACER_H__
#ifndef GST_USE_UNSTABLE_API
#warning "The tracer subsystem is unstable API and may change in future."
#warning "You can define GST_USE_UNSTABLE_API to avoid this warning."
#endif
#include <glib.h>
#include <glib-object.h>
#include <gst/gstconfig.h>
#include <gst/gstbin.h>
#include <gst/gsttracerutils.h>
G_BEGIN_DECLS
#ifndef GST_DISABLE_GST_DEBUG
/* hook flags and ids */
typedef enum
{
GST_TRACER_HOOK_NONE = 0,
GST_TRACER_HOOK_BUFFERS = (1 << 0),
GST_TRACER_HOOK_EVENTS = (1 << 1),
GST_TRACER_HOOK_MESSAGES = (1 << 2),
GST_TRACER_HOOK_QUERIES = (1 << 3),
GST_TRACER_HOOK_TOPOLOGY = (1 << 4),
/*
GST_TRACER_HOOK_TIMER
*/
GST_TRACER_HOOK_ALL = (1 << 5) - 1
} GstTracerHook;
typedef enum
{
GST_TRACER_HOOK_ID_BUFFERS = 0,
GST_TRACER_HOOK_ID_EVENTS,
GST_TRACER_HOOK_ID_MESSAGES,
GST_TRACER_HOOK_ID_QUERIES,
GST_TRACER_HOOK_ID_TOPLOGY,
/*
GST_TRACER_HOOK_ID_TIMER
*/
GST_TRACER_HOOK_ID_LAST
} GstTracerHookId;
typedef enum
{
GST_TRACER_MESSAGE_ID_PAD_PUSH_PRE = 0,
GST_TRACER_MESSAGE_ID_PAD_PUSH_POST,
GST_TRACER_MESSAGE_ID_PAD_PUSH_LIST_PRE,
GST_TRACER_MESSAGE_ID_PAD_PUSH_LIST_POST,
GST_TRACER_MESSAGE_ID_PAD_PULL_RANGE_PRE,
GST_TRACER_MESSAGE_ID_PAD_PULL_RANGE_POST,
GST_TRACER_MESSAGE_ID_PAD_PUSH_EVENT_PRE,
GST_TRACER_MESSAGE_ID_PAD_PUSH_EVENT_POST,
GST_TRACER_MESSAGE_ID_ELEMENT_POST_MESSAGE_PRE,
GST_TRACER_MESSAGE_ID_ELEMENT_POST_MESSAGE_POST,
GST_TRACER_MESSAGE_ID_ELEMENT_QUERY_PRE,
GST_TRACER_MESSAGE_ID_ELEMENT_QUERY_POST,
GST_TRACER_MESSAGE_ID_LAST
} GstTracerMessageId;
/* tracing plugins */
typedef struct _GstTracer GstTracer;
typedef struct _GstTracerPrivate GstTracerPrivate;
typedef struct _GstTracerClass GstTracerClass;
@ -111,150 +66,11 @@ struct _GstTracerClass {
gpointer _gst_reserved[GST_PADDING];
};
void gst_tracer_invoke (GstTracer * self, GstTracerHookId hid,
GstTracerMessageId mid, va_list var_args);
GType gst_tracer_get_type (void);
/* tracing hooks */
void _priv_gst_tracer_init (void);
void _priv_gst_tracer_deinit (void);
/* tracing modules */
gboolean gst_tracer_register (GstPlugin * plugin, const gchar * name, GType type);
/* tracing helpers */
void gst_tracer_dispatch (GstTracerHookId hid, GstTracerMessageId mid, ...);
/* tracing module helpers */
void gst_tracer_log_trace (GstStructure * s);
extern gboolean _priv_tracer_enabled;
extern GList *_priv_tracers[GST_TRACER_HOOK_ID_LAST];
extern GstClockTime _priv_gst_info_start_time;
#define GST_TRACER_IS_ENABLED(id) \
(_priv_tracer_enabled && (_priv_tracers[id] != NULL))
#define GST_TRACER_TS \
GST_CLOCK_DIFF (_priv_gst_info_start_time, gst_util_get_timestamp ())
/* tracing hooks */
#define GST_TRACER_PAD_PUSH_PRE(pad, buffer) G_STMT_START{ \
if (GST_TRACER_IS_ENABLED(GST_TRACER_HOOK_ID_BUFFERS)) { \
gst_tracer_dispatch (GST_TRACER_HOOK_ID_BUFFERS, \
GST_TRACER_MESSAGE_ID_PAD_PUSH_PRE, GST_TRACER_TS, \
pad, buffer); \
} \
}G_STMT_END
#define GST_TRACER_PAD_PUSH_POST(pad, res) G_STMT_START{ \
if (GST_TRACER_IS_ENABLED(GST_TRACER_HOOK_ID_BUFFERS)) { \
gst_tracer_dispatch (GST_TRACER_HOOK_ID_BUFFERS, \
GST_TRACER_MESSAGE_ID_PAD_PUSH_POST, GST_TRACER_TS, \
pad, res); \
} \
}G_STMT_END
#define GST_TRACER_PAD_PUSH_LIST_PRE(pad, list) G_STMT_START{ \
if (GST_TRACER_IS_ENABLED(GST_TRACER_HOOK_ID_BUFFERS)) { \
gst_tracer_dispatch (GST_TRACER_HOOK_ID_BUFFERS, \
GST_TRACER_MESSAGE_ID_PAD_PUSH_LIST_PRE, GST_TRACER_TS, \
pad, list); \
} \
}G_STMT_END
#define GST_TRACER_PAD_PUSH_LIST_POST(pad, res) G_STMT_START{ \
if (GST_TRACER_IS_ENABLED(GST_TRACER_HOOK_ID_BUFFERS)) { \
gst_tracer_dispatch (GST_TRACER_HOOK_ID_BUFFERS, \
GST_TRACER_MESSAGE_ID_PAD_PUSH_LIST_POST, GST_TRACER_TS, \
pad, res); \
} \
}G_STMT_END
#define GST_TRACER_PAD_PULL_RANGE_PRE(pad, offset, size) G_STMT_START{ \
if (GST_TRACER_IS_ENABLED(GST_TRACER_HOOK_ID_BUFFERS)) { \
gst_tracer_dispatch (GST_TRACER_HOOK_ID_BUFFERS, \
GST_TRACER_MESSAGE_ID_PAD_PULL_RANGE_PRE, GST_TRACER_TS, \
pad, offset, size); \
} \
}G_STMT_END
#define GST_TRACER_PAD_PULL_RANGE_POST(pad, buffer, res) G_STMT_START{ \
if (GST_TRACER_IS_ENABLED(GST_TRACER_HOOK_ID_BUFFERS)) { \
gst_tracer_dispatch (GST_TRACER_HOOK_ID_BUFFERS, \
GST_TRACER_MESSAGE_ID_PAD_PULL_RANGE_POST, GST_TRACER_TS, \
pad, buffer, res); \
} \
}G_STMT_END
#define GST_TRACER_PAD_PUSH_EVENT_PRE(pad, event) G_STMT_START{ \
if (GST_TRACER_IS_ENABLED(GST_TRACER_HOOK_ID_EVENTS)) { \
gst_tracer_dispatch (GST_TRACER_HOOK_ID_EVENTS, \
GST_TRACER_MESSAGE_ID_PAD_PUSH_EVENT_PRE, GST_TRACER_TS, \
pad, event); \
} \
}G_STMT_END
#define GST_TRACER_PAD_PUSH_EVENT_POST(pad, res) G_STMT_START{ \
if (GST_TRACER_IS_ENABLED(GST_TRACER_HOOK_ID_EVENTS)) { \
gst_tracer_dispatch (GST_TRACER_HOOK_ID_EVENTS, \
GST_TRACER_MESSAGE_ID_PAD_PUSH_EVENT_POST, GST_TRACER_TS, \
pad, res); \
} \
}G_STMT_END
#define GST_TRACER_ELEMENT_POST_MESSAGE_PRE(element, message) G_STMT_START{ \
if (GST_TRACER_IS_ENABLED(GST_TRACER_HOOK_ID_MESSAGES)) { \
gst_tracer_dispatch (GST_TRACER_HOOK_ID_MESSAGES, \
GST_TRACER_MESSAGE_ID_ELEMENT_POST_MESSAGE_PRE, GST_TRACER_TS, \
element, message); \
} \
}G_STMT_END
#define GST_TRACER_ELEMENT_POST_MESSAGE_POST(element, res) G_STMT_START{ \
if (GST_TRACER_IS_ENABLED(GST_TRACER_HOOK_ID_MESSAGES)) { \
gst_tracer_dispatch (GST_TRACER_HOOK_ID_MESSAGES, \
GST_TRACER_MESSAGE_ID_ELEMENT_POST_MESSAGE_POST, GST_TRACER_TS, \
element, res); \
} \
}G_STMT_END
#define GST_TRACER_ELEMENT_QUERY_PRE(element, query) G_STMT_START{ \
if (GST_TRACER_IS_ENABLED(GST_TRACER_HOOK_ID_QUERIES)) { \
gst_tracer_dispatch (GST_TRACER_HOOK_ID_QUERIES, \
GST_TRACER_MESSAGE_ID_ELEMENT_QUERY_PRE, GST_TRACER_TS, \
element, query); \
} \
}G_STMT_END
#define GST_TRACER_ELEMENT_QUERY_POST(element, res) G_STMT_START{ \
if (GST_TRACER_IS_ENABLED(GST_TRACER_HOOK_ID_QUERIES)) { \
gst_tracer_dispatch (GST_TRACER_HOOK_ID_QUERIES, \
GST_TRACER_MESSAGE_ID_ELEMENT_QUERY_POST, GST_TRACER_TS, \
element, res); \
} \
}G_STMT_END
#else /* !GST_DISABLE_GST_DEBUG */
#define GST_TRACER_PAD_PUSH_PRE(pad, buffer)
#define GST_TRACER_PAD_PUSH_POST(pad, res)
#define GST_TRACER_PAD_PUSH_LIST_PRE(pad, list)
#define GST_TRACER_PAD_PUSH_LIST_POST(pad, res)
#define GST_TRACER_PAD_PULL_RANGE_PRE(pad, offset, size)
#define GST_TRACER_PAD_PULL_RANGE_POST(pad, buffer, res)
#define GST_TRACER_PAD_PUSH_EVENT_PRE(pad, event)
#define GST_TRACER_PAD_PUSH_EVENT_POST(pad, res)
#define GST_TRACER_ELEMENT_POST_MESSAGE_PRE(element, message)
#define GST_TRACER_ELEMENT_POST_MESSAGE_POST(element, res)
#define GST_TRACER_ELEMENT_QUERY_PRE(element, query)
#define GST_TRACER_ELEMENT_QUERY_POST(element, res)
#endif /* GST_DISABLE_GST_DEBUG */
G_END_DECLS
#endif /* __GST_TRACER_H__ */

View file

@ -29,7 +29,6 @@
#include "gst_private.h"
#include "gstinfo.h"
#include "gsttracer.h"
#include "gsttracerfactory.h"
#include "gstregistry.h"

View file

@ -25,7 +25,6 @@
#include <gst/gstcaps.h>
#include <gst/gstplugin.h>
#include <gst/gstpluginfeature.h>
#include <gst/gsttracer.h>
G_BEGIN_DECLS

151
gst/gsttracerutils.c Normal file
View file

@ -0,0 +1,151 @@
/* GStreamer
* Copyright (C) 2013 Stefan Sauer <ensonic@users.sf.net>
*
* gsttracerutils.c: tracing subsystem
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/**
* SECTION:gsttracerutils
* @short_description: Tracing subsystem
*
* The tracing subsystem provides hooks in the core library and API for modules
* to attach to them.
*
* The user can activate tracers by setting the environment variable GST_TRACE
* to a ';' separated list of tracers.
*/
#define GST_USE_UNSTABLE_API
#include "gst_private.h"
#include "gsttracer.h"
#include "gsttracerfactory.h"
#include "gsttracerutils.h"
#ifndef GST_DISABLE_GST_DEBUG
/* tracing helpers */
gboolean _priv_tracer_enabled = FALSE;
/* TODO(ensonic): use array of GPtrArray* ? */
GList *_priv_tracers[GST_TRACER_HOOK_ID_LAST] = { NULL, };
/* Initialize the tracing system */
void
_priv_gst_tracer_init (void)
{
const gchar *env = g_getenv ("GST_TRACE");
if (env != NULL && *env != '\0') {
GstRegistry *registry = gst_registry_get ();
GstPluginFeature *feature;
GstTracerFactory *factory;
GstTracerHook mask;
GstObject *tracer;
gchar **t = g_strsplit_set (env, ";", 0);
gint i = 0, j;
gchar *params;
GST_INFO ("enabling tracers: '%s'", env);
while (t[i]) {
// check t[i] for params
if ((params = strchr (t[i], '('))) {
gchar *end = strchr (&params[1], ')');
*params = '\0';
params++;
if (end)
*end = '\0';
} else {
params = NULL;
}
GST_INFO ("checking tracer: '%s'", t[i]);
if ((feature = gst_registry_lookup_feature (registry, t[i]))) {
factory = GST_TRACER_FACTORY (gst_plugin_feature_load (feature));
if (factory) {
GST_INFO_OBJECT (factory, "creating tracer: type-id=%u",
(guint) factory->type);
tracer = g_object_new (factory->type, "params", params, NULL);
g_object_get (tracer, "mask", &mask, NULL);
if (mask) {
/* add to lists according to mask */
j = 0;
while (mask && (j < GST_TRACER_HOOK_ID_LAST)) {
if (mask & 1) {
_priv_tracers[j] = g_list_prepend (_priv_tracers[j],
gst_object_ref (tracer));
GST_WARNING_OBJECT (tracer, "added tracer to hook %d", j);
}
mask >>= 1;
j++;
}
_priv_tracer_enabled = TRUE;
} else {
GST_WARNING_OBJECT (tracer,
"tracer with zero mask won't have any effect");
}
gst_object_unref (tracer);
} else {
GST_WARNING_OBJECT (feature,
"loading plugin containing feature %s failed!", t[i]);
}
} else {
GST_WARNING ("no tracer named '%s'", t[i]);
}
i++;
}
g_strfreev (t);
}
}
void
_priv_gst_tracer_deinit (void)
{
gint i;
GList *node;
/* shutdown tracers for final reports */
for (i = 0; i < GST_TRACER_HOOK_ID_LAST; i++) {
for (node = _priv_tracers[i]; node; node = g_list_next (node)) {
gst_object_unref (node->data);
}
g_list_free (_priv_tracers[i]);
_priv_tracers[i] = NULL;
}
_priv_tracer_enabled = FALSE;
}
void
gst_tracer_dispatch (GstTracerHookId hid, GstTracerMessageId mid, ...)
{
va_list var_args;
GList *node;
for (node = _priv_tracers[hid]; node; node = g_list_next (node)) {
va_start (var_args, mid);
gst_tracer_invoke (node->data, hid, mid, var_args);
va_end (var_args);
}
}
#endif /* GST_DISABLE_GST_DEBUG */

225
gst/gsttracerutils.h Normal file
View file

@ -0,0 +1,225 @@
/* GStreamer
* Copyright (C) 2013 Stefan Sauer <ensonic@users.sf.net>
*
* gsttracerutils.h: tracing subsystem
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_TRACER_UTILS_H__
#define __GST_TRACER_UTILS_H__
#include <glib.h>
#include <glib-object.h>
#include <gst/gstconfig.h>
#include <gst/gstbin.h>
G_BEGIN_DECLS
#ifndef GST_DISABLE_GST_DEBUG
/* hook flags and ids */
typedef enum
{
GST_TRACER_HOOK_NONE = 0,
GST_TRACER_HOOK_BUFFERS = (1 << 0),
GST_TRACER_HOOK_EVENTS = (1 << 1),
GST_TRACER_HOOK_MESSAGES = (1 << 2),
GST_TRACER_HOOK_QUERIES = (1 << 3),
GST_TRACER_HOOK_TOPOLOGY = (1 << 4),
/*
GST_TRACER_HOOK_TIMER
*/
GST_TRACER_HOOK_ALL = (1 << 5) - 1
} GstTracerHook;
typedef enum
{
GST_TRACER_HOOK_ID_BUFFERS = 0,
GST_TRACER_HOOK_ID_EVENTS,
GST_TRACER_HOOK_ID_MESSAGES,
GST_TRACER_HOOK_ID_QUERIES,
GST_TRACER_HOOK_ID_TOPLOGY,
/*
GST_TRACER_HOOK_ID_TIMER
*/
GST_TRACER_HOOK_ID_LAST
} GstTracerHookId;
typedef enum
{
GST_TRACER_MESSAGE_ID_PAD_PUSH_PRE = 0,
GST_TRACER_MESSAGE_ID_PAD_PUSH_POST,
GST_TRACER_MESSAGE_ID_PAD_PUSH_LIST_PRE,
GST_TRACER_MESSAGE_ID_PAD_PUSH_LIST_POST,
GST_TRACER_MESSAGE_ID_PAD_PULL_RANGE_PRE,
GST_TRACER_MESSAGE_ID_PAD_PULL_RANGE_POST,
GST_TRACER_MESSAGE_ID_PAD_PUSH_EVENT_PRE,
GST_TRACER_MESSAGE_ID_PAD_PUSH_EVENT_POST,
GST_TRACER_MESSAGE_ID_ELEMENT_POST_MESSAGE_PRE,
GST_TRACER_MESSAGE_ID_ELEMENT_POST_MESSAGE_POST,
GST_TRACER_MESSAGE_ID_ELEMENT_QUERY_PRE,
GST_TRACER_MESSAGE_ID_ELEMENT_QUERY_POST,
GST_TRACER_MESSAGE_ID_LAST
} GstTracerMessageId;
/* tracing hooks */
void _priv_gst_tracer_init (void);
void _priv_gst_tracer_deinit (void);
/* tracing modules */
gboolean gst_tracer_register (GstPlugin * plugin, const gchar * name, GType type);
/* tracing helpers */
void gst_tracer_dispatch (GstTracerHookId hid, GstTracerMessageId mid, ...);
/* tracing module helpers */
void gst_tracer_log_trace (GstStructure * s);
extern gboolean _priv_tracer_enabled;
extern GList *_priv_tracers[GST_TRACER_HOOK_ID_LAST];
#define GST_TRACER_IS_ENABLED(id) \
(_priv_tracer_enabled && (_priv_tracers[id] != NULL))
#define GST_TRACER_TS \
GST_CLOCK_DIFF (_priv_gst_info_start_time, gst_util_get_timestamp ())
/* tracing hooks */
#define GST_TRACER_PAD_PUSH_PRE(pad, buffer) G_STMT_START{ \
if (GST_TRACER_IS_ENABLED(GST_TRACER_HOOK_ID_BUFFERS)) { \
gst_tracer_dispatch (GST_TRACER_HOOK_ID_BUFFERS, \
GST_TRACER_MESSAGE_ID_PAD_PUSH_PRE, GST_TRACER_TS, \
pad, buffer); \
} \
}G_STMT_END
#define GST_TRACER_PAD_PUSH_POST(pad, res) G_STMT_START{ \
if (GST_TRACER_IS_ENABLED(GST_TRACER_HOOK_ID_BUFFERS)) { \
gst_tracer_dispatch (GST_TRACER_HOOK_ID_BUFFERS, \
GST_TRACER_MESSAGE_ID_PAD_PUSH_POST, GST_TRACER_TS, \
pad, res); \
} \
}G_STMT_END
#define GST_TRACER_PAD_PUSH_LIST_PRE(pad, list) G_STMT_START{ \
if (GST_TRACER_IS_ENABLED(GST_TRACER_HOOK_ID_BUFFERS)) { \
gst_tracer_dispatch (GST_TRACER_HOOK_ID_BUFFERS, \
GST_TRACER_MESSAGE_ID_PAD_PUSH_LIST_PRE, GST_TRACER_TS, \
pad, list); \
} \
}G_STMT_END
#define GST_TRACER_PAD_PUSH_LIST_POST(pad, res) G_STMT_START{ \
if (GST_TRACER_IS_ENABLED(GST_TRACER_HOOK_ID_BUFFERS)) { \
gst_tracer_dispatch (GST_TRACER_HOOK_ID_BUFFERS, \
GST_TRACER_MESSAGE_ID_PAD_PUSH_LIST_POST, GST_TRACER_TS, \
pad, res); \
} \
}G_STMT_END
#define GST_TRACER_PAD_PULL_RANGE_PRE(pad, offset, size) G_STMT_START{ \
if (GST_TRACER_IS_ENABLED(GST_TRACER_HOOK_ID_BUFFERS)) { \
gst_tracer_dispatch (GST_TRACER_HOOK_ID_BUFFERS, \
GST_TRACER_MESSAGE_ID_PAD_PULL_RANGE_PRE, GST_TRACER_TS, \
pad, offset, size); \
} \
}G_STMT_END
#define GST_TRACER_PAD_PULL_RANGE_POST(pad, buffer, res) G_STMT_START{ \
if (GST_TRACER_IS_ENABLED(GST_TRACER_HOOK_ID_BUFFERS)) { \
gst_tracer_dispatch (GST_TRACER_HOOK_ID_BUFFERS, \
GST_TRACER_MESSAGE_ID_PAD_PULL_RANGE_POST, GST_TRACER_TS, \
pad, buffer, res); \
} \
}G_STMT_END
#define GST_TRACER_PAD_PUSH_EVENT_PRE(pad, event) G_STMT_START{ \
if (GST_TRACER_IS_ENABLED(GST_TRACER_HOOK_ID_EVENTS)) { \
gst_tracer_dispatch (GST_TRACER_HOOK_ID_EVENTS, \
GST_TRACER_MESSAGE_ID_PAD_PUSH_EVENT_PRE, GST_TRACER_TS, \
pad, event); \
} \
}G_STMT_END
#define GST_TRACER_PAD_PUSH_EVENT_POST(pad, res) G_STMT_START{ \
if (GST_TRACER_IS_ENABLED(GST_TRACER_HOOK_ID_EVENTS)) { \
gst_tracer_dispatch (GST_TRACER_HOOK_ID_EVENTS, \
GST_TRACER_MESSAGE_ID_PAD_PUSH_EVENT_POST, GST_TRACER_TS, \
pad, res); \
} \
}G_STMT_END
#define GST_TRACER_ELEMENT_POST_MESSAGE_PRE(element, message) G_STMT_START{ \
if (GST_TRACER_IS_ENABLED(GST_TRACER_HOOK_ID_MESSAGES)) { \
gst_tracer_dispatch (GST_TRACER_HOOK_ID_MESSAGES, \
GST_TRACER_MESSAGE_ID_ELEMENT_POST_MESSAGE_PRE, GST_TRACER_TS, \
element, message); \
} \
}G_STMT_END
#define GST_TRACER_ELEMENT_POST_MESSAGE_POST(element, res) G_STMT_START{ \
if (GST_TRACER_IS_ENABLED(GST_TRACER_HOOK_ID_MESSAGES)) { \
gst_tracer_dispatch (GST_TRACER_HOOK_ID_MESSAGES, \
GST_TRACER_MESSAGE_ID_ELEMENT_POST_MESSAGE_POST, GST_TRACER_TS, \
element, res); \
} \
}G_STMT_END
#define GST_TRACER_ELEMENT_QUERY_PRE(element, query) G_STMT_START{ \
if (GST_TRACER_IS_ENABLED(GST_TRACER_HOOK_ID_QUERIES)) { \
gst_tracer_dispatch (GST_TRACER_HOOK_ID_QUERIES, \
GST_TRACER_MESSAGE_ID_ELEMENT_QUERY_PRE, GST_TRACER_TS, \
element, query); \
} \
}G_STMT_END
#define GST_TRACER_ELEMENT_QUERY_POST(element, res) G_STMT_START{ \
if (GST_TRACER_IS_ENABLED(GST_TRACER_HOOK_ID_QUERIES)) { \
gst_tracer_dispatch (GST_TRACER_HOOK_ID_QUERIES, \
GST_TRACER_MESSAGE_ID_ELEMENT_QUERY_POST, GST_TRACER_TS, \
element, res); \
} \
}G_STMT_END
#else /* !GST_DISABLE_GST_DEBUG */
#define GST_TRACER_PAD_PUSH_PRE(pad, buffer)
#define GST_TRACER_PAD_PUSH_POST(pad, res)
#define GST_TRACER_PAD_PUSH_LIST_PRE(pad, list)
#define GST_TRACER_PAD_PUSH_LIST_POST(pad, res)
#define GST_TRACER_PAD_PULL_RANGE_PRE(pad, offset, size)
#define GST_TRACER_PAD_PULL_RANGE_POST(pad, buffer, res)
#define GST_TRACER_PAD_PUSH_EVENT_PRE(pad, event)
#define GST_TRACER_PAD_PUSH_EVENT_POST(pad, res)
#define GST_TRACER_ELEMENT_POST_MESSAGE_PRE(element, message)
#define GST_TRACER_ELEMENT_POST_MESSAGE_POST(element, res)
#define GST_TRACER_ELEMENT_QUERY_PRE(element, query)
#define GST_TRACER_ELEMENT_QUERY_POST(element, res)
#endif /* GST_DISABLE_GST_DEBUG */
G_END_DECLS
#endif /* __GST_TRACER_UTILS_H__ */

View file

@ -15,7 +15,8 @@ libgstcoretracers_la_SOURCES = \
gststats.c \
gsttracers.c
libgstcoretracers_la_CFLAGS = $(GST_OBJ_CFLAGS)
libgstcoretracers_la_CFLAGS = $(GST_OBJ_CFLAGS) \
-DGST_USE_UNSTABLE_API
libgstcoretracers_la_LIBADD = \
$(top_builddir)/gst/printf/libgstprintf.la \
$(GST_OBJ_LIBS)

View file

@ -23,6 +23,7 @@
#define __GST_LATENCY_TRACER_H__
#include <gst/gst.h>
#include <gst/gsttracer.h>
G_BEGIN_DECLS

View file

@ -23,6 +23,7 @@
#define __GST_LOG_TRACER_H__
#include <gst/gst.h>
#include <gst/gsttracer.h>
G_BEGIN_DECLS

View file

@ -23,6 +23,7 @@
#define __GST_RUSAGE_TRACER_H__
#include <gst/gst.h>
#include <gst/gsttracer.h>
G_BEGIN_DECLS

View file

@ -23,6 +23,7 @@
#define __GST_STATS_TRACER_H__
#include <gst/gst.h>
#include <gst/gsttracer.h>
G_BEGIN_DECLS