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