tracer: harmonize the query hooks
[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  * @query: the query
270  * @res: the result of gst_pad_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, GstQuery *query, gboolean res);
276 #define GST_TRACER_PAD_QUERY_POST(pad, query, res) G_STMT_START{ \
277   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_QUERY_POST), \
278     GstTracerHookPadQueryPost, (GST_TRACER_ARGS, pad, query, res)); \
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  * @query: the query
335  * @res: the result of gst_element_query()
336  *
337  * Post-hook for gst_element_query() named "element-query-post".
338  */
339 typedef void (*GstTracerHookElementQueryPost) (GObject *self, GstClockTime ts,
340     GstElement *element, GstQuery *query, gboolean res);
341 #define GST_TRACER_ELEMENT_QUERY_POST(element, query, res) G_STMT_START{ \
342   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_ELEMENT_QUERY_POST), \
343     GstTracerHookElementQueryPost, (GST_TRACER_ARGS, element, query, res)); \
344 }G_STMT_END
345
346 /**
347  * GstTracerHookElementNew:
348  * @self: the tracer instance
349  * @ts: the current timestamp
350  * @element: the element
351  *
352  * Hook for gst_element_new() named "element-new".
353  */
354 typedef void (*GstTracerHookElementNew) (GObject *self, GstClockTime ts,
355     GstElement *element);
356 #define GST_TRACER_ELEMENT_NEW(element) G_STMT_START{ \
357   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_ELEMENT_NEW), \
358     GstTracerHookElementNew, (GST_TRACER_ARGS, element)); \
359 }G_STMT_END
360
361 /**
362  * GstTracerHookElementAddPad:
363  * @self: the tracer instance
364  * @ts: the current timestamp
365  * @element: the element
366  * @pad: the pad
367  *
368  * Hook for gst_element_add_pad() named "element-add-pad".
369  */
370 typedef void (*GstTracerHookElementAddPad) (GObject *self, GstClockTime ts,
371     GstElement *element, GstPad *pad);
372 #define GST_TRACER_ELEMENT_ADD_PAD(element, pad) G_STMT_START{ \
373   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_ELEMENT_ADD_PAD), \
374     GstTracerHookElementAddPad, (GST_TRACER_ARGS, element, pad)); \
375 }G_STMT_END
376
377 /**
378  * GstTracerHookElementRemovePad:
379  * @self: the tracer instance
380  * @ts: the current timestamp
381  * @element: the element
382  * @pad: the pad
383  *
384  * Hook for gst_element_remove_pad() named "element-remove-pad".
385  */
386 typedef void (*GstTracerHookElementRemovePad) (GObject *self, GstClockTime ts,
387     GstElement *element, GstPad *pad);
388 #define GST_TRACER_ELEMENT_REMOVE_PAD(element, pad) G_STMT_START{ \
389   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_ELEMENT_REMOVE_PAD), \
390     GstTracerHookElementRemovePad, (GST_TRACER_ARGS, element, pad)); \
391 }G_STMT_END
392
393 /**
394  * GstTracerHookElementChangeStatePre:
395  * @self: the tracer instance
396  * @ts: the current timestamp
397  * @element: the element
398  * @transition: the transition
399  *
400  * Pre-hook for gst_element_change_state() named "element-change-state-pre".
401  */
402 typedef void (*GstTracerHookElementChangeStatePre) (GObject *self,
403     GstClockTime ts, GstElement *element, GstStateChange transition);
404 #define GST_TRACER_ELEMENT_CHANGE_STATE_PRE(element, transition) G_STMT_START{ \
405   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_ELEMENT_CHANGE_STATE_PRE), \
406     GstTracerHookElementChangeStatePre, (GST_TRACER_ARGS, element, transition)); \
407 }G_STMT_END
408
409 /**
410  * GstTracerHookElementChangeStatePost:
411  * @self: the tracer instance
412  * @ts: the current timestamp
413  * @element: the element
414  * @transition: the transition
415  * @result: the result of gst_pad_push()
416  *
417  * Post-hook for gst_element_change_state() named "element-change-state-post".
418  */
419 typedef void (*GstTracerHookElementChangeStatePost) (GObject *self,
420     GstClockTime ts, GstElement *element, GstStateChange transition,
421     GstStateChangeReturn result);
422 #define GST_TRACER_ELEMENT_CHANGE_STATE_POST(element, transition, result) G_STMT_START{ \
423   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_ELEMENT_CHANGE_STATE_POST), \
424     GstTracerHookElementChangeStatePost, (GST_TRACER_ARGS, element, transition, result)); \
425 }G_STMT_END
426
427 /**
428  * GstTracerHookBinAddPre:
429  * @self: the tracer instance
430  * @ts: the current timestamp
431  * @bin: the bin
432  * @element: the element
433  *
434  * Pre-hook for gst_bin_add() named "bin-add-pre".
435  */
436 typedef void (*GstTracerHookBinAddPre) (GObject *self, GstClockTime ts,
437     GstBin *bin, GstElement *element);
438 #define GST_TRACER_BIN_ADD_PRE(bin, element) G_STMT_START{ \
439   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_BIN_ADD_PRE), \
440     GstTracerHookBinAddPre, (GST_TRACER_ARGS, bin, element)); \
441 }G_STMT_END
442
443 /**
444  * GstTracerHookBinAddPost:
445  * @self: the tracer instance
446  * @ts: the current timestamp
447  * @bin: the bin
448  * @element: the element
449  * @result: the result of gst_bin_add()
450  *
451  * Post-hook for gst_bin_add() named "bin-add-post".
452  */
453 typedef void (*GstTracerHookBinAddPost) (GObject *self, GstClockTime ts,
454     GstBin *bin, GstElement *element, gboolean result);
455 #define GST_TRACER_BIN_ADD_POST(bin, element, result) G_STMT_START{ \
456   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_BIN_ADD_POST), \
457     GstTracerHookBinAddPost, (GST_TRACER_ARGS, bin, element, result)); \
458 }G_STMT_END
459
460 /**
461  * GstTracerHookBinRemovePre:
462  * @self: the tracer instance
463  * @ts: the current timestamp
464  * @bin: the bin
465  * @element: the element
466  *
467  * Pre-hook for gst_bin_remove() named "bin-remove-pre".
468  */
469 typedef void (*GstTracerHookBinRemovePre) (GObject *self, GstClockTime ts,
470     GstBin *bin, GstElement *element);
471 #define GST_TRACER_BIN_REMOVE_PRE(bin, element) G_STMT_START{ \
472   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_BIN_REMOVE_PRE), \
473     GstTracerHookBinRemovePre, (GST_TRACER_ARGS, bin, element)); \
474 }G_STMT_END
475
476 /**
477  * GstTracerHookBinRemovePost:
478  * @self: the tracer instance
479  * @ts: the current timestamp
480  * @bin: the bin
481  * @result: the result of gst_bin_remove()
482  *
483  * Post-hook for gst_bin_remove() named "bin-remove-post".
484  */
485 typedef void (*GstTracerHookBinRemovePost) (GObject *self, GstClockTime ts,
486     GstBin *bin, gboolean result);
487 #define GST_TRACER_BIN_REMOVE_POST(bin, result) G_STMT_START{ \
488   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_BIN_REMOVE_POST), \
489     GstTracerHookBinRemovePost, (GST_TRACER_ARGS, bin, result)); \
490 }G_STMT_END
491
492 /**
493  * GstTracerHookPadLinkPre:
494  * @self: the tracer instance
495  * @ts: the current timestamp
496  * @srcpad: the srcpad
497  * @sinkpad: the sinkpad
498  *
499  * Pre-hook for gst_pad_link() named "pad-link-pre".
500  */
501 typedef void (*GstTracerHookPadLinkPre) (GObject *self, GstClockTime ts,
502     GstPad *srcpad, GstPad *sinkpad);
503 #define GST_TRACER_PAD_LINK_PRE(srcpad, sinkpad) G_STMT_START{ \
504   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_LINK_PRE), \
505     GstTracerHookPadLinkPre, (GST_TRACER_ARGS, srcpad, sinkpad)); \
506 }G_STMT_END
507
508 /**
509  * GstTracerHookPadLinkPost:
510  * @self: the tracer instance
511  * @ts: the current timestamp
512  * @srcpad: the srcpad
513  * @sinkpad: the sinkpad
514  * @result: the result of gst_pad_link()
515  *
516  * Post-hook for gst_pad_link() named "pad-link-post".
517  */
518 typedef void (*GstTracerHookPadLinkPost) (GObject *self, GstClockTime ts,
519     GstPad *srcpad, GstPad *sinkpad, GstPadLinkReturn result);
520 #define GST_TRACER_PAD_LINK_POST(srcpad, sinkpad, result) G_STMT_START{ \
521   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_LINK_POST), \
522     GstTracerHookPadLinkPost, (GST_TRACER_ARGS, srcpad, sinkpad, result)); \
523 }G_STMT_END
524
525 /**
526  * GstTracerHookPadUnlinkPre:
527  * @self: the tracer instance
528  * @ts: the current timestamp
529  * @srcpad: the srcpad
530  * @sinkpad: the sinkpad
531  *
532  * Pre-hook for gst_pad_unlink() named "pad-unlink-pre".
533  */
534 typedef void (*GstTracerHookPadUnlinkPre) (GObject *self, GstClockTime ts,
535     GstPad *srcpad, GstPad *sinkpad);
536 #define GST_TRACER_PAD_UNLINK_PRE(srcpad, sinkpad) G_STMT_START{ \
537   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_UNLINK_PRE), \
538     GstTracerHookPadUnlinkPre, (GST_TRACER_ARGS, srcpad, sinkpad)); \
539 }G_STMT_END
540
541 /**
542  * GstTracerHookPadUnlinkPost:
543  * @self: the tracer instance
544  * @ts: the current timestamp
545  * @srcpad: the srcpad
546  * @sinkpad: the sinkpad
547  * @result: the result of gst_pad_push()
548  *
549  * Post-hook for gst_pad_unlink() named "pad-unlink-post".
550  */
551 typedef void (*GstTracerHookPadUnlinkPost) (GObject *self, GstClockTime ts,
552     GstPad *srcpad, GstPad *sinkpad, gboolean result);
553 #define GST_TRACER_PAD_UNLINK_POST(srcpad, sinkpad, result) G_STMT_START{ \
554   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_UNLINK_POST), \
555     GstTracerHookPadUnlinkPost, (GST_TRACER_ARGS, srcpad, sinkpad, result)); \
556 }G_STMT_END
557
558 #else /* !GST_DISABLE_GST_TRACER_HOOKS */
559
560 #define GST_TRACER_PAD_PUSH_PRE(pad, buffer)
561 #define GST_TRACER_PAD_PUSH_POST(pad, res)
562 #define GST_TRACER_PAD_PUSH_LIST_PRE(pad, list)
563 #define GST_TRACER_PAD_PUSH_LIST_POST(pad, res)
564 #define GST_TRACER_PAD_PULL_RANGE_PRE(pad, offset, size)
565 #define GST_TRACER_PAD_PULL_RANGE_POST(pad, buffer, res)
566 #define GST_TRACER_PAD_PUSH_EVENT_PRE(pad, event)
567 #define GST_TRACER_PAD_PUSH_EVENT_POST(pad, res)
568 #define GST_TRACER_PAD_QUERY_PRE(pad, query)
569 #define GST_TRACER_PAD_QUERY_POST(pad, query, res)
570 #define GST_TRACER_ELEMENT_POST_MESSAGE_PRE(element, message)
571 #define GST_TRACER_ELEMENT_POST_MESSAGE_POST(element, res)
572 #define GST_TRACER_ELEMENT_QUERY_PRE(element, query)
573 #define GST_TRACER_ELEMENT_QUERY_POST(element, query, res)
574 #define GST_TRACER_ELEMENT_NEW(element)
575 #define GST_TRACER_ELEMENT_ADD_PAD(element, pad)
576 #define GST_TRACER_ELEMENT_REMOVE_PAD(element, pad)
577 #define GST_TRACER_ELEMENT_CHANGE_STATE_PRE(element, transition)
578 #define GST_TRACER_ELEMENT_CHANGE_STATE_POST(element, transition, res)
579 #define GST_TRACER_BIN_ADD_PRE(bin, element)
580 #define GST_TRACER_BIN_ADD_POST(bin, element, res)
581 #define GST_TRACER_BIN_REMOVE_PRE(bin, element)
582 #define GST_TRACER_BIN_REMOVE_POST(bin, res)
583 #define GST_TRACER_PAD_LINK_PRE(srcpad, sinkpad)
584 #define GST_TRACER_PAD_LINK_POST(srcpad, sinkpad, res)
585 #define GST_TRACER_PAD_UNLINK_PRE(srcpad, sinkpad)
586 #define GST_TRACER_PAD_UNLINK_POST(srcpad, sinkpad, res)
587
588 #endif /* GST_DISABLE_GST_TRACER_HOOKS */
589
590 G_END_DECLS
591
592 #endif /* __GST_TRACER_UTILS_H__ */
593