15#if AVCPP_CXX_STANDARD >= 20
27#include <libavutil/attributes.h>
32#if AVCPP_HAS_PKT_SIDE_DATA
46 std::string_view
name() const noexcept;
52 AVPacketSideDataType
type() const noexcept;
87 operator
bool() const noexcept;
105#if AVCPP_API_AVCODEC_NEW_INIT_PACKET
113 void initFromAVPacket(
const AVPacket *avpacket,
bool deepCopy,
OptionalErrorCode ec);
126#if AVCPP_API_AVCODEC_NEW_INIT_PACKET
209#if AVCPP_CXX_STANDARD >= 20
216 explicit Packet(std::span<const uint8_t>
data,
bool doAllign =
true);
278#if AVCPP_CXX_STANDARD >= 20
293 std::span<const uint8_t>
span()
const;
450#if AVCPP_HAS_AVFORMAT
458 void dump(
const Stream & st,
bool dumpPayload =
false)
const;
474#if AVCPP_HAS_PKT_SIDE_DATA
482 std::span<const uint8_t>
sideData(AVPacketSideDataType type)
const;
490 std::span<uint8_t>
sideData(AVPacketSideDataType type);
566#if AVCPP_API_AVCODEC_NEW_INIT_PACKET
613#if AVCPP_API_AVCODEC_NEW_INIT_PACKET
FFmpeg version and API compatibility switches.
Error codes, error categories and the OptionalErrorCode convention.
Common helpers: comparisons, value lookup, non-copyable base, string utilities.
C-array (FFmpeg) wrapper witch can iterate over collection and represents any element via light-weigh...
Definition avutils.h:862
Carries the caller's choice between exceptions and error codes.
Definition averror.h:96
Simple view for the AVPacketSideData elements.
Definition packet.h:37
std::span< const uint8_t > span() const noexcept
Read-only view of the payload.
AVPacketSideDataType type() const noexcept
Identifier of the side data type.
std::string_view name() const noexcept
Name of the side data type, as FFmpeg spells it.
bool empty() const noexcept
Whether the entry carries no payload.
Timestamp ts() const
Timestamp FFmpeg would use for display, falling back to the decoding one.
const Rational & timeBase() const
Time base of pts() and dts().
Definition packet.h:466
Timestamp pts() const
Presentation timestamp.
std::span< const uint8_t > span() const
Read-only view of the payload.
Packet(uint8_t *data, size_t size, wrap_data_static, OptionalErrorCode ec=throws())
Wrap static data without taking ownership.
const uint8_t * data() const
Read access to the payload.
attribute_deprecated void setDts(int64_t dts, const Rational &tsTimeBase=Rational(0, 0))
Set the decoding timestamp.
Packet & operator=(const AVPacket *rhs)
Assign from an FFmpeg packet.
attribute_deprecated void setPts(int64_t pts, const Rational &tsTimeBase=Rational(0, 0))
Set the presentation timestamp.
int flags() const
Raw AV_PKT_FLAG_* mask.
void setKeyPacket(bool keyPacket)
Mark the packet as a key frame.
void setDts(const Timestamp &dts)
Set the decoding timestamp.
bool isComplete() const
Whether the packet is marked complete.
Timestamp dts() const
Decoding timestamp.
Packet & operator=(Packet &&rhs)
Move assignment.
void setComplete(bool complete)
Mark the packet as complete.
PacketSideData sideDataIndex(std::size_t index) noexcept
Get side data element by index.
Packet & operator=(const Packet &rhs)
Assign by referencing the other packet's payload.
void dump(const Stream &st, bool dumpPayload=false) const
Print the packet through the FFmpeg log system.
void setPts(const Timestamp &pts)
Set the presentation timestamp.
bool isNull() const
Whether the packet has no payload.
void freeSideData() noexcept
Remove and free all side data entries.
size_t size() const
Payload size.
int streamIndex() const
Index of the stream the packet belongs to.
std::span< uint8_t > sideData(AVPacketSideDataType type)
Mutable access to the side data of the given type.
std::span< const uint8_t > sideData(AVPacketSideDataType type) const
Read-only access to the side data of the given type.
Packet clone(OptionalErrorCode ec=throws()) const
Deep copy of the packet, payload included.
std::span< uint8_t > span()
Mutable view of the payload.
Packet(const uint8_t *data, size_t size, bool doAllign=true)
Copy a memory block into the packet payload.
Packet(const Packet &packet)
Copy a packet as a reference to the same data.
uint8_t * data()
Write access to the payload.
int refCount() const
Number of references to the payload.
AVPacket * makeRef(OptionalErrorCode ec) const
Create an independent reference to the packet.
Packet(Packet &&packet)
Move a packet.
Packet(std::span< uint8_t > data, wrap_data_static, OptionalErrorCode ec=throws())
Wrap static data from a span without taking ownership.
std::span< uint8_t > allocateSideData(AVPacketSideDataType type, std::size_t size, OptionalErrorCode ec=throws())
Allocate storage for the packet side data of the given type and return reference to it.
void addSideData(AVPacketSideDataType type, std::span< const uint8_t > data, OptionalErrorCode ec=throws())
Add side data of the given type into packet.
void setDuration(int duration, const Rational &durationTimeBase=Rational(0, 0))
Set the packet duration.
Packet(uint8_t *data, size_t size, wrap_data, OptionalErrorCode ec=throws())
Take ownership of a buffer allocated with the FFmpeg allocator.
void clearFlags(int flags)
Remove flags.
Packet()
Create an empty, valid packet with an allocated FFmpeg structure.
void addFlags(int flags)
Add flags.
bool isKeyPacket() const
Whether the packet is a key frame.
void setTimeBase(const Rational &value)
Set the time base used by pts() and dts().
std::size_t sideDataCount() const noexcept
Return count of the side data elements.
void setStreamIndex(int idx)
Set the stream index.
bool setData(const std::vector< uint8_t > &newData, OptionalErrorCode ec=throws())
Replace the payload with a copy of a byte vector.
int duration() const
Duration of the packet, in time base units.
bool isReferenced() const
Whether the payload is reference counted.
bool setData(std::span< const uint8_t > newData, OptionalErrorCode ec=throws())
Replace the payload with a copy of a span.
Packet(std::nullptr_t)
Create an empty packet without allocating.
Packet(const Packet &packet, OptionalErrorCode ec)
Copy a packet as a reference to the same data.
Packet(std::span< uint8_t > data, wrap_data, OptionalErrorCode ec=throws())
Take ownership of a span allocated with the FFmpeg allocator.
Packet(std::span< const uint8_t > data, bool doAllign=true)
Copy a span into the packet payload.
bool setData(const uint8_t *newData, size_t size, OptionalErrorCode ec=throws())
Replace the payload with a copy of a memory block.
void swap(Packet &other)
Exchange the contents of two packets.
void setFlags(int flags)
Replace the AV_PKT_FLAG_* mask.
Packet(const std::vector< uint8_t > &data)
Copy a byte vector into the packet payload.
Packet(const AVPacket *packet, OptionalErrorCode ec=throws())
Wrap an FFmpeg packet.
Rational number: a numerator and a denominator.
Definition rational.h:49
One stream inside a container.
Definition stream.h:34
The Timestamp class represents timestamp value and it timebase.
Definition timestamp.h:25
FFmpeg types re-exported for the public API and small value wrappers.
Root namespace of the library.
Definition audioresampler.h:19
OptionalErrorCode throws()
Helper to construct null OptionalErrorCode object.
Definition averror.h:310
Rational numbers, time bases and arithmetic on them.
Streams inside a container: parameters, time base and disposition.
Base for wrappers that hold a small FFmpeg structure by value.
Definition ffmpeg.h:189
Wrap static data, do not owning and free.
Definition packet.h:124
Wrap data and take owning.
Definition packet.h:119
Frame timestamps and their arithmetic.