Thibault Saunier e87b3b0359 tracerutils: keep tracers that do not register to any hook alive as others
This checks if a tracer has registered to any hook after
initialization and automatically registers it to the "none" hook if not
so the lifetime of those tracer is the same as tracer who registers to hooks.

For example the `dots` tracer was being freed right after initialization
which was unexpected.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9547>
2025-08-19 15:34:45 +00:00

1123 lines
36 KiB
C

/* GStreamer
* Copyright (C) 2013 Stefan Sauer <ensonic@users.sf.net>
*
* gsttracerutils.h: tracing subsystem
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_TRACER_UTILS_H__
#define __GST_TRACER_UTILS_H__
#include <glib.h>
#include <glib-object.h>
#include <gst/gstconfig.h>
#include <gst/gstbin.h>
#include <gst/gstutils.h>
G_BEGIN_DECLS
#ifndef GST_DISABLE_GST_TRACER_HOOKS
/* tracing hooks */
void _priv_gst_tracing_init (void);
void _priv_gst_tracing_deinit (void);
/* tracer quarks */
/* These enums need to match the number and order
* of strings declared in _quark_table, in gsttracerutils.c */
typedef enum /*< skip >*/
{
GST_TRACER_QUARK_HOOK_PAD_PUSH_PRE = 0,
GST_TRACER_QUARK_HOOK_PAD_PUSH_POST,
GST_TRACER_QUARK_HOOK_PAD_PUSH_LIST_PRE,
GST_TRACER_QUARK_HOOK_PAD_PUSH_LIST_POST,
GST_TRACER_QUARK_HOOK_PAD_PULL_RANGE_PRE,
GST_TRACER_QUARK_HOOK_PAD_PULL_RANGE_POST,
GST_TRACER_QUARK_HOOK_PAD_PUSH_EVENT_PRE ,
GST_TRACER_QUARK_HOOK_PAD_PUSH_EVENT_POST,
GST_TRACER_QUARK_HOOK_PAD_QUERY_PRE ,
GST_TRACER_QUARK_HOOK_PAD_QUERY_POST,
GST_TRACER_QUARK_HOOK_ELEMENT_POST_MESSAGE_PRE,
GST_TRACER_QUARK_HOOK_ELEMENT_POST_MESSAGE_POST,
GST_TRACER_QUARK_HOOK_ELEMENT_QUERY_PRE,
GST_TRACER_QUARK_HOOK_ELEMENT_QUERY_POST,
GST_TRACER_QUARK_HOOK_ELEMENT_NEW,
GST_TRACER_QUARK_HOOK_ELEMENT_ADD_PAD,
GST_TRACER_QUARK_HOOK_ELEMENT_REMOVE_PAD,
GST_TRACER_QUARK_HOOK_BIN_ADD_PRE,
GST_TRACER_QUARK_HOOK_BIN_ADD_POST,
GST_TRACER_QUARK_HOOK_BIN_REMOVE_PRE,
GST_TRACER_QUARK_HOOK_BIN_REMOVE_POST,
GST_TRACER_QUARK_HOOK_PAD_LINK_PRE,
GST_TRACER_QUARK_HOOK_PAD_LINK_POST,
GST_TRACER_QUARK_HOOK_PAD_UNLINK_PRE,
GST_TRACER_QUARK_HOOK_PAD_UNLINK_POST,
GST_TRACER_QUARK_HOOK_ELEMENT_CHANGE_STATE_PRE,
GST_TRACER_QUARK_HOOK_ELEMENT_CHANGE_STATE_POST,
GST_TRACER_QUARK_HOOK_MINI_OBJECT_CREATED,
GST_TRACER_QUARK_HOOK_MINI_OBJECT_DESTROYED,
GST_TRACER_QUARK_HOOK_OBJECT_CREATED,
GST_TRACER_QUARK_HOOK_OBJECT_DESTROYED,
GST_TRACER_QUARK_HOOK_MINI_OBJECT_REFFED,
GST_TRACER_QUARK_HOOK_MINI_OBJECT_UNREFFED,
GST_TRACER_QUARK_HOOK_OBJECT_REFFED,
GST_TRACER_QUARK_HOOK_OBJECT_UNREFFED,
GST_TRACER_QUARK_HOOK_PLUGIN_FEATURE_LOADED,
GST_TRACER_QUARK_HOOK_PAD_CHAIN_PRE,
GST_TRACER_QUARK_HOOK_PAD_CHAIN_POST,
GST_TRACER_QUARK_HOOK_PAD_CHAIN_LIST_PRE,
GST_TRACER_QUARK_HOOK_PAD_CHAIN_LIST_POST,
GST_TRACER_QUARK_HOOK_PAD_SEND_EVENT_PRE,
GST_TRACER_QUARK_HOOK_PAD_SEND_EVENT_POST,
/**
* GST_TRACER_QUARK_HOOK_MEMORY_INIT:
*
* Post-hook for memory initialization named "memory-init".
*
* Since: 1.26
*/
GST_TRACER_QUARK_HOOK_MEMORY_INIT,
/**
* GST_TRACER_QUARK_HOOK_MEMORY_FREE_PRE:
*
* Pre-hook for memory freeing named "memory-free-pre".
*
* Since: 1.26
*/
GST_TRACER_QUARK_HOOK_MEMORY_FREE_PRE,
/**
* GST_TRACER_QUARK_HOOK_MEMORY_FREE_POST:
*
* Post-hook for memory freeing named "memory-free-post".
*
* Since: 1.26
*/
GST_TRACER_QUARK_HOOK_MEMORY_FREE_POST,
/**
* GST_TRACER_QUARK_HOOK_POOL_BUFFER_QUEUED:
*
* Hook for buffers queued into a buffer pool.
*
* Since: 1.28
*/
GST_TRACER_QUARK_HOOK_POOL_BUFFER_QUEUED,
/**
* GST_TRACER_QUARK_HOOK_POOL_BUFFER_DEQUEUED:
*
* Hook for buffers dequeued from a buffer pool.
*
* Since: 1.28
*/
GST_TRACER_QUARK_HOOK_POOL_BUFFER_DEQUEUED,
GST_TRACER_QUARK_MAX
} GstTracerQuarkId;
extern GQuark _priv_gst_tracer_quark_table[GST_TRACER_QUARK_MAX + 1];
#define GST_TRACER_QUARK(q) _priv_gst_tracer_quark_table[GST_TRACER_QUARK_##q]
/* tracing module helpers */
typedef struct {
GObject *tracer;
GCallback func;
} GstTracerHook;
extern gboolean _priv_tracer_enabled;
/* key are hook-id quarks, values are GstTracerHook */
extern GHashTable *_priv_tracers;
#define GST_TRACER_IS_ENABLED (_priv_tracer_enabled)
#define GST_TRACER_TS \
GST_CLOCK_DIFF (_priv_gst_start_time, gst_util_get_timestamp ())
/* tracing hooks */
#define GST_TRACER_ARGS h->tracer, ts
#define GST_TRACER_DISPATCH(key,type,args) G_STMT_START{ \
if (GST_TRACER_IS_ENABLED) { \
GstClockTime ts = GST_TRACER_TS; \
GList *__l, *__n; \
GstTracerHook *h; \
__l = g_hash_table_lookup (_priv_tracers, GINT_TO_POINTER (key)); \
for (__n = __l; __n; __n = g_list_next (__n)) { \
h = (GstTracerHook *) __n->data; \
((type)(h->func)) args; \
} \
__l = g_hash_table_lookup (_priv_tracers, NULL); \
for (__n = __l; __n; __n = g_list_next (__n)) { \
h = (GstTracerHook *) __n->data; \
((type)(h->func)) args; \
} \
} \
}G_STMT_END
/**
* GstTracerHookPadPushPre:
* @self: the tracer instance
* @ts: the current timestamp
* @pad: the pad
* @buffer: the buffer
*
* Pre-hook for gst_pad_push() named "pad-push-pre".
*/
typedef void (*GstTracerHookPadPushPre) (GObject *self, GstClockTime ts,
GstPad *pad, GstBuffer *buffer);
#define GST_TRACER_PAD_PUSH_PRE(pad, buffer) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_PUSH_PRE), \
GstTracerHookPadPushPre, (GST_TRACER_ARGS, pad, buffer)); \
}G_STMT_END
/**
* GstTracerHookPadPushPost:
* @self: the tracer instance
* @ts: the current timestamp
* @pad: the pad
* @res: the result of gst_pad_push()
*
* Post-hook for gst_pad_push() named "pad-push-post".
*/
typedef void (*GstTracerHookPadPushPost) (GObject * self, GstClockTime ts,
GstPad *pad, GstFlowReturn res);
#define GST_TRACER_PAD_PUSH_POST(pad, res) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_PUSH_POST), \
GstTracerHookPadPushPost, (GST_TRACER_ARGS, pad, res)); \
}G_STMT_END
/**
* GstTracerHookPadPushListPre:
* @self: the tracer instance
* @ts: the current timestamp
* @pad: the pad
* @list: the buffer-list
*
* Pre-hook for gst_pad_push_list() named "pad-push-list-pre".
*/
typedef void (*GstTracerHookPadPushListPre) (GObject *self, GstClockTime ts,
GstPad *pad, GstBufferList *list);
#define GST_TRACER_PAD_PUSH_LIST_PRE(pad, list) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_PUSH_LIST_PRE), \
GstTracerHookPadPushListPre, (GST_TRACER_ARGS, pad, list)); \
}G_STMT_END
/**
* GstTracerHookPadPushListPost:
* @self: the tracer instance
* @ts: the current timestamp
* @pad: the pad
* @res: the result of gst_pad_push_list()
*
* Post-hook for gst_pad_push_list() named "pad-push-list-post".
*/
typedef void (*GstTracerHookPadPushListPost) (GObject *self, GstClockTime ts,
GstPad *pad,
GstFlowReturn res);
#define GST_TRACER_PAD_PUSH_LIST_POST(pad, res) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_PUSH_LIST_POST), \
GstTracerHookPadPushListPost, (GST_TRACER_ARGS, pad, res)); \
}G_STMT_END
/**
* GstTracerHookPadPullRangePre:
* @self: the tracer instance
* @ts: the current timestamp
* @pad: the pad
* @offset: the stream offset
* @size: the requested size
*
* Pre-hook for gst_pad_pull_range() named "pad-pull-range-pre".
*/
typedef void (*GstTracerHookPadPullRangePre) (GObject *self, GstClockTime ts,
GstPad *pad, guint64 offset, guint size);
#define GST_TRACER_PAD_PULL_RANGE_PRE(pad, offset, size) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_PULL_RANGE_PRE), \
GstTracerHookPadPullRangePre, (GST_TRACER_ARGS, pad, offset, size)); \
}G_STMT_END
/**
* GstTracerHookPadPullRangePost:
* @self: the tracer instance
* @ts: the current timestamp
* @pad: the pad
* @buffer: the buffer
* @res: the result of gst_pad_pull_range()
*
* Post-hook for gst_pad_pull_range() named "pad-pull-range-post".
*/
typedef void (*GstTracerHookPadPullRangePost) (GObject *self, GstClockTime ts,
GstPad *pad, GstBuffer *buffer, GstFlowReturn res);
#define GST_TRACER_PAD_PULL_RANGE_POST(pad, buffer, res) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_PULL_RANGE_POST), \
GstTracerHookPadPullRangePost, (GST_TRACER_ARGS, pad, buffer, res)); \
}G_STMT_END
/**
* GstTracerHookPadPushEventPre:
* @self: the tracer instance
* @ts: the current timestamp
* @pad: the pad
* @event: the event
*
* Pre-hook for when an event is pushed through a pad, named
* "pad-push-event-pre".
*
* Called by gst_pad_push_event(). Also called by functions other than
* gst_pad_push_event() that call gst_pad_push_event_unchecked() directly,
* namely push_sticky() and check_sticky().
*/
typedef void (*GstTracerHookPadPushEventPre) (GObject *self, GstClockTime ts,
GstPad *pad, GstEvent *event);
#define GST_TRACER_PAD_PUSH_EVENT_PRE(pad, event) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_PUSH_EVENT_PRE), \
GstTracerHookPadPushEventPre, (GST_TRACER_ARGS, pad, event)); \
}G_STMT_END
/**
* GstTracerHookPadPushEventPost:
* @self: the tracer instance
* @ts: the current timestamp
* @pad: the pad
* @res: the result of gst_pad_push_event()
*
* Post-hook for when an event has been pushed through a pad, named
* "pad-push-event-post".
*
* Called by gst_pad_push_event(). Also called by functions other than
* gst_pad_push_event() that call gst_pad_push_event_unchecked() directly,
* namely push_sticky() and check_sticky().
*/
typedef void (*GstTracerHookPadPushEventPost) (GObject *self, GstClockTime ts,
GstPad *pad, gboolean res);
#define GST_TRACER_PAD_PUSH_EVENT_POST(pad, res) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_PUSH_EVENT_POST), \
GstTracerHookPadPushEventPost, (GST_TRACER_ARGS, pad, res)); \
}G_STMT_END
/**
* GstTracerHookPadSendEventPre:
* @self: the tracer instance
* @ts: the current timestamp
* @pad: the pad
* @event: the event
*
* Pre-hook for gst_pad_send_event_unchecked() named "pad-send-event-pre".
*/
typedef void (*GstTracerHookPadSendEventPre) (GObject *self, GstClockTime ts,
GstPad *pad, GstEvent *event);
#define GST_TRACER_PAD_SEND_EVENT_PRE(pad, event) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_SEND_EVENT_PRE), \
GstTracerHookPadSendEventPre, (GST_TRACER_ARGS, pad, event)); \
}G_STMT_END
/**
* GstTracerHookPadSendEventPost:
* @self: the tracer instance
* @ts: the current timestamp
* @pad: the pad
* @res: the result of gst_pad_send_event_unchecked()
*
* Post-hook for gst_pad_send_event_unchecked() named "pad-send-event-post".
*/
typedef void (*GstTracerHookPadSendEventPost) (GObject *self, GstClockTime ts,
GstPad *pad, GstFlowReturn res);
#define GST_TRACER_PAD_SEND_EVENT_POST(pad, res) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_SEND_EVENT_POST), \
GstTracerHookPadSendEventPost, (GST_TRACER_ARGS, pad, res)); \
}G_STMT_END
/**
* GstTracerHookPadQueryPre:
* @self: the tracer instance
* @ts: the current timestamp
* @pad: the pad
* @query: the query
*
* Pre-hook for gst_pad_query() named "pad-query-pre".
*/
typedef void (*GstTracerHookPadQueryPre) (GObject *self, GstClockTime ts,
GstPad *pad, GstQuery *query);
#define GST_TRACER_PAD_QUERY_PRE(pad, query) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_QUERY_PRE), \
GstTracerHookPadQueryPre, (GST_TRACER_ARGS, pad, query)); \
}G_STMT_END
/**
* GstTracerHookPadQueryPost:
* @self: the tracer instance
* @ts: the current timestamp
* @pad: the pad
* @query: the query
* @res: the result of gst_pad_query()
*
* Post-hook for gst_pad_query() named "pad-query-post".
*/
typedef void (*GstTracerHookPadQueryPost) (GObject *self, GstClockTime ts,
GstPad *pad, GstQuery *query, gboolean res);
#define GST_TRACER_PAD_QUERY_POST(pad, query, res) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_QUERY_POST), \
GstTracerHookPadQueryPost, (GST_TRACER_ARGS, pad, query, res)); \
}G_STMT_END
/**
* GstTracerHookElementPostMessagePre:
* @self: the tracer instance
* @ts: the current timestamp
* @element: the element
* @message: the message
*
* Pre-hook for gst_element_post_message() named "element-post-message-pre".
*/
typedef void (*GstTracerHookElementPostMessagePre) (GObject *self,
GstClockTime ts, GstElement *element, GstMessage *message);
#define GST_TRACER_ELEMENT_POST_MESSAGE_PRE(element, message) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_ELEMENT_POST_MESSAGE_PRE), \
GstTracerHookElementPostMessagePre, (GST_TRACER_ARGS, element, message)); \
}G_STMT_END
/**
* GstTracerHookElementPostMessagePost:
* @self: the tracer instance
* @ts: the current timestamp
* @element: the element
* @res: the result of gst_element_post_message()
*
* Pre-hook for gst_element_post_message() named "element-post-message-post".
*/
typedef void (*GstTracerHookElementPostMessagePost) (GObject *self,
GstClockTime ts, GstElement *element, gboolean res);
#define GST_TRACER_ELEMENT_POST_MESSAGE_POST(element, res) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_ELEMENT_POST_MESSAGE_POST), \
GstTracerHookElementPostMessagePost, (GST_TRACER_ARGS, element, res)); \
}G_STMT_END
/**
* GstTracerHookElementQueryPre:
* @self: the tracer instance
* @ts: the current timestamp
* @element: the element
* @query: the query
*
* Pre-hook for gst_element_query() named "element-query-pre".
*/
typedef void (*GstTracerHookElementQueryPre) (GObject *self, GstClockTime ts,
GstElement *element, GstQuery *query);
#define GST_TRACER_ELEMENT_QUERY_PRE(element, query) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_ELEMENT_QUERY_PRE), \
GstTracerHookElementQueryPre, (GST_TRACER_ARGS, element, query)); \
}G_STMT_END
/**
* GstTracerHookElementQueryPost:
* @self: the tracer instance
* @ts: the current timestamp
* @element: the element
* @query: the query
* @res: the result of gst_element_query()
*
* Post-hook for gst_element_query() named "element-query-post".
*/
typedef void (*GstTracerHookElementQueryPost) (GObject *self, GstClockTime ts,
GstElement *element, GstQuery *query, gboolean res);
#define GST_TRACER_ELEMENT_QUERY_POST(element, query, res) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_ELEMENT_QUERY_POST), \
GstTracerHookElementQueryPost, (GST_TRACER_ARGS, element, query, res)); \
}G_STMT_END
/**
* GstTracerHookElementNew:
* @self: the tracer instance
* @ts: the current timestamp
* @element: the element
*
* Hook for whenever a new element is created, named "element-new".
*/
typedef void (*GstTracerHookElementNew) (GObject *self, GstClockTime ts,
GstElement *element);
#define GST_TRACER_ELEMENT_NEW(element) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_ELEMENT_NEW), \
GstTracerHookElementNew, (GST_TRACER_ARGS, element)); \
}G_STMT_END
/**
* GstTracerHookElementAddPad:
* @self: the tracer instance
* @ts: the current timestamp
* @element: the element
* @pad: the pad
*
* Hook for gst_element_add_pad() named "element-add-pad".
*/
typedef void (*GstTracerHookElementAddPad) (GObject *self, GstClockTime ts,
GstElement *element, GstPad *pad);
#define GST_TRACER_ELEMENT_ADD_PAD(element, pad) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_ELEMENT_ADD_PAD), \
GstTracerHookElementAddPad, (GST_TRACER_ARGS, element, pad)); \
}G_STMT_END
/**
* GstTracerHookElementRemovePad:
* @self: the tracer instance
* @ts: the current timestamp
* @element: the element
* @pad: the pad
*
* Hook for gst_element_remove_pad() named "element-remove-pad".
*/
typedef void (*GstTracerHookElementRemovePad) (GObject *self, GstClockTime ts,
GstElement *element, GstPad *pad);
#define GST_TRACER_ELEMENT_REMOVE_PAD(element, pad) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_ELEMENT_REMOVE_PAD), \
GstTracerHookElementRemovePad, (GST_TRACER_ARGS, element, pad)); \
}G_STMT_END
/**
* GstTracerHookElementChangeStatePre:
* @self: the tracer instance
* @ts: the current timestamp
* @element: the element
* @transition: the transition
*
* Pre-hook for gst_element_change_state() named "element-change-state-pre".
*/
typedef void (*GstTracerHookElementChangeStatePre) (GObject *self,
GstClockTime ts, GstElement *element, GstStateChange transition);
#define GST_TRACER_ELEMENT_CHANGE_STATE_PRE(element, transition) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_ELEMENT_CHANGE_STATE_PRE), \
GstTracerHookElementChangeStatePre, (GST_TRACER_ARGS, element, transition)); \
}G_STMT_END
/**
* GstTracerHookElementChangeStatePost:
* @self: the tracer instance
* @ts: the current timestamp
* @element: the element
* @transition: the transition
* @result: the result of gst_pad_push()
*
* Post-hook for gst_element_change_state() named "element-change-state-post".
*/
typedef void (*GstTracerHookElementChangeStatePost) (GObject *self,
GstClockTime ts, GstElement *element, GstStateChange transition,
GstStateChangeReturn result);
#define GST_TRACER_ELEMENT_CHANGE_STATE_POST(element, transition, result) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_ELEMENT_CHANGE_STATE_POST), \
GstTracerHookElementChangeStatePost, (GST_TRACER_ARGS, element, transition, result)); \
}G_STMT_END
/**
* GstTracerHookBinAddPre:
* @self: the tracer instance
* @ts: the current timestamp
* @bin: the bin
* @element: the element
*
* Pre-hook for gst_bin_add() named "bin-add-pre".
*/
typedef void (*GstTracerHookBinAddPre) (GObject *self, GstClockTime ts,
GstBin *bin, GstElement *element);
#define GST_TRACER_BIN_ADD_PRE(bin, element) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_BIN_ADD_PRE), \
GstTracerHookBinAddPre, (GST_TRACER_ARGS, bin, element)); \
}G_STMT_END
/**
* GstTracerHookBinAddPost:
* @self: the tracer instance
* @ts: the current timestamp
* @bin: the bin
* @element: the element
* @result: the result of gst_bin_add()
*
* Post-hook for gst_bin_add() named "bin-add-post".
*/
typedef void (*GstTracerHookBinAddPost) (GObject *self, GstClockTime ts,
GstBin *bin, GstElement *element, gboolean result);
#define GST_TRACER_BIN_ADD_POST(bin, element, result) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_BIN_ADD_POST), \
GstTracerHookBinAddPost, (GST_TRACER_ARGS, bin, element, result)); \
}G_STMT_END
/**
* GstTracerHookBinRemovePre:
* @self: the tracer instance
* @ts: the current timestamp
* @bin: the bin
* @element: the element
*
* Pre-hook for gst_bin_remove() named "bin-remove-pre".
*/
typedef void (*GstTracerHookBinRemovePre) (GObject *self, GstClockTime ts,
GstBin *bin, GstElement *element);
#define GST_TRACER_BIN_REMOVE_PRE(bin, element) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_BIN_REMOVE_PRE), \
GstTracerHookBinRemovePre, (GST_TRACER_ARGS, bin, element)); \
}G_STMT_END
/**
* GstTracerHookBinRemovePost:
* @self: the tracer instance
* @ts: the current timestamp
* @bin: the bin
* @result: the result of gst_bin_remove()
*
* Post-hook for gst_bin_remove() named "bin-remove-post".
*/
typedef void (*GstTracerHookBinRemovePost) (GObject *self, GstClockTime ts,
GstBin *bin, gboolean result);
#define GST_TRACER_BIN_REMOVE_POST(bin, result) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_BIN_REMOVE_POST), \
GstTracerHookBinRemovePost, (GST_TRACER_ARGS, bin, result)); \
}G_STMT_END
/**
* GstTracerHookPadLinkPre:
* @self: the tracer instance
* @ts: the current timestamp
* @srcpad: the srcpad
* @sinkpad: the sinkpad
*
* Pre-hook for gst_pad_link() named "pad-link-pre".
*/
typedef void (*GstTracerHookPadLinkPre) (GObject *self, GstClockTime ts,
GstPad *srcpad, GstPad *sinkpad);
#define GST_TRACER_PAD_LINK_PRE(srcpad, sinkpad) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_LINK_PRE), \
GstTracerHookPadLinkPre, (GST_TRACER_ARGS, srcpad, sinkpad)); \
}G_STMT_END
/**
* GstTracerHookPadLinkPost:
* @self: the tracer instance
* @ts: the current timestamp
* @srcpad: the srcpad
* @sinkpad: the sinkpad
* @result: the result of gst_pad_link()
*
* Post-hook for gst_pad_link() named "pad-link-post".
*/
typedef void (*GstTracerHookPadLinkPost) (GObject *self, GstClockTime ts,
GstPad *srcpad, GstPad *sinkpad, GstPadLinkReturn result);
#define GST_TRACER_PAD_LINK_POST(srcpad, sinkpad, result) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_LINK_POST), \
GstTracerHookPadLinkPost, (GST_TRACER_ARGS, srcpad, sinkpad, result)); \
}G_STMT_END
/**
* GstTracerHookPadUnlinkPre:
* @self: the tracer instance
* @ts: the current timestamp
* @srcpad: the srcpad
* @sinkpad: the sinkpad
*
* Pre-hook for gst_pad_unlink() named "pad-unlink-pre".
*/
typedef void (*GstTracerHookPadUnlinkPre) (GObject *self, GstClockTime ts,
GstPad *srcpad, GstPad *sinkpad);
#define GST_TRACER_PAD_UNLINK_PRE(srcpad, sinkpad) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_UNLINK_PRE), \
GstTracerHookPadUnlinkPre, (GST_TRACER_ARGS, srcpad, sinkpad)); \
}G_STMT_END
/**
* GstTracerHookPadUnlinkPost:
* @self: the tracer instance
* @ts: the current timestamp
* @srcpad: the srcpad
* @sinkpad: the sinkpad
* @result: the result of gst_pad_push()
*
* Post-hook for gst_pad_unlink() named "pad-unlink-post".
*/
typedef void (*GstTracerHookPadUnlinkPost) (GObject *self, GstClockTime ts,
GstPad *srcpad, GstPad *sinkpad, gboolean result);
#define GST_TRACER_PAD_UNLINK_POST(srcpad, sinkpad, result) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_UNLINK_POST), \
GstTracerHookPadUnlinkPost, (GST_TRACER_ARGS, srcpad, sinkpad, result)); \
}G_STMT_END
/**
* GstTracerHookMiniObjectCreated:
* @self: the tracer instance
* @ts: the current timestamp
* @object: the mini object being created
*
* Hook called when a #GstMiniObject is created named "mini-object-created".
*/
typedef void (*GstTracerHookMiniObjectCreated) (GObject *self, GstClockTime ts,
GstMiniObject *object);
#define GST_TRACER_MINI_OBJECT_CREATED(object) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_MINI_OBJECT_CREATED), \
GstTracerHookMiniObjectCreated, (GST_TRACER_ARGS, object)); \
}G_STMT_END
/**
* GstTracerHookMiniObjectDestroyed:
* @self: the tracer instance
* @ts: the current timestamp
* @object: the mini object being destroyed
*
* Hook called when a #GstMiniObject is being destroyed named
* "mini-object-destroyed".
*/
typedef void (*GstTracerHookMiniObjectDestroyed) (GObject *self, GstClockTime ts,
GstMiniObject *object);
#define GST_TRACER_MINI_OBJECT_DESTROYED(object) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_MINI_OBJECT_DESTROYED), \
GstTracerHookMiniObjectDestroyed, (GST_TRACER_ARGS, object)); \
}G_STMT_END
/**
* GstTracerHookObjectUnreffed:
* @self: the tracer instance
* @ts: the current timestamp
* @object: the object being unreffed
* @new_refcount: the new refcount after unrefing @object
*
* Hook called when a #GstObject is being unreffed named
* "object-unreffed"
*/
typedef void (*GstTracerHookObjectUnreffed) (GObject *self, GstClockTime ts,
GstObject *object, gint new_refcount);
#define GST_TRACER_OBJECT_UNREFFED(object, new_refcount) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_OBJECT_UNREFFED), \
GstTracerHookObjectUnreffed, (GST_TRACER_ARGS, object, new_refcount)); \
}G_STMT_END
/**
* GstTracerHookObjectReffed:
* @self: the tracer instance
* @ts: the current timestamp
* @object: the object being reffed
* @new_refcount: the new refcount after refing @object
*
* Hook called when a #GstObject is being reffed named
* "object-reffed".
*/
typedef void (*GstTracerHookObjectReffed) (GObject *self, GstClockTime ts,
GstObject *object, gint new_refcount);
#define GST_TRACER_OBJECT_REFFED(object, new_refcount) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_OBJECT_REFFED), \
GstTracerHookObjectReffed, (GST_TRACER_ARGS, object, new_refcount)); \
}G_STMT_END
/**
* GstTracerHookMiniObjectUnreffed:
* @self: the tracer instance
* @ts: the current timestamp
* @object: the mini object being unreffed
* @new_refcount: the new refcount after unrefing @object
*
* Hook called when a #GstMiniObject is being unreffed named
* "mini-object-unreffed".
*/
typedef void (*GstTracerHookMiniObjectUnreffed) (GObject *self, GstClockTime ts,
GstMiniObject *object, gint new_refcount);
#define GST_TRACER_MINI_OBJECT_UNREFFED(object, new_refcount) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_MINI_OBJECT_UNREFFED), \
GstTracerHookMiniObjectUnreffed, (GST_TRACER_ARGS, object, new_refcount)); \
}G_STMT_END
/**
* GstTracerHookMiniObjectReffed:
* @self: the tracer instance
* @ts: the current timestamp
* @object: the mini object being reffed
* @new_refcount: the new refcount after refing @object
*
* Hook called when a #GstMiniObject is being reffed named
* "mini-object-reffed".
*/
typedef void (*GstTracerHookMiniObjectReffed) (GObject *self, GstClockTime ts,
GstMiniObject *object, gint new_refcount);
#define GST_TRACER_MINI_OBJECT_REFFED(object, new_refcount) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_MINI_OBJECT_REFFED), \
GstTracerHookMiniObjectReffed, (GST_TRACER_ARGS, object, new_refcount)); \
}G_STMT_END
/**
* GstTracerHookObjectCreated:
* @self: the tracer instance
* @ts: the current timestamp
* @object: the object being created
*
* Hook called when a #GstObject is created named "object-created".
*/
typedef void (*GstTracerHookObjectCreated) (GObject *self, GstClockTime ts,
GstObject *object);
#define GST_TRACER_OBJECT_CREATED(object) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_OBJECT_CREATED), \
GstTracerHookObjectCreated, (GST_TRACER_ARGS, object)); \
}G_STMT_END
/**
* GstTracerHookObjectDestroyed:
* @self: the tracer instance
* @ts: the current timestamp
* @object: the object being destroyed
*
* Hook called when a #GstObject is being destroyed named
* "object-destroyed".
*/
typedef void (*GstTracerHookObjectDestroyed) (GObject *self, GstClockTime ts,
GstObject *object);
#define GST_TRACER_OBJECT_DESTROYED(object) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_OBJECT_DESTROYED), \
GstTracerHookObjectDestroyed, (GST_TRACER_ARGS, object)); \
}G_STMT_END
/**
* GstTracerHookPluginFeatureLoaded:
* @self: the tracer instance
* @ts: the current timestamp
* @feature: the plugin feature that was loaded
*
* Hook called when a GstPluginFeature is loaded named
* "plugin-feature-loaded".
*
* Since: 1.20
*/
typedef void (*GstTracerHookPluginFeatureLoaded) (GObject *self, GstClockTime ts,
GstPluginFeature *feature);
/**
* GST_TRACER_PLUGIN_FEATURE_LOADED:
* @feature: The feature that this tracer is called for
*
* Add a tracepoint when a plugin feature is loaded.
*
* Since: 1.20
*/
#define GST_TRACER_PLUGIN_FEATURE_LOADED(feature) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PLUGIN_FEATURE_LOADED), \
GstTracerHookPluginFeatureLoaded, (GST_TRACER_ARGS, feature)); \
}G_STMT_END
/**
* GstTracerHookPadChainPre:
* @self: the tracer instance
* @ts: the current timestamp
* @pad: the pad
* @buffer: the buffer
*
* Pre-hook for gst_pad_chain() named "pad-chain-pre".
*
* Since: 1.22
*/
typedef void (*GstTracerHookPadChainPre) (GObject *self, GstClockTime ts,
GstPad *pad, GstBuffer *buffer);
/**
* GST_TRACER_PAD_CHAIN_PRE:
* @pad: a %GstPad
* @buffer: a %GstBuffer
*
* Dispatches the "pad-chain-pre" hook.
*
* Since: 1.22
*/
#define GST_TRACER_PAD_CHAIN_PRE(pad, buffer) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_CHAIN_PRE), \
GstTracerHookPadChainPre, (GST_TRACER_ARGS, pad, buffer)); \
}G_STMT_END
/**
* GstTracerHookPadChainPost:
* @self: the tracer instance
* @ts: the current timestamp
* @pad: the pad
* @res: the result of gst_pad_chain()
*
* Post-hook for gst_pad_chain() named "pad-chain-post".
*
* Since: 1.22
*/
typedef void (*GstTracerHookPadChainPost) (GObject * self, GstClockTime ts,
GstPad *pad, GstFlowReturn res);
/**
* GST_TRACER_PAD_CHAIN_POST:
* @pad: a %GstPad
* @res: a %GstFlowReturn
*
* Dispatches the "pad-chain-post" hook.
*
* Since: 1.22
*/
#define GST_TRACER_PAD_CHAIN_POST(pad, res) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_CHAIN_POST), \
GstTracerHookPadChainPost, (GST_TRACER_ARGS, pad, res)); \
}G_STMT_END
/**
* GstTracerHookPadChainListPre:
* @self: the tracer instance
* @ts: the current timestamp
* @pad: the pad
* @list: the buffer-list
*
* Pre-hook for gst_pad_chain_list() named "pad-chain-list-pre".
*
* Since: 1.22
*/
typedef void (*GstTracerHookPadChainListPre) (GObject *self, GstClockTime ts,
GstPad *pad, GstBufferList *list);
/**
* GST_TRACER_PAD_CHAIN_LIST_PRE:
* @pad: a %GstPad
* @list: a %GstBufferList
*
* Dispatches the "pad-chain-list-pre" hook.
*
* Since: 1.22
*/
#define GST_TRACER_PAD_CHAIN_LIST_PRE(pad, list) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_CHAIN_LIST_PRE), \
GstTracerHookPadChainListPre, (GST_TRACER_ARGS, pad, list)); \
}G_STMT_END
/**
* GstTracerHookPadChainListPost:
* @self: the tracer instance
* @ts: the current timestamp
* @pad: the pad
* @res: the result of gst_pad_chain_list()
*
* Post-hook for gst_pad_chain_list() named "pad-chain-list-post".
*
* Since: 1.22
*/
typedef void (*GstTracerHookPadChainListPost) (GObject *self, GstClockTime ts,
GstPad *pad,
GstFlowReturn res);
/**
* GST_TRACER_PAD_CHAIN_LIST_POST:
* @pad: a %GstPad
* @res: a %GstFlowReturn
*
* Dispatches the "pad-chain-list-post" hook.
*
* Since: 1.22
*/
#define GST_TRACER_PAD_CHAIN_LIST_POST(pad, res) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_CHAIN_LIST_POST), \
GstTracerHookPadChainListPost, (GST_TRACER_ARGS, pad, res)); \
}G_STMT_END
/**
* GstTracerHookMemoryInit:
* @self: the tracer instance
* @ts: the current timestamp
* @mem: The GstMemory that was initialized
*
* Hook for memory initialization named "memory-init".
*
* Since: 1.26
*/
typedef void (*GstTracerHookMemoryInit) (GObject *self, GstClockTime ts,
GstMemory *mem);
/**
* GST_TRACER_MEMORY_INIT:
* @mem: a #GstMemory
*
* Dispatches the "memory-init" hook.
*
* Since: 1.26
*/
#define GST_TRACER_MEMORY_INIT(mem) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_MEMORY_INIT), \
GstTracerHookMemoryInit, (GST_TRACER_ARGS, mem)); \
}G_STMT_END
/**
* GstTracerHookMemoryFreePre:
* @self: the tracer instance
* @ts: the current timestamp
* @mem: the memory object for which the memory will be freed.
*
* Pre-hook for memory freeing named "memory-free-pre".
*
* Since: 1.26
*/
typedef void (*GstTracerHookMemoryFreePre) (GObject *self, GstClockTime ts, GstMemory *mem);
/**
* GST_TRACER_MEMORY_FREE_PRE:
* @mem: the memory object
*
* Dispatches the "memory-free-pre" hook.
*
* Since: 1.26
*/
#define GST_TRACER_MEMORY_FREE_PRE(mem) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_MEMORY_FREE_PRE), \
GstTracerHookMemoryFreePre, (GST_TRACER_ARGS, mem)); \
}G_STMT_END
/**
* GstTracerHookMemoryFreePost:
* @self: the tracer instance
* @ts: the current timestamp
* @mem: pointer to the memory object that has been freed
*
* Post-hook for memory freeing named "memory-free-post".
*
* Since: 1.26
*/
typedef void (*GstTracerHookMemoryFreePost) (GObject *self, GstClockTime ts, GstMemory *mem);
/**
* GST_TRACER_MEMORY_FREE_POST:
* @mem: pointer to the memory object that has been freed
*
* Dispatches the "memory-free-post" hook.
*
* Since: 1.26
*/
#define GST_TRACER_MEMORY_FREE_POST(mem) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_MEMORY_FREE_POST), \
GstTracerHookMemoryFreePost, (GST_TRACER_ARGS, mem)); \
}G_STMT_END
/**
* GstTracerHookPoolBufferQueued:
* @self: the tracer instance
* @ts: the current timestamp
* @pool: a #GstBufferPool
* @buffer: pointer to the #GstBuffer that has been queued into @pool
*
* Hook for pool buffer queued named "pool-buffer-queued".
*
* Since: 1.28
*/
typedef void (*GstTracerHookPoolBufferQueued) (GObject *self, GstClockTime ts, GstBufferPool *pool, GstBuffer *buffer);
/**
* GST_TRACER_POOL_BUFFER_QUEUED:
* @pool: a #GstBufferPool
* @buffer: pointer to the #GstBuffer that has been queued into @pool
*
* Dispatches the "pool-buffer-queued" hook.
*
* Since: 1.28
*/
#define GST_TRACER_POOL_BUFFER_QUEUED(pool, buf) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_POOL_BUFFER_QUEUED), \
GstTracerHookPoolBufferQueued, (GST_TRACER_ARGS, pool, buf)); \
}G_STMT_END
/**
* GstTracerHookPoolBufferDequeued:
* @self: the tracer instance
* @ts: the current timestamp
* @pool: a #GstBufferPool
* @buffer: pointer to the #GstBuffer that has been dequeued from @pool
*
* Hook for pool buffer dequeued named "pool-buffer-dequeued".
*
* Since: 1.28
*/
typedef void (*GstTracerHookPoolBufferDequeued) (GObject *self, GstClockTime ts, GstBufferPool *pool, GstBuffer *buffer);
/**
* GST_TRACER_POOL_BUFFER_DEQUEUED:
* @pool: a #GstBufferPool
* @buffer: pointer to the #GstBuffer that has been dequeued from @pool
*
* Dispatches the "pool-buffer-dequeued" hook.
*
* Since: 1.28
*/
#define GST_TRACER_POOL_BUFFER_DEQUEUED(pool, buffer) G_STMT_START{ \
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_POOL_BUFFER_DEQUEUED), \
GstTracerHookPoolBufferDequeued, (GST_TRACER_ARGS, pool, buffer)); \
}G_STMT_END
#else /* !GST_DISABLE_GST_TRACER_HOOKS */
static inline void
_priv_gst_tracing_init (void)
{
GST_DEBUG ("Tracing hooks are disabled");
}
static inline void
_priv_gst_tracing_deinit (void)
{
}
#define GST_TRACER_PAD_PUSH_PRE(pad, buffer)
#define GST_TRACER_PAD_PUSH_POST(pad, res)
#define GST_TRACER_PAD_PUSH_LIST_PRE(pad, list)
#define GST_TRACER_PAD_PUSH_LIST_POST(pad, res)
#define GST_TRACER_PAD_PULL_RANGE_PRE(pad, offset, size)
#define GST_TRACER_PAD_PULL_RANGE_POST(pad, buffer, res)
#define GST_TRACER_PAD_PUSH_EVENT_PRE(pad, event)
#define GST_TRACER_PAD_PUSH_EVENT_POST(pad, res)
#define GST_TRACER_PAD_QUERY_PRE(pad, query)
#define GST_TRACER_PAD_QUERY_POST(pad, query, res)
#define GST_TRACER_ELEMENT_POST_MESSAGE_PRE(element, message)
#define GST_TRACER_ELEMENT_POST_MESSAGE_POST(element, res)
#define GST_TRACER_ELEMENT_QUERY_PRE(element, query)
#define GST_TRACER_ELEMENT_QUERY_POST(element, query, res)
#define GST_TRACER_ELEMENT_NEW(element)
#define GST_TRACER_ELEMENT_ADD_PAD(element, pad)
#define GST_TRACER_ELEMENT_REMOVE_PAD(element, pad)
#define GST_TRACER_ELEMENT_CHANGE_STATE_PRE(element, transition)
#define GST_TRACER_ELEMENT_CHANGE_STATE_POST(element, transition, res)
#define GST_TRACER_BIN_ADD_PRE(bin, element)
#define GST_TRACER_BIN_ADD_POST(bin, element, res)
#define GST_TRACER_BIN_REMOVE_PRE(bin, element)
#define GST_TRACER_BIN_REMOVE_POST(bin, res)
#define GST_TRACER_PAD_LINK_PRE(srcpad, sinkpad)
#define GST_TRACER_PAD_LINK_POST(srcpad, sinkpad, res)
#define GST_TRACER_PAD_UNLINK_PRE(srcpad, sinkpad)
#define GST_TRACER_PAD_UNLINK_POST(srcpad, sinkpad, res)
#define GST_TRACER_MINI_OBJECT_CREATED(object)
#define GST_TRACER_MINI_OBJECT_DESTROYED(object)
#define GST_TRACER_MINI_OBJECT_REFFED(object, new_refcount)
#define GST_TRACER_MINI_OBJECT_UNREFFED(object, new_refcount)
#define GST_TRACER_OBJECT_CREATED(object)
#define GST_TRACER_OBJECT_DESTROYED(object)
#define GST_TRACER_OBJECT_REFFED(object, new_refcount)
#define GST_TRACER_OBJECT_UNREFFED(object, new_refcount)
#define GST_TRACER_PLUGIN_FEATURE_LOADED(feature)
#define GST_TRACER_PAD_CHAIN_PRE(pad, buffer)
#define GST_TRACER_PAD_CHAIN_POST(pad, res)
#define GST_TRACER_PAD_CHAIN_LIST_PRE(pad, list)
#define GST_TRACER_PAD_CHAIN_LIST_POST(pad, res)
#define GST_TRACER_PAD_SEND_EVENT_PRE(pad, event)
#define GST_TRACER_PAD_SEND_EVENT_POST(pad, res)
#define GST_TRACER_MEMORY_INIT(mem)
#define GST_TRACER_MEMORY_FREE_PRE(mem)
#define GST_TRACER_MEMORY_FREE_POST(mem)
#define GST_TRACER_POOL_BUFFER_QUEUED(pool, buffer)
#define GST_TRACER_POOL_BUFFER_DEQUEUED(pool, buffer)
#endif /* GST_DISABLE_GST_TRACER_HOOKS */
G_END_DECLS
#endif /* __GST_TRACER_UTILS_H__ */