2 * Copyright (C) 2013 Stefan Sauer <ensonic@users.sf.net>
4 * gststats.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 event stats
25 * A tracing module that builds usage statistic for elements and pads.
36 GST_DEBUG_CATEGORY_STATIC (gst_stats_debug);
37 #define GST_CAT_DEFAULT gst_stats_debug
39 static GQuark data_quark;
40 G_LOCK_DEFINE (_elem_stats);
41 G_LOCK_DEFINE (_pad_stats);
44 GST_DEBUG_CATEGORY_INIT (gst_stats_debug, "stats", 0, "stats tracer"); \
45 data_quark = g_quark_from_static_string ("gststats:data");
46 #define gst_stats_tracer_parent_class parent_class
47 G_DEFINE_TYPE_WITH_CODE (GstStatsTracer, gst_stats_tracer, GST_TYPE_TRACER,
50 static GstTracerRecord *tr_new_element;
51 static GstTracerRecord *tr_new_pad;
52 static GstTracerRecord *tr_buffer;
53 static GstTracerRecord *tr_element_query;
54 static GstTracerRecord *tr_event;
55 static GstTracerRecord *tr_message;
56 static GstTracerRecord *tr_query;
60 /* we can't rely on the address to be unique over time */
70 /* we can't rely on the address to be unique over time */
74 /* time spend in this element */
82 static GstElementStats no_elem_stats = { 0, };
84 static GstElementStats *
85 fill_element_stats (GstStatsTracer * self, GstElement * element)
87 GstElementStats *stats = g_slice_new0 (GstElementStats);
89 stats->index = self->num_elements++;
90 stats->parent_ix = G_MAXUINT;
95 log_new_element_stats (GstElementStats * stats, GstElement * element,
98 gst_tracer_record_log (tr_new_element, (guint64) (guintptr) g_thread_self (),
99 elapsed, stats->index, stats->parent_ix, GST_OBJECT_NAME (element),
100 G_OBJECT_TYPE_NAME (element), GST_IS_BIN (element));
104 free_element_stats (gpointer data)
106 g_slice_free (GstElementStats, data);
109 static GstElementStats *
110 create_element_stats (GstStatsTracer * self, GstElement * element)
112 GstElementStats *stats;
114 stats = fill_element_stats (self, element);
115 g_object_set_qdata_full ((GObject *) element, data_quark, stats,
121 static inline GstElementStats *
122 get_element_stats (GstStatsTracer * self, GstElement * element)
124 GstElementStats *stats;
125 gboolean is_new = FALSE;
128 no_elem_stats.index = G_MAXUINT;
129 return &no_elem_stats;
132 G_LOCK (_elem_stats);
133 if (!(stats = g_object_get_qdata ((GObject *) element, data_quark))) {
134 stats = create_element_stats (self, element);
137 G_UNLOCK (_elem_stats);
138 if (G_UNLIKELY (stats->parent_ix == G_MAXUINT)) {
139 GstElement *parent = GST_ELEMENT_PARENT (element);
141 GstElementStats *parent_stats = get_element_stats (self, parent);
142 stats->parent_ix = parent_stats->index;
145 if (G_UNLIKELY (is_new)) {
146 log_new_element_stats (stats, element, GST_CLOCK_TIME_NONE);
152 * Get the element/bin owning the pad.
158 * out: the element that contains the peer of the proxy
161 * out: the bin owning the ghostpad
163 /* TODO(ensonic): gst_pad_get_parent_element() would not work here, should we
164 * add this as new api, e.g. gst_pad_find_parent_element();
167 get_real_pad_parent (GstPad * pad)
174 parent = GST_OBJECT_PARENT (pad);
176 /* if parent of pad is a ghost-pad, then pad is a proxy_pad */
177 if (parent && GST_IS_GHOST_PAD (parent)) {
178 pad = GST_PAD_CAST (parent);
179 parent = GST_OBJECT_PARENT (pad);
181 return GST_ELEMENT_CAST (parent);
184 static GstPadStats no_pad_stats = { 0, };
187 fill_pad_stats (GstStatsTracer * self, GstPad * pad)
189 GstPadStats *stats = g_slice_new0 (GstPadStats);
191 stats->index = self->num_pads++;
192 stats->parent_ix = G_MAXUINT;
198 log_new_pad_stats (GstPadStats * stats, GstPad * pad)
200 gst_tracer_record_log (tr_new_pad, (guint64) (guintptr) g_thread_self (),
201 stats->index, stats->parent_ix, GST_OBJECT_NAME (pad),
202 G_OBJECT_TYPE_NAME (pad), GST_IS_GHOST_PAD (pad),
203 GST_PAD_DIRECTION (pad));
207 free_pad_stats (gpointer data)
209 g_slice_free (GstPadStats, data);
213 get_pad_stats (GstStatsTracer * self, GstPad * pad)
216 gboolean is_new = FALSE;
219 no_pad_stats.index = G_MAXUINT;
220 return &no_pad_stats;
224 if (!(stats = g_object_get_qdata ((GObject *) pad, data_quark))) {
225 stats = fill_pad_stats (self, pad);
226 g_object_set_qdata_full ((GObject *) pad, data_quark, stats,
230 G_UNLOCK (_pad_stats);
231 if (G_UNLIKELY (stats->parent_ix == G_MAXUINT)) {
232 GstElement *elem = get_real_pad_parent (pad);
234 GstElementStats *elem_stats = get_element_stats (self, elem);
236 stats->parent_ix = elem_stats->index;
239 if (G_UNLIKELY (is_new)) {
240 log_new_pad_stats (stats, pad);
246 do_buffer_stats (GstStatsTracer * self, GstPad * this_pad,
247 GstPadStats * this_pad_stats, GstPad * that_pad,
248 GstPadStats * that_pad_stats, GstBuffer * buf, GstClockTime elapsed)
250 GstElement *this_elem = get_real_pad_parent (this_pad);
251 GstElementStats *this_elem_stats = get_element_stats (self, this_elem);
252 GstElement *that_elem = get_real_pad_parent (that_pad);
253 GstElementStats *that_elem_stats = get_element_stats (self, that_elem);
254 GstClockTime pts = GST_BUFFER_PTS (buf);
255 GstClockTime dts = GST_BUFFER_DTS (buf);
256 GstClockTime dur = GST_BUFFER_DURATION (buf);
258 gst_tracer_record_log (tr_buffer, (guint64) (guintptr) g_thread_self (),
259 elapsed, this_pad_stats->index, this_elem_stats->index,
260 that_pad_stats->index, that_elem_stats->index, gst_buffer_get_size (buf),
261 GST_CLOCK_TIME_IS_VALID (pts), pts, GST_CLOCK_TIME_IS_VALID (dts), dts,
262 GST_CLOCK_TIME_IS_VALID (dur), dur, GST_BUFFER_FLAGS (buf));
266 do_query_stats (GstStatsTracer * self, GstPad * this_pad,
267 GstPadStats * this_pad_stats, GstPad * that_pad,
268 GstPadStats * that_pad_stats, GstQuery * qry, GstClockTime elapsed,
269 gboolean have_res, gboolean res)
271 GstElement *this_elem = get_real_pad_parent (this_pad);
272 GstElementStats *this_elem_stats = get_element_stats (self, this_elem);
273 GstElement *that_elem = get_real_pad_parent (that_pad);
274 GstElementStats *that_elem_stats = get_element_stats (self, that_elem);
276 gst_tracer_record_log (tr_query, (guint64) (guintptr) g_thread_self (),
277 elapsed, this_pad_stats->index, this_elem_stats->index,
278 that_pad_stats->index, that_elem_stats->index, GST_QUERY_TYPE_NAME (qry),
279 gst_query_get_structure (qry), have_res, res);
283 do_element_stats (GstStatsTracer * self, GstPad * pad, GstClockTime elapsed1,
284 GstClockTime elapsed2)
286 GstClockTimeDiff elapsed = GST_CLOCK_DIFF (elapsed1, elapsed2);
287 GstObject *parent = GST_OBJECT_PARENT (pad);
289 GST_ELEMENT_CAST (GST_IS_PAD (parent) ? GST_OBJECT_PARENT (parent) :
291 GstElementStats *this_stats = get_element_stats (self, this);
292 GstPad *peer_pad = GST_PAD_PEER (pad);
293 GstElementStats *peer_stats;
298 /* walk the ghost pad chain downstream to get the real pad */
299 /* if parent of peer_pad is a ghost-pad, then peer_pad is a proxy_pad */
300 parent = GST_OBJECT_PARENT (peer_pad);
301 if (parent && GST_IS_GHOST_PAD (parent)) {
302 peer_pad = GST_PAD_CAST (parent);
303 /* if this is now the ghost pad, get the peer of this */
304 get_pad_stats (self, peer_pad);
305 if ((parent = GST_OBJECT_PARENT (peer_pad))) {
306 get_element_stats (self, GST_ELEMENT_CAST (parent));
308 peer_pad = GST_PAD_PEER (GST_GHOST_PAD_CAST (peer_pad));
309 parent = peer_pad ? GST_OBJECT_PARENT (peer_pad) : NULL;
311 /* walk the ghost pad chain upstream to get the real pad */
312 /* if peer_pad is a ghost-pad, then parent is a bin and it is the parent of
314 while (peer_pad && GST_IS_GHOST_PAD (peer_pad)) {
315 get_pad_stats (self, peer_pad);
316 get_element_stats (self, GST_ELEMENT_CAST (parent));
317 peer_pad = gst_ghost_pad_get_target (GST_GHOST_PAD_CAST (peer_pad));
318 parent = peer_pad ? GST_OBJECT_PARENT (peer_pad) : NULL;
322 printf ("%" GST_TIME_FORMAT
323 " transmission on unparented target pad %s_%s -> %s_%s\n",
324 GST_TIME_ARGS (elapsed), GST_DEBUG_PAD_NAME (pad),
325 GST_DEBUG_PAD_NAME (peer_pad));
328 peer_stats = get_element_stats (self, GST_ELEMENT_CAST (parent));
330 /* we'd like to gather time spend in each element, but this does not make too
332 * pure push/pull-based:
333 * - the time spend in the push/pull_range is accounted for the peer and
334 * removed from the current element
335 * - this works for chains
336 * - drawback is sink elements that block to sync have a high time usage
337 * - we could rerun the ests with sync=false
339 * - a.g. demuxers both push and pull. thus we subtract time for the pull
340 * and the push operations, but never add anything.
341 * - can we start a counter after push/pull in such elements and add then
342 * time to the element upon next pad activity?
345 /* this does not make sense for demuxers */
346 this_stats->treal -= elapsed;
347 peer_stats->treal += elapsed;
349 /* this creates several >100% figures */
350 this_stats->treal += GST_CLOCK_DIFF (this_stats->last_ts, elapsed2) - elapsed;
351 peer_stats->treal += elapsed;
352 this_stats->last_ts = elapsed2;
353 peer_stats->last_ts = elapsed2;
360 do_push_buffer_pre (GstStatsTracer * self, guint64 ts, GstPad * this_pad,
363 GstPadStats *this_pad_stats = get_pad_stats (self, this_pad);
364 GstPad *that_pad = GST_PAD_PEER (this_pad);
365 GstPadStats *that_pad_stats = get_pad_stats (self, that_pad);
367 do_buffer_stats (self, this_pad, this_pad_stats, that_pad, that_pad_stats,
372 do_push_buffer_post (GstStatsTracer * self, guint64 ts, GstPad * pad,
375 GstPadStats *stats = get_pad_stats (self, pad);
377 do_element_stats (self, pad, stats->last_ts, ts);
382 GstStatsTracer *self;
384 GstPadStats *this_pad_stats;
386 GstPadStats *that_pad_stats;
388 } DoPushBufferListArgs;
391 do_push_buffer_list_item (GstBuffer ** buffer, guint idx, gpointer user_data)
393 DoPushBufferListArgs *args = (DoPushBufferListArgs *) user_data;
395 do_buffer_stats (args->self, args->this_pad, args->this_pad_stats,
396 args->that_pad, args->that_pad_stats, *buffer, args->ts);
401 do_push_buffer_list_pre (GstStatsTracer * self, guint64 ts, GstPad * this_pad,
402 GstBufferList * list)
404 GstPadStats *this_pad_stats = get_pad_stats (self, this_pad);
405 GstPad *that_pad = GST_PAD_PEER (this_pad);
406 GstPadStats *that_pad_stats = get_pad_stats (self, that_pad);
407 DoPushBufferListArgs args = { self, this_pad, this_pad_stats, that_pad,
411 gst_buffer_list_foreach (list, do_push_buffer_list_item, &args);
415 do_push_buffer_list_post (GstStatsTracer * self, guint64 ts, GstPad * pad,
418 GstPadStats *stats = get_pad_stats (self, pad);
420 do_element_stats (self, pad, stats->last_ts, ts);
424 do_pull_range_pre (GstStatsTracer * self, guint64 ts, GstPad * pad)
426 GstPadStats *stats = get_pad_stats (self, pad);
431 do_pull_range_post (GstStatsTracer * self, guint64 ts, GstPad * this_pad,
434 GstPadStats *this_pad_stats = get_pad_stats (self, this_pad);
435 guint64 last_ts = this_pad_stats->last_ts;
436 GstPad *that_pad = GST_PAD_PEER (this_pad);
437 GstPadStats *that_pad_stats = get_pad_stats (self, that_pad);
439 if (buffer != NULL) {
440 do_buffer_stats (self, this_pad, this_pad_stats, that_pad, that_pad_stats,
443 do_element_stats (self, this_pad, last_ts, ts);
447 do_push_event_pre (GstStatsTracer * self, guint64 ts, GstPad * pad,
450 GstElement *elem = get_real_pad_parent (pad);
451 GstElementStats *elem_stats = get_element_stats (self, elem);
452 GstPadStats *pad_stats = get_pad_stats (self, pad);
454 elem_stats->last_ts = ts;
455 gst_tracer_record_log (tr_event, (guint64) (guintptr) g_thread_self (), ts,
456 pad_stats->index, elem_stats->index, GST_EVENT_TYPE_NAME (ev));
460 do_post_message_pre (GstStatsTracer * self, guint64 ts, GstElement * elem,
463 GstElementStats *stats = get_element_stats (self, elem);
464 const GstStructure *msg_s = gst_message_get_structure (msg);
466 msg_s ? (GstStructure *) msg_s : gst_structure_new_empty ("dummy");
469 /* FIXME: work out whether using NULL instead of a dummy struct would work */
470 gst_tracer_record_log (tr_message, (guint64) (guintptr) g_thread_self (), ts,
471 stats->index, GST_MESSAGE_TYPE_NAME (msg), s);
473 gst_structure_free (s);
477 do_element_new (GstStatsTracer * self, guint64 ts, GstElement * elem)
479 GstElementStats *stats;
481 stats = create_element_stats (self, elem);
482 log_new_element_stats (stats, elem, ts);
486 do_element_query_pre (GstStatsTracer * self, guint64 ts, GstElement * elem,
489 GstElementStats *stats = get_element_stats (self, elem);
492 gst_tracer_record_log (tr_element_query,
493 (guint64) (guintptr) g_thread_self (), ts, stats->index,
494 GST_QUERY_TYPE_NAME (qry));
498 do_query_pre (GstStatsTracer * self, guint64 ts, GstPad * this_pad,
501 GstPadStats *this_pad_stats = get_pad_stats (self, this_pad);
502 GstPad *that_pad = GST_PAD_PEER (this_pad);
503 GstPadStats *that_pad_stats = get_pad_stats (self, that_pad);
505 do_query_stats (self, this_pad, this_pad_stats, that_pad, that_pad_stats,
506 qry, ts, FALSE, FALSE);
510 do_query_post (GstStatsTracer * self, guint64 ts, GstPad * this_pad,
511 GstQuery * qry, gboolean res)
513 GstPadStats *this_pad_stats = get_pad_stats (self, this_pad);
514 GstPad *that_pad = GST_PAD_PEER (this_pad);
515 GstPadStats *that_pad_stats = get_pad_stats (self, that_pad);
517 do_query_stats (self, this_pad, this_pad_stats, that_pad, that_pad_stats,
524 gst_stats_tracer_class_init (GstStatsTracerClass * klass)
526 /* announce trace formats */
528 tr_buffer = gst_tracer_record_new ("buffer.class",
529 "thread-id", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
530 "type", G_TYPE_GTYPE, G_TYPE_UINT64,
531 "related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_THREAD,
533 "ts", GST_TYPE_STRUCTURE, gst_structure_new ("value",
534 "type", G_TYPE_GTYPE, G_TYPE_UINT64,
535 "description", G_TYPE_STRING, "event ts",
537 "pad-ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
538 "type", G_TYPE_GTYPE, G_TYPE_UINT,
539 "related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_PAD,
541 "element-ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
542 "type", G_TYPE_GTYPE, G_TYPE_UINT,
543 "related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_ELEMENT,
545 "peer-pad-ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
546 "type", G_TYPE_GTYPE, G_TYPE_UINT,
547 "related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_PAD,
549 "peer-element-ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
550 "type", G_TYPE_GTYPE, G_TYPE_UINT,
551 "related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_ELEMENT,
553 "buffer-size", GST_TYPE_STRUCTURE, gst_structure_new ("value",
554 "type", G_TYPE_GTYPE, G_TYPE_UINT,
555 "description", G_TYPE_STRING, "size of buffer in bytes",
556 "min", G_TYPE_UINT, 0,
557 "max", G_TYPE_UINT, G_MAXUINT,
559 "buffer-pts", GST_TYPE_STRUCTURE, gst_structure_new ("value",
560 "type", G_TYPE_GTYPE, G_TYPE_UINT64,
561 "description", G_TYPE_STRING, "presentation timestamp of the buffer in ns",
562 "flags", GST_TYPE_TRACER_VALUE_FLAGS, GST_TRACER_VALUE_FLAGS_OPTIONAL,
563 "min", G_TYPE_UINT64, G_GUINT64_CONSTANT (0),
564 "max", G_TYPE_UINT64, G_MAXUINT64,
566 "buffer-dts", GST_TYPE_STRUCTURE, gst_structure_new ("value",
567 "type", G_TYPE_GTYPE, G_TYPE_UINT64,
568 "description", G_TYPE_STRING, "decoding timestamp of the buffer in ns",
569 "flags", GST_TYPE_TRACER_VALUE_FLAGS, GST_TRACER_VALUE_FLAGS_OPTIONAL,
570 "min", G_TYPE_UINT64, G_GUINT64_CONSTANT (0),
571 "max", G_TYPE_UINT64, G_MAXUINT64,
573 "buffer-duration", GST_TYPE_STRUCTURE, gst_structure_new ("value",
574 "type", G_TYPE_GTYPE, G_TYPE_UINT64,
575 "description", G_TYPE_STRING, "duration of the buffer in ns",
576 "flags", GST_TYPE_TRACER_VALUE_FLAGS, GST_TRACER_VALUE_FLAGS_OPTIONAL,
577 "min", G_TYPE_UINT64, G_GUINT64_CONSTANT (0),
578 "max", G_TYPE_UINT64, G_MAXUINT64,
580 "buffer-flags", GST_TYPE_STRUCTURE, gst_structure_new ("value",
581 "type", G_TYPE_GTYPE, GST_TYPE_BUFFER_FLAGS,
582 "description", G_TYPE_STRING, "flags of the buffer",
585 tr_event = gst_tracer_record_new ("event.class",
586 "thread-id", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
587 "type", G_TYPE_GTYPE, G_TYPE_UINT64,
588 "related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_THREAD,
590 "ts", GST_TYPE_STRUCTURE, gst_structure_new ("value",
591 "type", G_TYPE_GTYPE, G_TYPE_UINT64,
592 "description", G_TYPE_STRING, "event ts",
594 "pad-ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
595 "type", G_TYPE_GTYPE, G_TYPE_UINT,
596 "related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_PAD,
598 "element-ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
599 "type", G_TYPE_GTYPE, G_TYPE_UINT,
600 "related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_ELEMENT,
602 "name", GST_TYPE_STRUCTURE, gst_structure_new ("value",
603 "type", G_TYPE_GTYPE, G_TYPE_STRING,
604 "description", G_TYPE_STRING, "name of the event",
607 tr_message = gst_tracer_record_new ("message.class",
608 "thread-id", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
609 "type", G_TYPE_GTYPE, G_TYPE_UINT64,
610 "related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_THREAD,
612 "ts", GST_TYPE_STRUCTURE, gst_structure_new ("value",
613 "type", G_TYPE_GTYPE, G_TYPE_UINT64,
614 "description", G_TYPE_STRING, "event ts",
616 "element-ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
617 "type", G_TYPE_GTYPE, G_TYPE_UINT,
618 "related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_ELEMENT,
620 "name", GST_TYPE_STRUCTURE, gst_structure_new ("value",
621 "type", G_TYPE_GTYPE, G_TYPE_STRING,
622 "description", G_TYPE_STRING, "name of the message",
624 "structure", GST_TYPE_STRUCTURE, gst_structure_new ("structure",
625 "type", G_TYPE_GTYPE, GST_TYPE_STRUCTURE,
626 "description", G_TYPE_STRING, "message structure",
629 tr_element_query = gst_tracer_record_new ("element-query.class",
630 "thread-id", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
631 "type", G_TYPE_GTYPE, G_TYPE_UINT64,
632 "related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_THREAD,
634 "ts", GST_TYPE_STRUCTURE, gst_structure_new ("value",
635 "type", G_TYPE_GTYPE, G_TYPE_UINT64,
636 "description", G_TYPE_STRING, "event ts",
638 "element-ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
639 "type", G_TYPE_GTYPE, G_TYPE_UINT,
640 "related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_ELEMENT,
642 "name", GST_TYPE_STRUCTURE, gst_structure_new ("value",
643 "type", G_TYPE_GTYPE, G_TYPE_STRING,
644 "description", G_TYPE_STRING, "name of the query",
647 tr_query = gst_tracer_record_new ("query.class",
648 "thread-id", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
649 "type", G_TYPE_GTYPE, G_TYPE_UINT64,
650 "related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_THREAD,
652 "ts", GST_TYPE_STRUCTURE, gst_structure_new ("value",
653 "type", G_TYPE_GTYPE, G_TYPE_UINT64,
654 "description", G_TYPE_STRING, "event ts",
656 "pad-ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
657 "type", G_TYPE_GTYPE, G_TYPE_UINT,
658 "related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_PAD,
660 "element-ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
661 "type", G_TYPE_GTYPE, G_TYPE_UINT,
662 "related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_ELEMENT,
664 "peer-pad-ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
665 "type", G_TYPE_GTYPE, G_TYPE_UINT,
666 "related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_PAD,
668 "peer-element-ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
669 "type", G_TYPE_GTYPE, G_TYPE_UINT,
670 "related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_ELEMENT,
672 "name", GST_TYPE_STRUCTURE, gst_structure_new ("value",
673 "type", G_TYPE_GTYPE, G_TYPE_STRING,
674 "description", G_TYPE_STRING, "name of the query",
676 "structure", GST_TYPE_STRUCTURE, gst_structure_new ("value",
677 "type", G_TYPE_GTYPE, GST_TYPE_STRUCTURE,
678 "description", G_TYPE_STRING, "query structure",
680 "res", GST_TYPE_STRUCTURE, gst_structure_new ("value",
681 "type", G_TYPE_GTYPE, G_TYPE_BOOLEAN,
682 "description", G_TYPE_STRING, "query result",
683 "flags", GST_TYPE_TRACER_VALUE_FLAGS, GST_TRACER_VALUE_FLAGS_OPTIONAL,
686 tr_new_element = gst_tracer_record_new ("new-element.class",
687 "thread-id", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
688 "type", G_TYPE_GTYPE, G_TYPE_UINT64,
689 "related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_THREAD,
691 "ts", GST_TYPE_STRUCTURE, gst_structure_new ("value",
692 "type", G_TYPE_GTYPE, G_TYPE_UINT64,
693 "description", G_TYPE_STRING, "event ts",
695 "ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
696 "type", G_TYPE_GTYPE, G_TYPE_UINT,
697 "related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_ELEMENT,
699 "parent-ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
700 "type", G_TYPE_GTYPE, G_TYPE_UINT,
701 "related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_ELEMENT,
703 "name", GST_TYPE_STRUCTURE, gst_structure_new ("value",
704 "type", G_TYPE_GTYPE, G_TYPE_STRING,
705 "description", G_TYPE_STRING, "name of the element",
707 "type", GST_TYPE_STRUCTURE, gst_structure_new ("value",
708 "type", G_TYPE_GTYPE, G_TYPE_STRING,
709 "description", G_TYPE_STRING, "type name of the element",
711 "is-bin", GST_TYPE_STRUCTURE, gst_structure_new ("value",
712 "type", G_TYPE_GTYPE, G_TYPE_BOOLEAN,
713 "description", G_TYPE_STRING, "is element a bin",
716 tr_new_pad = gst_tracer_record_new ("new-pad.class",
717 "thread-id", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
718 "type", G_TYPE_GTYPE, G_TYPE_UINT64,
719 "related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_THREAD,
721 "ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
722 "type", G_TYPE_GTYPE, G_TYPE_UINT,
723 "related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_PAD,
725 "parent-ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
726 "type", G_TYPE_GTYPE, G_TYPE_UINT,
727 "related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_ELEMENT,
729 "name", GST_TYPE_STRUCTURE, gst_structure_new ("value",
730 "type", G_TYPE_GTYPE, G_TYPE_STRING,
731 "description", G_TYPE_STRING, "name of the pad",
733 "type", GST_TYPE_STRUCTURE, gst_structure_new ("value",
734 "type", G_TYPE_GTYPE, G_TYPE_STRING,
735 "description", G_TYPE_STRING, "type name of the pad",
737 "is-ghostpad", GST_TYPE_STRUCTURE, gst_structure_new ("value",
738 "type", G_TYPE_GTYPE, G_TYPE_BOOLEAN,
739 "description", G_TYPE_STRING, "is pad a ghostpad",
741 "pad-direction", GST_TYPE_STRUCTURE, gst_structure_new ("value",
742 "type", G_TYPE_GTYPE, GST_TYPE_PAD_DIRECTION,
743 "description", G_TYPE_STRING, "ipad direction",
750 gst_stats_tracer_init (GstStatsTracer * self)
752 GstTracer *tracer = GST_TRACER (self);
754 gst_tracing_register_hook (tracer, "pad-push-pre",
755 G_CALLBACK (do_push_buffer_pre));
756 gst_tracing_register_hook (tracer, "pad-push-post",
757 G_CALLBACK (do_push_buffer_post));
758 gst_tracing_register_hook (tracer, "pad-push-list-pre",
759 G_CALLBACK (do_push_buffer_list_pre));
760 gst_tracing_register_hook (tracer, "pad-push-list-post",
761 G_CALLBACK (do_push_buffer_list_post));
762 gst_tracing_register_hook (tracer, "pad-pull-range-pre",
763 G_CALLBACK (do_pull_range_pre));
764 gst_tracing_register_hook (tracer, "pad-pull-range-post",
765 G_CALLBACK (do_pull_range_post));
766 gst_tracing_register_hook (tracer, "pad-push-event-pre",
767 G_CALLBACK (do_push_event_pre));
768 gst_tracing_register_hook (tracer, "element-new",
769 G_CALLBACK (do_element_new));
770 gst_tracing_register_hook (tracer, "element-post-message-pre",
771 G_CALLBACK (do_post_message_pre));
772 gst_tracing_register_hook (tracer, "element-query-pre",
773 G_CALLBACK (do_element_query_pre));
774 gst_tracing_register_hook (tracer, "pad-query-pre",
775 G_CALLBACK (do_query_pre));
776 gst_tracing_register_hook (tracer, "pad-query-post",
777 G_CALLBACK (do_query_post));