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 typedef struct _GstTracer GstTracer;
66 typedef struct _GstTracerPrivate GstTracerPrivate;
67 typedef struct _GstTracerClass GstTracerClass;
69 #define GST_TYPE_TRACER (gst_tracer_get_type())
70 #define GST_TRACER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_TRACER,GstTracer))
71 #define GST_TRACER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_TRACER,GstTracerClass))
72 #define GST_IS_TRACER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_TRACER))
73 #define GST_IS_TRACER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_TRACER))
74 #define GST_TRACER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_TRACER,GstTracerClass))
75 #define GST_TRACER_CAST(obj) ((GstTracer *)(obj))
80 GstTracerPrivate *priv;
81 gpointer _gst_reserved[GST_PADDING];
84 typedef void (*GstTracerInvokeFunction) (GstTracer * self, GstTracerHookId id,
85 guint64 ts, GstStructure *s);
87 struct _GstTracerClass {
88 GstObjectClass parent_class;
91 GstTracerInvokeFunction invoke;
94 gpointer _gst_reserved[GST_PADDING];
97 GType gst_tracer_get_type (void);
101 void _priv_gst_tracer_init (void);
102 void _priv_gst_tracer_deinit (void);
104 gboolean gst_tracer_register (GstPlugin * plugin, const gchar * name, GType type);
106 gboolean gst_tracer_is_enabled (GstTracerHookId id);
108 void gst_tracer_push_pre (guint64 ts, GstPad *pad, GstBuffer *buffer);
109 void gst_tracer_push_post (guint64 ts, GstPad *pad, GstFlowReturn res);
110 void gst_tracer_push_list_pre (guint64 ts, GstPad * pad, GstBufferList * list);
111 void gst_tracer_push_list_post (guint64 ts, GstPad * pad, GstFlowReturn res);
113 #define GST_TRACER_PAD_PUSH_PRE(pad, buffer) G_STMT_START{ \
114 if (gst_tracer_is_enabled (GST_TRACER_HOOK_ID_BUFFERS)) \
115 gst_tracer_push_pre (gst_util_get_timestamp (), pad, buffer); \
118 #define GST_TRACER_PAD_PUSH_POST(pad, res) G_STMT_START{ \
119 if (gst_tracer_is_enabled (GST_TRACER_HOOK_ID_BUFFERS)) \
120 gst_tracer_push_post (gst_util_get_timestamp (), pad, res); \
123 #define GST_TRACER_PAD_PUSH_LIST_PRE(pad, list) G_STMT_START{ \
124 if (gst_tracer_is_enabled (GST_TRACER_HOOK_ID_BUFFERS)) \
125 gst_tracer_push_list_pre (gst_util_get_timestamp (), pad, list); \
128 #define GST_TRACER_PAD_PUSH_LIST_POST(pad, res) G_STMT_START{ \
129 if (gst_tracer_is_enabled (GST_TRACER_HOOK_ID_BUFFERS)) \
130 gst_tracer_push_list_post (gst_util_get_timestamp (), pad, res); \
133 #else /* !GST_DISABLE_GST_DEBUG */
135 #define GST_TRACER_PAD_PUSH_PRE(pad, buffer)
136 #define GST_TRACER_PAD_PUSH_POST(pad, res)
137 #define GST_TRACER_PAD_PUSH_LIST_PRE(pad, list)
138 #define GST_TRACER_PAD_PUSH_LIST_POST(pad, res)
140 #endif /* GST_DISABLE_GST_DEBUG */
144 #endif /* __GST_TRACER_H__ */