gstpad: Avoid race in (un)setting EOS flag on sinkpads
[platform/upstream/gstreamer.git] / subprojects / gstreamer / 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_HOOK_MINI_OBJECT_REFFED,
79   GST_TRACER_QUARK_HOOK_MINI_OBJECT_UNREFFED,
80   GST_TRACER_QUARK_HOOK_OBJECT_REFFED,
81   GST_TRACER_QUARK_HOOK_OBJECT_UNREFFED,
82   GST_TRACER_QUARK_HOOK_PLUGIN_FEATURE_LOADED,
83   GST_TRACER_QUARK_HOOK_PAD_CHAIN_PRE,
84   GST_TRACER_QUARK_HOOK_PAD_CHAIN_POST,
85   GST_TRACER_QUARK_HOOK_PAD_CHAIN_LIST_PRE,
86   GST_TRACER_QUARK_HOOK_PAD_CHAIN_LIST_POST,
87   GST_TRACER_QUARK_MAX
88 } GstTracerQuarkId;
89
90 extern GQuark _priv_gst_tracer_quark_table[GST_TRACER_QUARK_MAX];
91
92 #define GST_TRACER_QUARK(q) _priv_gst_tracer_quark_table[GST_TRACER_QUARK_##q]
93
94 /* tracing module helpers */
95
96 typedef struct {
97   GObject *tracer;
98   GCallback func;
99 } GstTracerHook;
100
101 extern gboolean _priv_tracer_enabled;
102 /* key are hook-id quarks, values are GstTracerHook */
103 extern GHashTable *_priv_tracers;
104
105 #define GST_TRACER_IS_ENABLED (_priv_tracer_enabled)
106
107 #define GST_TRACER_TS \
108   GST_CLOCK_DIFF (_priv_gst_start_time, gst_util_get_timestamp ())
109
110 /* tracing hooks */
111
112 #define GST_TRACER_ARGS h->tracer, ts
113 #define GST_TRACER_DISPATCH(key,type,args) G_STMT_START{ \
114   if (GST_TRACER_IS_ENABLED) {                                         \
115     GstClockTime ts = GST_TRACER_TS;                                   \
116     GList *__l, *__n;                                                  \
117     GstTracerHook *h;                                                  \
118     __l = g_hash_table_lookup (_priv_tracers, GINT_TO_POINTER (key));  \
119     for (__n = __l; __n; __n = g_list_next (__n)) {                    \
120       h = (GstTracerHook *) __n->data;                                 \
121       ((type)(h->func)) args;                                          \
122     }                                                                  \
123     __l = g_hash_table_lookup (_priv_tracers, NULL);                   \
124     for (__n = __l; __n; __n = g_list_next (__n)) {                    \
125       h = (GstTracerHook *) __n->data;                                 \
126       ((type)(h->func)) args;                                          \
127     }                                                                  \
128   }                                                                    \
129 }G_STMT_END
130
131 /**
132  * GstTracerHookPadPushPre:
133  * @self: the tracer instance
134  * @ts: the current timestamp
135  * @pad: the pad
136  * @buffer: the buffer
137  *
138  * Pre-hook for gst_pad_push() named "pad-push-pre".
139  */
140 typedef void (*GstTracerHookPadPushPre) (GObject *self, GstClockTime ts,
141     GstPad *pad, GstBuffer *buffer);
142 #define GST_TRACER_PAD_PUSH_PRE(pad, buffer) G_STMT_START{ \
143   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_PUSH_PRE), \
144     GstTracerHookPadPushPre, (GST_TRACER_ARGS, pad, buffer)); \
145 }G_STMT_END
146
147 /**
148  * GstTracerHookPadPushPost:
149  * @self: the tracer instance
150  * @ts: the current timestamp
151  * @pad: the pad
152  * @res: the result of gst_pad_push()
153  *
154  * Post-hook for gst_pad_push() named "pad-push-post".
155  */
156 typedef void (*GstTracerHookPadPushPost) (GObject * self, GstClockTime ts,
157     GstPad *pad, GstFlowReturn res);
158 #define GST_TRACER_PAD_PUSH_POST(pad, res) G_STMT_START{ \
159   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_PUSH_POST), \
160     GstTracerHookPadPushPost, (GST_TRACER_ARGS, pad, res)); \
161 }G_STMT_END
162
163 /**
164  * GstTracerHookPadPushListPre:
165  * @self: the tracer instance
166  * @ts: the current timestamp
167  * @pad: the pad
168  * @list: the buffer-list
169  *
170  * Pre-hook for gst_pad_push_list() named "pad-push-list-pre".
171  */
172 typedef void (*GstTracerHookPadPushListPre) (GObject *self, GstClockTime ts,
173     GstPad *pad, GstBufferList *list);
174 #define GST_TRACER_PAD_PUSH_LIST_PRE(pad, list) G_STMT_START{ \
175   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_PUSH_LIST_PRE), \
176     GstTracerHookPadPushListPre, (GST_TRACER_ARGS, pad, list)); \
177 }G_STMT_END
178
179 /**
180  * GstTracerHookPadPushListPost:
181  * @self: the tracer instance
182  * @ts: the current timestamp
183  * @pad: the pad
184  * @res: the result of gst_pad_push_list()
185  *
186  * Post-hook for gst_pad_push_list() named "pad-push-list-post".
187  */
188 typedef void (*GstTracerHookPadPushListPost) (GObject *self, GstClockTime ts,
189     GstPad *pad,
190     GstFlowReturn res);
191 #define GST_TRACER_PAD_PUSH_LIST_POST(pad, res) G_STMT_START{ \
192   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_PUSH_LIST_POST), \
193     GstTracerHookPadPushListPost, (GST_TRACER_ARGS, pad, res)); \
194 }G_STMT_END
195
196 /**
197  * GstTracerHookPadPullRangePre:
198  * @self: the tracer instance
199  * @ts: the current timestamp
200  * @pad: the pad
201  * @offset: the stream offset
202  * @size: the requested size
203  *
204  * Pre-hook for gst_pad_pull_range() named "pad-pull-range-pre".
205  */
206 typedef void (*GstTracerHookPadPullRangePre) (GObject *self, GstClockTime ts,
207     GstPad *pad, guint64 offset, guint size);
208 #define GST_TRACER_PAD_PULL_RANGE_PRE(pad, offset, size) G_STMT_START{ \
209   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_PULL_RANGE_PRE), \
210     GstTracerHookPadPullRangePre, (GST_TRACER_ARGS, pad, offset, size)); \
211 }G_STMT_END
212
213 /**
214  * GstTracerHookPadPullRangePost:
215  * @self: the tracer instance
216  * @ts: the current timestamp
217  * @pad: the pad
218  * @buffer: the buffer
219  * @res: the result of gst_pad_pull_range()
220  *
221  * Post-hook for gst_pad_pull_range() named "pad-pull-range-post".
222  */
223 typedef void (*GstTracerHookPadPullRangePost) (GObject *self, GstClockTime ts,
224     GstPad *pad, GstBuffer *buffer, GstFlowReturn res);
225 #define GST_TRACER_PAD_PULL_RANGE_POST(pad, buffer, res) G_STMT_START{ \
226   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_PULL_RANGE_POST), \
227     GstTracerHookPadPullRangePost, (GST_TRACER_ARGS, pad, buffer, res)); \
228 }G_STMT_END
229
230 /**
231  * GstTracerHookPadPushEventPre:
232  * @self: the tracer instance
233  * @ts: the current timestamp
234  * @pad: the pad
235  * @event: the event
236  *
237  * Pre-hook for gst_pad_push_event() named "pad-push-event-pre".
238  */
239 typedef void (*GstTracerHookPadPushEventPre) (GObject *self, GstClockTime ts,
240     GstPad *pad, GstEvent *event);
241 #define GST_TRACER_PAD_PUSH_EVENT_PRE(pad, event) G_STMT_START{ \
242   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_PUSH_EVENT_PRE), \
243     GstTracerHookPadPushEventPre, (GST_TRACER_ARGS, pad, event)); \
244 }G_STMT_END
245
246 /**
247  * GstTracerHookPadPushEventPost:
248  * @self: the tracer instance
249  * @ts: the current timestamp
250  * @pad: the pad
251  * @res: the result of gst_pad_push_event()
252  *
253  * Post-hook for gst_pad_push_event() named "pad-push-event-post".
254  */
255 typedef void (*GstTracerHookPadPushEventPost) (GObject *self, GstClockTime ts,
256     GstPad *pad, gboolean res);
257 #define GST_TRACER_PAD_PUSH_EVENT_POST(pad, res) G_STMT_START{ \
258   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_PUSH_EVENT_POST), \
259     GstTracerHookPadPushEventPost, (GST_TRACER_ARGS, pad, res)); \
260 }G_STMT_END
261
262 /**
263  * GstTracerHookPadQueryPre:
264  * @self: the tracer instance
265  * @ts: the current timestamp
266  * @pad: the pad
267  * @query: the query
268  *
269  * Pre-hook for gst_pad_query() named "pad-query-pre".
270  */
271 typedef void (*GstTracerHookPadQueryPre) (GObject *self, GstClockTime ts,
272     GstPad *pad, GstQuery *query);
273 #define GST_TRACER_PAD_QUERY_PRE(pad, query) G_STMT_START{ \
274   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_QUERY_PRE), \
275     GstTracerHookPadQueryPre, (GST_TRACER_ARGS, pad, query)); \
276 }G_STMT_END
277
278 /**
279  * GstTracerHookPadQueryPost:
280  * @self: the tracer instance
281  * @ts: the current timestamp
282  * @pad: the pad
283  * @query: the query
284  * @res: the result of gst_pad_query()
285  *
286  * Post-hook for gst_pad_query() named "pad-query-post".
287  */
288 typedef void (*GstTracerHookPadQueryPost) (GObject *self, GstClockTime ts,
289     GstPad *pad, GstQuery *query, gboolean res);
290 #define GST_TRACER_PAD_QUERY_POST(pad, query, res) G_STMT_START{ \
291   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_QUERY_POST), \
292     GstTracerHookPadQueryPost, (GST_TRACER_ARGS, pad, query, res)); \
293 }G_STMT_END
294
295 /**
296  * GstTracerHookElementPostMessagePre:
297  * @self: the tracer instance
298  * @ts: the current timestamp
299  * @element: the element
300  * @message: the message
301  *
302  * Pre-hook for gst_element_post_message() named "element-post-message-pre".
303  */
304 typedef void (*GstTracerHookElementPostMessagePre) (GObject *self,
305     GstClockTime ts, GstElement *element, GstMessage *message);
306 #define GST_TRACER_ELEMENT_POST_MESSAGE_PRE(element, message) G_STMT_START{ \
307   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_ELEMENT_POST_MESSAGE_PRE), \
308     GstTracerHookElementPostMessagePre, (GST_TRACER_ARGS, element, message)); \
309 }G_STMT_END
310
311 /**
312  * GstTracerHookElementPostMessagePost:
313  * @self: the tracer instance
314  * @ts: the current timestamp
315  * @element: the element
316  * @res: the result of gst_element_post_message()
317  *
318  * Pre-hook for gst_element_post_message() named "element-post-message-post".
319  */
320 typedef void (*GstTracerHookElementPostMessagePost) (GObject *self,
321     GstClockTime ts, GstElement *element, gboolean res);
322 #define GST_TRACER_ELEMENT_POST_MESSAGE_POST(element, res) G_STMT_START{ \
323   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_ELEMENT_POST_MESSAGE_POST), \
324     GstTracerHookElementPostMessagePost, (GST_TRACER_ARGS, element, res)); \
325 }G_STMT_END
326
327 /**
328  * GstTracerHookElementQueryPre:
329  * @self: the tracer instance
330  * @ts: the current timestamp
331  * @element: the element
332  * @query: the query
333  *
334  * Pre-hook for gst_element_query() named "element-query-pre".
335  */
336 typedef void (*GstTracerHookElementQueryPre) (GObject *self, GstClockTime ts,
337     GstElement *element, GstQuery *query);
338 #define GST_TRACER_ELEMENT_QUERY_PRE(element, query) G_STMT_START{ \
339   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_ELEMENT_QUERY_PRE), \
340     GstTracerHookElementQueryPre, (GST_TRACER_ARGS, element, query)); \
341 }G_STMT_END
342
343 /**
344  * GstTracerHookElementQueryPost:
345  * @self: the tracer instance
346  * @ts: the current timestamp
347  * @element: the element
348  * @query: the query
349  * @res: the result of gst_element_query()
350  *
351  * Post-hook for gst_element_query() named "element-query-post".
352  */
353 typedef void (*GstTracerHookElementQueryPost) (GObject *self, GstClockTime ts,
354     GstElement *element, GstQuery *query, gboolean res);
355 #define GST_TRACER_ELEMENT_QUERY_POST(element, query, res) G_STMT_START{ \
356   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_ELEMENT_QUERY_POST), \
357     GstTracerHookElementQueryPost, (GST_TRACER_ARGS, element, query, res)); \
358 }G_STMT_END
359
360 /**
361  * GstTracerHookElementNew:
362  * @self: the tracer instance
363  * @ts: the current timestamp
364  * @element: the element
365  *
366  * Hook for whenever a new element is created, named "element-new".
367  */
368 typedef void (*GstTracerHookElementNew) (GObject *self, GstClockTime ts,
369     GstElement *element);
370 #define GST_TRACER_ELEMENT_NEW(element) G_STMT_START{ \
371   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_ELEMENT_NEW), \
372     GstTracerHookElementNew, (GST_TRACER_ARGS, element)); \
373 }G_STMT_END
374
375 /**
376  * GstTracerHookElementAddPad:
377  * @self: the tracer instance
378  * @ts: the current timestamp
379  * @element: the element
380  * @pad: the pad
381  *
382  * Hook for gst_element_add_pad() named "element-add-pad".
383  */
384 typedef void (*GstTracerHookElementAddPad) (GObject *self, GstClockTime ts,
385     GstElement *element, GstPad *pad);
386 #define GST_TRACER_ELEMENT_ADD_PAD(element, pad) G_STMT_START{ \
387   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_ELEMENT_ADD_PAD), \
388     GstTracerHookElementAddPad, (GST_TRACER_ARGS, element, pad)); \
389 }G_STMT_END
390
391 /**
392  * GstTracerHookElementRemovePad:
393  * @self: the tracer instance
394  * @ts: the current timestamp
395  * @element: the element
396  * @pad: the pad
397  *
398  * Hook for gst_element_remove_pad() named "element-remove-pad".
399  */
400 typedef void (*GstTracerHookElementRemovePad) (GObject *self, GstClockTime ts,
401     GstElement *element, GstPad *pad);
402 #define GST_TRACER_ELEMENT_REMOVE_PAD(element, pad) G_STMT_START{ \
403   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_ELEMENT_REMOVE_PAD), \
404     GstTracerHookElementRemovePad, (GST_TRACER_ARGS, element, pad)); \
405 }G_STMT_END
406
407 /**
408  * GstTracerHookElementChangeStatePre:
409  * @self: the tracer instance
410  * @ts: the current timestamp
411  * @element: the element
412  * @transition: the transition
413  *
414  * Pre-hook for gst_element_change_state() named "element-change-state-pre".
415  */
416 typedef void (*GstTracerHookElementChangeStatePre) (GObject *self,
417     GstClockTime ts, GstElement *element, GstStateChange transition);
418 #define GST_TRACER_ELEMENT_CHANGE_STATE_PRE(element, transition) G_STMT_START{ \
419   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_ELEMENT_CHANGE_STATE_PRE), \
420     GstTracerHookElementChangeStatePre, (GST_TRACER_ARGS, element, transition)); \
421 }G_STMT_END
422
423 /**
424  * GstTracerHookElementChangeStatePost:
425  * @self: the tracer instance
426  * @ts: the current timestamp
427  * @element: the element
428  * @transition: the transition
429  * @result: the result of gst_pad_push()
430  *
431  * Post-hook for gst_element_change_state() named "element-change-state-post".
432  */
433 typedef void (*GstTracerHookElementChangeStatePost) (GObject *self,
434     GstClockTime ts, GstElement *element, GstStateChange transition,
435     GstStateChangeReturn result);
436 #define GST_TRACER_ELEMENT_CHANGE_STATE_POST(element, transition, result) G_STMT_START{ \
437   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_ELEMENT_CHANGE_STATE_POST), \
438     GstTracerHookElementChangeStatePost, (GST_TRACER_ARGS, element, transition, result)); \
439 }G_STMT_END
440
441 /**
442  * GstTracerHookBinAddPre:
443  * @self: the tracer instance
444  * @ts: the current timestamp
445  * @bin: the bin
446  * @element: the element
447  *
448  * Pre-hook for gst_bin_add() named "bin-add-pre".
449  */
450 typedef void (*GstTracerHookBinAddPre) (GObject *self, GstClockTime ts,
451     GstBin *bin, GstElement *element);
452 #define GST_TRACER_BIN_ADD_PRE(bin, element) G_STMT_START{ \
453   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_BIN_ADD_PRE), \
454     GstTracerHookBinAddPre, (GST_TRACER_ARGS, bin, element)); \
455 }G_STMT_END
456
457 /**
458  * GstTracerHookBinAddPost:
459  * @self: the tracer instance
460  * @ts: the current timestamp
461  * @bin: the bin
462  * @element: the element
463  * @result: the result of gst_bin_add()
464  *
465  * Post-hook for gst_bin_add() named "bin-add-post".
466  */
467 typedef void (*GstTracerHookBinAddPost) (GObject *self, GstClockTime ts,
468     GstBin *bin, GstElement *element, gboolean result);
469 #define GST_TRACER_BIN_ADD_POST(bin, element, result) G_STMT_START{ \
470   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_BIN_ADD_POST), \
471     GstTracerHookBinAddPost, (GST_TRACER_ARGS, bin, element, result)); \
472 }G_STMT_END
473
474 /**
475  * GstTracerHookBinRemovePre:
476  * @self: the tracer instance
477  * @ts: the current timestamp
478  * @bin: the bin
479  * @element: the element
480  *
481  * Pre-hook for gst_bin_remove() named "bin-remove-pre".
482  */
483 typedef void (*GstTracerHookBinRemovePre) (GObject *self, GstClockTime ts,
484     GstBin *bin, GstElement *element);
485 #define GST_TRACER_BIN_REMOVE_PRE(bin, element) G_STMT_START{ \
486   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_BIN_REMOVE_PRE), \
487     GstTracerHookBinRemovePre, (GST_TRACER_ARGS, bin, element)); \
488 }G_STMT_END
489
490 /**
491  * GstTracerHookBinRemovePost:
492  * @self: the tracer instance
493  * @ts: the current timestamp
494  * @bin: the bin
495  * @result: the result of gst_bin_remove()
496  *
497  * Post-hook for gst_bin_remove() named "bin-remove-post".
498  */
499 typedef void (*GstTracerHookBinRemovePost) (GObject *self, GstClockTime ts,
500     GstBin *bin, gboolean result);
501 #define GST_TRACER_BIN_REMOVE_POST(bin, result) G_STMT_START{ \
502   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_BIN_REMOVE_POST), \
503     GstTracerHookBinRemovePost, (GST_TRACER_ARGS, bin, result)); \
504 }G_STMT_END
505
506 /**
507  * GstTracerHookPadLinkPre:
508  * @self: the tracer instance
509  * @ts: the current timestamp
510  * @srcpad: the srcpad
511  * @sinkpad: the sinkpad
512  *
513  * Pre-hook for gst_pad_link() named "pad-link-pre".
514  */
515 typedef void (*GstTracerHookPadLinkPre) (GObject *self, GstClockTime ts,
516     GstPad *srcpad, GstPad *sinkpad);
517 #define GST_TRACER_PAD_LINK_PRE(srcpad, sinkpad) G_STMT_START{ \
518   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_LINK_PRE), \
519     GstTracerHookPadLinkPre, (GST_TRACER_ARGS, srcpad, sinkpad)); \
520 }G_STMT_END
521
522 /**
523  * GstTracerHookPadLinkPost:
524  * @self: the tracer instance
525  * @ts: the current timestamp
526  * @srcpad: the srcpad
527  * @sinkpad: the sinkpad
528  * @result: the result of gst_pad_link()
529  *
530  * Post-hook for gst_pad_link() named "pad-link-post".
531  */
532 typedef void (*GstTracerHookPadLinkPost) (GObject *self, GstClockTime ts,
533     GstPad *srcpad, GstPad *sinkpad, GstPadLinkReturn result);
534 #define GST_TRACER_PAD_LINK_POST(srcpad, sinkpad, result) G_STMT_START{ \
535   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_LINK_POST), \
536     GstTracerHookPadLinkPost, (GST_TRACER_ARGS, srcpad, sinkpad, result)); \
537 }G_STMT_END
538
539 /**
540  * GstTracerHookPadUnlinkPre:
541  * @self: the tracer instance
542  * @ts: the current timestamp
543  * @srcpad: the srcpad
544  * @sinkpad: the sinkpad
545  *
546  * Pre-hook for gst_pad_unlink() named "pad-unlink-pre".
547  */
548 typedef void (*GstTracerHookPadUnlinkPre) (GObject *self, GstClockTime ts,
549     GstPad *srcpad, GstPad *sinkpad);
550 #define GST_TRACER_PAD_UNLINK_PRE(srcpad, sinkpad) G_STMT_START{ \
551   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_UNLINK_PRE), \
552     GstTracerHookPadUnlinkPre, (GST_TRACER_ARGS, srcpad, sinkpad)); \
553 }G_STMT_END
554
555 /**
556  * GstTracerHookPadUnlinkPost:
557  * @self: the tracer instance
558  * @ts: the current timestamp
559  * @srcpad: the srcpad
560  * @sinkpad: the sinkpad
561  * @result: the result of gst_pad_push()
562  *
563  * Post-hook for gst_pad_unlink() named "pad-unlink-post".
564  */
565 typedef void (*GstTracerHookPadUnlinkPost) (GObject *self, GstClockTime ts,
566     GstPad *srcpad, GstPad *sinkpad, gboolean result);
567 #define GST_TRACER_PAD_UNLINK_POST(srcpad, sinkpad, result) G_STMT_START{ \
568   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_UNLINK_POST), \
569     GstTracerHookPadUnlinkPost, (GST_TRACER_ARGS, srcpad, sinkpad, result)); \
570 }G_STMT_END
571
572 /**
573  * GstTracerHookMiniObjectCreated:
574  * @self: the tracer instance
575  * @ts: the current timestamp
576  * @object: the mini object being created
577  *
578  * Hook called when a #GstMiniObject is created named "mini-object-created".
579  */
580 typedef void (*GstTracerHookMiniObjectCreated) (GObject *self, GstClockTime ts,
581     GstMiniObject *object);
582 #define GST_TRACER_MINI_OBJECT_CREATED(object) G_STMT_START{ \
583   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_MINI_OBJECT_CREATED), \
584     GstTracerHookMiniObjectCreated, (GST_TRACER_ARGS, object)); \
585 }G_STMT_END
586
587 /**
588  * GstTracerHookMiniObjectDestroyed:
589  * @self: the tracer instance
590  * @ts: the current timestamp
591  * @object: the mini object being destroyed
592  *
593  * Hook called when a #GstMiniObject is being destroyed named
594  * "mini-object-destroyed".
595  */
596 typedef void (*GstTracerHookMiniObjectDestroyed) (GObject *self, GstClockTime ts,
597     GstMiniObject *object);
598 #define GST_TRACER_MINI_OBJECT_DESTROYED(object) G_STMT_START{ \
599   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_MINI_OBJECT_DESTROYED), \
600     GstTracerHookMiniObjectDestroyed, (GST_TRACER_ARGS, object)); \
601 }G_STMT_END
602
603 /**
604  * GstTracerHookObjectUnreffed:
605  * @self: the tracer instance
606  * @ts: the current timestamp
607  * @object: the object being unreffed
608  * @new_refcount: the new refcount after unrefing @object
609  *
610  * Hook called when a #GstObject is being unreffed named
611  * "object-unreffed"
612  */
613 typedef void (*GstTracerHookObjectUnreffed) (GObject *self, GstClockTime ts,
614     GstObject *object, gint new_refcount);
615 #define GST_TRACER_OBJECT_UNREFFED(object, new_refcount) G_STMT_START{ \
616   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_OBJECT_UNREFFED), \
617     GstTracerHookObjectUnreffed, (GST_TRACER_ARGS, object, new_refcount)); \
618 }G_STMT_END
619
620 /**
621  * GstTracerHookObjectReffed:
622  * @self: the tracer instance
623  * @ts: the current timestamp
624  * @object: the object being reffed
625  * @new_refcount: the new refcount after refing @object
626  *
627  * Hook called when a #GstObject is being reffed named
628  * "object-reffed".
629  */
630 typedef void (*GstTracerHookObjectReffed) (GObject *self, GstClockTime ts,
631     GstObject *object, gint new_refcount);
632 #define GST_TRACER_OBJECT_REFFED(object, new_refcount) G_STMT_START{ \
633   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_OBJECT_REFFED), \
634     GstTracerHookObjectReffed, (GST_TRACER_ARGS, object, new_refcount)); \
635 }G_STMT_END
636
637 /**
638  * GstTracerHookMiniObjectUnreffed:
639  * @self: the tracer instance
640  * @ts: the current timestamp
641  * @object: the mini object being unreffed
642  * @new_refcount: the new refcount after unrefing @object
643  *
644  * Hook called when a #GstMiniObject is being unreffed named
645  * "mini-object-unreffed".
646  */
647 typedef void (*GstTracerHookMiniObjectUnreffed) (GObject *self, GstClockTime ts,
648     GstMiniObject *object, gint new_refcount);
649 #define GST_TRACER_MINI_OBJECT_UNREFFED(object, new_refcount) G_STMT_START{ \
650   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_MINI_OBJECT_UNREFFED), \
651     GstTracerHookMiniObjectUnreffed, (GST_TRACER_ARGS, object, new_refcount)); \
652 }G_STMT_END
653
654 /**
655  * GstTracerHookMiniObjectReffed:
656  * @self: the tracer instance
657  * @ts: the current timestamp
658  * @object: the mini object being reffed
659  * @new_refcount: the new refcount after refing @object
660  *
661  * Hook called when a #GstMiniObject is being reffed named
662  * "mini-object-reffed".
663  */
664 typedef void (*GstTracerHookMiniObjectReffed) (GObject *self, GstClockTime ts,
665     GstMiniObject *object, gint new_refcount);
666 #define GST_TRACER_MINI_OBJECT_REFFED(object, new_refcount) G_STMT_START{ \
667   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_MINI_OBJECT_REFFED), \
668     GstTracerHookMiniObjectReffed, (GST_TRACER_ARGS, object, new_refcount)); \
669 }G_STMT_END
670
671 /**
672  * GstTracerHookObjectCreated:
673  * @self: the tracer instance
674  * @ts: the current timestamp
675  * @object: the object being created
676  *
677  * Hook called when a #GstObject is created named "object-created".
678  */
679 typedef void (*GstTracerHookObjectCreated) (GObject *self, GstClockTime ts,
680     GstObject *object);
681 #define GST_TRACER_OBJECT_CREATED(object) G_STMT_START{ \
682   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_OBJECT_CREATED), \
683     GstTracerHookObjectCreated, (GST_TRACER_ARGS, object)); \
684 }G_STMT_END
685
686 /**
687  * GstTracerHookObjectDestroyed:
688  * @self: the tracer instance
689  * @ts: the current timestamp
690  * @object: the object being destroyed
691  *
692  * Hook called when a #GstObject is being destroyed named
693  * "object-destroyed".
694  */
695 typedef void (*GstTracerHookObjectDestroyed) (GObject *self, GstClockTime ts,
696     GstObject *object);
697
698 #define GST_TRACER_OBJECT_DESTROYED(object) G_STMT_START{ \
699   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_OBJECT_DESTROYED), \
700     GstTracerHookObjectDestroyed, (GST_TRACER_ARGS, object)); \
701 }G_STMT_END
702
703 /**
704  * GstTracerHookPluginFeatureLoaded:
705  * @self: the tracer instance
706  * @ts: the current timestamp
707  * @feature: the plugin feature that was loaded
708  *
709  * Hook called when a GstPluginFeature is loaded named
710  * "plugin-feature-loaded".
711  *
712  * Since: 1.20
713  */
714 typedef void (*GstTracerHookPluginFeatureLoaded) (GObject *self, GstClockTime ts,
715     GstPluginFeature *feature);
716 /**
717  * GST_TRACER_PLUGIN_FEATURE_LOADED:
718  * @feature: The feature that this tracer is called for
719  *
720  * Add a tracepoint when a plugin feature is loaded.
721  *
722  * Since: 1.20
723  */
724 #define GST_TRACER_PLUGIN_FEATURE_LOADED(feature) G_STMT_START{ \
725   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PLUGIN_FEATURE_LOADED), \
726     GstTracerHookPluginFeatureLoaded, (GST_TRACER_ARGS, feature)); \
727 }G_STMT_END
728
729 /**
730  * GstTracerHookPadChainPre:
731  * @self: the tracer instance
732  * @ts: the current timestamp
733  * @pad: the pad
734  * @buffer: the buffer
735  *
736  * Pre-hook for gst_pad_chain() named "pad-chain-pre".
737  *
738  * Since: 1.22
739  */
740 typedef void (*GstTracerHookPadChainPre) (GObject *self, GstClockTime ts,
741     GstPad *pad, GstBuffer *buffer);
742
743 /**
744  * GST_TRACER_PAD_CHAIN_PRE:
745  * @pad: a %GstPad
746  * @buffer: a %GstBuffer
747  *
748  * Dispatches the "pad-chain-pre" hook.
749  *
750  * Since: 1.22
751  */
752 #define GST_TRACER_PAD_CHAIN_PRE(pad, buffer) G_STMT_START{ \
753   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_CHAIN_PRE), \
754     GstTracerHookPadChainPre, (GST_TRACER_ARGS, pad, buffer)); \
755 }G_STMT_END
756
757 /**
758  * GstTracerHookPadChainPost:
759  * @self: the tracer instance
760  * @ts: the current timestamp
761  * @pad: the pad
762  * @res: the result of gst_pad_chain()
763  *
764  * Post-hook for gst_pad_chain() named "pad-chain-post".
765  *
766  * Since: 1.22
767  */
768 typedef void (*GstTracerHookPadChainPost) (GObject * self, GstClockTime ts,
769     GstPad *pad, GstFlowReturn res);
770
771 /**
772  * GST_TRACER_PAD_CHAIN_POST:
773  * @pad: a %GstPad
774  * @res: a %GstFlowReturn
775  *
776  * Dispatches the "pad-chain-post" hook.
777  *
778  * Since: 1.22
779  */
780 #define GST_TRACER_PAD_CHAIN_POST(pad, res) G_STMT_START{ \
781   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_CHAIN_POST), \
782     GstTracerHookPadChainPost, (GST_TRACER_ARGS, pad, res)); \
783 }G_STMT_END
784
785 /**
786  * GstTracerHookPadChainListPre:
787  * @self: the tracer instance
788  * @ts: the current timestamp
789  * @pad: the pad
790  * @list: the buffer-list
791  *
792  * Pre-hook for gst_pad_chain_list() named "pad-chain-list-pre".
793  *
794  * Since: 1.22
795  */
796 typedef void (*GstTracerHookPadChainListPre) (GObject *self, GstClockTime ts,
797     GstPad *pad, GstBufferList *list);
798
799 /**
800  * GST_TRACER_PAD_CHAIN_LIST_PRE:
801  * @pad: a %GstPad
802  * @list: a %GstBufferList
803  *
804  * Dispatches the "pad-chain-list-pre" hook.
805  *
806  * Since: 1.22
807  */
808 #define GST_TRACER_PAD_CHAIN_LIST_PRE(pad, list) G_STMT_START{ \
809   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_CHAIN_LIST_PRE), \
810     GstTracerHookPadChainListPre, (GST_TRACER_ARGS, pad, list)); \
811 }G_STMT_END
812
813 /**
814  * GstTracerHookPadChainListPost:
815  * @self: the tracer instance
816  * @ts: the current timestamp
817  * @pad: the pad
818  * @res: the result of gst_pad_chain_list()
819  *
820  * Post-hook for gst_pad_chain_list() named "pad-chain-list-post".
821  *
822  * Since: 1.22
823  */
824 typedef void (*GstTracerHookPadChainListPost) (GObject *self, GstClockTime ts,
825     GstPad *pad,
826     GstFlowReturn res);
827
828 /**
829  * GST_TRACER_PAD_CHAIN_LIST_POST:
830  * @pad: a %GstPad
831  * @res: a %GstFlowReturn
832  *
833  * Dispatches the "pad-chain-list-post" hook.
834  *
835  * Since: 1.22
836  */
837 #define GST_TRACER_PAD_CHAIN_LIST_POST(pad, res) G_STMT_START{ \
838   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_CHAIN_LIST_POST), \
839     GstTracerHookPadChainListPost, (GST_TRACER_ARGS, pad, res)); \
840 }G_STMT_END
841
842 #else /* !GST_DISABLE_GST_TRACER_HOOKS */
843
844 static inline void
845 _priv_gst_tracing_init (void)
846 {
847   GST_DEBUG ("Tracing hooks are disabled");
848 }
849
850 static inline void
851 _priv_gst_tracing_deinit (void)
852 {
853 }
854
855 #define GST_TRACER_PAD_PUSH_PRE(pad, buffer)
856 #define GST_TRACER_PAD_PUSH_POST(pad, res)
857 #define GST_TRACER_PAD_PUSH_LIST_PRE(pad, list)
858 #define GST_TRACER_PAD_PUSH_LIST_POST(pad, res)
859 #define GST_TRACER_PAD_PULL_RANGE_PRE(pad, offset, size)
860 #define GST_TRACER_PAD_PULL_RANGE_POST(pad, buffer, res)
861 #define GST_TRACER_PAD_PUSH_EVENT_PRE(pad, event)
862 #define GST_TRACER_PAD_PUSH_EVENT_POST(pad, res)
863 #define GST_TRACER_PAD_QUERY_PRE(pad, query)
864 #define GST_TRACER_PAD_QUERY_POST(pad, query, res)
865 #define GST_TRACER_ELEMENT_POST_MESSAGE_PRE(element, message)
866 #define GST_TRACER_ELEMENT_POST_MESSAGE_POST(element, res)
867 #define GST_TRACER_ELEMENT_QUERY_PRE(element, query)
868 #define GST_TRACER_ELEMENT_QUERY_POST(element, query, res)
869 #define GST_TRACER_ELEMENT_NEW(element)
870 #define GST_TRACER_ELEMENT_ADD_PAD(element, pad)
871 #define GST_TRACER_ELEMENT_REMOVE_PAD(element, pad)
872 #define GST_TRACER_ELEMENT_CHANGE_STATE_PRE(element, transition)
873 #define GST_TRACER_ELEMENT_CHANGE_STATE_POST(element, transition, res)
874 #define GST_TRACER_BIN_ADD_PRE(bin, element)
875 #define GST_TRACER_BIN_ADD_POST(bin, element, res)
876 #define GST_TRACER_BIN_REMOVE_PRE(bin, element)
877 #define GST_TRACER_BIN_REMOVE_POST(bin, res)
878 #define GST_TRACER_PAD_LINK_PRE(srcpad, sinkpad)
879 #define GST_TRACER_PAD_LINK_POST(srcpad, sinkpad, res)
880 #define GST_TRACER_PAD_UNLINK_PRE(srcpad, sinkpad)
881 #define GST_TRACER_PAD_UNLINK_POST(srcpad, sinkpad, res)
882 #define GST_TRACER_MINI_OBJECT_CREATED(object)
883 #define GST_TRACER_MINI_OBJECT_DESTROYED(object)
884 #define GST_TRACER_MINI_OBJECT_REFFED(object, new_refcount)
885 #define GST_TRACER_MINI_OBJECT_UNREFFED(object, new_refcount)
886 #define GST_TRACER_OBJECT_CREATED(object)
887 #define GST_TRACER_OBJECT_DESTROYED(object)
888 #define GST_TRACER_OBJECT_REFFED(object, new_refcount)
889 #define GST_TRACER_OBJECT_UNREFFED(object, new_refcount)
890 #define GST_TRACER_PLUGIN_FEATURE_LOADED(feature)
891 #define GST_TRACER_PAD_CHAIN_PRE(pad, buffer)
892 #define GST_TRACER_PAD_CHAIN_POST(pad, res)
893 #define GST_TRACER_PAD_CHAIN_LIST_PRE(pad, list)
894 #define GST_TRACER_PAD_CHAIN_LIST_POST(pad, res)
895
896 #endif /* GST_DISABLE_GST_TRACER_HOOKS */
897
898 G_END_DECLS
899
900 #endif /* __GST_TRACER_UTILS_H__ */
901