![]() |
TSDuck v3.43-4480
MPEG Transport Stream Toolkit
|
Read/write TS packets on a stream. More...
#include <tsTSPacketStream.h>

Public Member Functions | |
| TSPacketStream (TSPacketFormat format=TSPacketFormat::AUTODETECT, AbstractReadStreamInterface *reader=nullptr, AbstractWriteStreamInterface *writer=nullptr) | |
| Constructor. | |
| virtual | ~TSPacketStream () |
| Destructor. | |
| TSPacketFormat | packetFormat () const |
| Get the file format. | |
| UString | packetFormatString () const |
| Get the file format as a string. | |
| size_t | packetHeaderSize () const |
| Get the packet header size, based on the packet format. | |
| size_t | packetTrailerSize () const |
| Get the packet trailer size, based on the packet format. | |
| virtual size_t | readPackets (TSPacket *buffer, TSPacketMetadata *metadata, size_t max_packets, Report &report) |
| Read TS packets from the stream. | |
| PacketCounter | readPacketsCount () const |
| Get the number of read packets. | |
| virtual bool | writePackets (const TSPacket *buffer, const TSPacketMetadata *metadata, size_t packet_count, Report &report) |
| Write TS packets to the stream. | |
| PacketCounter | writePacketsCount () const |
| Get the number of written packets. | |
Static Public Attributes | |
| static constexpr size_t | MAX_HEADER_SIZE = ts::TSPacketMetadata::SERIALIZATION_SIZE |
| Maximum size in bytes of a packet header for non-TS format. | |
| static constexpr size_t | MAX_TRAILER_SIZE = ts::RS_SIZE |
| Maximum size in bytes of a packet trailer for non-TS format. | |
Protected Member Functions | |
| void | resetPacketStream (TSPacketFormat format, AbstractReadStreamInterface *reader, AbstractWriteStreamInterface *writer) |
| Reset the stream format and counters. | |
Protected Attributes | |
| PacketCounter | _total_read = 0 |
| Total read packets. | |
| PacketCounter | _total_write = 0 |
| Total written packets. | |
Read/write TS packets on a stream.
| ts::TSPacketStream::TSPacketStream | ( | TSPacketFormat | format = TSPacketFormat::AUTODETECT, |
| AbstractReadStreamInterface * | reader = nullptr, |
||
| AbstractWriteStreamInterface * | writer = nullptr |
||
| ) |
Constructor.
| [in] | format | Initial packet format. |
| [in] | reader | Reader interface. If null, all read operations will fail. |
| [in] | writer | Writer interface. If null, all write operations will fail. |
|
virtual |
Read TS packets from the stream.
| [out] | buffer | Address of reception packet buffer. |
| [out] | metadata | Optional packet metadata. If the file format provides time stamps, they are set in the metadata. Ignored if null pointer. |
| [in] | max_packets | Size of buffer in packets. Also size of metadata in number of objects (when specified). |
| [in,out] | report | Where to report errors. |
Reimplemented in ts::TSFile.
|
virtual |
Write TS packets to the stream.
| [in] | buffer | Address of first packet to write. |
| [in] | metadata | Optional packet metadata containing time stamps. If the file format requires time stamps, metadata must not be a null pointer and all packets must have a time stamp. Otherwise, the last written timestamp is repeated. |
| [in] | packet_count | Number of packets to write. Also size of metadata in number of objects (when specified). |
| [in,out] | report | Where to report errors. |
|
inline |
Get the number of read packets.
|
inline |
Get the number of written packets.
| size_t ts::TSPacketStream::packetHeaderSize | ( | ) | const |
Get the packet header size, based on the packet format.
This "header" comes before the classical 188-byte TS packet.
| size_t ts::TSPacketStream::packetTrailerSize | ( | ) | const |
Get the packet trailer size, based on the packet format.
This "trailer" comes after the classical 188-byte TS packet.
|
inline |
Get the file format.
|
inline |
Get the file format as a string.
|
protected |
Reset the stream format and counters.
| [in] | format | Initial packet format. |
| [in] | reader | Reader interface. If null, all read operations will fail. |
| [in] | writer | Writer interface. If null, all write operations will fail. |
|
staticconstexpr |
Maximum size in bytes of a packet header for non-TS format.
Must be lower than the TS packet size to allow auto-detection on read.
|
staticconstexpr |
Maximum size in bytes of a packet trailer for non-TS format.
Must be lower than the TS packet size to allow auto-detection on read.