Template Struct Packets

Struct Documentation

template<MediaType media>
struct Packets

Media packets template forward declaration.

Compressed media packets with metadata.

Packets structure carries compressed packets from demuxer to decoder, along with codec information and timing metadata. Similar to Frames, AVPacket pointers are managed for bulk resource release.

Template Parameters:

media – Media type (Audio, Video, or Image).

Public Functions

Packets() = default

Default constructor.

Packets(const std::string &src, int index, Codec<media> &&codec, const std::optional<TimeWindow> &timestamp = {})

Construct packets from demuxer for one-time decoding.

Includes codec information needed to initialize the decoder.

Parameters:
  • src – Source URI.

  • index – Stream index.

  • codecCodec information.

  • timestamp – Optional time window user specified.

Packets(const std::string &src, int index, const Rational &time_base, const std::optional<TimeWindow> &timestamp = {})

Construct packets from demuxer for streaming.

Decoder is initialized separately, so codec is not needed here.

Parameters:
  • src – Source URI.

  • index – Stream index.

  • time_base – Time base for timestamps.

  • timestamp – Optional time window user specified.

Packets(uintptr_t id, int stream_index, Rational time_base)

Construct packets from encoder for muxing.

Parameters:
  • id – Trace ID.

  • stream_index – Output stream index.

  • time_base – Time base for timestamps.

explicit Packets(const Packets<media>&)

Copy constructor.

Packets<media> &operator=(const Packets<media>&)

Copy assignment operator.

Packets(Packets<media>&&) noexcept

Move constructor.

Packets<media> &operator=(Packets<media>&&) noexcept

Move assignment operator.

~Packets() = default

Destructor.

Public Members

uintptr_t id = {}

Trace ID for debugging.

std::string src

Source URI or identifier.

int stream_index

Stream index in the source.

PacketSeries pkts

Series of compressed packets.

Rational time_base = {}

Time base for packet timestamps.

std::optional<TimeWindow> timestamp

Optional time window specified by user.

std::optional<Codec<media>> codec

Codec information for decoding. Available when packets are demuxed by demux_window method. For streaming demuxing, codec must be fetched from demuxer directly.