OpusSharp OpusSharp
OpusSharp OpusSharp
DocFX + Singulink = ♥

Search Results for

    Edit this page

    Class OpusDecoder

    An opus decoder.

    Inheritance
    object
    OpusDecoder
    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 OpusDecoder : IDisposable

    Constructors

    | Edit this page View Source

    OpusDecoder(int, int)

    Creates a new opus decoder.

    Declaration
    public OpusDecoder(int sample_rate, int channels)
    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.

    Exceptions
    Type Condition
    OpusException

    Fields

    | Edit this page View Source

    _handler

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

    Declaration
    protected OpusDecoderSafeHandle _handler
    Field Value
    Type Description
    OpusDecoderSafeHandle

    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(DecoderCTL)

    Performs a ctl request.

    Declaration
    public int Ctl(DecoderCTL request)
    Parameters
    Type Name Description
    DecoderCTL 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(DecoderCTL, int)

    Performs a ctl set request.

    Declaration
    public int Ctl(DecoderCTL request, int value)
    Parameters
    Type Name Description
    DecoderCTL 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>(DecoderCTL, ref T)

    Performs a ctl get/set request.

    Declaration
    public int Ctl<T>(DecoderCTL request, ref T value) where T : unmanaged
    Parameters
    Type Name Description
    DecoderCTL 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>(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

    Decode(byte[]?, int, byte[], int, bool)

    Decodes an opus encoded frame.

    Declaration
    public int Decode(byte[]? input, int length, byte[] output, int frame_size, bool decode_fec)
    Parameters
    Type Name Description
    byte[] input

    Input payload. Use null to indicate packet loss

    int length

    Number of bytes in payload.

    byte[] output

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

    int frame_size

    Number of samples per channel of available space in pcm. If this is less than the maximum packet duration (120ms; 5760 for 48kHz), this function will not be capable of decoding some packets. In the case of PLC (data==NULL) or FEC (decode_fec=true), then frame_size needs to be exactly the duration of audio that is missing, otherwise the decoder will not be in the optimal state to decode the next incoming packet. For the PLC and FEC cases, frame_size must be a multiple of 2.5 ms.

    bool decode_fec

    Request that any in-band forward error correction data be decoded. If no such data is available, the frame is decoded as if it were lost.

    Returns
    Type Description
    int

    Number of decoded samples or OpusErrorCodes.

    | Edit this page View Source

    Decode(byte[]?, int, short[], int, bool)

    Decodes an opus encoded frame.

    Declaration
    public int Decode(byte[]? input, int length, short[] output, int frame_size, bool decode_fec)
    Parameters
    Type Name Description
    byte[] input

    Input payload. Use null to indicate packet loss

    int length

    Number of bytes in payload.

    short[] output

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

    int frame_size

    Number of samples per channel of available space in pcm. If this is less than the maximum packet duration (120ms; 5760 for 48kHz), this function will not be capable of decoding some packets. In the case of PLC (data==NULL) or FEC (decode_fec=true), then frame_size needs to be exactly the duration of audio that is missing, otherwise the decoder will not be in the optimal state to decode the next incoming packet. For the PLC and FEC cases, frame_size must be a multiple of 2.5 ms.

    bool decode_fec

    Request that any in-band forward error correction data be decoded. If no such data is available, the frame is decoded as if it were lost.

    Returns
    Type Description
    int

    Number of decoded samples or OpusErrorCodes.

    | Edit this page View Source

    Decode(byte[]?, int, float[], int, bool)

    Decodes an opus encoded frame.

    Declaration
    public int Decode(byte[]? input, int length, float[] output, int frame_size, bool decode_fec)
    Parameters
    Type Name Description
    byte[] input

    Input payload. Use null to indicate packet loss

    int length

    Number of bytes in payload.

    float[] output

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

    int frame_size

    Number of samples per channel of available space in pcm. If this is less than the maximum packet duration (120ms; 5760 for 48kHz), this function will not be capable of decoding some packets. In the case of PLC (data==NULL) or FEC (decode_fec=true), then frame_size needs to be exactly the duration of audio that is missing, otherwise the decoder will not be in the optimal state to decode the next incoming packet. For the PLC and FEC cases, frame_size must be a multiple of 2.5 ms.

    bool decode_fec

    Request that any in-band forward error correction data be decoded. If no such data is available, the frame is decoded as if it were lost.

    Returns
    Type Description
    int

    Number of decoded samples or OpusErrorCodes.

    | Edit this page View Source

    Decode(Span<byte>, int, Span<byte>, int, bool)

    Decodes an opus encoded frame.

    Declaration
    public int Decode(Span<byte> input, int length, Span<byte> output, int frame_size, bool decode_fec)
    Parameters
    Type Name Description
    Span<byte> input

    Input payload. Use null to indicate packet loss

    int length

    Number of bytes in payload.

    Span<byte> output

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

    int frame_size

    Number of samples per channel of available space in pcm. If this is less than the maximum packet duration (120ms; 5760 for 48kHz), this function will not be capable of decoding some packets. In the case of PLC (data==NULL) or FEC (decode_fec=true), then frame_size needs to be exactly the duration of audio that is missing, otherwise the decoder will not be in the optimal state to decode the next incoming packet. For the PLC and FEC cases, frame_size must be a multiple of 2.5 ms.

    bool decode_fec

    Request that any in-band forward error correction data be decoded. If no such data is available, the frame is decoded as if it were lost.

    Returns
    Type Description
    int

    Number of decoded samples or OpusErrorCodes.

    | Edit this page View Source

    Decode(Span<byte>, int, Span<short>, int, bool)

    Decodes an opus encoded frame.

    Declaration
    public int Decode(Span<byte> input, int length, Span<short> output, int frame_size, bool decode_fec)
    Parameters
    Type Name Description
    Span<byte> input

    Input payload. Use null to indicate packet loss

    int length

    Number of bytes in payload.

    Span<short> output

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

    int frame_size

    Number of samples per channel of available space in pcm. If this is less than the maximum packet duration (120ms; 5760 for 48kHz), this function will not be capable of decoding some packets. In the case of PLC (data==NULL) or FEC (decode_fec=true), then frame_size needs to be exactly the duration of audio that is missing, otherwise the decoder will not be in the optimal state to decode the next incoming packet. For the PLC and FEC cases, frame_size must be a multiple of 2.5 ms.

    bool decode_fec

    Request that any in-band forward error correction data be decoded. If no such data is available, the frame is decoded as if it were lost.

    Returns
    Type Description
    int

    Number of decoded samples or OpusErrorCodes.

    | Edit this page View Source

    Decode(Span<byte>, int, Span<float>, int, bool)

    Decodes an opus encoded frame.

    Declaration
    public int Decode(Span<byte> input, int length, Span<float> output, int frame_size, bool decode_fec)
    Parameters
    Type Name Description
    Span<byte> input

    Input payload. Use null to indicate packet loss

    int length

    Number of bytes in payload.

    Span<float> output

    Output signal (interleaved if 2 channels). length is (frame_size*channels)/2. Note: I don't know if this is correct.

    int frame_size

    Number of samples per channel of available space in pcm. If this is less than the maximum packet duration (120ms; 5760 for 48kHz), this function will not be capable of decoding some packets. In the case of PLC (data==NULL) or FEC (decode_fec=true), then frame_size needs to be exactly the duration of audio that is missing, otherwise the decoder will not be in the optimal state to decode the next incoming packet. For the PLC and FEC cases, frame_size must be a multiple of 2.5 ms.

    bool decode_fec

    Request that any in-band forward error correction data be decoded. If no such data is available, the frame is decoded as if it were lost.

    Returns
    Type Description
    int

    Number of decoded samples or OpusErrorCodes.

    | 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

    ~OpusDecoder()

    Opus decoder destructor.

    Declaration
    protected ~OpusDecoder()
    | 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

    OpusDecoderExtensions.GetBandwidth(OpusDecoder)
    OpusDecoderExtensions.GetFinalRange(OpusDecoder)
    OpusDecoderExtensions.GetGain(OpusDecoder)
    OpusDecoderExtensions.GetLastPacketDuration(OpusDecoder)
    OpusDecoderExtensions.GetPhaseInversionDisabled(OpusDecoder)
    OpusDecoderExtensions.GetPitch(OpusDecoder)
    OpusDecoderExtensions.GetSampleRate(OpusDecoder)
    OpusDecoderExtensions.Reset(OpusDecoder)
    OpusDecoderExtensions.SetGain(OpusDecoder, short)
    OpusDecoderExtensions.SetPhaseInversionDisabled(OpusDecoder, bool)