FFmpegfs Fuse Multi Media Filesystem 2.19
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
FFmpeg_Packet Class Reference

RAII wrapper for AVPacket. More...

#include <ffmpeg_packet.h>

Public Member Functions

 FFmpeg_Packet (int stream_index=INVALID_STREAM)
 Allocate an empty packet.
 
 FFmpeg_Packet (const AVPacket *packet)
 Clone an existing packet.
 
 FFmpeg_Packet (const FFmpeg_Packet &packet)
 Deep-copy construct from another wrapper.
 
 FFmpeg_Packet (FFmpeg_Packet &&packet) noexcept
 Move construct from another wrapper.
 
virtual ~FFmpeg_Packet ()
 Free the underlying packet.
 
FFmpeg_Packetoperator= (const FFmpeg_Packet &packet) noexcept
 Deep-copy assign from another wrapper.
 
FFmpeg_Packetoperator= (FFmpeg_Packet &&packet) noexcept
 Move assign from another wrapper.
 
FFmpeg_Packetoperator= (const AVPacket *packet) noexcept
 Deep-copy assign from an AVPacket.
 
int res () const
 Get result of last operation.
 
AVPacket * clone () const
 Clone packet to a new AVPacket*. Caller owns the returned packet.
 
void unref ()
 Unreference packet payload, keep the AVPacket object allocated.
 
void free ()
 Free the underlying packet.
 
AVPacket * get ()
 Access the underlying packet.
 
const AVPacket * get () const
 Access the underlying packet.
 
 operator AVPacket * ()
 operator AVPacket*: behave like a packet pointer for FFmpeg APIs.
 
 operator const AVPacket * () const
 operator const AVPacket*: behave like a const packet pointer for FFmpeg APIs.
 
AVPacket * operator-> ()
 operator ->: behave like a packet pointer.
 
const AVPacket * operator-> () const
 operator ->: behave like a const packet pointer.
 

Protected Attributes

AVPacket * m_packet
 Pointer to underlying AVPacket struct.
 
int m_res
 0 if last operation was successful, or negative AVERROR value
 

Detailed Description

RAII wrapper for AVPacket.

AVPacket must not be stack allocated anymore. Newer FFmpeg versions deprecated av_init_packet() and explicitly warn that sizeof(AVPacket) is no longer meant to be part of the public ABI. This wrapper always uses av_packet_alloc() and releases the packet with av_packet_free().

Definition at line 32 of file ffmpeg_packet.h.

Constructor & Destructor Documentation

◆ FFmpeg_Packet() [1/4]

FFmpeg_Packet::FFmpeg_Packet ( int  stream_index = INVALID_STREAM)
explicit

Allocate an empty packet.

Definition at line 31 of file ffmpeg_packet.cc.

References m_packet, and m_res.

◆ FFmpeg_Packet() [2/4]

FFmpeg_Packet::FFmpeg_Packet ( const AVPacket *  packet)

Clone an existing packet.

Definition at line 43 of file ffmpeg_packet.cc.

References m_packet, and m_res.

◆ FFmpeg_Packet() [3/4]

FFmpeg_Packet::FFmpeg_Packet ( const FFmpeg_Packet packet)

Deep-copy construct from another wrapper.

Definition at line 58 of file ffmpeg_packet.cc.

References m_packet, and m_res.

◆ FFmpeg_Packet() [4/4]

FFmpeg_Packet::FFmpeg_Packet ( FFmpeg_Packet &&  packet)
noexcept

Move construct from another wrapper.

Definition at line 73 of file ffmpeg_packet.cc.

◆ ~FFmpeg_Packet()

FFmpeg_Packet::~FFmpeg_Packet ( )
virtual

Free the underlying packet.

Definition at line 81 of file ffmpeg_packet.cc.

References free().

Member Function Documentation

◆ clone()

AVPacket * FFmpeg_Packet::clone ( ) const

Clone packet to a new AVPacket*. Caller owns the returned packet.

Definition at line 151 of file ffmpeg_packet.cc.

References m_packet.

◆ free()

void FFmpeg_Packet::free ( )

Free the underlying packet.

Definition at line 164 of file ffmpeg_packet.cc.

References m_packet.

Referenced by ~FFmpeg_Packet().

◆ get() [1/2]

AVPacket * FFmpeg_Packet::get ( )

Access the underlying packet.

Definition at line 173 of file ffmpeg_packet.cc.

References m_packet.

◆ get() [2/2]

const AVPacket * FFmpeg_Packet::get ( ) const

Access the underlying packet.

Definition at line 178 of file ffmpeg_packet.cc.

References m_packet.

◆ operator AVPacket *()

FFmpeg_Packet::operator AVPacket * ( )

operator AVPacket*: behave like a packet pointer for FFmpeg APIs.

Definition at line 183 of file ffmpeg_packet.cc.

◆ operator const AVPacket *()

FFmpeg_Packet::operator const AVPacket * ( ) const

operator const AVPacket*: behave like a const packet pointer for FFmpeg APIs.

Definition at line 188 of file ffmpeg_packet.cc.

◆ operator->() [1/2]

AVPacket * FFmpeg_Packet::operator-> ( )

operator ->: behave like a packet pointer.

Definition at line 193 of file ffmpeg_packet.cc.

References m_packet.

◆ operator->() [2/2]

const AVPacket * FFmpeg_Packet::operator-> ( ) const

operator ->: behave like a const packet pointer.

Definition at line 198 of file ffmpeg_packet.cc.

References m_packet.

◆ operator=() [1/3]

FFmpeg_Packet & FFmpeg_Packet::operator= ( const AVPacket *  packet)
noexcept

Deep-copy assign from an AVPacket.

Definition at line 124 of file ffmpeg_packet.cc.

◆ operator=() [2/3]

FFmpeg_Packet & FFmpeg_Packet::operator= ( const FFmpeg_Packet packet)
noexcept

Deep-copy assign from another wrapper.

Definition at line 86 of file ffmpeg_packet.cc.

◆ operator=() [3/3]

FFmpeg_Packet & FFmpeg_Packet::operator= ( FFmpeg_Packet &&  packet)
noexcept

Move assign from another wrapper.

Definition at line 108 of file ffmpeg_packet.cc.

◆ res()

int FFmpeg_Packet::res ( ) const

◆ unref()

void FFmpeg_Packet::unref ( )

Unreference packet payload, keep the AVPacket object allocated.

Definition at line 156 of file ffmpeg_packet.cc.

References m_packet.

Referenced by FFmpeg_Transcoder::encode_audio_frame(), FFmpeg_Transcoder::encode_image_frame(), FFmpeg_Transcoder::encode_subtitle(), and FFmpeg_Transcoder::encode_video_frame().

Member Data Documentation

◆ m_packet

AVPacket* FFmpeg_Packet::m_packet
protected

Pointer to underlying AVPacket struct.

Definition at line 113 of file ffmpeg_packet.h.

Referenced by clone(), FFmpeg_Packet(), FFmpeg_Packet(), FFmpeg_Packet(), free(), get(), get(), operator->(), operator->(), and unref().

◆ m_res

int FFmpeg_Packet::m_res
protected

0 if last operation was successful, or negative AVERROR value

Definition at line 114 of file ffmpeg_packet.h.

Referenced by FFmpeg_Packet(), FFmpeg_Packet(), FFmpeg_Packet(), and res().


The documentation for this class was generated from the following files: