20#pragma GCC diagnostic push
21#pragma GCC diagnostic ignored "-Wconversion"
22#pragma GCC diagnostic ignored "-Wsign-conversion"
23#include <libavcodec/packet.h>
24#pragma GCC diagnostic pop
32 m_packet(av_packet_alloc()),
39 m_packet->stream_index = stream_index;
47 if (packet !=
nullptr)
54 m_res = AVERROR(EINVAL);
69 m_res = AVERROR(EINVAL);
74 m_packet(packet.m_packet),
77 packet.m_packet =
nullptr;
78 packet.m_res = AVERROR(EINVAL);
88 if (
this != &packet && m_packet != packet.m_packet)
90 AVPacket *new_packet =
nullptr;
91 int new_res = AVERROR(EINVAL);
93 if (packet.m_packet !=
nullptr)
95 new_packet = av_packet_clone(packet.m_packet);
96 new_res = (new_packet !=
nullptr) ? 0 : AVERROR(ENOMEM);
101 m_packet = new_packet;
114 m_packet = packet.m_packet;
115 m_res = packet.m_res;
117 packet.m_packet =
nullptr;
118 packet.m_res = AVERROR(EINVAL);
126 if (m_packet != packet)
128 AVPacket *new_packet =
nullptr;
129 int new_res = AVERROR(EINVAL);
131 if (packet !=
nullptr)
133 new_packet = av_packet_clone(packet);
134 new_res = (new_packet !=
nullptr) ? 0 : AVERROR(ENOMEM);
139 m_packet = new_packet;
183FFmpeg_Packet::operator AVPacket*()
188FFmpeg_Packet::operator
const AVPacket*()
const
RAII wrapper for AVPacket.
AVPacket * clone() const
Clone packet to a new AVPacket*. Caller owns the returned packet.
void unref()
Unreference packet payload, keep the AVPacket object allocated.
AVPacket * m_packet
Pointer to underlying AVPacket struct.
void free()
Free the underlying packet.
virtual ~FFmpeg_Packet()
Free the underlying packet.
AVPacket * operator->()
operator ->: behave like a packet pointer.
FFmpeg_Packet(int stream_index=INVALID_STREAM)
Allocate an empty packet.
int res() const
Get result of last operation.
int m_res
0 if last operation was successful, or negative AVERROR value
AVPacket * get()
Access the underlying packet.
FFmpeg_Packet & operator=(const FFmpeg_Packet &packet) noexcept
Deep-copy assign from another wrapper.
FFmpeg AVPacket RAII wrapper.