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

RAII wrapper for SwrContext. More...

#include <ffmpeg_swrcontext.h>

Public Member Functions

 FFmpeg_SwrContext ()
 Construct an empty resampler-context wrapper.
 
 FFmpeg_SwrContext (SwrContext *ctx)
 Construct a wrapper taking ownership of an existing context.
 
 ~FFmpeg_SwrContext ()
 Release the owned resampler context, if any.
 
 FFmpeg_SwrContext (const FFmpeg_SwrContext &)=delete
 
FFmpeg_SwrContextoperator= (const FFmpeg_SwrContext &)=delete
 
 FFmpeg_SwrContext (FFmpeg_SwrContext &&ctx) noexcept
 Move-construct a resampler-context wrapper.
 
FFmpeg_SwrContextoperator= (FFmpeg_SwrContext &&ctx) noexcept
 Move-assign a resampler-context wrapper.
 
SwrContext * get () const
 Get the owned FFmpeg resampler context pointer.
 
SwrContext ** address ()
 Get a writable pointer-to-pointer for FFmpeg allocation APIs.
 
SwrContext * release ()
 Release ownership without freeing the resampler context.
 
bool reset (SwrContext *ctx=nullptr)
 Replace the owned context.
 
bool empty () const
 Check whether the wrapper currently owns a resampler context.
 
 operator bool () const
 Check whether the wrapper owns a valid context.
 
 operator SwrContext * () const
 Convert to the underlying resampler context pointer.
 
SwrContext * operator-> () const
 Access members of the underlying resampler context.
 

Private Attributes

SwrContext * m_ctx
 Pointer to underlying SwrContext.
 

Detailed Description

RAII wrapper for SwrContext.

Owns a libswresample context and releases it with swr_free(). The wrapper is movable but not copyable.

Definition at line 28 of file ffmpeg_swrcontext.h.

Constructor & Destructor Documentation

◆ FFmpeg_SwrContext() [1/3]

FFmpeg_SwrContext::FFmpeg_SwrContext ( )

Construct an empty resampler-context wrapper.

Definition at line 16 of file ffmpeg_swrcontext.cc.

◆ FFmpeg_SwrContext() [2/3]

FFmpeg_SwrContext::FFmpeg_SwrContext ( SwrContext *  ctx)
explicit

Construct a wrapper taking ownership of an existing context.

Parameters
[in]ctxContext pointer to take ownership of, or nullptr.

Definition at line 21 of file ffmpeg_swrcontext.cc.

◆ ~FFmpeg_SwrContext()

FFmpeg_SwrContext::~FFmpeg_SwrContext ( )

Release the owned resampler context, if any.

Definition at line 26 of file ffmpeg_swrcontext.cc.

References reset().

◆ FFmpeg_SwrContext() [3/3]

FFmpeg_SwrContext::FFmpeg_SwrContext ( FFmpeg_SwrContext &&  ctx)
noexcept

Move-construct a resampler-context wrapper.

Parameters
[in,out]ctxSource wrapper whose context ownership is transferred.

Definition at line 31 of file ffmpeg_swrcontext.cc.

Member Function Documentation

◆ address()

SwrContext ** FFmpeg_SwrContext::address ( )

Get a writable pointer-to-pointer for FFmpeg allocation APIs.

Any currently owned context is freed first so that FFmpeg can write a new context pointer without leaking the previous one.

Returns
Address of the managed context pointer.

Definition at line 50 of file ffmpeg_swrcontext.cc.

References m_ctx, and reset().

Referenced by FFmpeg_Transcoder::init_resampler().

◆ empty()

bool FFmpeg_SwrContext::empty ( ) const

Check whether the wrapper currently owns a resampler context.

Returns
true if no context is owned, false otherwise.

Definition at line 78 of file ffmpeg_swrcontext.cc.

References m_ctx.

◆ get()

SwrContext * FFmpeg_SwrContext::get ( ) const

Get the owned FFmpeg resampler context pointer.

Returns
SwrContext pointer, or nullptr if empty.

Definition at line 45 of file ffmpeg_swrcontext.cc.

References m_ctx.

◆ operator bool()

FFmpeg_SwrContext::operator bool ( ) const
explicit

Check whether the wrapper owns a valid context.

Definition at line 83 of file ffmpeg_swrcontext.cc.

◆ operator SwrContext *()

FFmpeg_SwrContext::operator SwrContext * ( ) const

Convert to the underlying resampler context pointer.

Definition at line 88 of file ffmpeg_swrcontext.cc.

◆ operator->()

SwrContext * FFmpeg_SwrContext::operator-> ( ) const

Access members of the underlying resampler context.

Returns
SwrContext pointer.

Definition at line 93 of file ffmpeg_swrcontext.cc.

References m_ctx.

◆ operator=()

FFmpeg_SwrContext & FFmpeg_SwrContext::operator= ( FFmpeg_SwrContext &&  ctx)
noexcept

Move-assign a resampler-context wrapper.

Parameters
[in,out]ctxSource wrapper whose context ownership is transferred.
Returns
Reference to this wrapper.

Definition at line 36 of file ffmpeg_swrcontext.cc.

◆ release()

SwrContext * FFmpeg_SwrContext::release ( )

Release ownership without freeing the resampler context.

Returns
Previously owned SwrContext pointer, or nullptr if empty.

Definition at line 56 of file ffmpeg_swrcontext.cc.

References m_ctx.

◆ reset()

bool FFmpeg_SwrContext::reset ( SwrContext *  ctx = nullptr)

Replace the owned context.

Parameters
[in]ctxNew context pointer to own, or nullptr to only reset.
Returns
true if a previous context was freed, false otherwise.

Definition at line 63 of file ffmpeg_swrcontext.cc.

References m_ctx.

Referenced by address(), FFmpeg_Transcoder::close_resample(), FFmpeg_Transcoder::init_resampler(), and ~FFmpeg_SwrContext().

Member Data Documentation

◆ m_ctx

SwrContext* FFmpeg_SwrContext::m_ctx
private

Pointer to underlying SwrContext.

Definition at line 115 of file ffmpeg_swrcontext.h.

Referenced by address(), empty(), get(), operator->(), release(), and reset().


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