![]() |
TSDuck v3.46-4965
MPEG Transport Stream Toolkit
|
#include <tsTSSpeedMetrics.h>
Public Member Functions | |
| TSSpeedMetrics (PacketCounter packets=MIN_PACKET_PER_INTERVAL, cn::nanoseconds nanosecs=MIN_NANOSEC_PER_INTERVAL, size_t intervals=INTERVAL_COUNT) | |
| BitRate | bitrate () const |
| bool | processedPacket (PacketCounter count=1) |
| cn::nanoseconds | sessionNanoSeconds () const |
| void | start () |
Static Public Attributes | |
| static constexpr size_t | INTERVAL_COUNT = 20 |
| static constexpr cn::nanoseconds | MIN_NANOSEC_PER_INTERVAL = cn::milliseconds(100) |
| static constexpr PacketCounter | MIN_PACKET_PER_INTERVAL = 100 |
TS processing speed metrics evaluation.
An instance of this class evaluates the reading or processing speed of a TS. This is different from the TS bitrate, as evaluated by the class PCRAnalyzer, when the TS is not a live one but a file for instance.
This class is useful to perform actions at regular intervals, based on wall clock time, not TS clock. Instead of checking the system time at every packet, which is far from efficient, an application can predict an average number of packets to process before performing the repetitive action.
Warning: The processing speed of the TS is typically not stable. Buffer sizes impact the latency for instance. As well as any external factor in the operating system. So, predictions on packet distance are only hints at best. This class shall be considered as an optimization on the number of times the system time is probed, not a precise prediction.
Principle of operation:
| ts::TSSpeedMetrics::TSSpeedMetrics | ( | PacketCounter | packets = MIN_PACKET_PER_INTERVAL, |
| cn::nanoseconds | nanosecs = MIN_NANOSEC_PER_INTERVAL, | ||
| size_t | intervals = INTERVAL_COUNT ) |
Constructor.
| [in] | packets | Minimum packets to accumulate per interval. |
| [in] | nanosecs | Minimum number of nanoseconds per interval. |
| [in] | intervals | Max number of sliding time intervals. |
| void ts::TSSpeedMetrics::start | ( | ) |
Start a new processing time session.
| bool ts::TSSpeedMetrics::processedPacket | ( | PacketCounter | count = 1 | ) |
Report the processing of some TS packets by the application.
| [in] | count | Number of processed packets, one by default. |
| BitRate ts::TSSpeedMetrics::bitrate | ( | ) | const |
Get the evaluated processing bitrate in bits/second based on 188-byte packets.
|
inline |
Get the duration of the session, since start(), in nanoseconds. The value is the most precise when processedPacket() just returned true.
|
staticconstexpr |
Default minimum packets to accumulate per interval. See the description of the class.
|
staticconstexpr |
Default minimum number of nanoseconds per interval. See the description of the class.
|
staticconstexpr |
Default number of intervals in the sliding window of bitrate computation. See the description of the class.