The GStreamer framework includes a tracing module that helps determine source to sink latencies by injecting custom events at source and processing them at sinks. It effectively measures the time between when the buffer is produced by the source pad of the first element and when it reaches the sink pad of the last element. Consider the following pseudo pipeline:
source! element! element! sink
The GStreamer tracing module measures the latency introduced by element ! element, which is the inner processing of the pipeline. The rest (introduced by the capture source and display device) cannot be measured accurately by the user space.
Each element reports to GStreamer the maximum latency time it takes to output the buffer after it is received. GStreamer uses this information for synchronization.
The latency tracer module gives instantaneous latencies which might not be the same as the reported latencies. The latencies might be higher if the inner pipeline (element ! element) takes more time, or lower if the inner pipeline is running faster, but the GStreamer framework waits until the running time equals the reported latency.
You can measure the average userland latency using the following formulas:
The following section provides an example of measuring the latency-related data for the AVC 4kp60 capture→encode→decode→display use case. Follow the setup steps described in the wiki.