TSDuck v3.38-3691
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches
ts::TSPacketWindow Class Reference

A view over a window of a buffer of TS packets. More...

#include <tsTSPacketWindow.h>

Public Member Functions

 TSPacketWindow ()=default
 Constructor.
 
void addPacketsReference (TSPacket *packet, TSPacketMetadata *metadata, size_t count)
 Add the address of a range of packets and their metadata inside the window.
 
void clear ()
 Clear the content of the packet window.
 
void drop (size_t index)
 Drop the packet at the corresponding index.
 
size_t dropCount () const
 Get the number of dropped packets.
 
bool get (size_t index, TSPacket *&packet, TSPacketMetadata *&metadata) const
 Get the address of a packet and its metadata inside the window.
 
bool isNullPacket (size_t index) const
 Check if a packet inside the window is a null packet.
 
TSPacketMetadatametadata (size_t index) const
 Get the address of the metadata of a packet inside the window.
 
void nullify (size_t index)
 Nullify the packet at the corresponding index.
 
size_t nullifyCount () const
 Get the number of nullified packets.
 
TSPacketpacket (size_t index) const
 Get the address of a packet inside the window.
 
size_t packetIndexInBuffer (size_t index, const TSPacket *buffer, size_t buffer_size) const
 Get the physical index of a packet inside a buffer.
 
size_t segmentCount () const
 Get the number of contiguous segments of packets (informational only).
 
size_t size () const
 Get the number of packets in this window.
 

Detailed Description

A view over a window of a buffer of TS packets.

An instance of this class encapsulates a view over a logical buffer of TS packets. The logical view is a set of N packets with associated metadata. The physical implementation of the packets can be non-contiguous (scattered buffer).

The typical usage of this class is a logically contiguous view of a window over a circular buffer and/or a buffer with unused entries. This is the case of the TSProcessor global buffer.

Member Function Documentation

◆ addPacketsReference()

void ts::TSPacketWindow::addPacketsReference ( TSPacket packet,
TSPacketMetadata metadata,
size_t  count 
)

Add the address of a range of packets and their metadata inside the window.

Parameters
[in]packetThe address of the first packet.
[in]metadataThe address of the first corresponding packet metadata.
[in]countNumber of contiguous packets and metadata.

◆ size()

size_t ts::TSPacketWindow::size ( ) const
inline

Get the number of packets in this window.

Returns
The number of packets in this window.

◆ packet()

TSPacket * ts::TSPacketWindow::packet ( size_t  index) const

Get the address of a packet inside the window.

Parameters
[in]indexIndex of the packet inside the window, from 0 to size()-1.
Returns
The address of the corresponding packet. Return a null pointer if the index is out of range or if the packet was previously dropped.

◆ metadata()

TSPacketMetadata * ts::TSPacketWindow::metadata ( size_t  index) const

Get the address of the metadata of a packet inside the window.

Parameters
[in]indexIndex of the packet inside the window, from 0 to size()-1.
Returns
The address of the corresponding packet metadata. Return a null pointer if the index is out of range or if the packet was previously dropped.

◆ isNullPacket()

bool ts::TSPacketWindow::isNullPacket ( size_t  index) const

Check if a packet inside the window is a null packet.

Parameters
[in]indexIndex of the packet inside the window, from 0 to size()-1.
Returns
True if the corresponding packet is valid and a null packet, false otherwise.

◆ get()

bool ts::TSPacketWindow::get ( size_t  index,
TSPacket *&  packet,
TSPacketMetadata *&  metadata 
) const

Get the address of a packet and its metadata inside the window.

Parameters
[in]indexIndex of the packet inside the window, from 0 to size()-1.
[out]packetThe address of the corresponding packet.
[out]metadataThe address of the corresponding packet metadata.
Returns
True on success, false if the index is out of range or if the packet was previously dropped. In the latter case, packet and metadata are both null pointers.

◆ packetIndexInBuffer()

size_t ts::TSPacketWindow::packetIndexInBuffer ( size_t  index,
const TSPacket buffer,
size_t  buffer_size 
) const

Get the physical index of a packet inside a buffer.

Parameters
[in]indexIndex of the packet inside the window, from 0 to size()-1.
[in]bufferBase address of a packet buffer. The packet window must be a view over that buffer.
[in]buffer_sizeNumber of TS packets in the buffer.
Returns
The index of the packet in the buffer or NPOS if out of range.

◆ nullify()

void ts::TSPacketWindow::nullify ( size_t  index)

Nullify the packet at the corresponding index.

Parameters
[in]indexIndex of the packet inside the windows, from 0 to size()-1.

◆ drop()

void ts::TSPacketWindow::drop ( size_t  index)

Drop the packet at the corresponding index.

Internally, the sync byte of the packet in the buffer is zeroed and the packet is no longer usable.

Parameters
[in]indexIndex of the packet inside the windows, from 0 to size()-1.

◆ nullifyCount()

size_t ts::TSPacketWindow::nullifyCount ( ) const
inline

Get the number of nullified packets.

Returns
The number of nullified packets in this window. Packets which were already null before calling nullify() are not counted. Multiple calls to nullify() on the same packet are counted once only.

◆ dropCount()

size_t ts::TSPacketWindow::dropCount ( ) const
inline

Get the number of dropped packets.

Returns
The number of dropped packets in this window. Multiple calls to drop() on the same packet are counted once only.

◆ segmentCount()

size_t ts::TSPacketWindow::segmentCount ( ) const
inline

Get the number of contiguous segments of packets (informational only).

Returns
The number of contiguous segments of packets.

The documentation for this class was generated from the following file: