tracing: add hooks when objects or miniobjects are created and destroyed
[platform/upstream/gstreamer.git] / gst / gsttracerutils.h
1 /* GStreamer
2  * Copyright (C) 2013 Stefan Sauer <ensonic@users.sf.net>
3  *
4  * gsttracerutils.h: tracing subsystem
5  *
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.
10  *
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.
15  *
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.
20  */
21
22
23 #ifndef __GST_TRACER_UTILS_H__
24 #define __GST_TRACER_UTILS_H__
25
26 #include <glib.h>
27 #include <glib-object.h>
28 #include <gst/gstconfig.h>
29 #include <gst/gstbin.h>
30 #include <gst/gstutils.h>
31
32 G_BEGIN_DECLS
33
34 #ifndef GST_DISABLE_GST_TRACER_HOOKS
35
36 /* tracing hooks */
37
38 void _priv_gst_tracing_init (void);
39 void _priv_gst_tracing_deinit (void);
40
41 /* tracer quarks */
42
43 /* These enums need to match the number and order
44  * of strings declared in _quark_table, in gsttracerutils.c */
45 typedef enum /*< skip >*/
46 {
47   GST_TRACER_QUARK_HOOK_PAD_PUSH_PRE = 0,
48   GST_TRACER_QUARK_HOOK_PAD_PUSH_POST,
49   GST_TRACER_QUARK_HOOK_PAD_PUSH_LIST_PRE,
50   GST_TRACER_QUARK_HOOK_PAD_PUSH_LIST_POST,
51   GST_TRACER_QUARK_HOOK_PAD_PULL_RANGE_PRE,
52   GST_TRACER_QUARK_HOOK_PAD_PULL_RANGE_POST,
53   GST_TRACER_QUARK_HOOK_PAD_PUSH_EVENT_PRE ,
54   GST_TRACER_QUARK_HOOK_PAD_PUSH_EVENT_POST,
55   GST_TRACER_QUARK_HOOK_PAD_QUERY_PRE ,
56   GST_TRACER_QUARK_HOOK_PAD_QUERY_POST,
57   GST_TRACER_QUARK_HOOK_ELEMENT_POST_MESSAGE_PRE,
58   GST_TRACER_QUARK_HOOK_ELEMENT_POST_MESSAGE_POST,
59   GST_TRACER_QUARK_HOOK_ELEMENT_QUERY_PRE,
60   GST_TRACER_QUARK_HOOK_ELEMENT_QUERY_POST,
61   GST_TRACER_QUARK_HOOK_ELEMENT_NEW,
62   GST_TRACER_QUARK_HOOK_ELEMENT_ADD_PAD,
63   GST_TRACER_QUARK_HOOK_ELEMENT_REMOVE_PAD,
64   GST_TRACER_QUARK_HOOK_BIN_ADD_PRE,
65   GST_TRACER_QUARK_HOOK_BIN_ADD_POST,
66   GST_TRACER_QUARK_HOOK_BIN_REMOVE_PRE,
67   GST_TRACER_QUARK_HOOK_BIN_REMOVE_POST,
68   GST_TRACER_QUARK_HOOK_PAD_LINK_PRE,
69   GST_TRACER_QUARK_HOOK_PAD_LINK_POST,
70   GST_TRACER_QUARK_HOOK_PAD_UNLINK_PRE,
71   GST_TRACER_QUARK_HOOK_PAD_UNLINK_POST,
72   GST_TRACER_QUARK_HOOK_ELEMENT_CHANGE_STATE_PRE,
73   GST_TRACER_QUARK_HOOK_ELEMENT_CHANGE_STATE_POST,
74   GST_TRACER_QUARK_HOOK_MINI_OBJECT_CREATED,
75   GST_TRACER_QUARK_HOOK_MINI_OBJECT_DESTROYED,
76   GST_TRACER_QUARK_HOOK_OBJECT_CREATED,
77   GST_TRACER_QUARK_HOOK_OBJECT_DESTROYED,
78   GST_TRACER_QUARK_MAX
79 } GstTracerQuarkId;
80
81 extern GQuark _priv_gst_tracer_quark_table[GST_TRACER_QUARK_MAX];
82
83 #define GST_TRACER_QUARK(q) _priv_gst_tracer_quark_table[GST_TRACER_QUARK_##q]
84
85 /* tracing module helpers */
86
87 typedef struct {
88   GObject *tracer;
89   GCallback func;
90 } GstTracerHook;
91
92 extern gboolean _priv_tracer_enabled;
93 /* key are hook-id quarks, values are GstTracerHook */
94 extern GHashTable *_priv_tracers;
95
96 #define GST_TRACER_IS_ENABLED (_priv_tracer_enabled)
97
98 #define GST_TRACER_TS \
99   GST_CLOCK_DIFF (_priv_gst_start_time, gst_util_get_timestamp ())
100
101 /* tracing hooks */
102
103 #define GST_TRACER_ARGS h->tracer, ts
104 #define GST_TRACER_DISPATCH(key,type,args) G_STMT_START{ \
105   if (GST_TRACER_IS_ENABLED) {                                         \
106     GstClockTime ts = GST_TRACER_TS;                                   \
107     GList *__l, *__n;                                                  \
108     GstTracerHook *h;                                                  \
109     __l = g_hash_table_lookup (_priv_tracers, GINT_TO_POINTER (key));  \
110     for (__n = __l; __n; __n = g_list_next (__n)) {                    \
111       h = (GstTracerHook *) __n->data;                                 \
112       ((type)(h->func)) args;                                          \
113     }                                                                  \
114     __l = g_hash_table_lookup (_priv_tracers, NULL);                   \
115     for (__n = __l; __n; __n = g_list_next (__n)) {                    \
116       h = (GstTracerHook *) __n->data;                                 \
117       ((type)(h->func)) args;                                          \
118     }                                                                  \
119   }                                                                    \
120 }G_STMT_END
121
122 /**
123  * GstTracerHookPadPushPre:
124  * @self: the tracer instance
125  * @ts: the current timestamp
126  * @pad: the pad
127  * @buffer: the buffer
128  *
129  * Pre-hook for gst_pad_push() named "pad-push-pre".
130  */
131 typedef void (*GstTracerHookPadPushPre) (GObject *self, GstClockTime ts,
132     GstPad *pad, GstBuffer *buffer);
133 #define GST_TRACER_PAD_PUSH_PRE(pad, buffer) G_STMT_START{ \
134   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_PUSH_PRE), \
135     GstTracerHookPadPushPre, (GST_TRACER_ARGS, pad, buffer)); \
136 }G_STMT_END
137
138 /**
139  * GstTracerHookPadPushPost:
140  * @self: the tracer instance
141  * @ts: the current timestamp
142  * @pad: the pad
143  * @res: the result of gst_pad_push()
144  *
145  * Post-hook for gst_pad_push() named "pad-push-post".
146  */
147 typedef void (*GstTracerHookPadPushPost) (GObject * self, GstClockTime ts,
148     GstPad *pad, GstFlowReturn res);
149 #define GST_TRACER_PAD_PUSH_POST(pad, res) G_STMT_START{ \
150   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_PUSH_POST), \
151     GstTracerHookPadPushPost, (GST_TRACER_ARGS, pad, res)); \
152 }G_STMT_END
153
154 /**
155  * GstTracerHookPadPushListPre:
156  * @self: the tracer instance
157  * @ts: the current timestamp
158  * @pad: the pad
159  * @list: the buffer-list
160  *
161  * Pre-hook for gst_pad_push_list() named "pad-push-list-pre".
162  */
163 typedef void (*GstTracerHookPadPushListPre) (GObject *self, GstClockTime ts,
164     GstPad *pad, GstBufferList *list);
165 #define GST_TRACER_PAD_PUSH_LIST_PRE(pad, list) G_STMT_START{ \
166   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_PUSH_LIST_PRE), \
167     GstTracerHookPadPushListPre, (GST_TRACER_ARGS, pad, list)); \
168 }G_STMT_END
169
170 /**
171  * GstTracerHookPadPushListPost:
172  * @self: the tracer instance
173  * @ts: the current timestamp
174  * @pad: the pad
175  * @res: the result of gst_pad_push_list()
176  *
177  * Post-hook for gst_pad_push_list() named "pad-push-list-post".
178  */
179 typedef void (*GstTracerHookPadPushListPost) (GObject *self, GstClockTime ts,
180     GstPad *pad,
181     GstFlowReturn res);
182 #define GST_TRACER_PAD_PUSH_LIST_POST(pad, res) G_STMT_START{ \
183   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_PUSH_LIST_POST), \
184     GstTracerHookPadPushListPost, (GST_TRACER_ARGS, pad, res)); \
185 }G_STMT_END
186
187 /**
188  * GstTracerHookPadPullRangePre:
189  * @self: the tracer instance
190  * @ts: the current timestamp
191  * @pad: the pad
192  * @offset: the stream offset
193  * @size: the requested size
194  *
195  * Pre-hook for gst_pad_pull_range() named "pad-pull-range-pre".
196  */
197 typedef void (*GstTracerHookPadPullRangePre) (GObject *self, GstClockTime ts,
198     GstPad *pad, guint64 offset, guint size);
199 #define GST_TRACER_PAD_PULL_RANGE_PRE(pad, offset, size) G_STMT_START{ \
200   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_PULL_RANGE_PRE), \
201     GstTracerHookPadPullRangePre, (GST_TRACER_ARGS, pad, offset, size)); \
202 }G_STMT_END
203
204 /**
205  * GstTracerHookPadPullRangePost:
206  * @self: the tracer instance
207  * @ts: the current timestamp
208  * @pad: the pad
209  * @buffer: the buffer
210  * @res: the result of gst_pad_pull_range()
211  *
212  * Post-hook for gst_pad_pull_range() named "pad-pull-range-post".
213  */
214 typedef void (*GstTracerHookPadPullRangePost) (GObject *self, GstClockTime ts,
215     GstPad *pad, GstBuffer *buffer, GstFlowReturn res);
216 #define GST_TRACER_PAD_PULL_RANGE_POST(pad, buffer, res) G_STMT_START{ \
217   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_PULL_RANGE_POST), \
218     GstTracerHookPadPullRangePost, (GST_TRACER_ARGS, pad, buffer, res)); \
219 }G_STMT_END
220
221 /**
222  * GstTracerHookPadPushEventPre:
223  * @self: the tracer instance
224  * @ts: the current timestamp
225  * @pad: the pad
226  * @event: the event
227  *
228  * Pre-hook for gst_pad_push_event() named "pad-push-event-pre".
229  */
230 typedef void (*GstTracerHookPadPushEventPre) (GObject *self, GstClockTime ts,
231     GstPad *pad, GstEvent *event);
232 #define GST_TRACER_PAD_PUSH_EVENT_PRE(pad, event) G_STMT_START{ \
233   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_PUSH_EVENT_PRE), \
234     GstTracerHookPadPushEventPre, (GST_TRACER_ARGS, pad, event)); \
235 }G_STMT_END
236
237 /**
238  * GstTracerHookPadPushEventPost:
239  * @self: the tracer instance
240  * @ts: the current timestamp
241  * @pad: the pad
242  * @res: the result of gst_pad_push_event()
243  *
244  * Post-hook for gst_pad_push_event() named "pad-push-event-post".
245  */
246 typedef void (*GstTracerHookPadPushEventPost) (GObject *self, GstClockTime ts,
247     GstPad *pad, gboolean res);
248 #define GST_TRACER_PAD_PUSH_EVENT_POST(pad, res) G_STMT_START{ \
249   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_PUSH_EVENT_POST), \
250     GstTracerHookPadPushEventPost, (GST_TRACER_ARGS, pad, res)); \
251 }G_STMT_END
252
253 /**
254  * GstTracerHookPadQueryPre:
255  * @self: the tracer instance
256  * @ts: the current timestamp
257  * @pad: the pad
258  * @query: the query
259  *
260  * Pre-hook for gst_pad_query() named "pad-query-pre".
261  */
262 typedef void (*GstTracerHookPadQueryPre) (GObject *self, GstClockTime ts,
263     GstPad *pad, GstQuery *query);
264 #define GST_TRACER_PAD_QUERY_PRE(pad, query) G_STMT_START{ \
265   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_QUERY_PRE), \
266     GstTracerHookPadQueryPre, (GST_TRACER_ARGS, pad, query)); \
267 }G_STMT_END
268
269 /**
270  * GstTracerHookPadQueryPost:
271  * @self: the tracer instance
272  * @ts: the current timestamp
273  * @pad: the pad
274  * @query: the query
275  * @res: the result of gst_pad_query()
276  *
277  * Post-hook for gst_pad_query() named "pad-query-post".
278  */
279 typedef void (*GstTracerHookPadQueryPost) (GObject *self, GstClockTime ts,
280     GstPad *pad, GstQuery *query, gboolean res);
281 #define GST_TRACER_PAD_QUERY_POST(pad, query, res) G_STMT_START{ \
282   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_QUERY_POST), \
283     GstTracerHookPadQueryPost, (GST_TRACER_ARGS, pad, query, res)); \
284 }G_STMT_END
285
286 /**
287  * GstTracerHookElementPostMessagePre:
288  * @self: the tracer instance
289  * @ts: the current timestamp
290  * @element: the element
291  * @message: the message
292  *
293  * Pre-hook for gst_element_post_message() named "element-post-message-pre".
294  */
295 typedef void (*GstTracerHookElementPostMessagePre) (GObject *self,
296     GstClockTime ts, GstElement *element, GstMessage *message);
297 #define GST_TRACER_ELEMENT_POST_MESSAGE_PRE(element, message) G_STMT_START{ \
298   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_ELEMENT_POST_MESSAGE_PRE), \
299     GstTracerHookElementPostMessagePre, (GST_TRACER_ARGS, element, message)); \
300 }G_STMT_END
301
302 /**
303  * GstTracerHookElementPostMessagePost:
304  * @self: the tracer instance
305  * @ts: the current timestamp
306  * @element: the element
307  * @res: the result of gst_element_post_message()
308  *
309  * Pre-hook for gst_element_post_message() named "element-post-message-post".
310  */
311 typedef void (*GstTracerHookElementPostMessagePost) (GObject *self,
312     GstClockTime ts, GstElement *element, gboolean res);
313 #define GST_TRACER_ELEMENT_POST_MESSAGE_POST(element, res) G_STMT_START{ \
314   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_ELEMENT_POST_MESSAGE_POST), \
315     GstTracerHookElementPostMessagePost, (GST_TRACER_ARGS, element, res)); \
316 }G_STMT_END
317
318 /**
319  * GstTracerHookElementQueryPre:
320  * @self: the tracer instance
321  * @ts: the current timestamp
322  * @element: the element
323  * @query: the query
324  *
325  * Pre-hook for gst_element_query() named "element-query-pre".
326  */
327 typedef void (*GstTracerHookElementQueryPre) (GObject *self, GstClockTime ts,
328     GstElement *element, GstQuery *query);
329 #define GST_TRACER_ELEMENT_QUERY_PRE(element, query) G_STMT_START{ \
330   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_ELEMENT_QUERY_PRE), \
331     GstTracerHookElementQueryPre, (GST_TRACER_ARGS, element, query)); \
332 }G_STMT_END
333
334 /**
335  * GstTracerHookElementQueryPost:
336  * @self: the tracer instance
337  * @ts: the current timestamp
338  * @element: the element
339  * @query: the query
340  * @res: the result of gst_element_query()
341  *
342  * Post-hook for gst_element_query() named "element-query-post".
343  */
344 typedef void (*GstTracerHookElementQueryPost) (GObject *self, GstClockTime ts,
345     GstElement *element, GstQuery *query, gboolean res);
346 #define GST_TRACER_ELEMENT_QUERY_POST(element, query, res) G_STMT_START{ \
347   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_ELEMENT_QUERY_POST), \
348     GstTracerHookElementQueryPost, (GST_TRACER_ARGS, element, query, res)); \
349 }G_STMT_END
350
351 /**
352  * GstTracerHookElementNew:
353  * @self: the tracer instance
354  * @ts: the current timestamp
355  * @element: the element
356  *
357  * Hook for gst_element_new() named "element-new".
358  */
359 typedef void (*GstTracerHookElementNew) (GObject *self, GstClockTime ts,
360     GstElement *element);
361 #define GST_TRACER_ELEMENT_NEW(element) G_STMT_START{ \
362   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_ELEMENT_NEW), \
363     GstTracerHookElementNew, (GST_TRACER_ARGS, element)); \
364 }G_STMT_END
365
366 /**
367  * GstTracerHookElementAddPad:
368  * @self: the tracer instance
369  * @ts: the current timestamp
370  * @element: the element
371  * @pad: the pad
372  *
373  * Hook for gst_element_add_pad() named "element-add-pad".
374  */
375 typedef void (*GstTracerHookElementAddPad) (GObject *self, GstClockTime ts,
376     GstElement *element, GstPad *pad);
377 #define GST_TRACER_ELEMENT_ADD_PAD(element, pad) G_STMT_START{ \
378   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_ELEMENT_ADD_PAD), \
379     GstTracerHookElementAddPad, (GST_TRACER_ARGS, element, pad)); \
380 }G_STMT_END
381
382 /**
383  * GstTracerHookElementRemovePad:
384  * @self: the tracer instance
385  * @ts: the current timestamp
386  * @element: the element
387  * @pad: the pad
388  *
389  * Hook for gst_element_remove_pad() named "element-remove-pad".
390  */
391 typedef void (*GstTracerHookElementRemovePad) (GObject *self, GstClockTime ts,
392     GstElement *element, GstPad *pad);
393 #define GST_TRACER_ELEMENT_REMOVE_PAD(element, pad) G_STMT_START{ \
394   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_ELEMENT_REMOVE_PAD), \
395     GstTracerHookElementRemovePad, (GST_TRACER_ARGS, element, pad)); \
396 }G_STMT_END
397
398 /**
399  * GstTracerHookElementChangeStatePre:
400  * @self: the tracer instance
401  * @ts: the current timestamp
402  * @element: the element
403  * @transition: the transition
404  *
405  * Pre-hook for gst_element_change_state() named "element-change-state-pre".
406  */
407 typedef void (*GstTracerHookElementChangeStatePre) (GObject *self,
408     GstClockTime ts, GstElement *element, GstStateChange transition);
409 #define GST_TRACER_ELEMENT_CHANGE_STATE_PRE(element, transition) G_STMT_START{ \
410   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_ELEMENT_CHANGE_STATE_PRE), \
411     GstTracerHookElementChangeStatePre, (GST_TRACER_ARGS, element, transition)); \
412 }G_STMT_END
413
414 /**
415  * GstTracerHookElementChangeStatePost:
416  * @self: the tracer instance
417  * @ts: the current timestamp
418  * @element: the element
419  * @transition: the transition
420  * @result: the result of gst_pad_push()
421  *
422  * Post-hook for gst_element_change_state() named "element-change-state-post".
423  */
424 typedef void (*GstTracerHookElementChangeStatePost) (GObject *self,
425     GstClockTime ts, GstElement *element, GstStateChange transition,
426     GstStateChangeReturn result);
427 #define GST_TRACER_ELEMENT_CHANGE_STATE_POST(element, transition, result) G_STMT_START{ \
428   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_ELEMENT_CHANGE_STATE_POST), \
429     GstTracerHookElementChangeStatePost, (GST_TRACER_ARGS, element, transition, result)); \
430 }G_STMT_END
431
432 /**
433  * GstTracerHookBinAddPre:
434  * @self: the tracer instance
435  * @ts: the current timestamp
436  * @bin: the bin
437  * @element: the element
438  *
439  * Pre-hook for gst_bin_add() named "bin-add-pre".
440  */
441 typedef void (*GstTracerHookBinAddPre) (GObject *self, GstClockTime ts,
442     GstBin *bin, GstElement *element);
443 #define GST_TRACER_BIN_ADD_PRE(bin, element) G_STMT_START{ \
444   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_BIN_ADD_PRE), \
445     GstTracerHookBinAddPre, (GST_TRACER_ARGS, bin, element)); \
446 }G_STMT_END
447
448 /**
449  * GstTracerHookBinAddPost:
450  * @self: the tracer instance
451  * @ts: the current timestamp
452  * @bin: the bin
453  * @element: the element
454  * @result: the result of gst_bin_add()
455  *
456  * Post-hook for gst_bin_add() named "bin-add-post".
457  */
458 typedef void (*GstTracerHookBinAddPost) (GObject *self, GstClockTime ts,
459     GstBin *bin, GstElement *element, gboolean result);
460 #define GST_TRACER_BIN_ADD_POST(bin, element, result) G_STMT_START{ \
461   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_BIN_ADD_POST), \
462     GstTracerHookBinAddPost, (GST_TRACER_ARGS, bin, element, result)); \
463 }G_STMT_END
464
465 /**
466  * GstTracerHookBinRemovePre:
467  * @self: the tracer instance
468  * @ts: the current timestamp
469  * @bin: the bin
470  * @element: the element
471  *
472  * Pre-hook for gst_bin_remove() named "bin-remove-pre".
473  */
474 typedef void (*GstTracerHookBinRemovePre) (GObject *self, GstClockTime ts,
475     GstBin *bin, GstElement *element);
476 #define GST_TRACER_BIN_REMOVE_PRE(bin, element) G_STMT_START{ \
477   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_BIN_REMOVE_PRE), \
478     GstTracerHookBinRemovePre, (GST_TRACER_ARGS, bin, element)); \
479 }G_STMT_END
480
481 /**
482  * GstTracerHookBinRemovePost:
483  * @self: the tracer instance
484  * @ts: the current timestamp
485  * @bin: the bin
486  * @result: the result of gst_bin_remove()
487  *
488  * Post-hook for gst_bin_remove() named "bin-remove-post".
489  */
490 typedef void (*GstTracerHookBinRemovePost) (GObject *self, GstClockTime ts,
491     GstBin *bin, gboolean result);
492 #define GST_TRACER_BIN_REMOVE_POST(bin, result) G_STMT_START{ \
493   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_BIN_REMOVE_POST), \
494     GstTracerHookBinRemovePost, (GST_TRACER_ARGS, bin, result)); \
495 }G_STMT_END
496
497 /**
498  * GstTracerHookPadLinkPre:
499  * @self: the tracer instance
500  * @ts: the current timestamp
501  * @srcpad: the srcpad
502  * @sinkpad: the sinkpad
503  *
504  * Pre-hook for gst_pad_link() named "pad-link-pre".
505  */
506 typedef void (*GstTracerHookPadLinkPre) (GObject *self, GstClockTime ts,
507     GstPad *srcpad, GstPad *sinkpad);
508 #define GST_TRACER_PAD_LINK_PRE(srcpad, sinkpad) G_STMT_START{ \
509   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_LINK_PRE), \
510     GstTracerHookPadLinkPre, (GST_TRACER_ARGS, srcpad, sinkpad)); \
511 }G_STMT_END
512
513 /**
514  * GstTracerHookPadLinkPost:
515  * @self: the tracer instance
516  * @ts: the current timestamp
517  * @srcpad: the srcpad
518  * @sinkpad: the sinkpad
519  * @result: the result of gst_pad_link()
520  *
521  * Post-hook for gst_pad_link() named "pad-link-post".
522  */
523 typedef void (*GstTracerHookPadLinkPost) (GObject *self, GstClockTime ts,
524     GstPad *srcpad, GstPad *sinkpad, GstPadLinkReturn result);
525 #define GST_TRACER_PAD_LINK_POST(srcpad, sinkpad, result) G_STMT_START{ \
526   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_LINK_POST), \
527     GstTracerHookPadLinkPost, (GST_TRACER_ARGS, srcpad, sinkpad, result)); \
528 }G_STMT_END
529
530 /**
531  * GstTracerHookPadUnlinkPre:
532  * @self: the tracer instance
533  * @ts: the current timestamp
534  * @srcpad: the srcpad
535  * @sinkpad: the sinkpad
536  *
537  * Pre-hook for gst_pad_unlink() named "pad-unlink-pre".
538  */
539 typedef void (*GstTracerHookPadUnlinkPre) (GObject *self, GstClockTime ts,
540     GstPad *srcpad, GstPad *sinkpad);
541 #define GST_TRACER_PAD_UNLINK_PRE(srcpad, sinkpad) G_STMT_START{ \
542   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_UNLINK_PRE), \
543     GstTracerHookPadUnlinkPre, (GST_TRACER_ARGS, srcpad, sinkpad)); \
544 }G_STMT_END
545
546 /**
547  * GstTracerHookPadUnlinkPost:
548  * @self: the tracer instance
549  * @ts: the current timestamp
550  * @srcpad: the srcpad
551  * @sinkpad: the sinkpad
552  * @result: the result of gst_pad_push()
553  *
554  * Post-hook for gst_pad_unlink() named "pad-unlink-post".
555  */
556 typedef void (*GstTracerHookPadUnlinkPost) (GObject *self, GstClockTime ts,
557     GstPad *srcpad, GstPad *sinkpad, gboolean result);
558 #define GST_TRACER_PAD_UNLINK_POST(srcpad, sinkpad, result) G_STMT_START{ \
559   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_UNLINK_POST), \
560     GstTracerHookPadUnlinkPost, (GST_TRACER_ARGS, srcpad, sinkpad, result)); \
561 }G_STMT_END
562
563 /**
564  * GstTracerHookMiniObjectCreated:
565  * @self: the tracer instance
566  * @ts: the current timestamp
567  * @object: the mini object being created
568  *
569  * Hook called when a #GstMiniObject is created named "mini-object-created".
570  */
571 typedef void (*GstTracerHookMiniObjectCreated) (GObject *self, GstClockTime ts,
572     GstMiniObject *object);
573 #define GST_TRACER_MINI_OBJECT_CREATED(object) G_STMT_START{ \
574   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_MINI_OBJECT_CREATED), \
575     GstTracerHookMiniObjectCreated, (GST_TRACER_ARGS, object)); \
576 }G_STMT_END
577
578 /**
579  * GstTracerHookMiniObjectDestroyed:
580  * @self: the tracer instance
581  * @ts: the current timestamp
582  * @object: the mini object being destroyed
583  *
584  * Hook called when a #GstMiniObject is being destroyed named
585  * "mini-object-destroyed".
586  */
587 typedef void (*GstTracerHookMiniObjectDestroyed) (GObject *self, GstClockTime ts,
588     GstMiniObject *object);
589 #define GST_TRACER_MINI_OBJECT_DESTROYED(object) G_STMT_START{ \
590   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_MINI_OBJECT_DESTROYED), \
591     GstTracerHookMiniObjectDestroyed, (GST_TRACER_ARGS, object)); \
592 }G_STMT_END
593
594 /**
595  * GstTracerHookObjectCreated:
596  * @self: the tracer instance
597  * @ts: the current timestamp
598  * @object: the object being created
599  *
600  * Hook called when a #GstObject is created named "object-created".
601  */
602 typedef void (*GstTracerHookObjectCreated) (GObject *self, GstClockTime ts,
603     GstObject *object);
604 #define GST_TRACER_OBJECT_CREATED(object) G_STMT_START{ \
605   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_OBJECT_CREATED), \
606     GstTracerHookObjectCreated, (GST_TRACER_ARGS, object)); \
607 }G_STMT_END
608
609 /**
610  * GstTracerHookObjectDestroyed:
611  * @self: the tracer instance
612  * @ts: the current timestamp
613  * @object: the object being destroyed
614  *
615  * Hook called when a #GstObject is being destroyed named
616  * "object-destroyed".
617  */
618 typedef void (*GstTracerHookObjectDestroyed) (GObject *self, GstClockTime ts,
619     GstObject *object);
620 #define GST_TRACER_OBJECT_DESTROYED(object) G_STMT_START{ \
621   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_OBJECT_DESTROYED), \
622     GstTracerHookObjectDestroyed, (GST_TRACER_ARGS, object)); \
623 }G_STMT_END
624
625
626 #else /* !GST_DISABLE_GST_TRACER_HOOKS */
627
628 #define GST_TRACER_PAD_PUSH_PRE(pad, buffer)
629 #define GST_TRACER_PAD_PUSH_POST(pad, res)
630 #define GST_TRACER_PAD_PUSH_LIST_PRE(pad, list)
631 #define GST_TRACER_PAD_PUSH_LIST_POST(pad, res)
632 #define GST_TRACER_PAD_PULL_RANGE_PRE(pad, offset, size)
633 #define GST_TRACER_PAD_PULL_RANGE_POST(pad, buffer, res)
634 #define GST_TRACER_PAD_PUSH_EVENT_PRE(pad, event)
635 #define GST_TRACER_PAD_PUSH_EVENT_POST(pad, res)
636 #define GST_TRACER_PAD_QUERY_PRE(pad, query)
637 #define GST_TRACER_PAD_QUERY_POST(pad, query, res)
638 #define GST_TRACER_ELEMENT_POST_MESSAGE_PRE(element, message)
639 #define GST_TRACER_ELEMENT_POST_MESSAGE_POST(element, res)
640 #define GST_TRACER_ELEMENT_QUERY_PRE(element, query)
641 #define GST_TRACER_ELEMENT_QUERY_POST(element, query, res)
642 #define GST_TRACER_ELEMENT_NEW(element)
643 #define GST_TRACER_ELEMENT_ADD_PAD(element, pad)
644 #define GST_TRACER_ELEMENT_REMOVE_PAD(element, pad)
645 #define GST_TRACER_ELEMENT_CHANGE_STATE_PRE(element, transition)
646 #define GST_TRACER_ELEMENT_CHANGE_STATE_POST(element, transition, res)
647 #define GST_TRACER_BIN_ADD_PRE(bin, element)
648 #define GST_TRACER_BIN_ADD_POST(bin, element, res)
649 #define GST_TRACER_BIN_REMOVE_PRE(bin, element)
650 #define GST_TRACER_BIN_REMOVE_POST(bin, res)
651 #define GST_TRACER_PAD_LINK_PRE(srcpad, sinkpad)
652 #define GST_TRACER_PAD_LINK_POST(srcpad, sinkpad, res)
653 #define GST_TRACER_PAD_UNLINK_PRE(srcpad, sinkpad)
654 #define GST_TRACER_PAD_UNLINK_POST(srcpad, sinkpad, res)
655 #define GST_TRACER_MINI_OBJECT_CREATED(object)
656 #define GST_TRACER_MINI_OBJECT_DESTROYED(object)
657 #define GST_TRACER_OBJECT_CREATED(object)
658 #define GST_TRACER_OBJECT_DESTROYED(object)
659
660 #endif /* GST_DISABLE_GST_TRACER_HOOKS */
661
662 G_END_DECLS
663
664 #endif /* __GST_TRACER_UTILS_H__ */
665