![]() |
TSDuck v3.46-4965
MPEG Transport Stream Toolkit
|
#include <tsPacketInsertionController.h>
Public Member Functions | |
| PacketInsertionController (Report &report=(ts::NullReport::Instance())) | |
| BitRate | currentMainBitRate () const |
| BitRate | currentSubBitRate () const |
| void | declareMainPackets (size_t packets) |
| void | declareSubPackets (size_t packets) |
| bool | mustInsert (size_t waiting_packets=1) |
| void | reset () |
| void | setBitRateVariationResetThreshold (size_t percent) |
| void | setMainBitRate (const BitRate &rate) |
| void | setMainStreamName (const UString &name) |
| void | setSubBitRate (const BitRate &rate) |
| void | setSubStreamName (const UString &name) |
| void | setWaitPacketsAlertThreshold (size_t packets) |
Static Public Attributes | |
| static constexpr size_t | DEFAULT_BITRATE_RESET_PERCENT = 10 |
| static constexpr size_t | DEFAULT_WAIT_ALERT = 16 |
Control the insertion points of TS packets in a stream based on various criteria.
The scenarion is the following:
| ts::PacketInsertionController::PacketInsertionController | ( | Report & | report = (ts::NullReport::Instance()) | ) |
Constructor.
| [in] | report | Where to report verbose and debug messages. |
| void ts::PacketInsertionController::reset | ( | ) |
Reset the state of the controller. The packet counters are reset. The last bitrates and stream names are retained.
| void ts::PacketInsertionController::setMainBitRate | ( | const BitRate & | rate | ) |
Declare a new value for the bitrate of the main transport stream.
| [in] | rate | New bitrate value. Zero means unknown bitrate. |
| void ts::PacketInsertionController::setSubBitRate | ( | const BitRate & | rate | ) |
Declare a new value for the bitrate of the sub-stream.
| [in] | rate | New bitrate value. Zero means unknown bitrate. |
|
inline |
Get current bitrate of the main transport stream.
|
inline |
Get current bitrate of the sub-stream.
|
inline |
Count packets in the main transport stream. This method must be called each time packets pass through the main transport stream. This includes packets which are replaced with content from the sub-stream.
| [in] | packets | Number of passed packets in the main transport stream. |
|
inline |
Count packets in the sub-stream. This method must be called each time packets from the main transport stream are replaced with content from the sub-stream.
| [in] | packets | Number of packets which are replaced with content from the sub-stream. |
| bool ts::PacketInsertionController::mustInsert | ( | size_t | waiting_packets = 1 | ) |
Check if a packet from the sub-stream shall be inserted at the current position in the main transport stream.
| [in] | waiting_packets | Number of packets waiting to be inserted. This value is used only when greater than 1. In that case, it indicates that a real-time source is providing packets in bursts. If the bursts are too important, then packet insertion is temporarily accelerated to avoid overflow. |
|
inline |
Set an alert threshold to waiting packets.
When the number of current packets waiting to be inserted from the sub-stream becomes higher than the specified alert threshold, the insertion rate is temporarily accelerated to avoid overflow. When the sub-stream is correctly regulated on average but regularly bursts, the waiting packets threshold should be at least the burst size to keep a smooth insertion.
This parameter is used to make sure that 1) bursts do not affect the insertion rythm and 2) overflows are smoothly absorbed.
The initial default threshold is DEFAULT_WAIT_ALERT packets.
| [in] | packets | New alert threshold, in number of packets. When set to zero, no acceleration is performed. |
| void ts::PacketInsertionController::setBitRateVariationResetThreshold | ( | size_t | percent | ) |
Set a reset threshold for bitrate variation.
The bitrate, main stream or sub-stream, may vary. The actual bitrate which is used in computations is the average of all previously specified bitrate values. But if a bitrate suddenly varies from this average value by more than a given percentage, the average is reset to the new value. When the bitrate is reset that way, the insertion computation restarts.
The initial default threshold is DEFAULT_BITRATE_RESET_PERCENT.
| [in] | percent | New percentage threshold (0 to 100). |
|
inline |
Set a name for the main stream (only for debug messages).
| [in] | name | The new name to use. |
|
inline |
Set a name for the sub-stream (only for debug messages).
| [in] | name | The new name to use. |
|
staticconstexpr |
Default alert threshold for packets waiting from the sub-stream.
|
staticconstexpr |
Default reset threshold for bitrate variation (percentage).