Alternative to using Tracing to compute pipeline latency?

Nicolas Dufresne nicolas at ndufresne.ca
Tue Aug 24 17:47:27 UTC 2021


Le mardi 24 août 2021 à 11:22 -0500, Ben Rush via gstreamer-devel a écrit :
> My problem might be the result of misunderstanding the logging and tracing
> capabilities of GStreamer. If so, I apologize. 
> 
> Fundamentally what I want to do is measure the pipeline latencies for 3 media
> streams inside my RTSP server individually; so, my setup is an RTSP server
> running 3 separate media pipelines and for each I want to get back latency
> metrics. I see that the "standard" way of doing this (at least the most well-
> advertised) is to use Tracing and hook into GST_DEBUG to get latency
> metrics: GST_DEBUG="GST_TRACER:7" GST_TRACERS=latency, for example. 
> 
> I tried this: I set the GST_DEBUG and GST_TRACERS environment variables from
> my C code and subsequently got back a wealth of latency-related information to
> standard error. But that's also my problem: my server is written in C, and
> GST_DEBUG writes to standard error. I would prefer to have some well defined
> mechanism through which I could query the pipeline latency on an as-needed
> basis instead of hook into standard error and parse strings. Is this possible?
> Is there documentation or example code showing how to do this? 

Latency isn't a statistic build-in into GStreamer fundamental. So in general,
elements and pipeline do not "know" their latency at immediate point in time and
would not be able to reply to a query.

The tracing mechanism provide raw traces for later analyses. We don't have any
"live" view of the traces yet, some project like gst-debugger was considered,
but didn't happen.

Though, after you have stored your traces (btw you can store to disk too,
GST_DEBUG_FILE), you can analyze the trace data using tools. We currently
provide gst-stats-1.0 tools, which will combine and everage latencies for each
of your elements (assuming you enabled that flags in the tracer) or each of the
pipelines top level src/sink pairs (default). It will also dump the reported
latency, note that this one is a log since reported latency is something that
may change overtime and would not make much sense to average.

> 
> I looked at gst_tracing_register_hook and, while it looks as though it would
> be what I want (because it registers a callback to the specific tracing hooks
> I'm interested in), I'm not finding good documentation or example code about
> how to use it outside of a module in the pipeline itself. For example, most of
> the code I'm seeing while searching GitHub for this function is GstLatency.c
> itself, which begs the question of whether this API can be used by anything
> other than a plugin of the pipeline I'm inspecting? Will I need to write or
> extend a tracing plugin to do what I need, then? Can I not use this function
> from my RTSP server code to register a callback to these hooks? 

You can register to hooks outside of a tracer plugin, see gst-
devtools/validate/gst/validate/gst-validate-runner.c, this code will register to
the "element-new" hook in order to instruments the pads of each element for
further analyzes and validation of course.

> 
> Thanks, and I apologize of the question isn't clearly stated. I'm clearly not
> understanding something. 

I simply hope my answers are useful,

regards,
Nicolas



More information about the gstreamer-devel mailing list