StormByte-Multimedia 3.3.2
C++26 multimedia processing module of the StormByte suite
Loading...
Searching...
No Matches
StormByte::Multimedia::Pipeline::Packet Class Reference

One compressed access unit. More...

#include <StormByte/multimedia/pipeline/packet.hxx>

Inheritance diagram for StormByte::Multimedia::Pipeline::Packet:
Collaboration diagram for StormByte::Multimedia::Pipeline::Packet:

Public Types

using PointerType = StormByte::Safe::Shared<Packet>
 Base-heap shared owner of a packet; keep its providers loaded.

Public Member Functions

Construction
 Packet ()
 Empty packet (no payload, track -1, type Unknown).
 Packet (int track, enum Type type, enum Producer producer, StormByte::Buffer::FIFO payload, StormByte::Safe::Optional< Property::Duration > pts, StormByte::Safe::Optional< Property::Duration > dts, StormByte::Safe::Optional< Property::Duration > duration, bool key_frame, StormByte::Safe::Vector< SideData > attachments, const StormByte::Multimedia::Codec *codec, std::uint64_t serial, std::uint64_t part)
 Builds a packet.
 Packet (const Packet &other)
 Copy.
 Packet (Packet &&other) noexcept
 Move constructor.
 ~Packet () noexcept override
 Destructor.
Packet & operator= (const Packet &other)
 Copy assignment.
Packet & operator= (Packet &&other) noexcept
 Move assignment.
Timing
const StormByte::Safe::Optional< Property::Duration > & Pts () const noexcept
 Presentation timestamp on the stream clock.
const StormByte::Safe::Optional< Property::Duration > & Dts () const noexcept
 Decode timestamp on the stream clock.
const StormByte::Safe::Optional< Property::Duration > & Duration () const noexcept
 Packet duration on the stream clock.
bool KeyFrame () const noexcept
 Whether this is a key frame / key packet.
Lineage
const StormByte::Safe::Optional< std::uint64_t > & Serial () const noexcept
 Monotonic lineage id assigned when the unit enters the pipe.
std::uint64_t Part () const noexcept
 Sub-id inside Serial when one demuxed unit yields several frames.
Codec
const StormByte::Multimedia::Codec * Codec () const noexcept
 Registry codec of this access unit.
Payload
const StormByte::Buffer::FIFO & Payload () const noexcept
 Owned compressed payload.
StormByte::Buffer::FIFO & Payload () noexcept
 Owned compressed payload (mutable).
StormByte::ByteSize BufferingWeight () const noexcept
 Estimates the compressed payload weight for queue accounting.
const StormByte::Safe::Vector< SideData > & Attachments () const noexcept
 Side-data blobs bound to this access unit.
StormByte::Safe::Vector< SideData > & Attachments () noexcept
 Side-data blobs bound to this access unit (mutable).
Public Member Functions inherited from StormByte::Multimedia::Pipeline::Item
Kind Kind () const noexcept
 Whether this unit is a frame or a packet.
enum StormByte::Multimedia::Type Type () const noexcept
 Media of this access unit.
int Track () const noexcept
 Origin track index.
enum Producer Producer () const noexcept
 Stage that created this unit.
virtual ~Item () noexcept=default
 Destructor.

Friends

class Backend::Pipeline::Packet
 Allows the backend holder to access the packet's media storage.
class Decoder
 Allows the decoder to access the compressed backend packet.
class Demuxer
 Allows the demuxer to populate compressed media and metadata.
class Encoder
 Allows the encoder to populate encoded media and metadata.
class Filter::FFmpeg
 Allows FFmpeg filters to update compressed media and metadata.
class Muxer
 Allows the muxer to access the compressed backend packet.
class Remuxer

Additional Inherited Members

Protected Types inherited from StormByte::Safe::Clonable< Item >
typedef SmartPointer PointerType
 Item (const Item &other) noexcept=default
 Copy constructor.
 Item (Item &&other) noexcept=default
 Move constructor.
Item & operator= (const Item &other) noexcept=default
 Copy assignment.
Item & operator= (Item &&other) noexcept=default
 Move assignment.
Protected Member Functions inherited from StormByte::Safe::Clonable< Item >
constexpr Clonable ()=default
constexpr Clonable & operator= (const Clonable &)=default
virtual constexpr ~Clonable () noexcept=default
Static Protected Member Functions inherited from StormByte::Safe::Clonable< Item >
static PointerType MakePointer (Args &&... args)

Detailed Description

One compressed access unit.

Compressed bytes for one picture, audio block or subtitle event. Packet filters, Remuxer and Muxer can inspect the origin track, timestamps, payload, side data and the Registry StormByte::Multimedia::Codec of that AU. The Packet does not open a codec.

Copies and Clone share media buffers rather than duplicating compressed bytes. Metadata accessors borrow their wrappers until this packet is modified or destroyed. Safe optional arrow access returns a read-only snapshot for the current full expression. Mutable collection access uses write-back proxies.

See also
Item
Frame

Member Typedef Documentation

◆ PointerType

Base-heap shared owner of a packet; keep its providers loaded.

Constructor & Destructor Documentation

◆ Packet() [1/4]

Empty packet (no payload, track -1, type Unknown).

Exceptions
StormByte::ExceptionIf safe metadata storage cannot be allocated.

◆ Packet() [2/4]

StormByte::Multimedia::Pipeline::Packet::Packet ( int track,
enum Type type,
enum Producer producer,
StormByte::Buffer::FIFO payload,
StormByte::Safe::Optional< Property::Duration > pts,
StormByte::Safe::Optional< Property::Duration > dts,
StormByte::Safe::Optional< Property::Duration > duration,
bool key_frame,
StormByte::Safe::Vector< SideData > attachments,
const StormByte::Multimedia::Codec * codec,
std::uint64_t serial,
std::uint64_t part )

Builds a packet.

Parameters
trackOrigin container stream index.
typeMedia of this access unit.
producerStep that created this unit.
payloadOwned compressed bytes.
ptsPresentation timestamp, if known.
dtsDecode timestamp, if known.
durationPacket duration, if known.
key_frameWhether this is a key frame.
attachmentsSide-data blobs that must reach the muxer.
codecRegistry codec of this AU, or nullptr.
serialLineage id born at the demuxer for this origin track.
partSub-id inside serial. Zero when the demuxed unit did not split.

Encoder stamps the destination codec. Demuxer stamps the source stream codec. There is no public setter.

Exceptions
StormByte::ExceptionIf safe lineage storage cannot be allocated.

◆ Packet() [3/4]

Copy.

Metadata and FIFO handle are copied; the libav packet is referenced (av_packet_ref).

Parameters
otherSource packet.

Not a deep copy of compressed bytes. Clone uses this constructor.

Exceptions
StormByte::ExceptionIf safe metadata storage cannot be copied.
std::bad_allocIf the private backend holder cannot be allocated.

◆ Packet() [4/4]

Move constructor.

Parameters
otherPacket to take.

other becomes the empty sentinel.

◆ ~Packet()

StormByte::Multimedia::Pipeline::Packet::~Packet ( )
overridenoexcept

Destructor.

Member Function Documentation

◆ Attachments() [1/2]

const StormByte::Safe::Vector< SideData > & StormByte::Multimedia::Pipeline::Packet::Attachments ( ) const
inlinenoexcept

Side-data blobs bound to this access unit.

Returns
Blobs (HdrPlus, captions, …). Empty when none.

◆ Attachments() [2/2]

StormByte::Safe::Vector< SideData > & StormByte::Multimedia::Pipeline::Packet::Attachments ( )
inlinenoexcept

Side-data blobs bound to this access unit (mutable).

Returns
Blobs.

◆ BufferingWeight()

StormByte::ByteSize StormByte::Multimedia::Pipeline::Packet::BufferingWeight ( ) const
noexcept

Estimates the compressed payload weight for queue accounting.

Returns
The larger of the facade and FFmpeg packet payload sizes.

This is a logical estimate, not RSS or uniquely-owned physical memory. Packet copies may share the same payload.

◆ Codec()

const StormByte::Multimedia::Codec * StormByte::Multimedia::Pipeline::Packet::Codec ( ) const
inlinenoexcept

Registry codec of this access unit.

Returns
Borrowed pointer owned by Registry, or nullptr on the sentinel.
Note
The owning Registry and its provider must outlive this packet and its copies.

◆ Dts()

const StormByte::Safe::Optional< Property::Duration > & StormByte::Multimedia::Pipeline::Packet::Dts ( ) const
inlinenoexcept

Decode timestamp on the stream clock.

Returns
Dts, or empty.

◆ Duration()

const StormByte::Safe::Optional< Property::Duration > & StormByte::Multimedia::Pipeline::Packet::Duration ( ) const
inlinenoexcept

Packet duration on the stream clock.

Returns
Duration, or empty.

◆ KeyFrame()

bool StormByte::Multimedia::Pipeline::Packet::KeyFrame ( ) const
inlinenoexcept

Whether this is a key frame / key packet.

Returns
true if marked as a key frame.

◆ operator=() [1/2]

Packet & StormByte::Multimedia::Pipeline::Packet::operator= ( const Packet & other)

Copy assignment.

Same as the copy constructor.

Parameters
otherSource packet.
Returns
*this.
Note
The destination is unchanged if copying fails.
Exceptions
StormByte::ExceptionIf safe metadata storage cannot be copied.
std::bad_allocIf the private backend holder cannot be allocated.

◆ operator=() [2/2]

Packet & StormByte::Multimedia::Pipeline::Packet::operator= ( Packet && other)
noexcept

Move assignment.

Parameters
otherPacket to take.
Returns
*this.

other becomes the empty sentinel.

◆ Part()

std::uint64_t StormByte::Multimedia::Pipeline::Packet::Part ( ) const
inlinenoexcept

Sub-id inside Serial when one demuxed unit yields several frames.

Returns
Zero when the unit did not split; 0, 1, … after a split.

Downstream stages copy this value. It is not a pipe-wide counter.

◆ Payload() [1/2]

const StormByte::Buffer::FIFO & StormByte::Multimedia::Pipeline::Packet::Payload ( ) const
inlinenoexcept

Owned compressed payload.

Returns
FIFO (not thread-safe).

◆ Payload() [2/2]

StormByte::Buffer::FIFO & StormByte::Multimedia::Pipeline::Packet::Payload ( )
inlinenoexcept

Owned compressed payload (mutable).

Returns
FIFO (not thread-safe).

◆ Pts()

const StormByte::Safe::Optional< Property::Duration > & StormByte::Multimedia::Pipeline::Packet::Pts ( ) const
inlinenoexcept

Presentation timestamp on the stream clock.

Returns
Pts, or empty.

◆ Serial()

const StormByte::Safe::Optional< std::uint64_t > & StormByte::Multimedia::Pipeline::Packet::Serial ( ) const
inlinenoexcept

Monotonic lineage id assigned when the unit enters the pipe.

Returns
Serial born at the demuxer for this origin track; empty on the sentinel.

This is not a decoded-frame count and not an FFmpeg nb_frames / nb_read_frames figure. It identifies one demuxed access unit as it travels Demuxer → … → Muxer. Downstream stages copy it. Part distinguishes several frames born from the same serial.

◆ Backend::Pipeline::Packet

friend class Backend::Pipeline::Packet
friend

Allows the backend holder to access the packet's media storage.

◆ Decoder

friend class Decoder
friend

Allows the decoder to access the compressed backend packet.

◆ Demuxer

friend class Demuxer
friend

Allows the demuxer to populate compressed media and metadata.

◆ Encoder

friend class Encoder
friend

Allows the encoder to populate encoded media and metadata.

◆ Filter::FFmpeg

friend class Filter::FFmpeg
friend

Allows FFmpeg filters to update compressed media and metadata.

◆ Muxer

friend class Muxer
friend

Allows the muxer to access the compressed backend packet.

◆ Remuxer

friend class Remuxer
friend

The documentation for this class was generated from the following file:
  • lib/public/StormByte/multimedia/pipeline/packet.hxx