OpusSharp OpusSharp
OpusSharp OpusSharp
DocFX + Singulink = ♥

Search Results for

    Edit this page

    Class OpusEncoder

    An opus encoder.

    Inheritance
    object
    OpusEncoder
    Implements
    IDisposable
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: OpusSharp.Core
    Assembly: OpusSharp.Core.dll
    Syntax
    public class OpusEncoder : IDisposable

    Constructors

    | Edit this page View Source

    OpusEncoder(int, int, OpusPredefinedValues)

    Creates a new opus encoder.

    Declaration
    public OpusEncoder(int sample_rate, int channels, OpusPredefinedValues application)
    Parameters
    Type Name Description
    int sample_rate

    The sample rate, this must be one of 8000, 12000, 16000, 24000, or 48000.

    int channels

    Number of channels, this must be 1 or 2.

    OpusPredefinedValues application

    Coding mode (one of OPUS_APPLICATION_VOIP, OPUS_APPLICATION_AUDIO or OPUS_APPLICATION_RESTRICTED_LOWDELAY

    Exceptions
    Type Condition
    OpusException

    Fields

    | Edit this page View Source

    _handler

    Direct safe handle for the OpusEncoder. IT IS NOT RECOMMENDED TO CLOSE THE HANDLE DIRECTLY! Instead, use Dispose(bool) to dispose the handle and object safely.

    Declaration
    protected OpusEncoderSafeHandle _handler
    Field Value
    Type Description
    OpusEncoderSafeHandle

    Methods

    | Edit this page View Source

    CheckError(int)

    Checks if there is an opus error and throws if the error is a negative value.

    Declaration
    protected void CheckError(int error)
    Parameters
    Type Name Description
    int error

    The error code to input.

    Exceptions
    Type Condition
    OpusException
    | Edit this page View Source

    Ctl(EncoderCTL)

    Performs a ctl request.

    Declaration
    public int Ctl(EncoderCTL request)
    Parameters
    Type Name Description
    EncoderCTL request

    The request you want to specify.

    Returns
    Type Description
    int

    The result code of the request. See OpusErrorCodes.

    Exceptions
    Type Condition
    OpusException
    ObjectDisposedException
    | Edit this page View Source

    Ctl(EncoderCTL, int)

    Performs a ctl request.

    Declaration
    public int Ctl(EncoderCTL request, int value)
    Parameters
    Type Name Description
    EncoderCTL request

    The request you want to specify.

    int value

    The input value.

    Returns
    Type Description
    int

    The result code of the request. See OpusErrorCodes.

    Exceptions
    Type Condition
    OpusException
    ObjectDisposedException
    | Edit this page View Source

    Ctl(GenericCTL)

    Performs a ctl request.

    Declaration
    public int Ctl(GenericCTL request)
    Parameters
    Type Name Description
    GenericCTL request

    The request you want to specify.

    Returns
    Type Description
    int

    The result code of the request. See OpusErrorCodes.

    Exceptions
    Type Condition
    OpusException
    ObjectDisposedException
    | Edit this page View Source

    Ctl(GenericCTL, int)

    Performs a ctl set request.

    Declaration
    public int Ctl(GenericCTL request, int value)
    Parameters
    Type Name Description
    GenericCTL request

    The request you want to specify.

    int value

    The input value.

    Returns
    Type Description
    int

    The result code of the request. See OpusErrorCodes.

    Exceptions
    Type Condition
    OpusException
    ObjectDisposedException
    | Edit this page View Source

    Ctl<T>(EncoderCTL, int, ref T)

    Performs a ctl request.

    Declaration
    public int Ctl<T>(EncoderCTL request, int value, ref T value2) where T : unmanaged
    Parameters
    Type Name Description
    EncoderCTL request

    The request you want to specify.

    int value

    The input value.

    T value2

    The second input/output value.

    Returns
    Type Description
    int

    The result code of the request. See OpusErrorCodes.

    Type Parameters
    Name Description
    T

    The type you want to input/output.

    Exceptions
    Type Condition
    OpusException
    ObjectDisposedException
    | Edit this page View Source

    Ctl<T>(EncoderCTL, ref T)

    Performs a ctl request.

    Declaration
    public int Ctl<T>(EncoderCTL request, ref T value) where T : unmanaged
    Parameters
    Type Name Description
    EncoderCTL request

    The request you want to specify.

    T value

    The input/output value.

    Returns
    Type Description
    int

    The result code of the request. See OpusErrorCodes.

    Type Parameters
    Name Description
    T

    The type you want to input/output.

    Exceptions
    Type Condition
    OpusException
    ObjectDisposedException
    | Edit this page View Source

    Ctl<T>(EncoderCTL, ref T, int)

    Performs a ctl request.

    Declaration
    public int Ctl<T>(EncoderCTL request, ref T value, int value2) where T : unmanaged
    Parameters
    Type Name Description
    EncoderCTL request

    The request you want to specify.

    T value

    The input/output value.

    int value2

    The second input value.

    Returns
    Type Description
    int

    The result code of the request. See OpusErrorCodes.

    Type Parameters
    Name Description
    T

    The type you want to input/output.

    Exceptions
    Type Condition
    OpusException
    ObjectDisposedException
    | Edit this page View Source

    Ctl<T>(GenericCTL, ref T)

    Performs a ctl request.

    Declaration
    public int Ctl<T>(GenericCTL request, ref T value) where T : unmanaged
    Parameters
    Type Name Description
    GenericCTL request

    The request you want to specify.

    T value

    The input/output value.

    Returns
    Type Description
    int

    The result code of the request. See OpusErrorCodes.

    Type Parameters
    Name Description
    T

    The type you want to input/output.

    Exceptions
    Type Condition
    OpusException
    ObjectDisposedException
    | Edit this page View Source

    Ctl<T, T2>(EncoderCTL, ref T, ref T2)

    Performs a ctl request.

    Declaration
    public int Ctl<T, T2>(EncoderCTL request, ref T value, ref T2 value2) where T : unmanaged where T2 : unmanaged
    Parameters
    Type Name Description
    EncoderCTL request

    The request you want to specify.

    T value

    The input/output value.

    T2 value2

    The second input/output value.

    Returns
    Type Description
    int

    The result code of the request. See OpusErrorCodes.

    Type Parameters
    Name Description
    T

    The type you want to input/output.

    T2

    The second type you want to input/output.

    Exceptions
    Type Condition
    OpusException
    ObjectDisposedException
    | Edit this page View Source

    Dispose()

    Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

    Declaration
    public void Dispose()
    | Edit this page View Source

    Dispose(bool)

    Dispose logic.

    Declaration
    protected virtual void Dispose(bool disposing)
    Parameters
    Type Name Description
    bool disposing

    Set to true if fully disposing.

    | Edit this page View Source

    Encode(byte[], int, byte[], int)

    Encodes a pcm frame.

    Declaration
    public int Encode(byte[] input, int frame_size, byte[] output, int max_data_bytes)
    Parameters
    Type Name Description
    byte[] input

    Input signal (interleaved if 2 channels). length is frame_size*channels.

    int frame_size

    The frame size of the pcm data. This must be an Opus frame size for the encoder's sampling rate. For example, at 48 kHz the permitted values are 120, 240, 480, 960, 1920, and 2880. Passing in a duration of less than 10 ms (480 samples at 48 kHz) will prevent the encoder from using the LPC or hybrid modes.

    byte[] output

    Output payload. This must contain storage for at least max_data_bytes.

    int max_data_bytes

    Size of the allocated memory for the output payload. This may be used to impose an upper limit on the instant bitrate, but should not be used as the only bitrate control. Use OPUS_SET_BITRATE to control the bitrate.

    Returns
    Type Description
    int

    The length of the encoded packet (in bytes).

    Exceptions
    Type Condition
    OpusException
    ObjectDisposedException
    | Edit this page View Source

    Encode(short[], int, byte[], int)

    Encodes a pcm frame.

    Declaration
    public int Encode(short[] input, int frame_size, byte[] output, int max_data_bytes)
    Parameters
    Type Name Description
    short[] input

    Input signal (interleaved if 2 channels). length is frame_sizechannelssizeof(short).

    int frame_size

    The frame size of the pcm data. This must be an Opus frame size for the encoder's sampling rate. For example, at 48 kHz the permitted values are 120, 240, 480, 960, 1920, and 2880. Passing in a duration of less than 10 ms (480 samples at 48 kHz) will prevent the encoder from using the LPC or hybrid modes.

    byte[] output

    Output payload. This must contain storage for at least max_data_bytes.

    int max_data_bytes

    Size of the allocated memory for the output payload. This may be used to impose an upper limit on the instant bitrate, but should not be used as the only bitrate control. Use OPUS_SET_BITRATE to control the bitrate.

    Returns
    Type Description
    int

    The length of the encoded packet (in bytes).

    Exceptions
    Type Condition
    OpusException
    ObjectDisposedException
    | Edit this page View Source

    Encode(float[], int, byte[], int)

    Encodes a floating point pcm frame.

    Declaration
    public int Encode(float[] input, int frame_size, byte[] output, int max_data_bytes)
    Parameters
    Type Name Description
    float[] input

    Input signal (interleaved if 2 channels). length is frame_sizechannelssizeof(float).

    int frame_size

    The frame size of the pcm data. This must be an Opus frame size for the encoder's sampling rate. For example, at 48 kHz the permitted values are 120, 240, 480, 960, 1920, and 2880. Passing in a duration of less than 10 ms (480 samples at 48 kHz) will prevent the encoder from using the LPC or hybrid modes.

    byte[] output

    Output payload. This must contain storage for at least max_data_bytes.

    int max_data_bytes

    Size of the allocated memory for the output payload. This may be used to impose an upper limit on the instant bitrate, but should not be used as the only bitrate control. Use OPUS_SET_BITRATE to control the bitrate.

    Returns
    Type Description
    int

    The length of the encoded packet (in bytes).

    Exceptions
    Type Condition
    OpusException
    ObjectDisposedException
    | Edit this page View Source

    Encode(Span<byte>, int, Span<byte>, int)

    Encodes a pcm frame.

    Declaration
    public int Encode(Span<byte> input, int frame_size, Span<byte> output, int max_data_bytes)
    Parameters
    Type Name Description
    Span<byte> input

    Input signal (interleaved if 2 channels). length is frame_size*channels.

    int frame_size

    The frame size of the pcm data. This must be an Opus frame size for the encoder's sampling rate. For example, at 48 kHz the permitted values are 120, 240, 480, 960, 1920, and 2880. Passing in a duration of less than 10 ms (480 samples at 48 kHz) will prevent the encoder from using the LPC or hybrid modes.

    Span<byte> output

    Output payload. This must contain storage for at least max_data_bytes.

    int max_data_bytes

    Size of the allocated memory for the output payload. This may be used to impose an upper limit on the instant bitrate, but should not be used as the only bitrate control. Use OPUS_SET_BITRATE to control the bitrate.

    Returns
    Type Description
    int

    The length of the encoded packet (in bytes).

    Exceptions
    Type Condition
    OpusException
    ObjectDisposedException
    | Edit this page View Source

    Encode(Span<short>, int, Span<byte>, int)

    Encodes a pcm frame.

    Declaration
    public int Encode(Span<short> input, int frame_size, Span<byte> output, int max_data_bytes)
    Parameters
    Type Name Description
    Span<short> input

    Input signal (interleaved if 2 channels). length is frame_sizechannelssizeof(short).

    int frame_size

    The frame size of the pcm data. This must be an Opus frame size for the encoder's sampling rate. For example, at 48 kHz the permitted values are 120, 240, 480, 960, 1920, and 2880. Passing in a duration of less than 10 ms (480 samples at 48 kHz) will prevent the encoder from using the LPC or hybrid modes.

    Span<byte> output

    Output payload. This must contain storage for at least max_data_bytes.

    int max_data_bytes

    Size of the allocated memory for the output payload. This may be used to impose an upper limit on the instant bitrate, but should not be used as the only bitrate control. Use OPUS_SET_BITRATE to control the bitrate.

    Returns
    Type Description
    int

    The length of the encoded packet (in bytes).

    Exceptions
    Type Condition
    OpusException
    ObjectDisposedException
    | Edit this page View Source

    Encode(Span<float>, int, Span<byte>, int)

    Encodes a floating point pcm frame.

    Declaration
    public int Encode(Span<float> input, int frame_size, Span<byte> output, int max_data_bytes)
    Parameters
    Type Name Description
    Span<float> input

    Input signal (interleaved if 2 channels). length is frame_sizechannelssizeof(float).

    int frame_size

    The frame size of the pcm data. This must be an Opus frame size for the encoder's sampling rate. For example, at 48 kHz the permitted values are 120, 240, 480, 960, 1920, and 2880. Passing in a duration of less than 10 ms (480 samples at 48 kHz) will prevent the encoder from using the LPC or hybrid modes.

    Span<byte> output

    Output payload. This must contain storage for at least max_data_bytes.

    int max_data_bytes

    Size of the allocated memory for the output payload. This may be used to impose an upper limit on the instant bitrate, but should not be used as the only bitrate control. Use OPUS_SET_BITRATE to control the bitrate.

    Returns
    Type Description
    int

    The length of the encoded packet (in bytes).

    Exceptions
    Type Condition
    OpusException
    ObjectDisposedException
    | Edit this page View Source

    ~OpusEncoder()

    Opus encoder destructor.

    Declaration
    protected ~OpusEncoder()
    | Edit this page View Source

    ThrowIfDisposed()

    Throws an exception if this object is disposed or the handler is closed.

    Declaration
    protected virtual void ThrowIfDisposed()
    Exceptions
    Type Condition
    ObjectDisposedException

    Implements

    IDisposable

    Extension Methods

    OpusEncoderExtensions.GetApplication(OpusEncoder)
    OpusEncoderExtensions.GetBandwidth(OpusEncoder)
    OpusEncoderExtensions.GetBitRate(OpusEncoder)
    OpusEncoderExtensions.GetComplexity(OpusEncoder)
    OpusEncoderExtensions.GetDtx(OpusEncoder)
    OpusEncoderExtensions.GetExpertFrameDuration(OpusEncoder)
    OpusEncoderExtensions.GetFinalRange(OpusEncoder)
    OpusEncoderExtensions.GetForceChannels(OpusEncoder)
    OpusEncoderExtensions.GetInDtx(OpusEncoder)
    OpusEncoderExtensions.GetInbandFec(OpusEncoder)
    OpusEncoderExtensions.GetLookahead(OpusEncoder)
    OpusEncoderExtensions.GetLsbDepth(OpusEncoder)
    OpusEncoderExtensions.GetMaxBandwidth(OpusEncoder)
    OpusEncoderExtensions.GetPacketLostPercent(OpusEncoder)
    OpusEncoderExtensions.GetPhaseInversionDisabled(OpusEncoder)
    OpusEncoderExtensions.GetPredictionDisabled(OpusEncoder)
    OpusEncoderExtensions.GetSampleRate(OpusEncoder)
    OpusEncoderExtensions.GetSignal(OpusEncoder)
    OpusEncoderExtensions.GetVbr(OpusEncoder)
    OpusEncoderExtensions.GetVbrConstraint(OpusEncoder)
    OpusEncoderExtensions.Reset(OpusEncoder)
    OpusEncoderExtensions.SetApplication(OpusEncoder, OpusPredefinedValues)
    OpusEncoderExtensions.SetBandwidth(OpusEncoder, OpusPredefinedValues)
    OpusEncoderExtensions.SetBitRate(OpusEncoder, int)
    OpusEncoderExtensions.SetComplexity(OpusEncoder, int)
    OpusEncoderExtensions.SetDtx(OpusEncoder, bool)
    OpusEncoderExtensions.SetExpertFrameDuration(OpusEncoder, OpusPredefinedValues)
    OpusEncoderExtensions.SetForceChannels(OpusEncoder, int)
    OpusEncoderExtensions.SetInbandFec(OpusEncoder, int)
    OpusEncoderExtensions.SetLsbDepth(OpusEncoder, int)
    OpusEncoderExtensions.SetMaxBandwidth(OpusEncoder, int)
    OpusEncoderExtensions.SetPacketLostPercent(OpusEncoder, int)
    OpusEncoderExtensions.SetPhaseInversionDisabled(OpusEncoder, bool)
    OpusEncoderExtensions.SetPredictionDisabled(OpusEncoder, bool)
    OpusEncoderExtensions.SetSignal(OpusEncoder, OpusPredefinedValues)
    OpusEncoderExtensions.SetVbr(OpusEncoder, bool)
    OpusEncoderExtensions.SetVbrConstraint(OpusEncoder, bool)