Show / Hide Table of Contents

Interface IChannelLayout

Defines a common interface for working with FFmpeg audio channel layouts.

Inherited Members
IEquatable<IChannelLayout>.Equals(IChannelLayout)
Namespace: FFmpeg.Audio
Assembly: FFmpeg.dll
Syntax
public interface IChannelLayout : IEquatable<IChannelLayout>
Remarks

Implementations expose the properties and operations required to inspect, compare, initialize, and manipulate audio channel layouts, regardless of whether they own the underlying layout or reference an existing one.

A custom channel layout stores an explicit channel map instead of using one of FFmpeg's predefined channel masks. Methods for accessing channel names and channel identifiers are only valid for custom channel layouts.

Properties

View Source

Channels

Gets the number of channels in the current channel layout.

Declaration
int Channels { get; }
Property Value
Type Description
int

The number of channels.

View Source

Valid

Indicates whether the current channel layout is valid.

Declaration
bool Valid { get; }
Property Value
Type Description
bool

true if the channel layout is valid; otherwise, false.

Methods

View Source

Copy()

Creates a copy of the current channel layout.

Declaration
ChannelLayout Copy()
Returns
Type Description
ChannelLayout

A new ChannelLayout containing a copy of the current layout.

View Source

GetCustomChannelId(int)

Gets the channel identifier assigned to a channel in a custom channel layout.

Declaration
AudioChannel GetCustomChannelId(int channelNumber)
Parameters
Type Name Description
int channelNumber

The zero-based index of the channel.

Returns
Type Description
AudioChannel

The channel identifier assigned to the specified channel.

Exceptions
Type Condition
InvalidOperationException

The channel layout is not a custom channel layout.

ArgumentOutOfRangeException

channelNumber is outside the valid channel range.

View Source

GetCustomChannelName(int)

Gets the UTF-8 name assigned to a channel in a custom channel layout.

Declaration
string GetCustomChannelName(int channelNumber)
Parameters
Type Name Description
int channelNumber

The zero-based index of the channel.

Returns
Type Description
string

The UTF-8 channel name.

Exceptions
Type Condition
InvalidOperationException

The channel layout is not a custom channel layout.

ArgumentOutOfRangeException

channelNumber is outside the valid channel range.

View Source

HasChannel(AudioChannel)

Determines whether the current channel layout contains the specified audio channel.

Declaration
bool HasChannel(AudioChannel channelId)
Parameters
Type Name Description
AudioChannel channelId

The channel identifier to search for.

Returns
Type Description
bool

true if the specified channel is present in the layout; otherwise, false.

Remarks

For custom channel layouts, this method searches the custom channel map. For native and ambisonic layouts, it checks whether the corresponding channel is present in the layout's channel mask.

View Source

Init(int)

Initializes the current channel layout as a custom layout with the specified number of channels.

Declaration
void Init(int nb)
Parameters
Type Name Description
int nb

The number of channels in the custom layout.

Exceptions
Type Condition
ArgumentException

nb is not a valid channel count.

OutOfMemoryException

FFmpeg could not allocate memory for the custom channel map.

View Source

SetCustomChannelId(int, AudioChannel)

Sets the channel identifier assigned to a channel in a custom channel layout.

Declaration
void SetCustomChannelId(int channelNumber, AudioChannel channel)
Parameters
Type Name Description
int channelNumber

The zero-based index of the channel.

AudioChannel channel

The channel identifier to assign.

Exceptions
Type Condition
InvalidOperationException

The channel layout is not a custom channel layout.

ArgumentOutOfRangeException

channelNumber is outside the valid channel range.

View Source

SetCustomChannelName(int, ReadOnlySpan<char>)

Sets the UTF-8 name assigned to a channel in a custom channel layout.

Declaration
void SetCustomChannelName(int channelNumber, ReadOnlySpan<char> name)
Parameters
Type Name Description
int channelNumber

The zero-based index of the channel.

ReadOnlySpan<char> name

The UTF-8 channel name. The encoded name must not exceed 16 bytes.

Exceptions
Type Condition
InvalidOperationException

The channel layout is not a custom channel layout.

ArgumentOutOfRangeException

channelNumber is outside the valid channel range.

ArgumentException

The UTF-8 encoded channel name exceeds the 16-byte storage limit.

  • View Source
In this article
Back to top Generated by DocFX