From 1bfd04a5fee09a647a380d17bfe924f3860ad04c Mon Sep 17 00:00:00 2001 From: Stefan Sauer Date: Thu, 15 Dec 2016 15:37:45 +0100 Subject: [PATCH] tracers/stats: log optional fields instead of GST_CLOCK_TIME_NONE Simplify the traces and avoid trace analyzer to know that ((1<<64) - 1) means we had no value. --- plugins/tracers/gststats.c | 10 ++++++++-- tools/gst-stats.c | 7 ++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/plugins/tracers/gststats.c b/plugins/tracers/gststats.c index 8b7705b5ed..1a8f892a49 100644 --- a/plugins/tracers/gststats.c +++ b/plugins/tracers/gststats.c @@ -251,12 +251,15 @@ do_buffer_stats (GstStatsTracer * self, GstPad * 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); + GstClockTime pts = GST_BUFFER_PTS (buf); + GstClockTime dts = GST_BUFFER_DTS (buf); + GstClockTime dur = GST_BUFFER_DURATION (buf); 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), - GST_BUFFER_PTS (buf), GST_BUFFER_DTS (buf), GST_BUFFER_DURATION (buf), - GST_BUFFER_FLAGS (buf)); + 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)); } static void @@ -556,18 +559,21 @@ gst_stats_tracer_class_init (GstStatsTracerClass * klass) "buffer-pts", GST_TYPE_STRUCTURE, gst_structure_new ("value", "type", G_TYPE_GTYPE, G_TYPE_UINT64, "description", G_TYPE_STRING, "presentation timestamp of the buffer in ns", + "flags", GST_TYPE_TRACER_VALUE_FLAGS, GST_TRACER_VALUE_FLAGS_OPTIONAL, "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", + "flags", GST_TYPE_TRACER_VALUE_FLAGS, GST_TRACER_VALUE_FLAGS_OPTIONAL, "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", + "flags", GST_TYPE_TRACER_VALUE_FLAGS, GST_TRACER_VALUE_FLAGS_OPTIONAL, "min", G_TYPE_UINT64, G_GUINT64_CONSTANT (0), "max", G_TYPE_UINT64, G_MAXUINT64, NULL), diff --git a/tools/gst-stats.c b/tools/gst-stats.c index a9b1918a73..90241ac24b 100644 --- a/tools/gst-stats.c +++ b/tools/gst-stats.c @@ -280,7 +280,8 @@ do_element_stats (GstElementStats * stats, GstElementStats * peer_stats, static void do_buffer_stats (GstStructure * s) { - guint64 ts, buffer_pts, buffer_dur; + guint64 ts; + guint64 buffer_pts = GST_CLOCK_TIME_NONE, buffer_dur = GST_CLOCK_TIME_NONE; guint pad_ix, elem_ix, peer_elem_ix; guint size; GstBufferFlags buffer_flags; @@ -293,9 +294,9 @@ do_buffer_stats (GstStructure * s) "element-ix", G_TYPE_UINT, &elem_ix, "peer-element-ix", G_TYPE_UINT, &peer_elem_ix, "buffer-size", G_TYPE_UINT, &size, - "buffer-pts", G_TYPE_UINT64, &buffer_pts, - "buffer-duration", G_TYPE_UINT64, &buffer_dur, "buffer-flags", GST_TYPE_BUFFER_FLAGS, &buffer_flags, NULL); + gst_structure_get_uint64 (s, "buffer-pts", &buffer_pts); + gst_structure_get_uint64 (s, "buffer-duration", &buffer_dur); last_ts = MAX (last_ts, ts); if (!(pad_stats = get_pad_stats (pad_ix))) { GST_WARNING ("no pad stats found for ix=%u", pad_ix);