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(OpusEncoder)
Gets the encoder's configured application.
Declaration
public static OpusPredefinedValues GetApplication(this OpusEncoder encoder)
Parameters
Type | Name | Description |
---|---|---|
OpusEncoder | encoder | The encoder state. |
Returns
Type | Description |
---|---|
OpusPredefinedValues | The encoder's configured application. |
Exceptions
Type | Condition |
---|---|
OpusException | |
ObjectDisposedException |
GetBandwidth(OpusEncoder)
Gets the encoder's last bandpass.
Declaration
public static OpusPredefinedValues GetBandwidth(this OpusEncoder encoder)
Parameters
Type | Name | Description |
---|---|---|
OpusEncoder | encoder | The encoder state. |
Returns
Type | Description |
---|---|
OpusPredefinedValues | The encoder's last bandpass. |
Exceptions
Type | Condition |
---|---|
OpusException | |
ObjectDisposedException |
GetBitRate(OpusEncoder)
Gets the encoder's bitrate configuration.
Declaration
public static int GetBitRate(this OpusEncoder encoder)
Parameters
Type | Name | Description |
---|---|---|
OpusEncoder | encoder | The encoder state. |
Returns
Type | Description |
---|---|
int | The encoder's bitrate. |
Exceptions
Type | Condition |
---|---|
OpusException | |
ObjectDisposedException |
GetComplexity(OpusEncoder)
Gets the encoder's complexity configuration.
Declaration
public static int GetComplexity(this OpusEncoder encoder)
Parameters
Type | Name | Description |
---|---|---|
OpusEncoder | encoder | The encoder state. |
Returns
Type | Description |
---|---|
int | The encoder's complexity. |
Exceptions
Type | Condition |
---|---|
OpusException | |
ObjectDisposedException |
GetDtx(OpusEncoder)
Gets encoder's configured use of discontinuous transmission.
Declaration
public static bool GetDtx(this OpusEncoder encoder)
Parameters
Type | Name | Description |
---|---|---|
OpusEncoder | encoder | The encoder state. |
Returns
Type | Description |
---|---|
bool | Whether DTX is enabled or not. |
Exceptions
Type | Condition |
---|---|
OpusException | |
ObjectDisposedException |
GetExpertFrameDuration(OpusEncoder)
Gets the encoder's configured use of variable duration frames.
Declaration
public static OpusPredefinedValues GetExpertFrameDuration(this OpusEncoder encoder)
Parameters
Type | Name | Description |
---|---|---|
OpusEncoder | encoder | The encoder state. |
Returns
Type | Description |
---|---|
OpusPredefinedValues | The encoder's configured expert frame duration. |
Exceptions
Type | Condition |
---|---|
OpusException | |
ObjectDisposedException |
GetFinalRange(OpusEncoder)
Gets the final state of the codec's entropy coder.
Declaration
public static uint GetFinalRange(this OpusEncoder encoder)
Parameters
Type | Name | Description |
---|---|---|
OpusEncoder | encoder | The encoder state. |
Returns
Type | Description |
---|---|
uint | The final state of the codec's entropy coder. |
Exceptions
Type | Condition |
---|---|
OpusException | |
ObjectDisposedException |
GetForceChannels(OpusEncoder)
Gets the encoder's forced channel configuration.
Declaration
public static int GetForceChannels(this OpusEncoder encoder)
Parameters
Type | Name | Description |
---|---|---|
OpusEncoder | 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(OpusEncoder)
Gets the DTX state of the encoder.
Declaration
public static int GetInDtx(this OpusEncoder encoder)
Parameters
Type | Name | Description |
---|---|---|
OpusEncoder | 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(OpusEncoder)
Gets encoder's configured use of in-band forward error correction.
Declaration
public static int GetInbandFec(this OpusEncoder encoder)
Parameters
Type | Name | Description |
---|---|---|
OpusEncoder | encoder | The encoder state. |
Returns
Type | Description |
---|---|
int | The encoder's configured use of forward error correction. |
Exceptions
Type | Condition |
---|---|
OpusException | |
ObjectDisposedException |
GetLookahead(OpusEncoder)
Gets the total samples of delay added by the entire codec.
Declaration
public static int GetLookahead(this OpusEncoder encoder)
Parameters
Type | Name | Description |
---|---|---|
OpusEncoder | encoder | The encoder state. |
Returns
Type | Description |
---|---|
int | The total samples of delay added by the entire codec. |
Exceptions
Type | Condition |
---|---|
OpusException | |
ObjectDisposedException |
GetLsbDepth(OpusEncoder)
Gets the encoder's configured signal depth.
Declaration
public static int GetLsbDepth(this OpusEncoder encoder)
Parameters
Type | Name | Description |
---|---|---|
OpusEncoder | encoder | The encoder state. |
Returns
Type | Description |
---|---|
int | The encoder's LSB depth. |
Exceptions
Type | Condition |
---|---|
OpusException | |
ObjectDisposedException |
GetMaxBandwidth(OpusEncoder)
Configures the maximum bandpass that the encoder will select automatically.
Declaration
public static int GetMaxBandwidth(this OpusEncoder encoder)
Parameters
Type | Name | Description |
---|---|---|
OpusEncoder | encoder | The encoder state. |
Returns
Type | Description |
---|---|
int | The encoder's max bandwidth. |
Exceptions
Type | Condition |
---|---|
OpusException | |
ObjectDisposedException |
GetPacketLostPercent(OpusEncoder)
Gets the encoder's configured packet loss percentage.
Declaration
public static int GetPacketLostPercent(this OpusEncoder encoder)
Parameters
Type | Name | Description |
---|---|---|
OpusEncoder | encoder | The encoder state. |
Returns
Type | Description |
---|---|
int | The encoder's packet loss percentage. |
Exceptions
Type | Condition |
---|---|
OpusException | |
ObjectDisposedException |
GetPhaseInversionDisabled(OpusEncoder)
Gets the encoder's configured phase inversion status.
Declaration
public static bool GetPhaseInversionDisabled(this OpusEncoder encoder)
Parameters
Type | Name | Description |
---|---|---|
OpusEncoder | encoder | The encoder state. |
Returns
Type | Description |
---|---|
bool | Whether the phase inversion is disabled or not. |
Exceptions
Type | Condition |
---|---|
OpusException | |
ObjectDisposedException |
GetPredictionDisabled(OpusEncoder)
Gets the encoder's configured prediction status.
Declaration
public static bool GetPredictionDisabled(this OpusEncoder encoder)
Parameters
Type | Name | Description |
---|---|---|
OpusEncoder | encoder | The encoder state. |
Returns
Type | Description |
---|---|
bool | Whether the encoder's prediction is disabled or not. |
Exceptions
Type | Condition |
---|---|
OpusException | |
ObjectDisposedException |
GetSampleRate(OpusEncoder)
Gets the sampling rate the encoder was initialized with.
Declaration
public static int GetSampleRate(this OpusEncoder encoder)
Parameters
Type | Name | Description |
---|---|---|
OpusEncoder | encoder | The encoder state. |
Returns
Type | Description |
---|---|
int | The encoder's configured sample rate. |
Exceptions
Type | Condition |
---|---|
OpusException | |
ObjectDisposedException |
GetSignal(OpusEncoder)
Gets the encoder's configured signal type.
Declaration
public static OpusPredefinedValues GetSignal(this OpusEncoder encoder)
Parameters
Type | Name | Description |
---|---|---|
OpusEncoder | encoder | The encoder state. |
Returns
Type | Description |
---|---|
OpusPredefinedValues | The encoder's signal type. |
Exceptions
Type | Condition |
---|---|
OpusException | |
ObjectDisposedException |
GetVbr(OpusEncoder)
Enables or disables variable bitrate (VBR) in the encoder.
Declaration
public static bool GetVbr(this OpusEncoder encoder)
Parameters
Type | Name | Description |
---|---|---|
OpusEncoder | encoder | The encoder state. |
Returns
Type | Description |
---|---|
bool | Whether the vbr is enabled or not. |
Exceptions
Type | Condition |
---|---|
OpusException | |
ObjectDisposedException |
GetVbrConstraint(OpusEncoder)
Determine if constrained VBR is enabled in the encoder.
Declaration
public static bool GetVbrConstraint(this OpusEncoder encoder)
Parameters
Type | Name | Description |
---|---|---|
OpusEncoder | encoder | The encoder state. |
Returns
Type | Description |
---|---|
bool | Whether the constrained VBR is enabled or not. |
Exceptions
Type | Condition |
---|---|
OpusException | |
ObjectDisposedException |
Reset(OpusEncoder)
Resets the codec state to be equivalent to a freshly initialized state.
Declaration
public static void Reset(this OpusEncoder encoder)
Parameters
Type | Name | Description |
---|---|---|
OpusEncoder | encoder | The encoder state. |
Exceptions
Type | Condition |
---|---|
OpusException | |
ObjectDisposedException |
SetApplication(OpusEncoder, OpusPredefinedValues)
Configures the encoder's intended application.
Declaration
public static void SetApplication(this OpusEncoder encoder, OpusPredefinedValues application)
Parameters
Type | Name | Description |
---|---|---|
OpusEncoder | 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(OpusEncoder, OpusPredefinedValues)
Sets the encoder's bandpass to a specific value.
Declaration
public static void SetBandwidth(this OpusEncoder encoder, OpusPredefinedValues bandwidth)
Parameters
Type | Name | Description |
---|---|---|
OpusEncoder | encoder | The encoder state. |
OpusPredefinedValues | bandwidth | The bandwidth to set. |
Exceptions
Type | Condition |
---|---|
OpusException | |
ObjectDisposedException |
SetBitRate(OpusEncoder, int)
Configures the bitrate in the encoder.
Declaration
public static void SetBitRate(this OpusEncoder encoder, int bitRate)
Parameters
Type | Name | Description |
---|---|---|
OpusEncoder | encoder | The encoder state. |
int | bitRate | The bitRate to set. |
Exceptions
Type | Condition |
---|---|
OpusException | |
ObjectDisposedException |
SetComplexity(OpusEncoder, int)
Configures the encoder's computational complexity.
Declaration
public static void SetComplexity(this OpusEncoder encoder, int complexity)
Parameters
Type | Name | Description |
---|---|---|
OpusEncoder | encoder | The encoder state. |
int | complexity | The complexity to set between 1-10. |
Exceptions
Type | Condition |
---|---|
OpusException | |
ObjectDisposedException |
SetDtx(OpusEncoder, bool)
Configures the encoder's use of discontinuous transmission (DTX).
Declaration
public static void SetDtx(this OpusEncoder encoder, bool enabled)
Parameters
Type | Name | Description |
---|---|---|
OpusEncoder | encoder | The encoder state. |
bool | enabled | Whether to enable the DTX or not. |
Exceptions
Type | Condition |
---|---|
OpusException | |
ObjectDisposedException |
SetExpertFrameDuration(OpusEncoder, OpusPredefinedValues)
Configures the encoder's use of variable duration frames.
Declaration
public static void SetExpertFrameDuration(this OpusEncoder encoder, OpusPredefinedValues expertDuration)
Parameters
Type | Name | Description |
---|---|---|
OpusEncoder | 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(OpusEncoder, int)
Configures mono/stereo forcing in the encoder.
Declaration
public static void SetForceChannels(this OpusEncoder encoder, int channels)
Parameters
Type | Name | Description |
---|---|---|
OpusEncoder | encoder | The encoder state. |
int | channels | The number of channels to set. |
Exceptions
Type | Condition |
---|---|
OpusException | |
ObjectDisposedException |
SetInbandFec(OpusEncoder, int)
Configures the encoder's use of in-band forward error correction (FEC).
Declaration
public static void SetInbandFec(this OpusEncoder encoder, int mode)
Parameters
Type | Name | Description |
---|---|---|
OpusEncoder | 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(OpusEncoder, int)
Configures the depth of signal being encoded.
Declaration
public static void SetLsbDepth(this OpusEncoder encoder, int depth)
Parameters
Type | Name | Description |
---|---|---|
OpusEncoder | encoder | The encoder state. |
int | depth | The LSB depth to set. |
Exceptions
Type | Condition |
---|---|
OpusException | |
ObjectDisposedException |
SetMaxBandwidth(OpusEncoder, int)
Configures the maximum bandpass that the encoder will select automatically.
Declaration
public static void SetMaxBandwidth(this OpusEncoder encoder, int maxBandwidth)
Parameters
Type | Name | Description |
---|---|---|
OpusEncoder | encoder | The encoder state. |
int | maxBandwidth | The max bandwidth to set. |
Exceptions
Type | Condition |
---|---|
OpusException | |
ObjectDisposedException |
SetPacketLostPercent(OpusEncoder, int)
Configures the encoder's expected packet loss percentage.
Declaration
public static void SetPacketLostPercent(this OpusEncoder encoder, int percent)
Parameters
Type | Name | Description |
---|---|---|
OpusEncoder | encoder | The encoder state. |
int | percent | The expected packet loss percentage value between 0-100. |
Exceptions
Type | Condition |
---|---|
OpusException | |
ObjectDisposedException |
SetPhaseInversionDisabled(OpusEncoder, 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 OpusEncoder encoder, bool disabled)
Parameters
Type | Name | Description |
---|---|---|
OpusEncoder | encoder | The encoder state. |
bool | disabled | Whether to disable or not. |
Exceptions
Type | Condition |
---|---|
OpusException | |
ObjectDisposedException |
SetPredictionDisabled(OpusEncoder, 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 OpusEncoder encoder, bool disabled)
Parameters
Type | Name | Description |
---|---|---|
OpusEncoder | encoder | The encoder state. |
bool | disabled | Whether to disable to encoder's prediction. |
Exceptions
Type | Condition |
---|---|
OpusException | |
ObjectDisposedException |
SetSignal(OpusEncoder, OpusPredefinedValues)
Configures the type of signal being encoded.
Declaration
public static void SetSignal(this OpusEncoder encoder, OpusPredefinedValues signal)
Parameters
Type | Name | Description |
---|---|---|
OpusEncoder | 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(OpusEncoder, bool)
Enables or disables variable bitrate (VBR) in the encoder.
Declaration
public static void SetVbr(this OpusEncoder encoder, bool enabled)
Parameters
Type | Name | Description |
---|---|---|
OpusEncoder | encoder | The encoder state. |
bool | enabled | Whether to enable/disable the encoder's vbr. |
Exceptions
Type | Condition |
---|---|
OpusException | |
ObjectDisposedException |
SetVbrConstraint(OpusEncoder, bool)
Enables or disables constrained VBR in the encoder.
Declaration
public static void SetVbrConstraint(this OpusEncoder encoder, bool enabled)
Parameters
Type | Name | Description |
---|---|---|
OpusEncoder | encoder | The encoder state. |
bool | enabled | Whether to enable the constrained VBR or not. |
Exceptions
Type | Condition |
---|---|
OpusException | |
ObjectDisposedException |