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);
255 gst_tracer_record_log (tr_buffer, (guint64) (guintptr) g_thread_self (),
256 elapsed, this_pad_stats->index, this_elem_stats->index,
257 that_pad_stats->index, that_elem_stats->index, gst_buffer_get_size (buf),
258 GST_BUFFER_PTS (buf), GST_BUFFER_DTS (buf), GST_BUFFER_DURATION (buf),
259 GST_BUFFER_FLAGS (buf));
263 do_query_stats (GstStatsTracer * self, GstPad * this_pad,
264 GstPadStats * this_pad_stats, GstPad * that_pad,
265 GstPadStats * that_pad_stats, GstQuery * qry, GstClockTime elapsed,
266 gboolean have_res, gboolean res)
268 GstElement *this_elem = get_real_pad_parent (this_pad);
269 GstElementStats *this_elem_stats = get_element_stats (self, this_elem);
270 GstElement *that_elem = get_real_pad_parent (that_pad);
271 GstElementStats *that_elem_stats = get_element_stats (self, that_elem);
273 gst_tracer_record_log (tr_query, (guint64) (guintptr) g_thread_self (),
274 elapsed, this_pad_stats->index, this_elem_stats->index,
275 that_pad_stats->index, that_elem_stats->index, GST_QUERY_TYPE_NAME (qry),
276 gst_query_get_structure (qry), have_res, res);
280 do_element_stats (GstStatsTracer * self, GstPad * pad, GstClockTime elapsed1,
281 GstClockTime elapsed2)
283 GstClockTimeDiff elapsed = GST_CLOCK_DIFF (elapsed1, elapsed2);
284 GstObject *parent = GST_OBJECT_PARENT (pad);
286 GST_ELEMENT_CAST (GST_IS_PAD (parent) ? GST_OBJECT_PARENT (parent) :
288 GstElementStats *this_stats = get_element_stats (self, this);
289 GstPad *peer_pad = GST_PAD_PEER (pad);
290 GstElementStats *peer_stats;
295 /* walk the ghost pad chain downstream to get the real pad */
296 /* if parent of peer_pad is a ghost-pad, then peer_pad is a proxy_pad */
297 parent = GST_OBJECT_PARENT (peer_pad);
298 if (parent && GST_IS_GHOST_PAD (parent)) {
299 peer_pad = GST_PAD_CAST (parent);
300 /* if this is now the ghost pad, get the peer of this */
301 get_pad_stats (self, peer_pad);
302 if ((parent = GST_OBJECT_PARENT (peer_pad))) {
303 get_element_stats (self, GST_ELEMENT_CAST (parent));
305 peer_pad = GST_PAD_PEER (GST_GHOST_PAD_CAST (peer_pad));
306 parent = peer_pad ? GST_OBJECT_PARENT (peer_pad) : NULL;
308 /* walk the ghost pad chain upstream to get the real pad */
309 /* if peer_pad is a ghost-pad, then parent is a bin and it is the parent of
311 while (peer_pad && GST_IS_GHOST_PAD (peer_pad)) {
312 get_pad_stats (self, peer_pad);
313 get_element_stats (self, GST_ELEMENT_CAST (parent));
314 peer_pad = gst_ghost_pad_get_target (GST_GHOST_PAD_CAST (peer_pad));
315 parent = peer_pad ? GST_OBJECT_PARENT (peer_pad) : NULL;
319 printf ("%" GST_TIME_FORMAT
320 " transmission on unparented target pad %s_%s -> %s_%s\n",
321 GST_TIME_ARGS (elapsed), GST_DEBUG_PAD_NAME (pad),
322 GST_DEBUG_PAD_NAME (peer_pad));
325 peer_stats = get_element_stats (self, GST_ELEMENT_CAST (parent));
327 /* we'd like to gather time spend in each element, but this does not make too
329 * pure push/pull-based:
330 * - the time spend in the push/pull_range is accounted for the peer and
331 * removed from the current element
332 * - this works for chains
333 * - drawback is sink elements that block to sync have a high time usage
334 * - we could rerun the ests with sync=false
336 * - a.g. demuxers both push and pull. thus we subtract time for the pull
337 * and the push operations, but never add anything.
338 * - can we start a counter after push/pull in such elements and add then
339 * time to the element upon next pad activity?
342 /* this does not make sense for demuxers */
343 this_stats->treal -= elapsed;
344 peer_stats->treal += elapsed;
346 /* this creates several >100% figures */
347 this_stats->treal += GST_CLOCK_DIFF (this_stats->last_ts, elapsed2) - elapsed;
348 peer_stats->treal += elapsed;
349 this_stats->last_ts = elapsed2;
350 peer_stats->last_ts = elapsed2;
357 do_push_buffer_pre (GstStatsTracer * self, guint64 ts, GstPad * this_pad,
360 GstPadStats *this_pad_stats = get_pad_stats (self, this_pad);
361 GstPad *that_pad = GST_PAD_PEER (this_pad);
362 GstPadStats *that_pad_stats = get_pad_stats (self, that_pad);
364 do_buffer_stats (self, this_pad, this_pad_stats, that_pad, that_pad_stats,
369 do_push_buffer_post (GstStatsTracer * self, guint64 ts, GstPad * pad,
372 GstPadStats *stats = get_pad_stats (self, pad);
374 do_element_stats (self, pad, stats->last_ts, ts);
379 GstStatsTracer *self;
381 GstPadStats *this_pad_stats;
383 GstPadStats *that_pad_stats;
385 } DoPushBufferListArgs;
388 do_push_buffer_list_item (GstBuffer ** buffer, guint idx, gpointer user_data)
390 DoPushBufferListArgs *args = (DoPushBufferListArgs *) user_data;
392 do_buffer_stats (args->self, args->this_pad, args->this_pad_stats,
393 args->that_pad, args->that_pad_stats, *buffer, args->ts);
398 do_push_buffer_list_pre (GstStatsTracer * self, guint64 ts, GstPad * this_pad,
399 GstBufferList * list)
401 GstPadStats *this_pad_stats = get_pad_stats (self, this_pad);
402 GstPad *that_pad = GST_PAD_PEER (this_pad);
403 GstPadStats *that_pad_stats = get_pad_stats (self, that_pad);
404 DoPushBufferListArgs args = { self, this_pad, this_pad_stats, that_pad,
408 gst_buffer_list_foreach (list, do_push_buffer_list_item, &args);
412 do_push_buffer_list_post (GstStatsTracer * self, guint64 ts, GstPad * pad,
415 GstPadStats *stats = get_pad_stats (self, pad);
417 do_element_stats (self, pad, stats->last_ts, ts);
421 do_pull_range_pre (GstStatsTracer * self, guint64 ts, GstPad * pad)
423 GstPadStats *stats = get_pad_stats (self, pad);
428 do_pull_range_post (GstStatsTracer * self, guint64 ts, GstPad * this_pad,
431 GstPadStats *this_pad_stats = get_pad_stats (self, this_pad);
432 guint64 last_ts = this_pad_stats->last_ts;
433 GstPad *that_pad = GST_PAD_PEER (this_pad);
434 GstPadStats *that_pad_stats = get_pad_stats (self, that_pad);
436 if (buffer != NULL) {
437 do_buffer_stats (self, this_pad, this_pad_stats, that_pad, that_pad_stats,
440 do_element_stats (self, this_pad, last_ts, ts);
444 do_push_event_pre (GstStatsTracer * self, guint64 ts, GstPad * pad,
447 GstElement *elem = get_real_pad_parent (pad);
448 GstElementStats *elem_stats = get_element_stats (self, elem);
449 GstPadStats *pad_stats = get_pad_stats (self, pad);
451 elem_stats->last_ts = ts;
452 gst_tracer_record_log (tr_event, (guint64) (guintptr) g_thread_self (), ts,
453 pad_stats->index, elem_stats->index, GST_EVENT_TYPE_NAME (ev));
457 do_post_message_pre (GstStatsTracer * self, guint64 ts, GstElement * elem,
460 GstElementStats *stats = get_element_stats (self, elem);
461 const GstStructure *msg_s = gst_message_get_structure (msg);
464 gst_tracer_record_log (tr_message, (guint64) (guintptr) g_thread_self (), ts,
465 stats->index, GST_MESSAGE_TYPE_NAME (msg),
466 (msg_s ? msg_s : gst_structure_new_empty ("dummy")));
470 do_element_new (GstStatsTracer * self, guint64 ts, GstElement * elem)
472 GstElementStats *stats;
474 stats = create_element_stats (self, elem);
475 log_new_element_stats (stats, elem, ts);
479 do_element_query_pre (GstStatsTracer * self, guint64 ts, GstElement * elem,
482 GstElementStats *stats = get_element_stats (self, elem);
485 gst_tracer_record_log (tr_element_query,
486 (guint64) (guintptr) g_thread_self (), ts, stats->index,
487 GST_QUERY_TYPE_NAME (qry));
491 do_query_pre (GstStatsTracer * self, guint64 ts, GstPad * this_pad,
494 GstPadStats *this_pad_stats = get_pad_stats (self, this_pad);
495 GstPad *that_pad = GST_PAD_PEER (this_pad);
496 GstPadStats *that_pad_stats = get_pad_stats (self, that_pad);
498 do_query_stats (self, this_pad, this_pad_stats, that_pad, that_pad_stats,
499 qry, ts, FALSE, FALSE);
503 do_query_post (GstStatsTracer * self, guint64 ts, GstPad * this_pad,
504 GstQuery * qry, gboolean res)
506 GstPadStats *this_pad_stats = get_pad_stats (self, this_pad);
507 GstPad *that_pad = GST_PAD_PEER (this_pad);
508 GstPadStats *that_pad_stats = get_pad_stats (self, that_pad);
510 do_query_stats (self, this_pad, this_pad_stats, that_pad, that_pad_stats,
517 gst_stats_tracer_class_init (GstStatsTracerClass * klass)
519 /* announce trace formats */
521 tr_buffer = gst_tracer_record_new (gst_structure_new ("buffer.class",
522 "thread-id", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
523 "type", G_TYPE_GTYPE, G_TYPE_UINT64,
524 "related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_THREAD,
526 "ts", GST_TYPE_STRUCTURE, gst_structure_new ("value",
527 "type", G_TYPE_GTYPE, G_TYPE_UINT64,
528 "description", G_TYPE_STRING, "event ts",
530 "pad-ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
531 "type", G_TYPE_GTYPE, G_TYPE_UINT,
532 "related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_PAD,
534 "element-ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
535 "type", G_TYPE_GTYPE, G_TYPE_UINT,
536 "related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_ELEMENT,
538 "peer-pad-ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
539 "type", G_TYPE_GTYPE, G_TYPE_UINT,
540 "related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_PAD,
542 "peer-element-ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
543 "type", G_TYPE_GTYPE, G_TYPE_UINT,
544 "related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_ELEMENT,
546 "buffer-size", GST_TYPE_STRUCTURE, gst_structure_new ("value",
547 "type", G_TYPE_GTYPE, G_TYPE_UINT,
548 "description", G_TYPE_STRING, "size of buffer in bytes",
549 "min", G_TYPE_UINT, 0,
550 "max", G_TYPE_UINT, G_MAXUINT,
552 "buffer-ts", GST_TYPE_STRUCTURE, gst_structure_new ("value",
553 "type", G_TYPE_GTYPE, G_TYPE_UINT64,
554 "description", G_TYPE_STRING, "timestamp of the buffer in ns",
555 "min", G_TYPE_UINT64, G_GUINT64_CONSTANT (0),
556 "max", G_TYPE_UINT64, G_MAXUINT64,
558 "buffer-duration", GST_TYPE_STRUCTURE, gst_structure_new ("value",
559 "type", G_TYPE_GTYPE, G_TYPE_UINT64,
560 "description", G_TYPE_STRING, "duration of the buffer in ns",
561 "min", G_TYPE_UINT64, G_GUINT64_CONSTANT (0),
562 "max", G_TYPE_UINT64, G_MAXUINT64,
564 /* TODO(ensonic): "buffer-flags" */
566 tr_event = gst_tracer_record_new (gst_structure_new ("event.class",
567 "thread-id", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
568 "type", G_TYPE_GTYPE, G_TYPE_UINT64,
569 "related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_THREAD,
571 "ts", GST_TYPE_STRUCTURE, gst_structure_new ("value",
572 "type", G_TYPE_GTYPE, G_TYPE_UINT64,
573 "description", G_TYPE_STRING, "event ts",
575 "pad-ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
576 "type", G_TYPE_GTYPE, G_TYPE_UINT,
577 "related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_PAD,
579 "element-ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
580 "type", G_TYPE_GTYPE, G_TYPE_UINT,
581 "related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_ELEMENT,
583 "name", GST_TYPE_STRUCTURE, gst_structure_new ("value",
584 "type", G_TYPE_GTYPE, G_TYPE_STRING,
585 "description", G_TYPE_STRING, "name of the event",
588 tr_message = gst_tracer_record_new (gst_structure_new ("message.class",
589 "thread-id", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
590 "type", G_TYPE_GTYPE, G_TYPE_UINT64,
591 "related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_THREAD,
593 "ts", GST_TYPE_STRUCTURE, gst_structure_new ("value",
594 "type", G_TYPE_GTYPE, G_TYPE_UINT64,
595 "description", G_TYPE_STRING, "event ts",
597 "element-ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
598 "type", G_TYPE_GTYPE, G_TYPE_UINT,
599 "related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_ELEMENT,
601 "name", GST_TYPE_STRUCTURE, gst_structure_new ("value",
602 "type", G_TYPE_GTYPE, G_TYPE_STRING,
603 "description", G_TYPE_STRING, "name of the message",
605 "structure", GST_TYPE_STRUCTURE, gst_structure_new ("structure",
606 "type", G_TYPE_GTYPE, GST_TYPE_STRUCTURE,
607 "description", G_TYPE_STRING, "message structure",
610 tr_element_query = gst_tracer_record_new (gst_structure_new (
611 "element-query.class",
612 "thread-id", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
613 "type", G_TYPE_GTYPE, G_TYPE_UINT64,
614 "related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_THREAD,
616 "ts", GST_TYPE_STRUCTURE, gst_structure_new ("value",
617 "type", G_TYPE_GTYPE, G_TYPE_UINT64,
618 "description", G_TYPE_STRING, "event ts",
620 "element-ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
621 "type", G_TYPE_GTYPE, G_TYPE_UINT,
622 "related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_ELEMENT,
624 "name", GST_TYPE_STRUCTURE, gst_structure_new ("value",
625 "type", G_TYPE_GTYPE, G_TYPE_STRING,
626 "description", G_TYPE_STRING, "name of the query",
629 tr_query = gst_tracer_record_new (gst_structure_new ("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 "pad-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_PAD,
642 "element-ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
643 "type", G_TYPE_GTYPE, G_TYPE_UINT,
644 "related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_ELEMENT,
646 "peer-pad-ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
647 "type", G_TYPE_GTYPE, G_TYPE_UINT,
648 "related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_PAD,
650 "peer-element-ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
651 "type", G_TYPE_GTYPE, G_TYPE_UINT,
652 "related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_ELEMENT,
654 "name", GST_TYPE_STRUCTURE, gst_structure_new ("value",
655 "type", G_TYPE_GTYPE, G_TYPE_STRING,
656 "description", G_TYPE_STRING, "name of the query",
658 "structure", GST_TYPE_STRUCTURE, gst_structure_new ("value",
659 "type", G_TYPE_GTYPE, GST_TYPE_STRUCTURE,
660 "description", G_TYPE_STRING, "query structure",
662 "res", GST_TYPE_STRUCTURE, gst_structure_new ("value",
663 "type", G_TYPE_GTYPE, G_TYPE_BOOLEAN,
664 "description", G_TYPE_STRING, "query result",
665 "flags", GST_TYPE_TRACER_VALUE_FLAGS, GST_TRACER_VALUE_FLAGS_OPTIONAL,
667 /* TODO(ensonic): "buffer-flags" */
669 tr_new_element = gst_tracer_record_new (gst_structure_new (
671 "thread-id", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
672 "type", G_TYPE_GTYPE, G_TYPE_UINT64,
673 "related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_THREAD,
675 "ts", GST_TYPE_STRUCTURE, gst_structure_new ("value",
676 "type", G_TYPE_GTYPE, G_TYPE_UINT64,
677 "description", G_TYPE_STRING, "event ts",
679 "ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
680 "type", G_TYPE_GTYPE, G_TYPE_UINT,
681 "related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_ELEMENT,
683 "parent-ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
684 "type", G_TYPE_GTYPE, G_TYPE_UINT,
685 "related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_ELEMENT,
687 "name", GST_TYPE_STRUCTURE, gst_structure_new ("value",
688 "type", G_TYPE_GTYPE, G_TYPE_STRING,
689 "description", G_TYPE_STRING, "name of the element",
691 "type", GST_TYPE_STRUCTURE, gst_structure_new ("value",
692 "type", G_TYPE_GTYPE, G_TYPE_STRING,
693 "description", G_TYPE_STRING, "type name of the element",
695 "is-bin", GST_TYPE_STRUCTURE, gst_structure_new ("value",
696 "type", G_TYPE_GTYPE, G_TYPE_BOOLEAN,
697 "description", G_TYPE_STRING, "is element a bin",
700 tr_new_pad = gst_tracer_record_new (gst_structure_new ("new-pad.class",
701 "thread-id", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
702 "type", G_TYPE_GTYPE, G_TYPE_UINT64,
703 "related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_THREAD,
705 "ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
706 "type", G_TYPE_GTYPE, G_TYPE_UINT,
707 "related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_PAD,
709 "parent-ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
710 "type", G_TYPE_GTYPE, G_TYPE_UINT,
711 "related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_ELEMENT,
713 "name", GST_TYPE_STRUCTURE, gst_structure_new ("value",
714 "type", G_TYPE_GTYPE, G_TYPE_STRING,
715 "description", G_TYPE_STRING, "name of the pad",
717 "type", GST_TYPE_STRUCTURE, gst_structure_new ("value",
718 "type", G_TYPE_GTYPE, G_TYPE_STRING,
719 "description", G_TYPE_STRING, "type name of the pad",
721 "is-ghostpad", GST_TYPE_STRUCTURE, gst_structure_new ("value",
722 "type", G_TYPE_GTYPE, G_TYPE_BOOLEAN,
723 "description", G_TYPE_STRING, "is pad a ghostpad",
725 "pad-direction", GST_TYPE_STRUCTURE, gst_structure_new ("value",
726 "type", G_TYPE_GTYPE, GST_TYPE_PAD_DIRECTION,
727 "description", G_TYPE_STRING, "ipad direction",
734 gst_stats_tracer_init (GstStatsTracer * self)
736 GstTracer *tracer = GST_TRACER (self);
738 gst_tracing_register_hook (tracer, "pad-push-pre",
739 G_CALLBACK (do_push_buffer_pre));
740 gst_tracing_register_hook (tracer, "pad-push-post",
741 G_CALLBACK (do_push_buffer_post));
742 gst_tracing_register_hook (tracer, "pad-push-list-pre",
743 G_CALLBACK (do_push_buffer_list_pre));
744 gst_tracing_register_hook (tracer, "pad-push-list-post",
745 G_CALLBACK (do_push_buffer_list_post));
746 gst_tracing_register_hook (tracer, "pad-pull-range-pre",
747 G_CALLBACK (do_pull_range_pre));
748 gst_tracing_register_hook (tracer, "pad-pull-range-post",
749 G_CALLBACK (do_pull_range_post));
750 gst_tracing_register_hook (tracer, "pad-push-event-pre",
751 G_CALLBACK (do_push_event_pre));
752 gst_tracing_register_hook (tracer, "element-new",
753 G_CALLBACK (do_element_new));
754 gst_tracing_register_hook (tracer, "element-post-message-pre",
755 G_CALLBACK (do_post_message_pre));
756 gst_tracing_register_hook (tracer, "element-query-pre",
757 G_CALLBACK (do_element_query_pre));
758 gst_tracing_register_hook (tracer, "pad-query-pre",
759 G_CALLBACK (do_query_pre));
760 gst_tracing_register_hook (tracer, "pad-query-post",
761 G_CALLBACK (do_query_post));