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

#include <tsTSPacketWindow.h>

Public Member Functions

 TSPacketWindow ()=default
void addPacketsReference (TSPacket *packet, TSPacketMetadata *metadata, size_t count)
void clear ()
void drop (size_t index)
size_t dropCount () const
bool get (size_t index, TSPacket *&packet, TSPacketMetadata *&metadata) const
bool isNullPacket (size_t index) const
TSPacketMetadata * metadata (size_t index) const
void nullify (size_t index)
size_t nullifyCount () const
TSPacket * packet (size_t index) const
size_t packetIndexInBuffer (size_t index, const TSPacket *buffer, size_t buffer_size) const
size_t segmentCount () const
size_t size () const

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.

Constructor & Destructor Documentation

◆ TSPacketWindow()

ts::TSPacketWindow::TSPacketWindow ( )
default

Constructor.

Member Function Documentation

◆ clear()

void ts::TSPacketWindow::clear ( )

Clear the content of the packet window.

◆ 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: