StormByte C++ Library: Multimedia module 0.0.9999
StormByte-Multimedia is a StormByte library module for parsing configuration files
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
StormByte::Multimedia::FFmpeg::Swr Class Reference

RAII SwrContext for audio convert / resample. More...

#include <StormByte/multimedia/ffmpeg/Swr.hxx>

Inheritance diagram for StormByte::Multimedia::FFmpeg::Swr:
Inheritance graph
[legend]
Collaboration diagram for StormByte::Multimedia::FFmpeg::Swr:
Collaboration graph
[legend]

Public Member Functions

 Swr (Swr &&other) noexcept=default
 Move constructor.
 
 ~Swr () noexcept override
 Destructor.
 
Swroperator= (Swr &&other) noexcept=default
 Move assignment.
 
 operator bool () const noexcept
 Whether a resampler context is open.
 
bool Convert (const AVFrame &src, AVFrame &dst) const noexcept
 Converts src into dst (swr_convert_frame).
 
bool Drain (AVFrame &dst) const noexcept
 Flushes delayed samples into dst (swr_convert_frame with a null source).
 
std::int64_t Delay (std::int64_t base) const noexcept
 Buffered delay in units of 1/base seconds (swr_get_delay).
 
- Public Member Functions inherited from StormByte::Multimedia::FFmpeg::AVPointer<::SwrContext >
constexpr AVPointer () noexcept=delete
 Default constructor (deleted).
 
constexpr AVPointer (const AVPointer &) noexcept=delete
 Copy constructor (deleted).
 
constexpr AVPointer (AVPointer &&other) noexcept
 Move constructor.
 
virtual ~AVPointer () noexcept=default
 Destructor.
 
constexpr AVPointeroperator= (const AVPointer &) noexcept=delete
 Copy assignment (deleted).
 
constexpr AVPointeroperator= (AVPointer &&other) noexcept
 Move assignment.
 

Static Public Member Functions

static Swr Open (const AVChannelLayout &out_layout, int out_fmt, int out_rate, const AVChannelLayout &in_layout, int in_fmt, int in_rate) noexcept
 Opens a resampler.
 

Additional Inherited Members

- Protected Member Functions inherited from StormByte::Multimedia::FFmpeg::AVPointer<::SwrContext >
constexpr AVPointer (std::decay_t< ::SwrContext > *ptr) noexcept
 Adopts ptr.
 
constexpr const std::decay_t< ::SwrContext > * Get () const noexcept
 Const view of the raw FFmpeg pointer.
 
constexpr std::decay_t< ::SwrContext > * Get () noexcept
 Mutable view of the raw FFmpeg pointer.
 
constexpr std::decay_t< ::SwrContext > * Detach () noexcept
 Yields the raw pointer and leaves this wrapper empty.
 
- Protected Attributes inherited from StormByte::Multimedia::FFmpeg::AVPointer<::SwrContext >
std::decay_t< ::SwrContext > * m_ptr
 Owned FFmpeg pointer.
 

Detailed Description

RAII SwrContext for audio convert / resample.

Constructor & Destructor Documentation

◆ Swr()

StormByte::Multimedia::FFmpeg::Swr::Swr ( Swr &&  other)
defaultnoexcept

Move constructor.

Transfers the resampler.

Parameters
otherSource resampler; left empty.

◆ ~Swr()

StormByte::Multimedia::FFmpeg::Swr::~Swr ( )
overridenoexcept

Destructor.

Frees the SwrContext.

Member Function Documentation

◆ Convert()

bool StormByte::Multimedia::FFmpeg::Swr::Convert ( const AVFrame src,
AVFrame dst 
) const
noexcept

Converts src into dst (swr_convert_frame).

Parameters
srcSource frame.
dstDestination frame (geometry already set).
Returns
false on failure.

◆ Delay()

std::int64_t StormByte::Multimedia::FFmpeg::Swr::Delay ( std::int64_t  base) const
noexcept

Buffered delay in units of 1/base seconds (swr_get_delay).

Parameters
baseUnit. Pass the input sample rate to get samples.
Returns
Delay, or 0.

◆ Drain()

bool StormByte::Multimedia::FFmpeg::Swr::Drain ( AVFrame dst) const
noexcept

Flushes delayed samples into dst (swr_convert_frame with a null source).

Parameters
dstDestination frame (geometry already set).
Returns
false on failure.

◆ Open()

static Swr StormByte::Multimedia::FFmpeg::Swr::Open ( const AVChannelLayout out_layout,
int  out_fmt,
int  out_rate,
const AVChannelLayout in_layout,
int  in_fmt,
int  in_rate 
)
staticnoexcept

Opens a resampler.

Empty wrapper on failure.

Parameters
out_layoutDestination channel layout.
out_fmtDestination AVSampleFormat as int.
out_rateDestination sample rate in Hz.
in_layoutSource channel layout.
in_fmtSource AVSampleFormat as int.
in_rateSource sample rate in Hz.
Returns
Open resampler, or empty on failure.

◆ operator bool()

StormByte::Multimedia::FFmpeg::Swr::operator bool ( ) const
explicitnoexcept

Whether a resampler context is open.

Returns
true if Convert can run.

◆ operator=()

Swr & StormByte::Multimedia::FFmpeg::Swr::operator= ( Swr &&  other)
defaultnoexcept

Move assignment.

Frees *this, then takes other.

Parameters
otherSource resampler; left empty.
Returns
*this.

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