avcpp 3.2.1
Wrapper for the FFmpeg that simplify usage from C++ projects.
Loading...
Searching...
No Matches
av::ChannelLayoutView Class Reference

Non-owning view of an AVChannelLayout. More...

#include <channellayout.h>

Inheritance diagram for av::ChannelLayoutView:

Public Member Functions

 ChannelLayoutView () noexcept
 Create an empty, invalid view.
 ChannelLayoutView (const AVChannelLayout &layout) noexcept
 Wrap an FFmpeg channel layout.
AVChannelLayout * raw ()
 The underlying FFmpeg layout, mutable.
const AVChannelLayout * raw () const
 The underlying FFmpeg layout, read-only.
int channels () const noexcept
 Number of channels in the layout.
uint64_t layout () const noexcept
 The layout as a bit mask when it can be expressed as one.
uint64_t subset (uint64_t mask) const noexcept
 Intersection of the layout with a mask.
bool isValid () const noexcept
 Whether the view refers to a usable layout.
std::string describe () const
 Text description of the layout.
void describe (std::string &desc) const
 Text description of the layout into an existing string.
int index (AVChannel channel) const
 Position of a speaker in the layout.
int index (const char *name) const
 Position of a speaker in the layout, by name.
AVChannel channel (unsigned int index) const
 Speaker at a position.
AVChannel channel (const char *name) const
 Speaker by name.
bool operator== (const ChannelLayoutView &other) const noexcept
 Compare two layouts.
ChannelLayout clone () const
 Deep copy of the layout.

Static Public Member Functions

template<typename Callable>
static void iterate (Callable callable)
 Iterate the standard layouts FFmpeg knows about.
static void dumpLayouts ()
 Print every standard layout through the FFmpeg log system.

Protected Attributes

AVChannelLayout m_layout {}
 The viewed layout; for the view it is a shallow copy of the descriptor.

Detailed Description

The view shares the descriptor with its owner, which is enough for every query FFmpeg offers. Use ChannelLayout when the layout has to outlive the FFmpeg structure it came from, or when it has to be built from a mask, a name or a channel count.

Constructor & Destructor Documentation

◆ ChannelLayoutView()

av::ChannelLayoutView::ChannelLayoutView ( const AVChannelLayout & layout)
noexcept

The conversion is implicit on purpose, so an AVChannelLayout can be passed where a view is expected.

Parameters
layoutthe layout to view; it must outlive the view

Member Function Documentation

◆ channel() [1/2]

AVChannel av::ChannelLayoutView::channel ( const char * name) const
Parameters
namethe channel name
Returns
the AV_CHAN_* value, or AV_CHAN_NONE when the layout does not contain it

◆ channel() [2/2]

AVChannel av::ChannelLayoutView::channel ( unsigned int index) const
Parameters
indexzero-based position
Returns
the AV_CHAN_* value, or AV_CHAN_NONE when the index is out of range

◆ channels()

int av::ChannelLayoutView::channels ( ) const
noexcept
Returns
the channel count, or zero for an invalid layout

◆ clone()

ChannelLayout av::ChannelLayoutView::clone ( ) const
Returns
an owning copy that can outlive this view

◆ describe() [1/2]

std::string av::ChannelLayoutView::describe ( ) const
Returns
a string such as "stereo" or "5.1"

◆ describe() [2/2]

void av::ChannelLayoutView::describe ( std::string & desc) const
Parameters
descthe string that receives the description

◆ index() [1/2]

int av::ChannelLayoutView::index ( AVChannel channel) const
Parameters
channelthe AV_CHAN_* value to look for
Returns
the zero-based index, or -1 when the channel is not present

◆ index() [2/2]

int av::ChannelLayoutView::index ( const char * name) const
Parameters
namethe channel name to look for
Returns
the zero-based index, or -1 when the channel is not present

◆ isValid()

bool av::ChannelLayoutView::isValid ( ) const
noexcept
Returns
true when the order or the mask is set

◆ iterate()

template<typename Callable>
void av::ChannelLayoutView::iterate ( Callable callable)
inlinestatic
Template Parameters
Callablecallable taking a ChannelLayoutView and returning true to stop the iteration
Parameters
callableinvoked once per standard layout

◆ layout()

uint64_t av::ChannelLayoutView::layout ( ) const
noexcept
Returns
the AV_CH_LAYOUT_* mask, or zero for a custom layout that has no mask representation

◆ operator==()

bool av::ChannelLayoutView::operator== ( const ChannelLayoutView & other) const
noexcept
Parameters
otherthe layout to compare with
Returns
true when both describe the same channels in the same order

◆ raw() [1/2]

AVChannelLayout * av::ChannelLayoutView::raw ( )
Returns
a pointer to the layout; valid while the owner lives

◆ raw() [2/2]

const AVChannelLayout * av::ChannelLayoutView::raw ( ) const
Returns
a pointer to the layout; valid while the owner lives

◆ subset()

uint64_t av::ChannelLayoutView::subset ( uint64_t mask) const
noexcept
Parameters
maskthe AV_CH_* bits to keep
Returns
the selected channels as a mask

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