Struct ChannelLayout_ref
Represents a reference to an FFmpeg FFmpeg.AutoGen._AVChannelLayout structure.
Implements
Inherited Members
Namespace: FFmpeg.Audio
Assembly: FFmpeg.dll
Syntax
public readonly struct ChannelLayout_ref : IChannelLayout, IEquatable<IChannelLayout>, IEquatable<ChannelLayout_ref>, IEquatable<ChannelLayout>, IReference<ChannelLayout>
Remarks
This struct provides a read-only or read-write reference to an FFmpeg channel layout. It implements IChannelLayout for accessing channel layout properties and supports copying and comparison operations.
Properties
View SourceChannels
Gets the number of channels in the layout.
Declaration
public int Channels { get; }
Property Value
| Type | Description |
|---|---|
| int | The number of channels. |
IsReadOnly
Indicates whether this instance is read-only.
Declaration
public bool IsReadOnly { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Valid
Determines whether the current ChannelLayout_ref instance is valid.
Declaration
public bool Valid { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Methods
View SourceCopy()
Creates a deep copy of the referenced channel layout.
Declaration
public ChannelLayout Copy()
Returns
| Type | Description |
|---|---|
| ChannelLayout | A new ChannelLayout containing a copy of the referenced channel layout. |
Remarks
The returned ChannelLayout owns its copied layout independently of this reference.
CopyFrom(ChannelLayout)
Copies the layout from a ChannelLayout instance into the current ChannelLayout_ref instance.
Declaration
public void CopyFrom(ChannelLayout layout)
Parameters
| Type | Name | Description |
|---|---|---|
| ChannelLayout | layout | The ChannelLayout instance to copy from. |
Remarks
This method replaces the layout of the current instance with the layout from the specified ChannelLayout instance, provided the current instance is not read-only.
Exceptions
| Type | Condition |
|---|---|
| NotSupportedException | Thrown if the current instance is read-only. |
| Exception | Thrown if an error occurs during copying. |
CopyFrom(ChannelLayout_ref)
Copies the layout from another ChannelLayout_ref instance into the current instance.
Declaration
public void CopyFrom(ChannelLayout_ref layout)
Parameters
| Type | Name | Description |
|---|---|---|
| ChannelLayout_ref | layout | The ChannelLayout_ref instance to copy from. |
Remarks
This method replaces the layout of the current instance with the layout from the specified ChannelLayout_ref instance, provided the current instance is not read-only.
Exceptions
| Type | Condition |
|---|---|
| NotSupportedException | Thrown if the current instance is read-only. |
| Exception | Thrown if an error occurs during copying. |
Equals(ChannelLayout?)
Determines whether the current instance is equal to another ChannelLayout instance.
Declaration
public bool Equals(ChannelLayout? other)
Parameters
| Type | Name | Description |
|---|---|---|
| ChannelLayout | other | The ChannelLayout instance to compare with the current instance. |
Returns
| Type | Description |
|---|---|
| bool | true if the current instance is equal to the specified ChannelLayout instance; otherwise, false. |
Remarks
This method uses FFmpeg.AutoGen.ffmpeg.av_channel_layout_compare(FFmpeg.AutoGen._AVChannelLayout*, FFmpeg.AutoGen._AVChannelLayout*) to compare the layout of the current instance with the layout of the specified ChannelLayout instance.
Equals(ChannelLayout_ref)
Determines whether the current instance is equal to another ChannelLayout_ref instance.
Declaration
public bool Equals(ChannelLayout_ref other)
Parameters
| Type | Name | Description |
|---|---|---|
| ChannelLayout_ref | other | The ChannelLayout_ref instance to compare with the current instance. |
Returns
| Type | Description |
|---|---|
| bool | true if the current instance is equal to the specified ChannelLayout_ref instance; otherwise, false. |
Remarks
This method uses FFmpeg.AutoGen.ffmpeg.av_channel_layout_compare(FFmpeg.AutoGen._AVChannelLayout*, FFmpeg.AutoGen._AVChannelLayout*) to compare the layout of the current instance with the layout of the specified ChannelLayout_ref instance.
Equals(IChannelLayout?)
Determines whether the current instance is equal to another IChannelLayout instance.
Declaration
public bool Equals(IChannelLayout? other)
Parameters
| Type | Name | Description |
|---|---|---|
| IChannelLayout | other | The IChannelLayout instance to compare with the current instance. |
Returns
| Type | Description |
|---|---|
| bool | true if the current instance is equal to the specified IChannelLayout instance; otherwise, false. |
Remarks
This method uses FFmpeg.AutoGen.ffmpeg.av_channel_layout_compare(FFmpeg.AutoGen._AVChannelLayout*, FFmpeg.AutoGen._AVChannelLayout*) to compare the layout of the current instance with the layout of the specified IChannelLayout.
Equals(object?)
Determines whether the current instance is equal to another object.
Declaration
public override bool Equals(object? obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj | The object to compare with the current instance. |
Returns
| Type | Description |
|---|---|
| bool | true if the current instance is equal to the specified object; otherwise, false. |
Overrides
Remarks
This method checks if the given obj is of type ChannelLayout_ref or ChannelLayout or IChannelLayout
and uses the appropriate equality comparison method based on the type.
GetCustomChannelId(int)
Gets the channel identifier assigned to a channel in a custom channel layout.
Declaration
public 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 |
|
GetCustomChannelName(int)
Gets the UTF-8 name assigned to a channel in a custom channel layout.
Declaration
public 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. |
Remarks
Custom channel names are stored in a fixed-size 16-byte UTF-8 buffer.
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | The channel layout is not a custom channel layout. |
| ArgumentOutOfRangeException |
|
GetHashCode()
Returns the hash code for the current instance.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int | An int that represents the hash code for the current instance. |
Overrides
Remarks
The hash code is computed based on the number of channels in the channel layout.
GetReferencedObject()
Retrieves a copy of the referenced channel layout.
Declaration
public ChannelLayout GetReferencedObject()
Returns
| Type | Description |
|---|---|
| ChannelLayout | A new ChannelLayout containing a copy of the referenced layout. |
Remarks
The returned ChannelLayout is independent of the referenced layout. Modifying either instance does not affect the other.
Exceptions
| Type | Condition |
|---|---|
| OutOfMemoryException | FFmpeg could not allocate memory while copying the channel layout. |
HasChannel(AudioChannel)
Determines whether the current channel layout contains the specified audio channel.
Declaration
public 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 bit is set in the layout's channel mask.
Init(int)
Initializes the current channel layout as a custom layout with the specified number of channels.
Declaration
public void Init(int nb)
Parameters
| Type | Name | Description |
|---|---|---|
| int | nb | The number of channels in the custom layout. |
Remarks
This method initializes the referenced channel layout as a custom layout by calling av_channel_layout_custom_init(_AVChannelLayout*, int). Any previous layout is released before the new layout is created.
Exceptions
| Type | Condition |
|---|---|
| NotSupportedException | The current instance is read-only. |
| OutOfMemoryException | FFmpeg could not allocate memory for the custom channel map. |
| ArgumentException |
|
SetCustomChannelId(int, AudioChannel)
Sets the channel identifier assigned to a channel in a custom channel layout.
Declaration
public 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 |
|---|---|
| NotSupportedException | The current instance is read-only. |
| InvalidOperationException | The channel layout is not a custom channel layout. |
| ArgumentOutOfRangeException |
|
SetCustomChannelName(int, ReadOnlySpan<char>)
Sets the UTF-8 name assigned to a channel in a custom channel layout.
Declaration
public 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. |
Remarks
Any unused bytes in the fixed-size channel name buffer are cleared.
Exceptions
| Type | Condition |
|---|---|
| NotSupportedException | The current instance is read-only. |
| InvalidOperationException | The channel layout is not a custom channel layout. |
| ArgumentOutOfRangeException |
|
| ArgumentException | The UTF-8 encoded channel name exceeds the 16-byte storage limit. |
SetReferencedObject(ChannelLayout?)
Sets the referenced channel layout.
Declaration
public void SetReferencedObject(ChannelLayout? obj)
Parameters
| Type | Name | Description |
|---|---|---|
| ChannelLayout | obj | The channel layout to copy into the referenced layout, or null to uninitialize the current layout. |
Remarks
If obj is null, the referenced layout
is uninitialized using FFmpeg.AutoGen.ffmpeg.av_channel_layout_uninit(FFmpeg.AutoGen._AVChannelLayout*).
Otherwise, the layout is replaced with a copy of
obj using
FFmpeg.AutoGen.ffmpeg.av_channel_layout_copy(FFmpeg.AutoGen._AVChannelLayout*, FFmpeg.AutoGen._AVChannelLayout*).
Exceptions
| Type | Condition |
|---|---|
| NotSupportedException | The current instance is read-only. |
| OutOfMemoryException | FFmpeg could not allocate memory while copying the channel layout. |
ToString()
Returns a human-readable description of the current channel layout.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string | A string describing the channel layout, or an empty string if the description could not be generated. |
Overrides
Remarks
This method uses av_channel_layout_describe(_AVChannelLayout*, byte*, ulong) to format the
channel layout using FFmpeg's standard textual representation, such as
"stereo", "5.1", or a custom channel list.
Operators
View Sourceoperator ==(ChannelLayout_ref, ChannelLayout?)
Determines whether a ChannelLayout_ref instance is equal to a ChannelLayout instance.
Declaration
public static bool operator ==(ChannelLayout_ref left, ChannelLayout? right)
Parameters
| Type | Name | Description |
|---|---|---|
| ChannelLayout_ref | left | The ChannelLayout_ref instance to compare. |
| ChannelLayout | right | The ChannelLayout instance to compare. |
Returns
| Type | Description |
|---|---|
| bool | true if the ChannelLayout_ref instance is equal to the ChannelLayout instance; otherwise, false. |
Remarks
This operator uses Equals(ChannelLayout?) to determine equality between a ChannelLayout_ref instance and a ChannelLayout instance.
operator ==(ChannelLayout_ref, ChannelLayout_ref)
Determines whether two ChannelLayout_ref instances are equal.
Declaration
public static bool operator ==(ChannelLayout_ref left, ChannelLayout_ref right)
Parameters
| Type | Name | Description |
|---|---|---|
| ChannelLayout_ref | left | The first ChannelLayout_ref instance to compare. |
| ChannelLayout_ref | right | The second ChannelLayout_ref instance to compare. |
Returns
| Type | Description |
|---|---|
| bool |
Remarks
This operator uses Equals(ChannelLayout_ref) to determine equality between two ChannelLayout_ref instances.
operator ==(ChannelLayout_ref, IChannelLayout?)
Determines whether a ChannelLayout_ref instance is equal to an IChannelLayout instance.
Declaration
public static bool operator ==(ChannelLayout_ref left, IChannelLayout? right)
Parameters
| Type | Name | Description |
|---|---|---|
| ChannelLayout_ref | left | The ChannelLayout_ref instance to compare. |
| IChannelLayout | right | The IChannelLayout instance to compare. |
Returns
| Type | Description |
|---|---|
| bool | true if the ChannelLayout_ref instance is equal to the IChannelLayout instance; otherwise, false. |
Remarks
This operator uses Equals(IChannelLayout?) to determine equality between a ChannelLayout_ref instance and an IChannelLayout instance.
operator !=(ChannelLayout_ref, ChannelLayout?)
Determines whether a ChannelLayout_ref instance is not equal to a ChannelLayout instance.
Declaration
public static bool operator !=(ChannelLayout_ref left, ChannelLayout? right)
Parameters
| Type | Name | Description |
|---|---|---|
| ChannelLayout_ref | left | The ChannelLayout_ref instance to compare. |
| ChannelLayout | right | The ChannelLayout instance to compare. |
Returns
| Type | Description |
|---|---|
| bool | true if the ChannelLayout_ref instance is not equal to the ChannelLayout instance; otherwise, false. |
Remarks
This operator uses Equals(ChannelLayout?) to determine if a ChannelLayout_ref instance is not equal to a ChannelLayout instance.
operator !=(ChannelLayout_ref, ChannelLayout_ref)
Determines whether two ChannelLayout_ref instances are not equal.
Declaration
public static bool operator !=(ChannelLayout_ref left, ChannelLayout_ref right)
Parameters
| Type | Name | Description |
|---|---|---|
| ChannelLayout_ref | left | The first ChannelLayout_ref instance to compare. |
| ChannelLayout_ref | right | The second ChannelLayout_ref instance to compare. |
Returns
| Type | Description |
|---|---|
| bool |
Remarks
This operator uses Equals(ChannelLayout_ref) to determine if two ChannelLayout_ref instances are not equal.
operator !=(ChannelLayout_ref, IChannelLayout?)
Determines whether a ChannelLayout_ref instance is not equal to an IChannelLayout instance.
Declaration
public static bool operator !=(ChannelLayout_ref left, IChannelLayout? right)
Parameters
| Type | Name | Description |
|---|---|---|
| ChannelLayout_ref | left | The ChannelLayout_ref instance to compare. |
| IChannelLayout | right | The IChannelLayout instance to compare. |
Returns
| Type | Description |
|---|---|
| bool | true if the ChannelLayout_ref instance is not equal to the IChannelLayout instance; otherwise, false. |
Remarks
This operator uses Equals(IChannelLayout?) to determine if a ChannelLayout_ref instance is not equal to an IChannelLayout instance.