2 * Copyright (C) 2013 Stefan Sauer <ensonic@users.sf.net>
4 * gsttracer.h: tracing subsystem
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
22 #ifndef __GST_TRACER_H__
23 #define __GST_TRACER_H__
26 #include <glib-object.h>
27 #include <gst/gstconfig.h>
28 #include <gst/gstbin.h>
32 #ifndef GST_DISABLE_GST_DEBUG
34 /* hook flags and ids */
38 GST_TRACER_HOOK_NONE = 0,
39 GST_TRACER_HOOK_BUFFERS = (1 << 0),
40 GST_TRACER_HOOK_EVENTS = (1 << 1),
41 GST_TRACER_HOOK_MESSAGES = (1 << 2),
42 GST_TRACER_HOOK_QUERIES = (1 << 3),
43 GST_TRACER_HOOK_TOPOLOGY = (1 << 4),
47 GST_TRACER_HOOK_ALL = (1 << 5) - 1
52 GST_TRACER_HOOK_ID_BUFFERS = 0,
53 GST_TRACER_HOOK_ID_EVENTS,
54 GST_TRACER_HOOK_ID_MESSAGES,
55 GST_TRACER_HOOK_ID_QUERIES,
56 GST_TRACER_HOOK_ID_TOPLOGY,
58 GST_TRACER_HOOK_ID_TIMER
60 GST_TRACER_HOOK_ID_LAST
65 GST_TRACER_MESSAGE_ID_PAD_PUSH_PRE = 0,
66 GST_TRACER_MESSAGE_ID_PAD_PUSH_POST,
67 GST_TRACER_MESSAGE_ID_PAD_PUSH_LIST_PRE,
68 GST_TRACER_MESSAGE_ID_PAD_PUSH_LIST_POST,
69 GST_TRACER_MESSAGE_ID_LAST
74 typedef struct _GstTracer GstTracer;
75 typedef struct _GstTracerPrivate GstTracerPrivate;
76 typedef struct _GstTracerClass GstTracerClass;
78 #define GST_TYPE_TRACER (gst_tracer_get_type())
79 #define GST_TRACER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_TRACER,GstTracer))
80 #define GST_TRACER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_TRACER,GstTracerClass))
81 #define GST_IS_TRACER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_TRACER))
82 #define GST_IS_TRACER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_TRACER))
83 #define GST_TRACER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_TRACER,GstTracerClass))
84 #define GST_TRACER_CAST(obj) ((GstTracer *)(obj))
89 GstTracerPrivate *priv;
90 gpointer _gst_reserved[GST_PADDING];
93 typedef void (*GstTracerInvokeFunction) (GstTracer * self, GstTracerHookId hid,
94 GstTracerMessageId mid, va_list var_args);
96 struct _GstTracerClass {
97 GstObjectClass parent_class;
100 GstTracerInvokeFunction invoke;
103 gpointer _gst_reserved[GST_PADDING];
106 GType gst_tracer_get_type (void);
110 void _priv_gst_tracer_init (void);
111 void _priv_gst_tracer_deinit (void);
113 gboolean gst_tracer_register (GstPlugin * plugin, const gchar * name, GType type);
114 void gst_tracer_dispatch (GstTracerHookId hid, GstTracerMessageId mid, ...);
116 extern gboolean _priv_tracer_enabled;
117 extern GList *_priv_tracers[GST_TRACER_HOOK_ID_LAST];
119 #define GST_TRACER_IS_ENABLED(id) \
120 (_priv_tracer_enabled && (_priv_tracers[id] != NULL))
124 #define GST_TRACER_PAD_PUSH_PRE(pad, buffer) G_STMT_START{ \
125 if (GST_TRACER_IS_ENABLED(GST_TRACER_HOOK_ID_BUFFERS)) { \
126 gst_tracer_dispatch (GST_TRACER_HOOK_ID_BUFFERS, \
127 GST_TRACER_MESSAGE_ID_PAD_PUSH_PRE, gst_util_get_timestamp (), \
132 #define GST_TRACER_PAD_PUSH_POST(pad, res) G_STMT_START{ \
133 if (GST_TRACER_IS_ENABLED(GST_TRACER_HOOK_ID_BUFFERS)) { \
134 gst_tracer_dispatch (GST_TRACER_HOOK_ID_BUFFERS, \
135 GST_TRACER_MESSAGE_ID_PAD_PUSH_POST, gst_util_get_timestamp (), \
140 #define GST_TRACER_PAD_PUSH_LIST_PRE(pad, list) G_STMT_START{ \
141 if (GST_TRACER_IS_ENABLED(GST_TRACER_HOOK_ID_BUFFERS)) { \
142 gst_tracer_dispatch (GST_TRACER_HOOK_ID_BUFFERS, \
143 GST_TRACER_MESSAGE_ID_PAD_PUSH_LIST_PRE, gst_util_get_timestamp (), \
148 #define GST_TRACER_PAD_PUSH_LIST_POST(pad, res) G_STMT_START{ \
149 if (GST_TRACER_IS_ENABLED(GST_TRACER_HOOK_ID_BUFFERS)) { \
150 gst_tracer_dispatch (GST_TRACER_HOOK_ID_BUFFERS, \
151 GST_TRACER_MESSAGE_ID_PAD_PUSH_LIST_POST, gst_util_get_timestamp (), \
156 #else /* !GST_DISABLE_GST_DEBUG */
158 #define GST_TRACER_PAD_PUSH_PRE(pad, buffer)
159 #define GST_TRACER_PAD_PUSH_POST(pad, res)
160 #define GST_TRACER_PAD_PUSH_LIST_PRE(pad, list)
161 #define GST_TRACER_PAD_PUSH_LIST_POST(pad, res)
163 #endif /* GST_DISABLE_GST_DEBUG */
167 #endif /* __GST_TRACER_H__ */