2013-10-28 07:08:20 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2013 Stefan Sauer <ensonic@users.sf.net>
|
|
|
|
*
|
|
|
|
* gststats.c: tracing module that logs events
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2014-07-16 16:48:52 +00:00
|
|
|
/**
|
2017-12-05 10:36:34 +00:00
|
|
|
* SECTION:element-statstracer
|
2014-07-16 16:48:52 +00:00
|
|
|
* @short_description: log event stats
|
|
|
|
*
|
2016-01-10 13:30:05 +00:00
|
|
|
* A tracing module that builds usage statistic for elements and pads.
|
2014-07-16 16:48:52 +00:00
|
|
|
*/
|
2013-10-28 07:08:20 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "gststats.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_STATIC (gst_stats_debug);
|
|
|
|
#define GST_CAT_DEFAULT gst_stats_debug
|
|
|
|
|
|
|
|
static GQuark data_quark;
|
2014-09-17 06:38:02 +00:00
|
|
|
G_LOCK_DEFINE (_elem_stats);
|
|
|
|
G_LOCK_DEFINE (_pad_stats);
|
2013-10-28 07:08:20 +00:00
|
|
|
|
|
|
|
#define _do_init \
|
|
|
|
GST_DEBUG_CATEGORY_INIT (gst_stats_debug, "stats", 0, "stats tracer"); \
|
2013-10-28 20:59:19 +00:00
|
|
|
data_quark = g_quark_from_static_string ("gststats:data");
|
2013-10-28 07:08:20 +00:00
|
|
|
#define gst_stats_tracer_parent_class parent_class
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GstStatsTracer, gst_stats_tracer, GST_TYPE_TRACER,
|
|
|
|
_do_init);
|
|
|
|
|
2016-01-12 13:59:04 +00:00
|
|
|
static GstTracerRecord *tr_new_element;
|
|
|
|
static GstTracerRecord *tr_new_pad;
|
|
|
|
static GstTracerRecord *tr_buffer;
|
|
|
|
static GstTracerRecord *tr_element_query;
|
|
|
|
static GstTracerRecord *tr_event;
|
|
|
|
static GstTracerRecord *tr_message;
|
|
|
|
static GstTracerRecord *tr_query;
|
|
|
|
|
2013-10-28 07:08:20 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2013-11-04 19:11:09 +00:00
|
|
|
/* we can't rely on the address to be unique over time */
|
2013-10-28 07:08:20 +00:00
|
|
|
guint index;
|
2013-11-04 19:11:09 +00:00
|
|
|
/* for pre + post */
|
|
|
|
GstClockTime last_ts;
|
|
|
|
/* hierarchy */
|
|
|
|
guint parent_ix;
|
2013-10-28 07:08:20 +00:00
|
|
|
} GstPadStats;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2013-11-04 19:11:09 +00:00
|
|
|
/* we can't rely on the address to be unique over time */
|
2013-10-28 07:08:20 +00:00
|
|
|
guint index;
|
2013-11-04 19:11:09 +00:00
|
|
|
/* for pre + post */
|
|
|
|
GstClockTime last_ts;
|
2013-10-28 07:08:20 +00:00
|
|
|
/* time spend in this element */
|
|
|
|
GstClockTime treal;
|
|
|
|
/* hierarchy */
|
|
|
|
guint parent_ix;
|
|
|
|
} GstElementStats;
|
|
|
|
|
|
|
|
/* data helper */
|
|
|
|
|
2013-11-04 19:11:09 +00:00
|
|
|
static GstElementStats no_elem_stats = { 0, };
|
|
|
|
|
2013-10-28 07:08:20 +00:00
|
|
|
static GstElementStats *
|
|
|
|
fill_element_stats (GstStatsTracer * self, GstElement * element)
|
|
|
|
{
|
|
|
|
GstElementStats *stats = g_slice_new0 (GstElementStats);
|
|
|
|
|
|
|
|
stats->index = self->num_elements++;
|
|
|
|
stats->parent_ix = G_MAXUINT;
|
2013-11-19 07:04:38 +00:00
|
|
|
return stats;
|
|
|
|
}
|
2013-10-28 07:08:20 +00:00
|
|
|
|
2013-11-19 07:04:38 +00:00
|
|
|
static void
|
2015-10-28 09:03:39 +00:00
|
|
|
log_new_element_stats (GstElementStats * stats, GstElement * element,
|
|
|
|
GstClockTime elapsed)
|
2013-11-19 07:04:38 +00:00
|
|
|
{
|
2016-01-17 23:49:27 +00:00
|
|
|
gst_tracer_record_log (tr_new_element, (guint64) (guintptr) g_thread_self (),
|
2016-01-12 13:59:04 +00:00
|
|
|
elapsed, stats->index, stats->parent_ix, GST_OBJECT_NAME (element),
|
|
|
|
G_OBJECT_TYPE_NAME (element), GST_IS_BIN (element));
|
2013-10-28 07:08:20 +00:00
|
|
|
}
|
|
|
|
|
2014-09-17 06:38:02 +00:00
|
|
|
static void
|
|
|
|
free_element_stats (gpointer data)
|
|
|
|
{
|
|
|
|
g_slice_free (GstElementStats, data);
|
|
|
|
}
|
|
|
|
|
2015-10-28 09:03:39 +00:00
|
|
|
static GstElementStats *
|
|
|
|
create_element_stats (GstStatsTracer * self, GstElement * element)
|
|
|
|
{
|
|
|
|
GstElementStats *stats;
|
|
|
|
|
|
|
|
stats = fill_element_stats (self, element);
|
|
|
|
g_object_set_qdata_full ((GObject *) element, data_quark, stats,
|
|
|
|
free_element_stats);
|
|
|
|
|
|
|
|
return stats;
|
|
|
|
}
|
|
|
|
|
2013-10-28 07:08:20 +00:00
|
|
|
static inline GstElementStats *
|
|
|
|
get_element_stats (GstStatsTracer * self, GstElement * element)
|
|
|
|
{
|
|
|
|
GstElementStats *stats;
|
2013-11-19 07:04:38 +00:00
|
|
|
gboolean is_new = FALSE;
|
2013-10-28 07:08:20 +00:00
|
|
|
|
2013-11-04 19:11:09 +00:00
|
|
|
if (!element) {
|
|
|
|
no_elem_stats.index = G_MAXUINT;
|
|
|
|
return &no_elem_stats;
|
|
|
|
}
|
|
|
|
|
2014-09-17 06:38:02 +00:00
|
|
|
G_LOCK (_elem_stats);
|
2013-10-28 07:08:20 +00:00
|
|
|
if (!(stats = g_object_get_qdata ((GObject *) element, data_quark))) {
|
2015-10-28 09:03:39 +00:00
|
|
|
stats = create_element_stats (self, element);
|
2013-11-19 07:04:38 +00:00
|
|
|
is_new = TRUE;
|
2013-10-28 07:08:20 +00:00
|
|
|
}
|
2014-09-17 06:38:02 +00:00
|
|
|
G_UNLOCK (_elem_stats);
|
2013-10-28 07:08:20 +00:00
|
|
|
if (G_UNLIKELY (stats->parent_ix == G_MAXUINT)) {
|
|
|
|
GstElement *parent = GST_ELEMENT_PARENT (element);
|
|
|
|
if (parent) {
|
|
|
|
GstElementStats *parent_stats = get_element_stats (self, parent);
|
|
|
|
stats->parent_ix = parent_stats->index;
|
|
|
|
}
|
|
|
|
}
|
2013-11-19 07:04:38 +00:00
|
|
|
if (G_UNLIKELY (is_new)) {
|
2015-10-28 09:03:39 +00:00
|
|
|
log_new_element_stats (stats, element, GST_CLOCK_TIME_NONE);
|
2013-11-19 07:04:38 +00:00
|
|
|
}
|
2013-10-28 07:08:20 +00:00
|
|
|
return stats;
|
|
|
|
}
|
|
|
|
|
2013-11-04 19:11:09 +00:00
|
|
|
/*
|
2016-01-10 13:30:05 +00:00
|
|
|
* Get the element/bin owning the pad.
|
2013-11-04 19:11:09 +00:00
|
|
|
*
|
|
|
|
* in: a normal pad
|
|
|
|
* out: the element
|
|
|
|
*
|
|
|
|
* in: a proxy pad
|
|
|
|
* out: the element that contains the peer of the proxy
|
|
|
|
*
|
|
|
|
* in: a ghost pad
|
|
|
|
* out: the bin owning the ghostpad
|
|
|
|
*/
|
|
|
|
/* TODO(ensonic): gst_pad_get_parent_element() would not work here, should we
|
|
|
|
* add this as new api, e.g. gst_pad_find_parent_element();
|
|
|
|
*/
|
|
|
|
static GstElement *
|
|
|
|
get_real_pad_parent (GstPad * pad)
|
|
|
|
{
|
|
|
|
GstObject *parent;
|
|
|
|
|
|
|
|
if (!pad)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
parent = GST_OBJECT_PARENT (pad);
|
|
|
|
|
|
|
|
/* if parent of pad is a ghost-pad, then pad is a proxy_pad */
|
|
|
|
if (parent && GST_IS_GHOST_PAD (parent)) {
|
|
|
|
pad = GST_PAD_CAST (parent);
|
|
|
|
parent = GST_OBJECT_PARENT (pad);
|
|
|
|
}
|
|
|
|
return GST_ELEMENT_CAST (parent);
|
|
|
|
}
|
|
|
|
|
2013-11-19 07:04:38 +00:00
|
|
|
static GstPadStats no_pad_stats = { 0, };
|
|
|
|
|
|
|
|
static GstPadStats *
|
|
|
|
fill_pad_stats (GstStatsTracer * self, GstPad * pad)
|
|
|
|
{
|
|
|
|
GstPadStats *stats = g_slice_new0 (GstPadStats);
|
|
|
|
|
|
|
|
stats->index = self->num_pads++;
|
|
|
|
stats->parent_ix = G_MAXUINT;
|
|
|
|
|
|
|
|
return stats;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
log_new_pad_stats (GstPadStats * stats, GstPad * pad)
|
|
|
|
{
|
2016-01-17 23:49:27 +00:00
|
|
|
gst_tracer_record_log (tr_new_pad, (guint64) (guintptr) g_thread_self (),
|
2016-01-12 13:59:04 +00:00
|
|
|
stats->index, stats->parent_ix, GST_OBJECT_NAME (pad),
|
|
|
|
G_OBJECT_TYPE_NAME (pad), GST_IS_GHOST_PAD (pad),
|
|
|
|
GST_PAD_DIRECTION (pad));
|
2013-11-19 07:04:38 +00:00
|
|
|
}
|
|
|
|
|
2014-09-17 06:38:02 +00:00
|
|
|
static void
|
|
|
|
free_pad_stats (gpointer data)
|
|
|
|
{
|
|
|
|
g_slice_free (GstPadStats, data);
|
|
|
|
}
|
|
|
|
|
2013-10-28 07:08:20 +00:00
|
|
|
static GstPadStats *
|
|
|
|
get_pad_stats (GstStatsTracer * self, GstPad * pad)
|
|
|
|
{
|
|
|
|
GstPadStats *stats;
|
2013-11-19 07:04:38 +00:00
|
|
|
gboolean is_new = FALSE;
|
2013-10-28 07:08:20 +00:00
|
|
|
|
2013-11-04 19:11:09 +00:00
|
|
|
if (!pad) {
|
|
|
|
no_pad_stats.index = G_MAXUINT;
|
|
|
|
return &no_pad_stats;
|
|
|
|
}
|
2013-10-28 07:08:20 +00:00
|
|
|
|
2014-09-17 06:38:02 +00:00
|
|
|
G_LOCK (_pad_stats);
|
2013-10-28 07:08:20 +00:00
|
|
|
if (!(stats = g_object_get_qdata ((GObject *) pad, data_quark))) {
|
|
|
|
stats = fill_pad_stats (self, pad);
|
2014-09-17 06:38:02 +00:00
|
|
|
g_object_set_qdata_full ((GObject *) pad, data_quark, stats,
|
|
|
|
free_pad_stats);
|
2013-11-19 07:04:38 +00:00
|
|
|
is_new = TRUE;
|
2013-10-28 07:08:20 +00:00
|
|
|
}
|
2014-09-17 06:38:02 +00:00
|
|
|
G_UNLOCK (_pad_stats);
|
2013-11-04 19:11:09 +00:00
|
|
|
if (G_UNLIKELY (stats->parent_ix == G_MAXUINT)) {
|
|
|
|
GstElement *elem = get_real_pad_parent (pad);
|
|
|
|
if (elem) {
|
|
|
|
GstElementStats *elem_stats = get_element_stats (self, elem);
|
|
|
|
|
|
|
|
stats->parent_ix = elem_stats->index;
|
2013-10-28 07:08:20 +00:00
|
|
|
}
|
|
|
|
}
|
2013-11-19 07:04:38 +00:00
|
|
|
if (G_UNLIKELY (is_new)) {
|
|
|
|
log_new_pad_stats (stats, pad);
|
|
|
|
}
|
2013-10-28 07:08:20 +00:00
|
|
|
return stats;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-11-04 19:11:09 +00:00
|
|
|
do_buffer_stats (GstStatsTracer * self, GstPad * this_pad,
|
|
|
|
GstPadStats * this_pad_stats, GstPad * that_pad,
|
|
|
|
GstPadStats * that_pad_stats, GstBuffer * buf, GstClockTime elapsed)
|
2013-10-28 07:08:20 +00:00
|
|
|
{
|
2013-11-04 19:11:09 +00:00
|
|
|
GstElement *this_elem = get_real_pad_parent (this_pad);
|
|
|
|
GstElementStats *this_elem_stats = get_element_stats (self, this_elem);
|
|
|
|
GstElement *that_elem = get_real_pad_parent (that_pad);
|
|
|
|
GstElementStats *that_elem_stats = get_element_stats (self, that_elem);
|
2016-12-15 14:37:45 +00:00
|
|
|
GstClockTime pts = GST_BUFFER_PTS (buf);
|
|
|
|
GstClockTime dts = GST_BUFFER_DTS (buf);
|
|
|
|
GstClockTime dur = GST_BUFFER_DURATION (buf);
|
2013-11-04 19:11:09 +00:00
|
|
|
|
2016-01-17 23:49:27 +00:00
|
|
|
gst_tracer_record_log (tr_buffer, (guint64) (guintptr) g_thread_self (),
|
|
|
|
elapsed, this_pad_stats->index, this_elem_stats->index,
|
|
|
|
that_pad_stats->index, that_elem_stats->index, gst_buffer_get_size (buf),
|
2016-12-15 14:37:45 +00:00
|
|
|
GST_CLOCK_TIME_IS_VALID (pts), pts, GST_CLOCK_TIME_IS_VALID (dts), dts,
|
|
|
|
GST_CLOCK_TIME_IS_VALID (dur), dur, GST_BUFFER_FLAGS (buf));
|
2013-10-28 07:08:20 +00:00
|
|
|
}
|
|
|
|
|
2015-03-13 13:10:42 +00:00
|
|
|
static void
|
|
|
|
do_query_stats (GstStatsTracer * self, GstPad * this_pad,
|
|
|
|
GstPadStats * this_pad_stats, GstPad * that_pad,
|
|
|
|
GstPadStats * that_pad_stats, GstQuery * qry, GstClockTime elapsed,
|
2016-01-12 13:59:04 +00:00
|
|
|
gboolean have_res, gboolean res)
|
2015-03-13 13:10:42 +00:00
|
|
|
{
|
|
|
|
GstElement *this_elem = get_real_pad_parent (this_pad);
|
|
|
|
GstElementStats *this_elem_stats = get_element_stats (self, this_elem);
|
|
|
|
GstElement *that_elem = get_real_pad_parent (that_pad);
|
|
|
|
GstElementStats *that_elem_stats = get_element_stats (self, that_elem);
|
2016-01-12 13:59:04 +00:00
|
|
|
|
2016-01-17 23:49:27 +00:00
|
|
|
gst_tracer_record_log (tr_query, (guint64) (guintptr) g_thread_self (),
|
|
|
|
elapsed, this_pad_stats->index, this_elem_stats->index,
|
|
|
|
that_pad_stats->index, that_elem_stats->index, GST_QUERY_TYPE_NAME (qry),
|
2016-01-12 13:59:04 +00:00
|
|
|
gst_query_get_structure (qry), have_res, res);
|
2015-03-13 13:10:42 +00:00
|
|
|
}
|
|
|
|
|
2013-10-28 07:08:20 +00:00
|
|
|
static void
|
|
|
|
do_element_stats (GstStatsTracer * self, GstPad * pad, GstClockTime elapsed1,
|
|
|
|
GstClockTime elapsed2)
|
|
|
|
{
|
|
|
|
GstClockTimeDiff elapsed = GST_CLOCK_DIFF (elapsed1, elapsed2);
|
|
|
|
GstObject *parent = GST_OBJECT_PARENT (pad);
|
|
|
|
GstElement *this =
|
|
|
|
GST_ELEMENT_CAST (GST_IS_PAD (parent) ? GST_OBJECT_PARENT (parent) :
|
|
|
|
parent);
|
|
|
|
GstElementStats *this_stats = get_element_stats (self, this);
|
|
|
|
GstPad *peer_pad = GST_PAD_PEER (pad);
|
|
|
|
GstElementStats *peer_stats;
|
|
|
|
|
|
|
|
if (!peer_pad)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* walk the ghost pad chain downstream to get the real pad */
|
|
|
|
/* if parent of peer_pad is a ghost-pad, then peer_pad is a proxy_pad */
|
|
|
|
parent = GST_OBJECT_PARENT (peer_pad);
|
|
|
|
if (parent && GST_IS_GHOST_PAD (parent)) {
|
|
|
|
peer_pad = GST_PAD_CAST (parent);
|
|
|
|
/* if this is now the ghost pad, get the peer of this */
|
|
|
|
get_pad_stats (self, peer_pad);
|
|
|
|
if ((parent = GST_OBJECT_PARENT (peer_pad))) {
|
|
|
|
get_element_stats (self, GST_ELEMENT_CAST (parent));
|
|
|
|
}
|
|
|
|
peer_pad = GST_PAD_PEER (GST_GHOST_PAD_CAST (peer_pad));
|
|
|
|
parent = peer_pad ? GST_OBJECT_PARENT (peer_pad) : NULL;
|
|
|
|
}
|
|
|
|
/* walk the ghost pad chain upstream to get the real pad */
|
|
|
|
/* if peer_pad is a ghost-pad, then parent is a bin and it is the parent of
|
|
|
|
* a proxy_pad */
|
|
|
|
while (peer_pad && GST_IS_GHOST_PAD (peer_pad)) {
|
|
|
|
get_pad_stats (self, peer_pad);
|
|
|
|
get_element_stats (self, GST_ELEMENT_CAST (parent));
|
|
|
|
peer_pad = gst_ghost_pad_get_target (GST_GHOST_PAD_CAST (peer_pad));
|
|
|
|
parent = peer_pad ? GST_OBJECT_PARENT (peer_pad) : NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!parent) {
|
|
|
|
printf ("%" GST_TIME_FORMAT
|
2013-11-04 19:11:09 +00:00
|
|
|
" transmission on unparented target pad %s_%s -> %s_%s\n",
|
|
|
|
GST_TIME_ARGS (elapsed), GST_DEBUG_PAD_NAME (pad),
|
2013-10-28 07:08:20 +00:00
|
|
|
GST_DEBUG_PAD_NAME (peer_pad));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
peer_stats = get_element_stats (self, GST_ELEMENT_CAST (parent));
|
|
|
|
|
|
|
|
/* we'd like to gather time spend in each element, but this does not make too
|
|
|
|
* much sense yet
|
|
|
|
* pure push/pull-based:
|
|
|
|
* - the time spend in the push/pull_range is accounted for the peer and
|
|
|
|
* removed from the current element
|
|
|
|
* - this works for chains
|
|
|
|
* - drawback is sink elements that block to sync have a high time usage
|
|
|
|
* - we could rerun the ests with sync=false
|
|
|
|
* both:
|
|
|
|
* - a.g. demuxers both push and pull. thus we subtract time for the pull
|
|
|
|
* and the push operations, but never add anything.
|
|
|
|
* - can we start a counter after push/pull in such elements and add then
|
|
|
|
* time to the element upon next pad activity?
|
|
|
|
*/
|
|
|
|
#if 1
|
|
|
|
/* this does not make sense for demuxers */
|
|
|
|
this_stats->treal -= elapsed;
|
|
|
|
peer_stats->treal += elapsed;
|
|
|
|
#else
|
|
|
|
/* this creates several >100% figures */
|
|
|
|
this_stats->treal += GST_CLOCK_DIFF (this_stats->last_ts, elapsed2) - elapsed;
|
|
|
|
peer_stats->treal += elapsed;
|
|
|
|
this_stats->last_ts = elapsed2;
|
|
|
|
peer_stats->last_ts = elapsed2;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-11-04 19:11:09 +00:00
|
|
|
/* hooks */
|
|
|
|
|
2013-10-28 07:08:20 +00:00
|
|
|
static void
|
2014-09-18 06:26:19 +00:00
|
|
|
do_push_buffer_pre (GstStatsTracer * self, guint64 ts, GstPad * this_pad,
|
|
|
|
GstBuffer * buffer)
|
2013-10-28 07:08:20 +00:00
|
|
|
{
|
2013-11-04 19:11:09 +00:00
|
|
|
GstPadStats *this_pad_stats = get_pad_stats (self, this_pad);
|
|
|
|
GstPad *that_pad = GST_PAD_PEER (this_pad);
|
|
|
|
GstPadStats *that_pad_stats = get_pad_stats (self, that_pad);
|
2013-10-28 07:08:20 +00:00
|
|
|
|
2013-11-04 19:11:09 +00:00
|
|
|
do_buffer_stats (self, this_pad, this_pad_stats, that_pad, that_pad_stats,
|
|
|
|
buffer, ts);
|
2013-10-28 07:08:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-01-07 21:47:37 +00:00
|
|
|
do_push_buffer_post (GstStatsTracer * self, guint64 ts, GstPad * pad,
|
|
|
|
GstFlowReturn res)
|
2013-10-28 07:08:20 +00:00
|
|
|
{
|
2013-10-28 20:59:19 +00:00
|
|
|
GstPadStats *stats = get_pad_stats (self, pad);
|
2013-10-28 07:08:20 +00:00
|
|
|
|
|
|
|
do_element_stats (self, pad, stats->last_ts, ts);
|
|
|
|
}
|
|
|
|
|
2013-10-30 07:19:41 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GstStatsTracer *self;
|
2013-11-04 19:11:09 +00:00
|
|
|
GstPad *this_pad;
|
|
|
|
GstPadStats *this_pad_stats;
|
|
|
|
GstPad *that_pad;
|
|
|
|
GstPadStats *that_pad_stats;
|
2013-10-30 07:19:41 +00:00
|
|
|
guint64 ts;
|
|
|
|
} DoPushBufferListArgs;
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
do_push_buffer_list_item (GstBuffer ** buffer, guint idx, gpointer user_data)
|
|
|
|
{
|
|
|
|
DoPushBufferListArgs *args = (DoPushBufferListArgs *) user_data;
|
|
|
|
|
2013-11-04 19:11:09 +00:00
|
|
|
do_buffer_stats (args->self, args->this_pad, args->this_pad_stats,
|
|
|
|
args->that_pad, args->that_pad_stats, *buffer, args->ts);
|
2013-10-30 07:19:41 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-09-18 06:26:19 +00:00
|
|
|
do_push_buffer_list_pre (GstStatsTracer * self, guint64 ts, GstPad * this_pad,
|
|
|
|
GstBufferList * list)
|
2013-10-30 07:19:41 +00:00
|
|
|
{
|
2013-11-04 19:11:09 +00:00
|
|
|
GstPadStats *this_pad_stats = get_pad_stats (self, this_pad);
|
|
|
|
GstPad *that_pad = GST_PAD_PEER (this_pad);
|
|
|
|
GstPadStats *that_pad_stats = get_pad_stats (self, that_pad);
|
|
|
|
DoPushBufferListArgs args = { self, this_pad, this_pad_stats, that_pad,
|
|
|
|
that_pad_stats, ts
|
|
|
|
};
|
2013-10-30 07:19:41 +00:00
|
|
|
|
|
|
|
gst_buffer_list_foreach (list, do_push_buffer_list_item, &args);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-01-07 21:47:37 +00:00
|
|
|
do_push_buffer_list_post (GstStatsTracer * self, guint64 ts, GstPad * pad,
|
|
|
|
GstFlowReturn res)
|
2013-10-30 07:19:41 +00:00
|
|
|
{
|
|
|
|
GstPadStats *stats = get_pad_stats (self, pad);
|
|
|
|
|
|
|
|
do_element_stats (self, pad, stats->last_ts, ts);
|
|
|
|
}
|
|
|
|
|
2014-07-16 07:22:14 +00:00
|
|
|
static void
|
2014-09-18 06:26:19 +00:00
|
|
|
do_pull_range_pre (GstStatsTracer * self, guint64 ts, GstPad * pad)
|
2014-07-16 07:22:14 +00:00
|
|
|
{
|
|
|
|
GstPadStats *stats = get_pad_stats (self, pad);
|
|
|
|
stats->last_ts = ts;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-09-18 06:26:19 +00:00
|
|
|
do_pull_range_post (GstStatsTracer * self, guint64 ts, GstPad * this_pad,
|
|
|
|
GstBuffer * buffer)
|
2014-07-16 07:22:14 +00:00
|
|
|
{
|
2013-11-04 19:11:09 +00:00
|
|
|
GstPadStats *this_pad_stats = get_pad_stats (self, this_pad);
|
|
|
|
guint64 last_ts = this_pad_stats->last_ts;
|
|
|
|
GstPad *that_pad = GST_PAD_PEER (this_pad);
|
|
|
|
GstPadStats *that_pad_stats = get_pad_stats (self, that_pad);
|
2014-07-16 07:22:14 +00:00
|
|
|
|
|
|
|
if (buffer != NULL) {
|
2013-11-04 19:11:09 +00:00
|
|
|
do_buffer_stats (self, this_pad, this_pad_stats, that_pad, that_pad_stats,
|
|
|
|
buffer, ts);
|
2014-07-16 07:22:14 +00:00
|
|
|
}
|
2013-11-04 19:11:09 +00:00
|
|
|
do_element_stats (self, this_pad, last_ts, ts);
|
2014-07-16 07:22:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-09-18 06:26:19 +00:00
|
|
|
do_push_event_pre (GstStatsTracer * self, guint64 ts, GstPad * pad,
|
|
|
|
GstEvent * ev)
|
2014-07-16 07:22:14 +00:00
|
|
|
{
|
2013-11-04 19:11:09 +00:00
|
|
|
GstElement *elem = get_real_pad_parent (pad);
|
|
|
|
GstElementStats *elem_stats = get_element_stats (self, elem);
|
2013-11-19 07:04:38 +00:00
|
|
|
GstPadStats *pad_stats = get_pad_stats (self, pad);
|
2013-11-04 19:11:09 +00:00
|
|
|
|
|
|
|
elem_stats->last_ts = ts;
|
2016-01-17 23:49:27 +00:00
|
|
|
gst_tracer_record_log (tr_event, (guint64) (guintptr) g_thread_self (), ts,
|
2016-01-12 13:59:04 +00:00
|
|
|
pad_stats->index, elem_stats->index, GST_EVENT_TYPE_NAME (ev));
|
2014-07-16 07:22:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-09-18 06:26:19 +00:00
|
|
|
do_post_message_pre (GstStatsTracer * self, guint64 ts, GstElement * elem,
|
|
|
|
GstMessage * msg)
|
2014-07-16 07:22:14 +00:00
|
|
|
{
|
|
|
|
GstElementStats *stats = get_element_stats (self, elem);
|
2016-01-10 13:30:05 +00:00
|
|
|
const GstStructure *msg_s = gst_message_get_structure (msg);
|
2016-10-14 09:59:24 +00:00
|
|
|
GstStructure *s =
|
|
|
|
msg_s ? (GstStructure *) msg_s : gst_structure_new_empty ("dummy");
|
2014-07-16 07:22:14 +00:00
|
|
|
|
|
|
|
stats->last_ts = ts;
|
2016-10-13 11:18:12 +00:00
|
|
|
/* FIXME: work out whether using NULL instead of a dummy struct would work */
|
2016-01-17 23:49:27 +00:00
|
|
|
gst_tracer_record_log (tr_message, (guint64) (guintptr) g_thread_self (), ts,
|
2016-10-13 11:18:12 +00:00
|
|
|
stats->index, GST_MESSAGE_TYPE_NAME (msg), s);
|
|
|
|
if (s != msg_s)
|
|
|
|
gst_structure_free (s);
|
2014-07-16 07:22:14 +00:00
|
|
|
}
|
|
|
|
|
2015-10-28 09:03:39 +00:00
|
|
|
static void
|
|
|
|
do_element_new (GstStatsTracer * self, guint64 ts, GstElement * elem)
|
|
|
|
{
|
|
|
|
GstElementStats *stats;
|
|
|
|
|
|
|
|
stats = create_element_stats (self, elem);
|
|
|
|
log_new_element_stats (stats, elem, ts);
|
|
|
|
}
|
|
|
|
|
2014-07-16 07:22:14 +00:00
|
|
|
static void
|
2015-03-13 13:10:42 +00:00
|
|
|
do_element_query_pre (GstStatsTracer * self, guint64 ts, GstElement * elem,
|
2014-09-18 06:26:19 +00:00
|
|
|
GstQuery * qry)
|
2014-07-16 07:22:14 +00:00
|
|
|
{
|
|
|
|
GstElementStats *stats = get_element_stats (self, elem);
|
|
|
|
|
|
|
|
stats->last_ts = ts;
|
2016-01-17 23:49:27 +00:00
|
|
|
gst_tracer_record_log (tr_element_query,
|
|
|
|
(guint64) (guintptr) g_thread_self (), ts, stats->index,
|
|
|
|
GST_QUERY_TYPE_NAME (qry));
|
2014-07-16 07:22:14 +00:00
|
|
|
}
|
|
|
|
|
2015-03-13 13:10:42 +00:00
|
|
|
static void
|
|
|
|
do_query_pre (GstStatsTracer * self, guint64 ts, GstPad * this_pad,
|
|
|
|
GstQuery * qry)
|
|
|
|
{
|
|
|
|
GstPadStats *this_pad_stats = get_pad_stats (self, this_pad);
|
|
|
|
GstPad *that_pad = GST_PAD_PEER (this_pad);
|
|
|
|
GstPadStats *that_pad_stats = get_pad_stats (self, that_pad);
|
|
|
|
|
|
|
|
do_query_stats (self, this_pad, this_pad_stats, that_pad, that_pad_stats,
|
2016-01-10 13:30:05 +00:00
|
|
|
qry, ts, FALSE, FALSE);
|
2015-03-13 13:10:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
do_query_post (GstStatsTracer * self, guint64 ts, GstPad * this_pad,
|
2016-01-07 22:03:48 +00:00
|
|
|
GstQuery * qry, gboolean res)
|
2015-03-13 13:10:42 +00:00
|
|
|
{
|
|
|
|
GstPadStats *this_pad_stats = get_pad_stats (self, this_pad);
|
|
|
|
GstPad *that_pad = GST_PAD_PEER (this_pad);
|
|
|
|
GstPadStats *that_pad_stats = get_pad_stats (self, that_pad);
|
|
|
|
|
|
|
|
do_query_stats (self, this_pad, this_pad_stats, that_pad, that_pad_stats,
|
2016-01-12 13:59:04 +00:00
|
|
|
qry, ts, TRUE, res);
|
2015-03-13 13:10:42 +00:00
|
|
|
}
|
|
|
|
|
2014-09-15 11:15:17 +00:00
|
|
|
/* tracer class */
|
|
|
|
|
2013-10-28 07:08:20 +00:00
|
|
|
static void
|
2014-09-15 11:15:17 +00:00
|
|
|
gst_stats_tracer_class_init (GstStatsTracerClass * klass)
|
2013-10-28 07:08:20 +00:00
|
|
|
{
|
2014-09-15 11:15:17 +00:00
|
|
|
/* announce trace formats */
|
|
|
|
/* *INDENT-OFF* */
|
2016-01-21 07:12:01 +00:00
|
|
|
tr_buffer = gst_tracer_record_new ("buffer.class",
|
2015-03-13 18:31:40 +00:00
|
|
|
"thread-id", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
|
2016-01-12 13:59:04 +00:00
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_UINT64,
|
2016-01-16 12:24:16 +00:00
|
|
|
"related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_THREAD,
|
2015-03-13 18:31:40 +00:00
|
|
|
NULL),
|
2016-01-12 13:59:04 +00:00
|
|
|
"ts", GST_TYPE_STRUCTURE, gst_structure_new ("value",
|
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_UINT64,
|
|
|
|
"description", G_TYPE_STRING, "event ts",
|
|
|
|
NULL),
|
2014-09-15 11:15:17 +00:00
|
|
|
"pad-ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
|
2016-01-12 13:59:04 +00:00
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_UINT,
|
2016-01-16 12:24:16 +00:00
|
|
|
"related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_PAD,
|
2014-09-15 11:15:17 +00:00
|
|
|
NULL),
|
|
|
|
"element-ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
|
2016-01-12 13:59:04 +00:00
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_UINT,
|
2016-01-16 12:24:16 +00:00
|
|
|
"related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_ELEMENT,
|
2014-09-15 11:15:17 +00:00
|
|
|
NULL),
|
|
|
|
"peer-pad-ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
|
2016-01-12 13:59:04 +00:00
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_UINT,
|
2016-01-16 12:24:16 +00:00
|
|
|
"related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_PAD,
|
2014-09-15 11:15:17 +00:00
|
|
|
NULL),
|
|
|
|
"peer-element-ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
|
2016-01-12 13:59:04 +00:00
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_UINT,
|
2016-01-16 12:24:16 +00:00
|
|
|
"related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_ELEMENT,
|
2014-09-15 11:15:17 +00:00
|
|
|
NULL),
|
|
|
|
"buffer-size", GST_TYPE_STRUCTURE, gst_structure_new ("value",
|
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_UINT,
|
|
|
|
"description", G_TYPE_STRING, "size of buffer in bytes",
|
2016-01-10 13:30:05 +00:00
|
|
|
"min", G_TYPE_UINT, 0,
|
2014-09-15 11:15:17 +00:00
|
|
|
"max", G_TYPE_UINT, G_MAXUINT,
|
|
|
|
NULL),
|
2016-01-18 20:09:49 +00:00
|
|
|
"buffer-pts", GST_TYPE_STRUCTURE, gst_structure_new ("value",
|
2014-09-15 11:15:17 +00:00
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_UINT64,
|
2016-01-18 20:09:49 +00:00
|
|
|
"description", G_TYPE_STRING, "presentation timestamp of the buffer in ns",
|
2016-12-15 14:37:45 +00:00
|
|
|
"flags", GST_TYPE_TRACER_VALUE_FLAGS, GST_TRACER_VALUE_FLAGS_OPTIONAL,
|
2016-01-18 20:09:49 +00:00
|
|
|
"min", G_TYPE_UINT64, G_GUINT64_CONSTANT (0),
|
|
|
|
"max", G_TYPE_UINT64, G_MAXUINT64,
|
|
|
|
NULL),
|
|
|
|
"buffer-dts", GST_TYPE_STRUCTURE, gst_structure_new ("value",
|
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_UINT64,
|
|
|
|
"description", G_TYPE_STRING, "decoding timestamp of the buffer in ns",
|
2016-12-15 14:37:45 +00:00
|
|
|
"flags", GST_TYPE_TRACER_VALUE_FLAGS, GST_TRACER_VALUE_FLAGS_OPTIONAL,
|
2014-09-15 11:15:17 +00:00
|
|
|
"min", G_TYPE_UINT64, G_GUINT64_CONSTANT (0),
|
|
|
|
"max", G_TYPE_UINT64, G_MAXUINT64,
|
|
|
|
NULL),
|
|
|
|
"buffer-duration", GST_TYPE_STRUCTURE, gst_structure_new ("value",
|
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_UINT64,
|
|
|
|
"description", G_TYPE_STRING, "duration of the buffer in ns",
|
2016-12-15 14:37:45 +00:00
|
|
|
"flags", GST_TYPE_TRACER_VALUE_FLAGS, GST_TRACER_VALUE_FLAGS_OPTIONAL,
|
2014-09-15 11:15:17 +00:00
|
|
|
"min", G_TYPE_UINT64, G_GUINT64_CONSTANT (0),
|
|
|
|
"max", G_TYPE_UINT64, G_MAXUINT64,
|
|
|
|
NULL),
|
2016-01-18 20:09:49 +00:00
|
|
|
"buffer-flags", GST_TYPE_STRUCTURE, gst_structure_new ("value",
|
|
|
|
"type", G_TYPE_GTYPE, GST_TYPE_BUFFER_FLAGS,
|
|
|
|
"description", G_TYPE_STRING, "flags of the buffer",
|
|
|
|
NULL),
|
2016-01-21 07:12:01 +00:00
|
|
|
NULL);
|
|
|
|
tr_event = gst_tracer_record_new ("event.class",
|
2015-03-13 18:31:40 +00:00
|
|
|
"thread-id", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
|
2016-01-12 13:59:04 +00:00
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_UINT64,
|
2016-01-16 12:24:16 +00:00
|
|
|
"related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_THREAD,
|
2015-03-13 18:31:40 +00:00
|
|
|
NULL),
|
2016-01-12 13:59:04 +00:00
|
|
|
"ts", GST_TYPE_STRUCTURE, gst_structure_new ("value",
|
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_UINT64,
|
|
|
|
"description", G_TYPE_STRING, "event ts",
|
|
|
|
NULL),
|
2014-09-15 11:15:17 +00:00
|
|
|
"pad-ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
|
2016-01-12 13:59:04 +00:00
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_UINT,
|
2016-01-16 12:24:16 +00:00
|
|
|
"related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_PAD,
|
2014-09-15 11:15:17 +00:00
|
|
|
NULL),
|
|
|
|
"element-ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
|
2016-01-12 13:59:04 +00:00
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_UINT,
|
2016-01-16 12:24:16 +00:00
|
|
|
"related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_ELEMENT,
|
2014-09-15 11:15:17 +00:00
|
|
|
NULL),
|
|
|
|
"name", GST_TYPE_STRUCTURE, gst_structure_new ("value",
|
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_STRING,
|
|
|
|
"description", G_TYPE_STRING, "name of the event",
|
|
|
|
NULL),
|
2016-01-21 07:12:01 +00:00
|
|
|
NULL);
|
|
|
|
tr_message = gst_tracer_record_new ("message.class",
|
2015-03-13 18:31:40 +00:00
|
|
|
"thread-id", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
|
2016-01-12 13:59:04 +00:00
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_UINT64,
|
2016-01-16 12:24:16 +00:00
|
|
|
"related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_THREAD,
|
2015-03-13 18:31:40 +00:00
|
|
|
NULL),
|
2016-01-12 13:59:04 +00:00
|
|
|
"ts", GST_TYPE_STRUCTURE, gst_structure_new ("value",
|
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_UINT64,
|
|
|
|
"description", G_TYPE_STRING, "event ts",
|
|
|
|
NULL),
|
2014-09-15 11:15:17 +00:00
|
|
|
"element-ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
|
2016-01-12 13:59:04 +00:00
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_UINT,
|
2016-01-16 12:24:16 +00:00
|
|
|
"related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_ELEMENT,
|
2014-09-15 11:15:17 +00:00
|
|
|
NULL),
|
|
|
|
"name", GST_TYPE_STRUCTURE, gst_structure_new ("value",
|
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_STRING,
|
|
|
|
"description", G_TYPE_STRING, "name of the message",
|
|
|
|
NULL),
|
2015-09-01 19:39:30 +00:00
|
|
|
"structure", GST_TYPE_STRUCTURE, gst_structure_new ("structure",
|
|
|
|
"type", G_TYPE_GTYPE, GST_TYPE_STRUCTURE,
|
|
|
|
"description", G_TYPE_STRING, "message structure",
|
|
|
|
NULL),
|
2016-01-21 07:12:01 +00:00
|
|
|
NULL);
|
|
|
|
tr_element_query = gst_tracer_record_new ("element-query.class",
|
2015-03-13 18:31:40 +00:00
|
|
|
"thread-id", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
|
2016-01-12 13:59:04 +00:00
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_UINT64,
|
2016-01-16 12:24:16 +00:00
|
|
|
"related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_THREAD,
|
2015-03-13 18:31:40 +00:00
|
|
|
NULL),
|
2016-01-12 13:59:04 +00:00
|
|
|
"ts", GST_TYPE_STRUCTURE, gst_structure_new ("value",
|
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_UINT64,
|
|
|
|
"description", G_TYPE_STRING, "event ts",
|
|
|
|
NULL),
|
2015-03-13 13:10:42 +00:00
|
|
|
"element-ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
|
2016-01-12 13:59:04 +00:00
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_UINT,
|
2016-01-16 12:24:16 +00:00
|
|
|
"related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_ELEMENT,
|
2015-03-13 13:10:42 +00:00
|
|
|
NULL),
|
|
|
|
"name", GST_TYPE_STRUCTURE, gst_structure_new ("value",
|
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_STRING,
|
|
|
|
"description", G_TYPE_STRING, "name of the query",
|
|
|
|
NULL),
|
2016-01-21 07:12:01 +00:00
|
|
|
NULL);
|
|
|
|
tr_query = gst_tracer_record_new ("query.class",
|
2015-03-13 18:31:40 +00:00
|
|
|
"thread-id", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
|
2016-01-12 13:59:04 +00:00
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_UINT64,
|
2016-01-16 12:24:16 +00:00
|
|
|
"related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_THREAD,
|
2015-03-13 18:31:40 +00:00
|
|
|
NULL),
|
2016-01-12 13:59:04 +00:00
|
|
|
"ts", GST_TYPE_STRUCTURE, gst_structure_new ("value",
|
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_UINT64,
|
|
|
|
"description", G_TYPE_STRING, "event ts",
|
|
|
|
NULL),
|
2015-03-13 13:10:42 +00:00
|
|
|
"pad-ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
|
2016-01-12 13:59:04 +00:00
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_UINT,
|
2016-01-16 12:24:16 +00:00
|
|
|
"related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_PAD,
|
2015-03-13 13:10:42 +00:00
|
|
|
NULL),
|
2014-09-15 11:15:17 +00:00
|
|
|
"element-ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
|
2016-01-12 13:59:04 +00:00
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_UINT,
|
2016-01-16 12:24:16 +00:00
|
|
|
"related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_ELEMENT,
|
2014-09-15 11:15:17 +00:00
|
|
|
NULL),
|
2015-03-13 13:10:42 +00:00
|
|
|
"peer-pad-ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
|
2016-01-12 13:59:04 +00:00
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_UINT,
|
2016-01-16 12:24:16 +00:00
|
|
|
"related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_PAD,
|
2015-03-13 13:10:42 +00:00
|
|
|
NULL),
|
|
|
|
"peer-element-ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
|
2016-01-12 13:59:04 +00:00
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_UINT,
|
2016-01-16 12:24:16 +00:00
|
|
|
"related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_ELEMENT,
|
2015-03-13 13:10:42 +00:00
|
|
|
NULL),
|
2014-09-15 11:15:17 +00:00
|
|
|
"name", GST_TYPE_STRUCTURE, gst_structure_new ("value",
|
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_STRING,
|
|
|
|
"description", G_TYPE_STRING, "name of the query",
|
|
|
|
NULL),
|
2015-03-13 13:10:42 +00:00
|
|
|
"structure", GST_TYPE_STRUCTURE, gst_structure_new ("value",
|
|
|
|
"type", G_TYPE_GTYPE, GST_TYPE_STRUCTURE,
|
|
|
|
"description", G_TYPE_STRING, "query structure",
|
|
|
|
NULL),
|
2016-01-12 13:59:04 +00:00
|
|
|
"res", GST_TYPE_STRUCTURE, gst_structure_new ("value",
|
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_BOOLEAN,
|
|
|
|
"description", G_TYPE_STRING, "query result",
|
2016-01-16 17:55:07 +00:00
|
|
|
"flags", GST_TYPE_TRACER_VALUE_FLAGS, GST_TRACER_VALUE_FLAGS_OPTIONAL,
|
2016-01-12 13:59:04 +00:00
|
|
|
NULL),
|
2016-01-21 07:12:01 +00:00
|
|
|
NULL);
|
|
|
|
tr_new_element = gst_tracer_record_new ("new-element.class",
|
2016-01-12 13:59:04 +00:00
|
|
|
"thread-id", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
|
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_UINT64,
|
2016-01-16 12:24:16 +00:00
|
|
|
"related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_THREAD,
|
2016-01-12 13:59:04 +00:00
|
|
|
NULL),
|
|
|
|
"ts", GST_TYPE_STRUCTURE, gst_structure_new ("value",
|
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_UINT64,
|
|
|
|
"description", G_TYPE_STRING, "event ts",
|
|
|
|
NULL),
|
|
|
|
"ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
|
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_UINT,
|
2016-01-16 12:24:16 +00:00
|
|
|
"related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_ELEMENT,
|
2016-01-12 13:59:04 +00:00
|
|
|
NULL),
|
|
|
|
"parent-ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
|
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_UINT,
|
2016-01-16 12:24:16 +00:00
|
|
|
"related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_ELEMENT,
|
2016-01-12 13:59:04 +00:00
|
|
|
NULL),
|
|
|
|
"name", GST_TYPE_STRUCTURE, gst_structure_new ("value",
|
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_STRING,
|
|
|
|
"description", G_TYPE_STRING, "name of the element",
|
|
|
|
NULL),
|
|
|
|
"type", GST_TYPE_STRUCTURE, gst_structure_new ("value",
|
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_STRING,
|
|
|
|
"description", G_TYPE_STRING, "type name of the element",
|
|
|
|
NULL),
|
|
|
|
"is-bin", GST_TYPE_STRUCTURE, gst_structure_new ("value",
|
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_BOOLEAN,
|
|
|
|
"description", G_TYPE_STRING, "is element a bin",
|
|
|
|
NULL),
|
2016-01-21 07:12:01 +00:00
|
|
|
NULL);
|
|
|
|
tr_new_pad = gst_tracer_record_new ("new-pad.class",
|
2016-01-12 13:59:04 +00:00
|
|
|
"thread-id", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
|
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_UINT64,
|
2016-01-16 12:24:16 +00:00
|
|
|
"related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_THREAD,
|
2016-01-12 13:59:04 +00:00
|
|
|
NULL),
|
|
|
|
"ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
|
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_UINT,
|
2016-01-16 12:24:16 +00:00
|
|
|
"related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_PAD,
|
2016-01-12 13:59:04 +00:00
|
|
|
NULL),
|
|
|
|
"parent-ix", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
|
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_UINT,
|
2016-01-16 12:24:16 +00:00
|
|
|
"related-to", GST_TYPE_TRACER_VALUE_SCOPE, GST_TRACER_VALUE_SCOPE_ELEMENT,
|
2016-01-12 13:59:04 +00:00
|
|
|
NULL),
|
|
|
|
"name", GST_TYPE_STRUCTURE, gst_structure_new ("value",
|
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_STRING,
|
|
|
|
"description", G_TYPE_STRING, "name of the pad",
|
|
|
|
NULL),
|
|
|
|
"type", GST_TYPE_STRUCTURE, gst_structure_new ("value",
|
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_STRING,
|
|
|
|
"description", G_TYPE_STRING, "type name of the pad",
|
|
|
|
NULL),
|
|
|
|
"is-ghostpad", GST_TYPE_STRUCTURE, gst_structure_new ("value",
|
|
|
|
"type", G_TYPE_GTYPE, G_TYPE_BOOLEAN,
|
|
|
|
"description", G_TYPE_STRING, "is pad a ghostpad",
|
|
|
|
NULL),
|
|
|
|
"pad-direction", GST_TYPE_STRUCTURE, gst_structure_new ("value",
|
|
|
|
"type", G_TYPE_GTYPE, GST_TYPE_PAD_DIRECTION,
|
|
|
|
"description", G_TYPE_STRING, "ipad direction",
|
|
|
|
NULL),
|
2016-01-21 07:12:01 +00:00
|
|
|
NULL);
|
2014-09-15 11:15:17 +00:00
|
|
|
/* *INDENT-ON* */
|
2019-08-02 07:37:58 +00:00
|
|
|
|
|
|
|
GST_OBJECT_FLAG_SET (tr_buffer, GST_OBJECT_FLAG_MAY_BE_LEAKED);
|
|
|
|
GST_OBJECT_FLAG_SET (tr_event, GST_OBJECT_FLAG_MAY_BE_LEAKED);
|
|
|
|
GST_OBJECT_FLAG_SET (tr_message, GST_OBJECT_FLAG_MAY_BE_LEAKED);
|
|
|
|
GST_OBJECT_FLAG_SET (tr_element_query, GST_OBJECT_FLAG_MAY_BE_LEAKED);
|
|
|
|
GST_OBJECT_FLAG_SET (tr_query, GST_OBJECT_FLAG_MAY_BE_LEAKED);
|
|
|
|
GST_OBJECT_FLAG_SET (tr_new_element, GST_OBJECT_FLAG_MAY_BE_LEAKED);
|
|
|
|
GST_OBJECT_FLAG_SET (tr_new_pad, GST_OBJECT_FLAG_MAY_BE_LEAKED);
|
2013-10-28 07:08:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-09-15 11:15:17 +00:00
|
|
|
gst_stats_tracer_init (GstStatsTracer * self)
|
2013-10-28 07:08:20 +00:00
|
|
|
{
|
2014-09-15 11:15:17 +00:00
|
|
|
GstTracer *tracer = GST_TRACER (self);
|
|
|
|
|
2014-09-22 07:55:56 +00:00
|
|
|
gst_tracing_register_hook (tracer, "pad-push-pre",
|
2014-09-18 06:26:19 +00:00
|
|
|
G_CALLBACK (do_push_buffer_pre));
|
2014-09-22 07:55:56 +00:00
|
|
|
gst_tracing_register_hook (tracer, "pad-push-post",
|
2014-09-18 06:26:19 +00:00
|
|
|
G_CALLBACK (do_push_buffer_post));
|
2014-09-22 07:55:56 +00:00
|
|
|
gst_tracing_register_hook (tracer, "pad-push-list-pre",
|
2014-09-18 06:26:19 +00:00
|
|
|
G_CALLBACK (do_push_buffer_list_pre));
|
2014-09-22 07:55:56 +00:00
|
|
|
gst_tracing_register_hook (tracer, "pad-push-list-post",
|
2014-09-18 06:26:19 +00:00
|
|
|
G_CALLBACK (do_push_buffer_list_post));
|
2014-09-22 07:55:56 +00:00
|
|
|
gst_tracing_register_hook (tracer, "pad-pull-range-pre",
|
2014-09-18 06:26:19 +00:00
|
|
|
G_CALLBACK (do_pull_range_pre));
|
2014-09-22 07:55:56 +00:00
|
|
|
gst_tracing_register_hook (tracer, "pad-pull-range-post",
|
2014-09-18 06:26:19 +00:00
|
|
|
G_CALLBACK (do_pull_range_post));
|
2014-09-22 07:55:56 +00:00
|
|
|
gst_tracing_register_hook (tracer, "pad-push-event-pre",
|
2014-09-18 06:26:19 +00:00
|
|
|
G_CALLBACK (do_push_event_pre));
|
2015-10-28 09:03:39 +00:00
|
|
|
gst_tracing_register_hook (tracer, "element-new",
|
|
|
|
G_CALLBACK (do_element_new));
|
2014-09-22 07:55:56 +00:00
|
|
|
gst_tracing_register_hook (tracer, "element-post-message-pre",
|
2014-09-18 06:26:19 +00:00
|
|
|
G_CALLBACK (do_post_message_pre));
|
2014-09-22 07:55:56 +00:00
|
|
|
gst_tracing_register_hook (tracer, "element-query-pre",
|
2015-03-13 13:10:42 +00:00
|
|
|
G_CALLBACK (do_element_query_pre));
|
|
|
|
gst_tracing_register_hook (tracer, "pad-query-pre",
|
2014-09-18 06:26:19 +00:00
|
|
|
G_CALLBACK (do_query_pre));
|
2015-03-13 13:10:42 +00:00
|
|
|
gst_tracing_register_hook (tracer, "pad-query-post",
|
|
|
|
G_CALLBACK (do_query_post));
|
2013-10-28 07:08:20 +00:00
|
|
|
}
|