![]() |
TSDuck v3.46-4964
MPEG Transport Stream Toolkit
|
#include <tsTimeShiftBuffer.h>


Public Member Functions | |
| TimeShiftBuffer (Report *report, size_t count=DEFAULT_TOTAL_PACKETS) | |
| TimeShiftBuffer (ReporterBase *delegate, size_t count=DEFAULT_TOTAL_PACKETS) | |
| virtual | ~TimeShiftBuffer () override |
| bool | close (bool silent=false) |
| size_t | count () const |
| bool | empty () const |
| bool | full () const |
| bool | isOpen () const |
| bool | memoryResident () const |
| bool | muteReport (bool mute) |
| bool | open () |
| virtual Report & | report () const override |
| bool | setBackupDirectory (const fs::path &directory) |
| bool | setMemoryPackets (size_t count) |
| Report * | setReport (Report *report) |
| ReporterBase * | setReport (ReporterBase *delegate) |
| bool | setTotalPackets (size_t count) |
| bool | shift (TSPacket &packet, TSPacketMetadata &metadata) |
| size_t | size () const |
Static Public Member Functions | |
| static int | SilentLevel (bool silent, int default_severity=Severity::Error) |
Static Public Attributes | |
| static constexpr size_t | DEFAULT_MEMORY_PACKETS = 128 |
| static constexpr size_t | DEFAULT_TOTAL_PACKETS = 128 |
| static constexpr size_t | MIN_MEMORY_PACKETS = 2 |
| static constexpr size_t | MIN_TOTAL_PACKETS = 2 |
A TS packet buffer for time shift. The buffer is partly implemented in virtual memory and partly on disk.
|
explicit |
Constructor.
| [in] | report | Where to report errors. The report object must remain valid as long as this object exists or setReport() is used with another Report object. If report is null, log messages are discarded. |
| [in] | count | Max number of packets in the buffer. |
|
explicit |
Constructor.
| [in] | delegate | Use the report of another ReporterBase. If delegate is null, log messages are discarded. |
| [in] | count | Max number of packets in the buffer. |
|
overridevirtual |
Destructor.
| bool ts::TimeShiftBuffer::setTotalPackets | ( | size_t | count | ) |
Set the total size of the time shift buffer in packets. Must be called before open().
| [in] | count | Max number of packets in the buffer. |
| bool ts::TimeShiftBuffer::setMemoryPackets | ( | size_t | count | ) |
Set the maximum number of cached packets to be held in memory. Must be called before open().
| [in] | count | Max number of cached packets in memory. |
| bool ts::TimeShiftBuffer::setBackupDirectory | ( | const fs::path & | directory | ) |
Set the directory for the backup file on disk. Must be called before open(). By default, the file is created in the system-dependent temporary directory. When the maximum number of cached packets in memory is larger than the buffer size, the buffer is entirely resident in memory and no file is created. The back file is automatically deleted when the time-shift buffer is closed.
| [in] | directory | Directory name. |
| bool ts::TimeShiftBuffer::open | ( | ) |
Open the buffer.
| bool ts::TimeShiftBuffer::close | ( | bool | silent = false | ) |
Close the buffer. The memory is freed and the disk backup file is deleted.
| [in] | silent | If true, do not report errors. This is typically useful when the object is in some error condition and closing it is necessary although it may generate additional meaningless errors. |
|
inline |
Check if the buffer is open.
|
inline |
Get the total size in packets of the time-shift buffer.
|
inline |
Get the current number of packets in the time-shift buffer.
|
inline |
Check if the buffer is empty.
|
inline |
Check if the buffer is full.
|
inline |
Check if the buffer is completely memory resident.
| bool ts::TimeShiftBuffer::shift | ( | TSPacket & | packet, |
| TSPacketMetadata & | metadata ) |
Push a packet in the time-shift buffer and pull the oldest one.
As long as the buffer is not full, a null packet is returned. When the buffer is full, the oldest packet is returned and removed from the buffer. Initial null packets which are generated while the time-shift buffer is filling can be recognized as they are marked as "input stuffing" in their metadata, after returning from shift().
| [in,out] | packet | On input, contains the packet to push. On output, contains the time-shifted packet. |
| [in,out] | metadata | Packet metadata. |
|
overridevirtualinherited |
Access the Report which is associated with this object. Can be called from another thread only if the Report object is thread-safe.
Implements ts::ReporterInterface.
Associate this object with another Report to log errors.
| [in] | report | Where to report errors. The report object must remain valid as long as this object exists or setReport() is used with another Report object. If report is null, log messages are discarded. |
|
inherited |
Associate this object with another ReporterBase to log errors.
| [in] | delegate | Use the report of another ReporterBase. If delegate is null, the previous explicit Report is used.. |
|
inherited |
Temporarily mute the associated report.
| [in] | mute | It true, report() will return a null report (log messages are discarded), until muteReport() is invoked again with mute set to false. |
|
inlinestaticinherited |
Compute a log severity level from a "silent" parameter. Some subclass methods have a "silent" parameter to avoid reporting errors which may be insignificant, typically when closing a device after an error, in which case the close operation may produce other errors if the previous error left the device in an inconsistent state. While those errors should not be displayed as errors, we still display them at debug level.
| [in] | silent | If true, do not report errors, report debug messages instead. |
| [in] | default_severity | Default severity, in non-silent mode (error by default). |
|
staticconstexpr |
Minimum size in packets of a time shift buffer.
|
staticconstexpr |
Default size in packets of a time shift buffer.
|
staticconstexpr |
Minimum number of cached packets in memory.
|
staticconstexpr |
Default number of cached packets in memory.