2 * Copyright (C) 2013 Stefan Sauer <ensonic@users.sf.net>
4 * gstlog.c: tracing module that logs events
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.
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.
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.
23 * @short_description: log hook event
25 * A tracing module that logs all data from all hooks.
34 #include <gst/printf/printf.h>
36 GST_DEBUG_CATEGORY_STATIC (gst_log_debug);
37 #define GST_CAT_DEFAULT gst_log_debug
38 GST_DEBUG_CATEGORY_STATIC (GST_CAT_BUFFER);
39 GST_DEBUG_CATEGORY_STATIC (GST_CAT_BUFFER_LIST);
40 GST_DEBUG_CATEGORY_STATIC (GST_CAT_EVENT);
41 GST_DEBUG_CATEGORY_STATIC (GST_CAT_MESSAGE);
42 GST_DEBUG_CATEGORY_STATIC (GST_CAT_QUERY);
45 GST_DEBUG_CATEGORY_INIT (gst_log_debug, "log", 0, "log tracer"); \
46 GST_DEBUG_CATEGORY_GET (GST_CAT_BUFFER, "GST_BUFFER"); \
47 GST_DEBUG_CATEGORY_GET (GST_CAT_BUFFER_LIST, "GST_BUFFER_LIST"); \
48 GST_DEBUG_CATEGORY_GET (GST_CAT_EVENT, "GST_EVENT"); \
49 GST_DEBUG_CATEGORY_GET (GST_CAT_MESSAGE, "GST_MESSAGE"); \
50 GST_DEBUG_CATEGORY_GET (GST_CAT_QUERY, "query");
51 #define gst_log_tracer_parent_class parent_class
52 G_DEFINE_TYPE_WITH_CODE (GstLogTracer, gst_log_tracer, GST_TYPE_TRACER,
56 do_log (GstDebugCategory * cat, const char *fmt, ...)
60 va_start (var_args, fmt);
61 gst_debug_log_valist (cat, GST_LEVEL_TRACE, "", "", 0, NULL, fmt, var_args);
66 do_push_buffer_pre (GstTracer * self, guint64 ts, GstPad * pad,
69 do_log (GST_CAT_BUFFER,
70 "%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", buffer=%" GST_PTR_FORMAT,
75 do_push_buffer_post (GstTracer * self, guint64 ts, GstPad * pad,
78 do_log (GST_CAT_BUFFER,
79 "%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", res=%d", ts, pad, res);
83 do_push_buffer_list_pre (GstTracer * self, guint64 ts, GstPad * pad,
86 do_log (GST_CAT_BUFFER_LIST,
87 "%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", list=%p", ts, pad, list);
91 do_push_buffer_list_post (GstTracer * self, guint64 ts, GstPad * pad,
94 do_log (GST_CAT_BUFFER_LIST,
95 "%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", res=%d", ts, pad, res);
99 do_pull_range_pre (GstTracer * self, guint64 ts, GstPad * pad, guint64 offset,
102 do_log (GST_CAT_BUFFER,
103 "%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", offset=%" G_GUINT64_FORMAT
104 ", size=%u", ts, pad, offset, size);
108 do_pull_range_post (GstTracer * self, guint64 ts, GstPad * pad,
109 GstBuffer * buffer, GstFlowReturn res)
111 do_log (GST_CAT_BUFFER,
112 "%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", buffer=%" GST_PTR_FORMAT
113 ", res=%d", ts, pad, buffer, res);
117 do_push_event_pre (GstTracer * self, guint64 ts, GstPad * pad, GstEvent * event)
119 do_log (GST_CAT_EVENT,
120 "%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", event=%" GST_PTR_FORMAT,
125 do_push_event_post (GstTracer * self, guint64 ts, GstPad * pad, gboolean res)
127 do_log (GST_CAT_EVENT,
128 "%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", res=%d", ts, pad, res);
132 do_post_message_pre (GstTracer * self, guint64 ts, GstElement * elem,
135 do_log (GST_CAT_EVENT,
136 "%" GST_TIME_FORMAT ", element=%" GST_PTR_FORMAT ", message=%"
137 GST_PTR_FORMAT, ts, elem, msg);
141 do_post_message_post (GstTracer * self, guint64 ts, GstElement * elem,
144 do_log (GST_CAT_EVENT,
145 "%" GST_TIME_FORMAT ", element=%" GST_PTR_FORMAT ", res=%d", ts, elem,
150 do_query_pre (GstTracer * self, guint64 ts, GstElement * elem, GstQuery * query)
152 do_log (GST_CAT_QUERY,
153 "%" GST_TIME_FORMAT ", element=%" GST_PTR_FORMAT ", query=%"
154 GST_PTR_FORMAT, ts, elem, query);
158 do_query_post (GstTracer * self, guint64 ts, GstElement * elem, gboolean res)
160 do_log (GST_CAT_QUERY,
161 "%" GST_TIME_FORMAT ", element=%" GST_PTR_FORMAT ", res=%d", ts, elem,
169 gst_log_tracer_class_init (GstLogTracerClass * klass)
174 gst_log_tracer_init (GstLogTracer * self)
176 GstTracer *tracer = GST_TRACER (self);
178 gst_tracer_register_hook (tracer, "pad-push-pre",
179 G_CALLBACK (do_push_buffer_pre));
180 gst_tracer_register_hook (tracer, "pad-push-post",
181 G_CALLBACK (do_push_buffer_post));
182 gst_tracer_register_hook (tracer, "pad-push-list-pre",
183 G_CALLBACK (do_push_buffer_list_pre));
184 gst_tracer_register_hook (tracer, "pad-push-list-post",
185 G_CALLBACK (do_push_buffer_list_post));
186 gst_tracer_register_hook (tracer, "pad-pull-range-pre",
187 G_CALLBACK (do_pull_range_pre));
188 gst_tracer_register_hook (tracer, "pad-pull-range-post",
189 G_CALLBACK (do_pull_range_post));
190 gst_tracer_register_hook (tracer, "pad-push-event-pre",
191 G_CALLBACK (do_push_event_pre));
192 gst_tracer_register_hook (tracer, "pad-push-event-post",
193 G_CALLBACK (do_push_event_post));
194 gst_tracer_register_hook (tracer, "element-post-message-pre",
195 G_CALLBACK (do_post_message_pre));
196 gst_tracer_register_hook (tracer, "element-post-message-post",
197 G_CALLBACK (do_post_message_post));
198 gst_tracer_register_hook (tracer, "element-query-pre",
199 G_CALLBACK (do_query_pre));
200 gst_tracer_register_hook (tracer, "element-query-post",
201 G_CALLBACK (do_query_post));