Class OpusEncoderExtensions
Contains the OpusEncoder helper extensions.
Inherited Members
Namespace: OpusSharp.Core.Extensions
Assembly: OpusSharp.Core.dll
Syntax
public static class OpusEncoderExtensions
Methods
| Edit this page View SourceGetApplication(IOpusEncoder)
Gets the encoder's configured application.
Declaration
public static OpusPredefinedValues GetApplication(this IOpusEncoder encoder)
Parameters
| Type | Name | Description |
|---|---|---|
| IOpusEncoder | encoder | The encoder state. |
Returns
| Type | Description |
|---|---|
| OpusPredefinedValues | The encoder's configured application. |
Exceptions
| Type | Condition |
|---|---|
| OpusException | |
| ObjectDisposedException |
GetBandwidth(IOpusEncoder)
Gets the encoder's last bandpass.
Declaration
public static OpusPredefinedValues GetBandwidth(this IOpusEncoder encoder)
Parameters
| Type | Name | Description |
|---|---|---|
| IOpusEncoder | encoder | The encoder state. |
Returns
| Type | Description |
|---|---|
| OpusPredefinedValues | The encoder's last bandpass. |
Exceptions
| Type | Condition |
|---|---|
| OpusException | |
| ObjectDisposedException |
GetBitRate(IOpusEncoder)
Gets the encoder's bitrate configuration.
Declaration
public static int GetBitRate(this IOpusEncoder encoder)
Parameters
| Type | Name | Description |
|---|---|---|
| IOpusEncoder | encoder | The encoder state. |
Returns
| Type | Description |
|---|---|
| int | The encoder's bitrate. |
Exceptions
| Type | Condition |
|---|---|
| OpusException | |
| ObjectDisposedException |
GetComplexity(IOpusEncoder)
Gets the encoder's complexity configuration.
Declaration
public static int GetComplexity(this IOpusEncoder encoder)
Parameters
| Type | Name | Description |
|---|---|---|
| IOpusEncoder | encoder | The encoder state. |
Returns
| Type | Description |
|---|---|
| int | The encoder's complexity. |
Exceptions
| Type | Condition |
|---|---|
| OpusException | |
| ObjectDisposedException |
GetDtx(IOpusEncoder)
Gets encoder's configured use of discontinuous transmission.
Declaration
public static bool GetDtx(this IOpusEncoder encoder)
Parameters
| Type | Name | Description |
|---|---|---|
| IOpusEncoder | encoder | The encoder state. |
Returns
| Type | Description |
|---|---|
| bool | Whether DTX is enabled or not. |
Exceptions
| Type | Condition |
|---|---|
| OpusException | |
| ObjectDisposedException |
GetExpertFrameDuration(IOpusEncoder)
Gets the encoder's configured use of variable duration frames.
Declaration
public static OpusPredefinedValues GetExpertFrameDuration(this IOpusEncoder encoder)
Parameters
| Type | Name | Description |
|---|---|---|
| IOpusEncoder | encoder | The encoder state. |
Returns
| Type | Description |
|---|---|
| OpusPredefinedValues | The encoder's configured expert frame duration. |
Exceptions
| Type | Condition |
|---|---|
| OpusException | |
| ObjectDisposedException |
GetFinalRange(IOpusEncoder)
Gets the final state of the codec's entropy coder.
Declaration
public static uint GetFinalRange(this IOpusEncoder encoder)
Parameters
| Type | Name | Description |
|---|---|---|
| IOpusEncoder | encoder | The encoder state. |
Returns
| Type | Description |
|---|---|
| uint | The final state of the codec's entropy coder. |
Exceptions
| Type | Condition |
|---|---|
| OpusException | |
| ObjectDisposedException |
GetForceChannels(IOpusEncoder)
Gets the encoder's forced channel configuration.
Declaration
public static int GetForceChannels(this IOpusEncoder encoder)
Parameters
| Type | Name | Description |
|---|---|---|
| IOpusEncoder | encoder | The encoder state. |
Returns
| Type | Description |
|---|---|
| int | The number of channels enforced by the encoder. |
Remarks
By default, this is set to OPUS_AUTO.
Exceptions
| Type | Condition |
|---|---|
| OpusException | |
| ObjectDisposedException |
GetInDtx(IOpusEncoder)
Gets the DTX state of the encoder.
Declaration
public static int GetInDtx(this IOpusEncoder encoder)
Parameters
| Type | Name | Description |
|---|---|---|
| IOpusEncoder | encoder | The encoder state. |
Returns
| Type | Description |
|---|---|
| int | The dtx state of the encoder. |
Remarks
I have no idea how this works even by looking at the source code, it seems to do something with speech but that's as far as I've gotten. (Sine)
Exceptions
| Type | Condition |
|---|---|
| OpusException | |
| ObjectDisposedException |
GetInbandFec(IOpusEncoder)
Gets encoder's configured use of in-band forward error correction.
Declaration
public static int GetInbandFec(this IOpusEncoder encoder)
Parameters
| Type | Name | Description |
|---|---|---|
| IOpusEncoder | encoder | The encoder state. |
Returns
| Type | Description |
|---|---|
| int | The encoder's configured use of forward error correction. |
Exceptions
| Type | Condition |
|---|---|
| OpusException | |
| ObjectDisposedException |
GetLookahead(IOpusEncoder)
Gets the total samples of delay added by the entire codec.
Declaration
public static int GetLookahead(this IOpusEncoder encoder)
Parameters
| Type | Name | Description |
|---|---|---|
| IOpusEncoder | encoder | The encoder state. |
Returns
| Type | Description |
|---|---|
| int | The total samples of delay added by the entire codec. |
Exceptions
| Type | Condition |
|---|---|
| OpusException | |
| ObjectDisposedException |
GetLsbDepth(IOpusEncoder)
Gets the encoder's configured signal depth.
Declaration
public static int GetLsbDepth(this IOpusEncoder encoder)
Parameters
| Type | Name | Description |
|---|---|---|
| IOpusEncoder | encoder | The encoder state. |
Returns
| Type | Description |
|---|---|
| int | The encoder's LSB depth. |
Exceptions
| Type | Condition |
|---|---|
| OpusException | |
| ObjectDisposedException |
GetMaxBandwidth(IOpusEncoder)
Configures the maximum bandpass that the encoder will select automatically.
Declaration
public static int GetMaxBandwidth(this IOpusEncoder encoder)
Parameters
| Type | Name | Description |
|---|---|---|
| IOpusEncoder | encoder | The encoder state. |
Returns
| Type | Description |
|---|---|
| int | The encoder's max bandwidth. |
Exceptions
| Type | Condition |
|---|---|
| OpusException | |
| ObjectDisposedException |
GetPacketLostPercent(IOpusEncoder)
Gets the encoder's configured packet loss percentage.
Declaration
public static int GetPacketLostPercent(this IOpusEncoder encoder)
Parameters
| Type | Name | Description |
|---|---|---|
| IOpusEncoder | encoder | The encoder state. |
Returns
| Type | Description |
|---|---|
| int | The encoder's packet loss percentage. |
Exceptions
| Type | Condition |
|---|---|
| OpusException | |
| ObjectDisposedException |
GetPhaseInversionDisabled(IOpusEncoder)
Gets the encoder's configured phase inversion status.
Declaration
public static bool GetPhaseInversionDisabled(this IOpusEncoder encoder)
Parameters
| Type | Name | Description |
|---|---|---|
| IOpusEncoder | encoder | The encoder state. |
Returns
| Type | Description |
|---|---|
| bool | Whether the phase inversion is disabled or not. |
Exceptions
| Type | Condition |
|---|---|
| OpusException | |
| ObjectDisposedException |
GetPredictionDisabled(IOpusEncoder)
Gets the encoder's configured prediction status.
Declaration
public static bool GetPredictionDisabled(this IOpusEncoder encoder)
Parameters
| Type | Name | Description |
|---|---|---|
| IOpusEncoder | encoder | The encoder state. |
Returns
| Type | Description |
|---|---|
| bool | Whether the encoder's prediction is disabled or not. |
Exceptions
| Type | Condition |
|---|---|
| OpusException | |
| ObjectDisposedException |
GetQext(IOpusEncoder)
Determine if the QEXT extension is enabled in the encoder.
Declaration
public static bool GetQext(this IOpusEncoder encoder)
Parameters
| Type | Name | Description |
|---|---|---|
| IOpusEncoder | encoder | The encoder state. |
Returns
| Type | Description |
|---|---|
| bool | Whether the QEXT extension is enabled or not. |
Exceptions
| Type | Condition |
|---|---|
| OpusException | |
| ObjectDisposedException |
GetSampleRate(IOpusEncoder)
Gets the sampling rate the encoder was initialized with.
Declaration
public static int GetSampleRate(this IOpusEncoder encoder)
Parameters
| Type | Name | Description |
|---|---|---|
| IOpusEncoder | encoder | The encoder state. |
Returns
| Type | Description |
|---|---|
| int | The encoder's configured sample rate. |
Exceptions
| Type | Condition |
|---|---|
| OpusException | |
| ObjectDisposedException |
GetSignal(IOpusEncoder)
Gets the encoder's configured signal type.
Declaration
public static OpusPredefinedValues GetSignal(this IOpusEncoder encoder)
Parameters
| Type | Name | Description |
|---|---|---|
| IOpusEncoder | encoder | The encoder state. |
Returns
| Type | Description |
|---|---|
| OpusPredefinedValues | The encoder's signal type. |
Exceptions
| Type | Condition |
|---|---|
| OpusException | |
| ObjectDisposedException |
GetVbr(IOpusEncoder)
Enables or disables variable bitrate (VBR) in the encoder.
Declaration
public static bool GetVbr(this IOpusEncoder encoder)
Parameters
| Type | Name | Description |
|---|---|---|
| IOpusEncoder | encoder | The encoder state. |
Returns
| Type | Description |
|---|---|
| bool | Whether the vbr is enabled or not. |
Exceptions
| Type | Condition |
|---|---|
| OpusException | |
| ObjectDisposedException |
GetVbrConstraint(IOpusEncoder)
Determine if constrained VBR is enabled in the encoder.
Declaration
public static bool GetVbrConstraint(this IOpusEncoder encoder)
Parameters
| Type | Name | Description |
|---|---|---|
| IOpusEncoder | encoder | The encoder state. |
Returns
| Type | Description |
|---|---|
| bool | Whether the constrained VBR is enabled or not. |
Exceptions
| Type | Condition |
|---|---|
| OpusException | |
| ObjectDisposedException |
Reset(IOpusEncoder)
Resets the codec state to be equivalent to a freshly initialized state.
Declaration
public static void Reset(this IOpusEncoder encoder)
Parameters
| Type | Name | Description |
|---|---|---|
| IOpusEncoder | encoder | The encoder state. |
Exceptions
| Type | Condition |
|---|---|
| OpusException | |
| ObjectDisposedException |
SetApplication(IOpusEncoder, OpusPredefinedValues)
Configures the encoder's intended application.
Declaration
public static void SetApplication(this IOpusEncoder encoder, OpusPredefinedValues application)
Parameters
| Type | Name | Description |
|---|---|---|
| IOpusEncoder | encoder | The encoder state. |
| OpusPredefinedValues | application | The application to set. Must be one of OPUS_APPLICATION_VOIP, OPUS_APPLICATION_AUDIO or OPUS_APPLICATION_RESTRICTED_LOWDELAY. |
Exceptions
| Type | Condition |
|---|---|
| OpusException | |
| ObjectDisposedException |
SetBandwidth(IOpusEncoder, OpusPredefinedValues)
Sets the encoder's bandpass to a specific value.
Declaration
public static void SetBandwidth(this IOpusEncoder encoder, OpusPredefinedValues bandwidth)
Parameters
| Type | Name | Description |
|---|---|---|
| IOpusEncoder | encoder | The encoder state. |
| OpusPredefinedValues | bandwidth | The bandwidth to set. |
Exceptions
| Type | Condition |
|---|---|
| OpusException | |
| ObjectDisposedException |
SetBitRate(IOpusEncoder, int)
Configures the bitrate in the encoder.
Declaration
public static void SetBitRate(this IOpusEncoder encoder, int bitRate)
Parameters
| Type | Name | Description |
|---|---|---|
| IOpusEncoder | encoder | The encoder state. |
| int | bitRate | The bitRate to set. |
Exceptions
| Type | Condition |
|---|---|
| OpusException | |
| ObjectDisposedException |
SetComplexity(IOpusEncoder, int)
Configures the encoder's computational complexity.
Declaration
public static void SetComplexity(this IOpusEncoder encoder, int complexity)
Parameters
| Type | Name | Description |
|---|---|---|
| IOpusEncoder | encoder | The encoder state. |
| int | complexity | The complexity to set between 1-10. |
Exceptions
| Type | Condition |
|---|---|
| OpusException | |
| ObjectDisposedException |
SetDtx(IOpusEncoder, bool)
Configures the encoder's use of discontinuous transmission (DTX).
Declaration
public static void SetDtx(this IOpusEncoder encoder, bool enabled)
Parameters
| Type | Name | Description |
|---|---|---|
| IOpusEncoder | encoder | The encoder state. |
| bool | enabled | Whether to enable the DTX or not. |
Exceptions
| Type | Condition |
|---|---|
| OpusException | |
| ObjectDisposedException |
SetExpertFrameDuration(IOpusEncoder, OpusPredefinedValues)
Configures the encoder's use of variable duration frames.
Declaration
public static void SetExpertFrameDuration(this IOpusEncoder encoder, OpusPredefinedValues expertDuration)
Parameters
| Type | Name | Description |
|---|---|---|
| IOpusEncoder | encoder | The encoder state. |
| OpusPredefinedValues | expertDuration | The frame duration to set. Must be one of OPUS_FRAMESIZE_ARG, OPUS_FRAMESIZE_2_5_MS, OPUS_FRAMESIZE_5_MS, OPUS_FRAMESIZE_10_MS, OPUS_FRAMESIZE_20_MS, OPUS_FRAMESIZE_40_MS, OPUS_FRAMESIZE_60_MS, OPUS_FRAMESIZE_80_MS, OPUS_FRAMESIZE_100_MS or OPUS_FRAMESIZE_120_MS |
Exceptions
| Type | Condition |
|---|---|
| OpusException | |
| ObjectDisposedException |
SetForceChannels(IOpusEncoder, int)
Configures mono/stereo forcing in the encoder.
Declaration
public static void SetForceChannels(this IOpusEncoder encoder, int channels)
Parameters
| Type | Name | Description |
|---|---|---|
| IOpusEncoder | encoder | The encoder state. |
| int | channels | The number of channels to set. |
Exceptions
| Type | Condition |
|---|---|
| OpusException | |
| ObjectDisposedException |
SetInbandFec(IOpusEncoder, int)
Configures the encoder's use of in-band forward error correction (FEC).
Declaration
public static void SetInbandFec(this IOpusEncoder encoder, int mode)
Parameters
| Type | Name | Description |
|---|---|---|
| IOpusEncoder | encoder | The encoder state. |
| int | mode | The FEC mode to set. |
Remarks
0: Disable in-band FEC (default). 1: In-band FEC enabled. If the packet loss rate is sufficiently high, Opus will automatically switch to SILK even at high rates to enable use of that FEC. 2: In-band FEC enabled, but does not necessarily switch to SILK if we have music.
Exceptions
| Type | Condition |
|---|---|
| OpusException | |
| ObjectDisposedException |
SetLsbDepth(IOpusEncoder, int)
Configures the depth of signal being encoded.
Declaration
public static void SetLsbDepth(this IOpusEncoder encoder, int depth)
Parameters
| Type | Name | Description |
|---|---|---|
| IOpusEncoder | encoder | The encoder state. |
| int | depth | The LSB depth to set. |
Exceptions
| Type | Condition |
|---|---|
| OpusException | |
| ObjectDisposedException |
SetMaxBandwidth(IOpusEncoder, int)
Configures the maximum bandpass that the encoder will select automatically.
Declaration
public static void SetMaxBandwidth(this IOpusEncoder encoder, int maxBandwidth)
Parameters
| Type | Name | Description |
|---|---|---|
| IOpusEncoder | encoder | The encoder state. |
| int | maxBandwidth | The max bandwidth to set. |
Exceptions
| Type | Condition |
|---|---|
| OpusException | |
| ObjectDisposedException |
SetPacketLostPercent(IOpusEncoder, int)
Configures the encoder's expected packet loss percentage.
Declaration
public static void SetPacketLostPercent(this IOpusEncoder encoder, int percent)
Parameters
| Type | Name | Description |
|---|---|---|
| IOpusEncoder | encoder | The encoder state. |
| int | percent | The expected packet loss percentage value between 0-100. |
Exceptions
| Type | Condition |
|---|---|
| OpusException | |
| ObjectDisposedException |
SetPhaseInversionDisabled(IOpusEncoder, bool)
If set to true, disables the use of phase inversion for intensity stereo, improving the quality of mono down-mixes, but slightly reducing normal stereo quality.
Declaration
public static void SetPhaseInversionDisabled(this IOpusEncoder encoder, bool disabled)
Parameters
| Type | Name | Description |
|---|---|---|
| IOpusEncoder | encoder | The encoder state. |
| bool | disabled | Whether to disable or not. |
Exceptions
| Type | Condition |
|---|---|
| OpusException | |
| ObjectDisposedException |
SetPredictionDisabled(IOpusEncoder, bool)
If set to true, disables almost all use of prediction, making frames almost completely independent. This reduces quality.
Declaration
public static void SetPredictionDisabled(this IOpusEncoder encoder, bool disabled)
Parameters
| Type | Name | Description |
|---|---|---|
| IOpusEncoder | encoder | The encoder state. |
| bool | disabled | Whether to disable to encoder's prediction. |
Exceptions
| Type | Condition |
|---|---|
| OpusException | |
| ObjectDisposedException |
SetQext(IOpusEncoder, bool)
Configures the encoder's QEXT extension.
Declaration
public static void SetQext(this IOpusEncoder encoder, bool enabled)
Parameters
| Type | Name | Description |
|---|---|---|
| IOpusEncoder | encoder | The encoder state. |
| bool | enabled | Whether to enable the QEXT extension or not. |
Exceptions
| Type | Condition |
|---|---|
| OpusException | |
| ObjectDisposedException |
SetSignal(IOpusEncoder, OpusPredefinedValues)
Configures the type of signal being encoded.
Declaration
public static void SetSignal(this IOpusEncoder encoder, OpusPredefinedValues signal)
Parameters
| Type | Name | Description |
|---|---|---|
| IOpusEncoder | encoder | The encoder state. |
| OpusPredefinedValues | signal | The signal type to set. Must be one of OPUS_AUTO, OPUS_SIGNAL_VOICE or OPUS_SIGNAL_MUSIC. |
Exceptions
| Type | Condition |
|---|---|
| OpusException | |
| ObjectDisposedException |
SetVbr(IOpusEncoder, bool)
Enables or disables variable bitrate (VBR) in the encoder.
Declaration
public static void SetVbr(this IOpusEncoder encoder, bool enabled)
Parameters
| Type | Name | Description |
|---|---|---|
| IOpusEncoder | encoder | The encoder state. |
| bool | enabled | Whether to enable/disable the encoder's vbr. |
Exceptions
| Type | Condition |
|---|---|
| OpusException | |
| ObjectDisposedException |
SetVbrConstraint(IOpusEncoder, bool)
Enables or disables constrained VBR in the encoder.
Declaration
public static void SetVbrConstraint(this IOpusEncoder encoder, bool enabled)
Parameters
| Type | Name | Description |
|---|---|---|
| IOpusEncoder | encoder | The encoder state. |
| bool | enabled | Whether to enable the constrained VBR or not. |
Exceptions
| Type | Condition |
|---|---|
| OpusException | |
| ObjectDisposedException |