How to measure QoS
Measuring QoS
Elements that synchronize buffers on the pipeline clock will usually measure the current QoS. They will also need to keep some statistics in order to generate the QOS event.
For each buffer that arrives in the sink, the element needs to calculate how late or how early it was. This is called the jitter. Negative jitter values mean that the buffer was early, positive values mean that the buffer was late. the jitter value gives an indication of how early/late a buffer was.
A synchronizing element will also need to calculate how much time elapsed between receiving two consecutive buffers. We call this the processing time because that is the amount of time it takes for the upstream element to produce/process the buffer. We can compare this processing time to the duration of the buffer to have a measurement of how fast upstream can produce data, called the proportion.
If, for example, upstream can produce a buffer in 0.5 seconds of 1 second long, it is operating at twice the required speed. If, on the other hand, it takes 2 seconds to produce a buffer with 1 seconds worth of data, upstream is producing buffers too slow and we won't be able to keep synchronization. Usually, a running average is kept of the proportion.
A synchronizing element also needs to measure its own performance in order to figure out if the performance problem is upstream of itself.
These measurements are used to construct a QOS event that is sent upstream. Note that a QoS event is sent for each buffer that arrives in the sink.
GstBuffer
Buffers are the basic unit of data transfer in GStreamer. They contain the timing and offset along with other arbitrary metadata that is associated with the GstMemory blocks that the buffer contains.
Buffers are usually created with gst_buffer_new. After a buffer has been created one will typically allocate memory for it and add it to the buffer. The following example creates a buffer that can hold a given video frame with a given width, height and bits per plane.
Members
- mini_object (GstMiniObject) – the parent structure
- pool (GstBufferPool *) – pointer to the pool owner of the buffer
- pts (GstClockTime) – presentation timestamp of the buffer, can be GST_CLOCK_TIME_NONE when the pts is not known or relevant. The pts contains the timestamp when the media should be presented to the user.
- dts (GstClockTime) – decoding timestamp of the buffer, can be GST_CLOCK_TIME_NONE when the dts is not known or relevant. The dts contains the timestamp when the media should be processed.
- duration (GstClockTime) – duration in time of the buffer data, can be GST_CLOCK_TIME_NONE when the duration is not known or relevant.
- offset (guint64) – a media specific offset for the buffer data. For video frames, this is the frame number of this buffer. For audio samples, this is the offset of the first sample in this buffer. For file data or compressed data this is the byte offset of the first byte in this buffer.
- offset_end (guint64) – the last offset contained in this buffer. It has the same format as offset.