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