Class NativeOpus
Native opus handler that directly calls the exported opus functions. Requires a dynamically loaded library.
Inherited Members
Namespace: OpusSharp.Core
Assembly: OpusSharp.Core.dll
Syntax
public static class NativeOpus
Methods
opus_decode(OpusDecoderSafeHandle, byte*, int, short*, int, int)
Decode an Opus packet.
Declaration
public static extern int opus_decode(OpusDecoderSafeHandle st, byte* data, int len, short* pcm, int frame_size, int decode_fec)
Parameters
| Type | Name | Description |
|---|---|---|
| OpusDecoderSafeHandle | st | Decoder state. |
| byte* | data | Input payload. Use a NULL pointer to indicate packet loss. |
| int | len | Number of bytes in payload. |
| short* | pcm | 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=1), 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. |
| int | decode_fec | Flag (0 or 1) to 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. |
opus_decode_float(OpusDecoderSafeHandle, byte*, int, float*, int, int)
Decode an Opus packet with floating point output.
Declaration
public static extern int opus_decode_float(OpusDecoderSafeHandle st, byte* data, int len, float* pcm, int frame_size, int decode_fec)
Parameters
| Type | Name | Description |
|---|---|---|
| OpusDecoderSafeHandle | st | Decoder state. |
| byte* | data | Input payload. Use a NULL pointer to indicate packet loss. |
| int | len | Number of bytes in payload. |
| float* | pcm | 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=1), 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. |
| int | decode_fec | Flag (0 or 1) to 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 |
opus_decoder_create(int, int, int*)
Allocates and initializes a OpusDecoderSafeHandle state.
Declaration
public static extern OpusDecoderSafeHandle opus_decoder_create(int Fs, int channels, int* error)
Parameters
| Type | Name | Description |
|---|---|---|
| int | Fs | Sample rate to decode at (Hz). This must be one of 8000, 12000, 16000, 24000, or 48000. |
| int | channels | Number of channels (1 or 2) to decode. |
| int* | error | OPUS_OK Success or OpusErrorCodes. |
Returns
| Type | Description |
|---|---|
| OpusDecoderSafeHandle |
opus_decoder_ctl(OpusDecoderSafeHandle, int)
Perform a CTL function on an OpusDecoderSafeHandle.
Declaration
public static extern int opus_decoder_ctl(OpusDecoderSafeHandle st, int request)
Parameters
| Type | Name | Description |
|---|---|---|
| OpusDecoderSafeHandle | st | Decoder state. |
| int | request | This and all remaining parameters should be replaced by one of the convenience macros in GenericCTL or DecoderCTL. |
Returns
| Type | Description |
|---|---|
| int |
opus_decoder_ctl(OpusDecoderSafeHandle, int, int)
Perform a CTL function on an OpusDecoderSafeHandle.
Declaration
public static extern int opus_decoder_ctl(OpusDecoderSafeHandle st, int request, int data)
Parameters
| Type | Name | Description |
|---|---|---|
| OpusDecoderSafeHandle | st | Decoder state. |
| int | request | This and all remaining parameters should be replaced by one of the convenience macros in GenericCTL or DecoderCTL. |
| int | data | The data to input. |
Returns
| Type | Description |
|---|---|
| int |
opus_decoder_ctl(OpusDecoderSafeHandle, int, void*)
Perform a CTL function on an OpusDecoderSafeHandle.
Declaration
public static extern int opus_decoder_ctl(OpusDecoderSafeHandle st, int request, void* data)
Parameters
| Type | Name | Description |
|---|---|---|
| OpusDecoderSafeHandle | st | Decoder state. |
| int | request | This and all remaining parameters should be replaced by one of the convenience macros in GenericCTL or DecoderCTL. |
| void* | data | The data to input or output. |
Returns
| Type | Description |
|---|---|
| int |
opus_decoder_destroy(IntPtr)
Frees an OpusDecoderSafeHandle allocated by opus_decoder_create(int, int, int*).
Declaration
public static extern void opus_decoder_destroy(IntPtr st)
Parameters
| Type | Name | Description |
|---|---|---|
| IntPtr | st | State to be freed. |
opus_decoder_dred_decode(OpusDecoderSafeHandle, OpusDREDSafeHandle, int, short*, int)
Decode audio from an OpusDREDSafeHandle packet with floating point output.
Declaration
public static extern int opus_decoder_dred_decode(OpusDecoderSafeHandle st, OpusDREDSafeHandle dred, int dred_offset, short* pcm, int frame_size)
Parameters
| Type | Name | Description |
|---|---|---|
| OpusDecoderSafeHandle | st | Decoder state. |
| OpusDREDSafeHandle | dred | DRED state. |
| int | dred_offset | position of the redundancy to decode (in samples before the beginning of the real audio data in the packet). |
| short* | pcm | Output signal (interleaved if 2 channels). length is frame_sizechannelssizeof(short) |
| int | frame_size | Number of samples per channel to decode in pcm. frame_size must be a multiple of 2.5 ms. |
Returns
| Type | Description |
|---|---|
| int | Number of decoded samples or OpusErrorCodes. |
opus_decoder_dred_decode_float(OpusDecoderSafeHandle, OpusDREDSafeHandle, int, float*, int)
Decode audio from an OpusDREDSafeHandle packet with floating point output.
Declaration
public static extern int opus_decoder_dred_decode_float(OpusDecoderSafeHandle st, OpusDREDSafeHandle dred, int dred_offset, float* pcm, int frame_size)
Parameters
| Type | Name | Description |
|---|---|---|
| OpusDecoderSafeHandle | st | Decoder state. |
| OpusDREDSafeHandle | dred | DRED state. |
| int | dred_offset | position of the redundancy to decode (in samples before the beginning of the real audio data in the packet). |
| float* | pcm | Output signal (interleaved if 2 channels). length is frame_sizechannelssizeof(float). |
| int | frame_size | Number of samples per channel to decode in pcm. frame_size must be a multiple of 2.5 ms. |
Returns
| Type | Description |
|---|---|
| int | Number of decoded samples or OpusErrorCodes. |
opus_decoder_get_nb_samples(OpusDecoderSafeHandle, byte*, int)
Gets the number of samples of an Opus packet.
Declaration
public static extern int opus_decoder_get_nb_samples(OpusDecoderSafeHandle dec, byte* packet, int len)
Parameters
| Type | Name | Description |
|---|---|---|
| OpusDecoderSafeHandle | dec | Decoder state. |
| byte* | packet | Opus packet. |
| int | len | Length of packet. |
Returns
| Type | Description |
|---|---|
| int | Number of samples or OpusErrorCodes. |
opus_decoder_get_size(int)
Gets the size of an OpusDecoderSafeHandle structure.
Declaration
public static extern int opus_decoder_get_size(int channels)
Parameters
| Type | Name | Description |
|---|---|---|
| int | channels | Number of channels. This must be 1 or 2. |
Returns
| Type | Description |
|---|---|
| int | The size in bytes. |
opus_decoder_init(OpusDecoderSafeHandle, int, int)
Initializes a previously allocated OpusDecoderSafeHandle state.
Declaration
public static extern int opus_decoder_init(OpusDecoderSafeHandle st, int Fs, int channels)
Parameters
| Type | Name | Description |
|---|---|---|
| OpusDecoderSafeHandle | st | Decoder state. |
| int | Fs | Sampling rate to decode to (Hz). This must be one of 8000, 12000, 16000, 24000, or 48000. |
| int | channels | Number of channels (1 or 2) to decode. |
Returns
| Type | Description |
|---|---|
| int | OPUS_OK Success or OpusErrorCodes. |
opus_dred_alloc(int*)
Allocates and initializes a OpusDREDSafeHandle state.
Declaration
public static extern OpusDREDSafeHandle opus_dred_alloc(int* error)
Parameters
| Type | Name | Description |
|---|---|---|
| int* | error | OPUS_OK Success or OpusErrorCodes. |
Returns
| Type | Description |
|---|---|
| OpusDREDSafeHandle |
opus_dred_decoder_create(int*)
Allocates and initializes an OpusDREDDecoderSafeHandle state.
Declaration
public static extern OpusDREDDecoderSafeHandle opus_dred_decoder_create(int* error)
Parameters
| Type | Name | Description |
|---|---|---|
| int* | error | OPUS_OK Success or OpusErrorCodes. |
Returns
| Type | Description |
|---|---|
| OpusDREDDecoderSafeHandle |
opus_dred_decoder_ctl(OpusDREDDecoderSafeHandle, int)
Perform a CTL function on an OpusDREDDecoderSafeHandle.
Declaration
public static extern int opus_dred_decoder_ctl(OpusDREDDecoderSafeHandle dred_dec, int request)
Parameters
| Type | Name | Description |
|---|---|---|
| OpusDREDDecoderSafeHandle | dred_dec | DRED Decoder state. |
| int | request | This and all remaining parameters should be replaced by one of the convenience macros in GenericCTL or DecoderCTL. |
Returns
| Type | Description |
|---|---|
| int |
opus_dred_decoder_ctl(OpusDREDDecoderSafeHandle, int, void*)
Perform a CTL function on an OpusDREDDecoderSafeHandle.
Declaration
public static extern int opus_dred_decoder_ctl(OpusDREDDecoderSafeHandle dred_dec, int request, void* data)
Parameters
| Type | Name | Description |
|---|---|---|
| OpusDREDDecoderSafeHandle | dred_dec | DRED Decoder state. |
| int | request | This and all remaining parameters should be replaced by one of the convenience macros in GenericCTL or DecoderCTL. |
| void* | data | The data to input or output. |
Returns
| Type | Description |
|---|---|
| int |
opus_dred_decoder_destroy(IntPtr)
Frees an OpusDREDDecoderSafeHandle allocated by opus_dred_decoder_create(int*).
Declaration
public static extern void opus_dred_decoder_destroy(IntPtr dec)
Parameters
| Type | Name | Description |
|---|---|---|
| IntPtr | dec | State to be freed. |
opus_dred_decoder_get_size()
Gets the size of an OpusDREDDecoderSafeHandle structure.
Declaration
public static extern int opus_dred_decoder_get_size()
Returns
| Type | Description |
|---|---|
| int | The size in bytes. |
opus_dred_decoder_init(OpusDREDDecoderSafeHandle)
Initializes an OpusDREDDecoderSafeHandle state.
Declaration
public static extern int opus_dred_decoder_init(OpusDREDDecoderSafeHandle dec)
Parameters
| Type | Name | Description |
|---|---|---|
| OpusDREDDecoderSafeHandle | dec | State to be initialized. |
Returns
| Type | Description |
|---|---|
| int |
opus_dred_free(IntPtr)
Frees an OpusDREDSafeHandle allocated by opus_dred_alloc(int*).
Declaration
public static extern void opus_dred_free(IntPtr dec)
Parameters
| Type | Name | Description |
|---|---|---|
| IntPtr | dec | State to be freed. |
opus_dred_get_size()
Gets the size of an OpusDREDSafeHandle structure.
Declaration
public static extern int opus_dred_get_size()
Returns
| Type | Description |
|---|---|
| int | The size in bytes. |
opus_dred_parse(OpusDREDDecoderSafeHandle, OpusDREDSafeHandle, byte*, int, int, int, int*, int)
Decode an Opus DRED packet.
Declaration
public static extern int opus_dred_parse(OpusDREDDecoderSafeHandle dred_dec, OpusDREDSafeHandle dred, byte* data, int len, int max_dred_samples, int sampling_rate, int* dred_end, int defer_processing)
Parameters
| Type | Name | Description |
|---|---|---|
| OpusDREDDecoderSafeHandle | dred_dec | DRED Decoder state. |
| OpusDREDSafeHandle | dred | DRED state. |
| byte* | data | Input payload. |
| int | len | Number of bytes in payload. |
| int | max_dred_samples | Maximum number of DRED samples that may be needed (if available in the packet). |
| int | sampling_rate | Sampling rate used for max_dred_samples argument. Needs not match the actual sampling rate of the decoder. |
| int* | dred_end | Number of non-encoded (silence) samples between the DRED timestamp and the last DRED sample. |
| int | defer_processing | Flag (0 or 1). If set to one, the CPU-intensive part of the DRED decoding is deferred until opus_dred_process(OpusDREDDecoderSafeHandle, OpusDREDSafeHandle, OpusDREDSafeHandle) is called. |
Returns
| Type | Description |
|---|---|
| int | Offset (positive) of the first decoded DRED samples, zero if no DRED is present, or OpusErrorCodes |
opus_dred_process(OpusDREDDecoderSafeHandle, OpusDREDSafeHandle, OpusDREDSafeHandle)
Finish decoding an OpusDREDSafeHandle packet.
Declaration
public static extern int opus_dred_process(OpusDREDDecoderSafeHandle dred_dec, OpusDREDSafeHandle src, OpusDREDSafeHandle dst)
Parameters
| Type | Name | Description |
|---|---|---|
| OpusDREDDecoderSafeHandle | dred_dec | DRED Decoder state. |
| OpusDREDSafeHandle | src | Source DRED state to start the processing from. |
| OpusDREDSafeHandle | dst | Destination DRED state to store the updated state after processing. |
Returns
| Type | Description |
|---|---|
| int |
opus_encode(OpusEncoderSafeHandle, short*, int, byte*, int)
Encodes an Opus frame.
Declaration
public static extern int opus_encode(OpusEncoderSafeHandle st, short* pcm, int frame_size, byte* data, int max_data_bytes)
Parameters
| Type | Name | Description |
|---|---|---|
| OpusEncoderSafeHandle | st | Encoder state. |
| short* | pcm | Input signal (interleaved if 2 channels). length is frame_sizechannelssizeof(short) |
| int | frame_size | Number of samples per channel in the input signal. 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* | data | 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) on success or a negative error code (see OpusErrorCodes) on failure. |
opus_encode_float(OpusEncoderSafeHandle, float*, int, byte*, int)
Encodes an Opus frame from floating point input.
Declaration
public static extern int opus_encode_float(OpusEncoderSafeHandle st, float* pcm, int frame_size, byte* data, int max_data_bytes)
Parameters
| Type | Name | Description |
|---|---|---|
| OpusEncoderSafeHandle | st | Encoder state. |
| float* | pcm | Input in float format (interleaved if 2 channels), with a normal range of +/-1.0. Samples with a range beyond +/-1.0 are supported but will be clipped by decoders using the integer API and should only be used if it is known that the far end supports extended dynamic range. length is frame_sizechannelssizeof(float) |
| int | frame_size | Number of samples per channel in the input signal. 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* | data | 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) on success or a negative error code (see OpusErrorCodes) on failure. |
opus_encoder_create(int, int, int, int*)
Allocates and initializes an encoder state.
Declaration
public static extern OpusEncoderSafeHandle opus_encoder_create(int Fs, int channels, int application, int* error)
Parameters
| Type | Name | Description |
|---|---|---|
| int | Fs | Sampling rate of input signal (Hz) This must be one of 8000, 12000, 16000, 24000, or 48000. |
| int | channels | Number of channels (1 or 2) in input signal. |
| int | application | Coding mode (one of OPUS_APPLICATION_VOIP, OPUS_APPLICATION_AUDIO or OPUS_APPLICATION_RESTRICTED_LOWDELAY) |
| int* | error | OPUS_OK Success or OpusErrorCodes. |
Returns
| Type | Description |
|---|---|
| OpusEncoderSafeHandle |
opus_encoder_ctl(OpusEncoderSafeHandle, int)
Perform a CTL function on an OpusEncoderSafeHandle.
Declaration
public static extern int opus_encoder_ctl(OpusEncoderSafeHandle st, int request)
Parameters
| Type | Name | Description |
|---|---|---|
| OpusEncoderSafeHandle | st | Encoder state. |
| int | request | This and all remaining parameters should be replaced by one of the convenience macros in GenericCTL or EncoderCTL. |
Returns
| Type | Description |
|---|---|
| int |
opus_encoder_ctl(OpusEncoderSafeHandle, int, int)
Perform a CTL function on an OpusEncoderSafeHandle.
Declaration
public static extern int opus_encoder_ctl(OpusEncoderSafeHandle st, int request, int data)
Parameters
| Type | Name | Description |
|---|---|---|
| OpusEncoderSafeHandle | st | Encoder state. |
| int | request | This and all remaining parameters should be replaced by one of the convenience macros in GenericCTL or EncoderCTL. |
| int | data | The data to input. |
Returns
| Type | Description |
|---|---|
| int |
opus_encoder_ctl(OpusEncoderSafeHandle, int, int, void*)
Perform a CTL function on an Opus encoder.
Declaration
public static extern int opus_encoder_ctl(OpusEncoderSafeHandle st, int request, int data, void* data2)
Parameters
| Type | Name | Description |
|---|---|---|
| OpusEncoderSafeHandle | st | Encoder state. |
| int | request | This and all remaining parameters should be replaced by one of the convenience macros in GenericCTL or EncoderCTL. |
| int | data | The data to input. |
| void* | data2 | The second data to input/output. |
Returns
| Type | Description |
|---|---|
| int |
opus_encoder_ctl(OpusEncoderSafeHandle, int, void*)
Perform a CTL function on an OpusEncoderSafeHandle.
Declaration
public static extern int opus_encoder_ctl(OpusEncoderSafeHandle st, int request, void* data)
Parameters
| Type | Name | Description |
|---|---|---|
| OpusEncoderSafeHandle | st | Encoder state. |
| int | request | This and all remaining parameters should be replaced by one of the convenience macros in GenericCTL or EncoderCTL. |
| void* | data | The data to input/output. |
Returns
| Type | Description |
|---|---|
| int |
opus_encoder_ctl(OpusEncoderSafeHandle, int, void*, int)
Perform a CTL function on an Opus encoder.
Declaration
public static extern int opus_encoder_ctl(OpusEncoderSafeHandle st, int request, void* data, int data2)
Parameters
| Type | Name | Description |
|---|---|---|
| OpusEncoderSafeHandle | st | Encoder state. |
| int | request | This and all remaining parameters should be replaced by one of the convenience macros in GenericCTL or EncoderCTL. |
| void* | data | The data to input/output. |
| int | data2 | The second data to input. |
Returns
| Type | Description |
|---|---|
| int |
opus_encoder_ctl(OpusEncoderSafeHandle, int, void*, void*)
Perform a CTL function on an Opus encoder.
Declaration
public static extern int opus_encoder_ctl(OpusEncoderSafeHandle st, int request, void* data, void* data2)
Parameters
| Type | Name | Description |
|---|---|---|
| OpusEncoderSafeHandle | st | Encoder state. |
| int | request | This and all remaining parameters should be replaced by one of the convenience macros in GenericCTL or EncoderCTL. |
| void* | data | The data to input/output. |
| void* | data2 | The second data to input/output. |
Returns
| Type | Description |
|---|---|
| int |
opus_encoder_destroy(IntPtr)
Frees an OpusEncoderSafeHandle allocated by opus_encoder_create(int, int, int, int*).
Declaration
public static extern void opus_encoder_destroy(IntPtr st)
Parameters
| Type | Name | Description |
|---|---|---|
| IntPtr | st | State to be freed. |
opus_encoder_get_size(int)
Gets the size of an OpusEncoderSafeHandle structure.
Declaration
public static extern int opus_encoder_get_size(int channels)
Parameters
| Type | Name | Description |
|---|---|---|
| int | channels | Number of channels. This must be 1 or 2. |
Returns
| Type | Description |
|---|---|
| int | The size in bytes. |
opus_encoder_init(OpusEncoderSafeHandle, int, int, int)
Initializes a previously allocated OpusEncoderSafeHandle state. The memory pointed to by st must be at least the size returned by opus_encoder_get_size(int).
Declaration
public static extern int opus_encoder_init(OpusEncoderSafeHandle st, int Fs, int channels, int application)
Parameters
| Type | Name | Description |
|---|---|---|
| OpusEncoderSafeHandle | st | Encoder state. |
| int | Fs | Sampling rate of input signal (Hz) This must be one of 8000, 12000, 16000, 24000, or 48000. |
| int | channels | Number of channels (1 or 2) in input signal. |
| int | application |
|
Returns
| Type | Description |
|---|---|
| int |
opus_get_version_string()
Gets the libopus version string.
Declaration
public static extern byte* opus_get_version_string()
Returns
| Type | Description |
|---|---|
| byte* | Version string |
opus_multistream_decode(OpusMSDecoderSafeHandle, byte*, int, short*, int, int)
Decode a multistream Opus packet.
Declaration
public static extern int opus_multistream_decode(OpusMSDecoderSafeHandle st, byte* data, int len, short* pcm, int frame_size, int decode_fec)
Parameters
| Type | Name | Description |
|---|---|---|
| OpusMSDecoderSafeHandle | st | Multistream decoder state. |
| byte* | data | Input payload. Use a NULL pointer to indicate packet loss. |
| int | len | Number of bytes in payload. |
| short* | pcm | Output signal, with interleaved samples. This must contain room for frame_size*channels samples. |
| int | frame_size | The number of samples per channel of available space in pcm. If this is less than the maximum packet duration (120 ms; 5760 for 48kHz), this function will not be capable of decoding some packets. In the case of PLC (data==NULL) or FEC (decode_fec=1), 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. |
| int | decode_fec | Flag (0 or 1) to 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 samples decoded on success or a negative error code (see OpusErrorCodes) on failure. |
opus_multistream_decode_float(OpusMSDecoderSafeHandle, byte*, int, float*, int, int)
Decode a multistream Opus packet with floating point output.
Declaration
public static extern int opus_multistream_decode_float(OpusMSDecoderSafeHandle st, byte* data, int len, float* pcm, int frame_size, int decode_fec)
Parameters
| Type | Name | Description |
|---|---|---|
| OpusMSDecoderSafeHandle | st | Multistream decoder state. |
| byte* | data | Input payload. Use a NULL pointer to indicate packet loss. |
| int | len | Number of bytes in payload. |
| float* | pcm | Output signal, with interleaved samples. This must contain room for frame_size*channels samples. |
| int | frame_size | The number of samples per channel of available space in pcm. If this is less than the maximum packet duration (120 ms; 5760 for 48kHz), this function will not be capable of decoding some packets. In the case of PLC (data==NULL) or FEC (decode_fec=1), 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. |
| int | decode_fec | Flag (0 or 1) to 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 samples decoded on success or a negative error code (see OpusErrorCodes) on failure. |
opus_multistream_decoder_create(int, int, int, int, byte*, int*)
Allocates and initializes a OpusMSDecoderSafeHandle state.
Declaration
public static extern OpusMSDecoderSafeHandle opus_multistream_decoder_create(int Fs, int channels, int streams, int coupled_streams, byte* mapping, int* error)
Parameters
| Type | Name | Description |
|---|---|---|
| int | Fs | Sampling rate to decode at (in Hz). This must be one of 8000, 12000, 16000, 24000, or 48000. |
| int | channels | Number of channels to output. This must be at most 255. It may be different from the number of coded channels (streams + coupled_streams). |
| int | streams | The total number of streams coded in the input. This must be no more than 255. |
| int | coupled_streams | Number of streams to decode as coupled (2 channel) streams. This must be no larger than the total number of streams. Additionally, The total number of coded channels (streams + coupled_streams) must be no more than 255. |
| byte* | mapping | Mapping from coded channels to output channels, as described in Opus Multistream API. |
| int* | error | Returns OPUS_OK on success, or an error code (see OpusErrorCodes) on failure. |
Returns
| Type | Description |
|---|---|
| OpusMSDecoderSafeHandle |
opus_multistream_decoder_ctl(OpusMSDecoderSafeHandle, int)
Perform a CTL function on a OpusMSEncoderSafeHandle.
Declaration
public static extern int opus_multistream_decoder_ctl(OpusMSDecoderSafeHandle st, int request)
Parameters
| Type | Name | Description |
|---|---|---|
| OpusMSDecoderSafeHandle | st | Multistream decoder state. |
| int | request | This and all remaining parameters should be replaced by one of the convenience macros in GenericCTL, DecoderCTL, or MultistreamCTL specific encoder and decoder CTLs. |
Returns
| Type | Description |
|---|---|
| int |
opus_multistream_decoder_ctl(OpusMSDecoderSafeHandle, int, int)
Perform a CTL function on a OpusMSEncoderSafeHandle.
Declaration
public static extern int opus_multistream_decoder_ctl(OpusMSDecoderSafeHandle st, int request, int data)
Parameters
| Type | Name | Description |
|---|---|---|
| OpusMSDecoderSafeHandle | st | Multistream decoder state. |
| int | request | This and all remaining parameters should be replaced by one of the convenience macros in GenericCTL, DecoderCTL, or MultistreamCTL specific encoder and decoder CTLs. |
| int | data | The input data. |
Returns
| Type | Description |
|---|---|
| int |
opus_multistream_decoder_ctl(OpusMSDecoderSafeHandle, int, void*)
Perform a CTL function on a OpusMSEncoderSafeHandle.
Declaration
public static extern int opus_multistream_decoder_ctl(OpusMSDecoderSafeHandle st, int request, void* data)
Parameters
| Type | Name | Description |
|---|---|---|
| OpusMSDecoderSafeHandle | st | Multistream decoder state. |
| int | request | This and all remaining parameters should be replaced by one of the convenience macros in GenericCTL, DecoderCTL, or MultistreamCTL specific encoder and decoder CTLs. |
| void* | data | The input/output data. |
Returns
| Type | Description |
|---|---|
| int |
opus_multistream_decoder_destroy(IntPtr)
Frees an OpusMSDecoderSafeHandle allocated by opus_multistream_decoder_create(int, int, int, int, byte*, int*).
Declaration
public static extern void opus_multistream_decoder_destroy(IntPtr st)
Parameters
| Type | Name | Description |
|---|---|---|
| IntPtr | st | Multistream decoder state to be freed. |
opus_multistream_decoder_get_size(int, int)
Gets the size of an OpusMSDecoderSafeHandle structure.
Declaration
public static extern int opus_multistream_decoder_get_size(int streams, int coupled_streams)
Parameters
| Type | Name | Description |
|---|---|---|
| int | streams | The total number of streams coded in the input. This must be no more than 255. |
| int | coupled_streams | Number streams to decode as coupled (2 channel) streams. This must be no larger than the total number of streams. Additionally, The total number of coded channels (streams + coupled_streams) must be no more than 255. |
Returns
| Type | Description |
|---|---|
| int | The size in bytes on success, or a negative error code (see OpusErrorCodes) on error. |
opus_multistream_decoder_init(OpusMSDecoderSafeHandle, int, int, int, int, byte*)
Initialize a previously allocated OpusMSDecoderSafeHandle state object.
Declaration
public static extern int opus_multistream_decoder_init(OpusMSDecoderSafeHandle st, int Fs, int channels, int streams, int coupled_streams, byte* mapping)
Parameters
| Type | Name | Description |
|---|---|---|
| OpusMSDecoderSafeHandle | st | Multistream encoder state to initialize. |
| int | Fs | Sampling rate to decode at (in Hz). This must be one of 8000, 12000, 16000, 24000, or 48000. |
| int | channels | Number of channels to output. This must be at most 255. It may be different from the number of coded channels (streams + coupled_streams). |
| int | streams | The total number of streams coded in the input. This must be no more than 255. |
| int | coupled_streams | Number of streams to decode as coupled (2 channel) streams. This must be no larger than the total number of streams. Additionally, The total number of coded channels (streams + coupled_streams) must be no more than 255. |
| byte* | mapping | Mapping from coded channels to output channels, as described in Opus Multistream API. |
Returns
| Type | Description |
|---|---|
| int | OPUS_OK on success, or an error code (see OpusErrorCodes) on failure. |
opus_multistream_encode(OpusMSEncoderSafeHandle, short*, int, byte*, int)
Encodes a multistream Opus frame.
Declaration
public static extern int opus_multistream_encode(OpusMSEncoderSafeHandle st, short* pcm, int frame_size, byte* data, int max_data_bytes)
Parameters
| Type | Name | Description |
|---|---|---|
| OpusMSEncoderSafeHandle | st | Multistream encoder state. |
| short* | pcm | The input signal as interleaved samples. This must contain frame_size*channels samples. |
| int | frame_size | Number of samples per channel in the input signal. 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* | data | 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) on success or a negative error code (see OpusErrorCodes) on failure. |
opus_multistream_encode_float(OpusMSEncoderSafeHandle, float*, int, byte*, int)
Encodes a multistream Opus frame from floating point input.
Declaration
public static extern int opus_multistream_encode_float(OpusMSEncoderSafeHandle st, float* pcm, int frame_size, byte* data, int max_data_bytes)
Parameters
| Type | Name | Description |
|---|---|---|
| OpusMSEncoderSafeHandle | st | Multistream encoder state. |
| float* | pcm | The input signal as interleaved samples with a normal range of +/-1.0. Samples with a range beyond +/-1.0 are supported but will be clipped by decoders using the integer API and should only be used if it is known that the far end supports extended dynamic range. This must contain frame_size*channels samples. |
| int | frame_size | Number of samples per channel in the input signal. 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* | data | 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) on success or a negative error code (see OpusErrorCodes) on failure. |
opus_multistream_encoder_create(int, int, int, int, byte*, int, int*)
Allocates and initializes a OpusMSEncoderSafeHandle state.
Declaration
public static extern OpusMSEncoderSafeHandle opus_multistream_encoder_create(int Fs, int channels, int streams, int coupled_streams, byte* mapping, int application, int* error)
Parameters
| Type | Name | Description |
|---|---|---|
| int | Fs | Sampling rate of the input signal (in Hz). This must be one of 8000, 12000, 16000, 24000, or 48000. |
| int | channels | Number of channels in the input signal. This must be at most 255. It may be greater than the number of coded channels (streams + coupled_streams). |
| int | streams | The total number of streams to encode from the input. This must be no more than the number of channels. |
| int | coupled_streams | Number of coupled (2 channel) streams to encode. This must be no larger than the total number of streams. Additionally, The total number of encoded channels (streams + coupled_streams) must be no more than the number of input channels. |
| byte* | mapping | Mapping from encoded channels to input channels, as described in Opus Multistream API. As an extra constraint, the multistream encoder does not allow encoding coupled streams for which one channel is unused since this is never a good idea. |
| int | application | The target encoder application. This must be one of the following: OPUS_APPLICATION_VOIP, OPUS_APPLICATION_AUDIO or OPUS_APPLICATION_RESTRICTED_LOWDELAY. |
| int* | error | Returns OPUS_OK on success, or an error code (see OpusErrorCodes) on failure. |
Returns
| Type | Description |
|---|---|
| OpusMSEncoderSafeHandle |
opus_multistream_encoder_ctl(OpusMSEncoderSafeHandle, int)
Perform a CTL function on a OpusMSEncoderSafeHandle.
Declaration
public static extern int opus_multistream_encoder_ctl(OpusMSEncoderSafeHandle st, int request)
Parameters
| Type | Name | Description |
|---|---|---|
| OpusMSEncoderSafeHandle | st | Multistream encoder state. |
| int | request | This and all remaining parameters should be replaced by one of the convenience macros in GenericCTL, EncoderCTL, or MultistreamCTL specific encoder and decoder CTLs. |
Returns
| Type | Description |
|---|---|
| int |
opus_multistream_encoder_ctl(OpusMSEncoderSafeHandle, int, int)
Perform a CTL function on a OpusMSEncoderSafeHandle.
Declaration
public static extern int opus_multistream_encoder_ctl(OpusMSEncoderSafeHandle st, int request, int data)
Parameters
| Type | Name | Description |
|---|---|---|
| OpusMSEncoderSafeHandle | st | Multistream encoder state. |
| int | request | This and all remaining parameters should be replaced by one of the convenience macros in GenericCTL, EncoderCTL, or MultistreamCTL specific encoder and decoder CTLs. |
| int | data | The input data. |
Returns
| Type | Description |
|---|---|
| int |
opus_multistream_encoder_ctl(OpusMSEncoderSafeHandle, int, int, void*)
Perform a CTL function on a OpusMSEncoderSafeHandle.
Declaration
public static extern int opus_multistream_encoder_ctl(OpusMSEncoderSafeHandle st, int request, int data, void* data2)
Parameters
| Type | Name | Description |
|---|---|---|
| OpusMSEncoderSafeHandle | st | Multistream encoder state. |
| int | request | This and all remaining parameters should be replaced by one of the convenience macros in GenericCTL, EncoderCTL, or MultistreamCTL specific encoder and decoder CTLs. |
| int | data | The input data. |
| void* | data2 | The input/output data. |
Returns
| Type | Description |
|---|---|
| int |
opus_multistream_encoder_ctl(OpusMSEncoderSafeHandle, int, void*)
Perform a CTL function on a OpusMSEncoderSafeHandle.
Declaration
public static extern int opus_multistream_encoder_ctl(OpusMSEncoderSafeHandle st, int request, void* data)
Parameters
| Type | Name | Description |
|---|---|---|
| OpusMSEncoderSafeHandle | st | Multistream encoder state. |
| int | request | This and all remaining parameters should be replaced by one of the convenience macros in GenericCTL, EncoderCTL, or MultistreamCTL specific encoder and decoder CTLs. |
| void* | data | The input/output data. |
Returns
| Type | Description |
|---|---|
| int |
opus_multistream_encoder_ctl(OpusMSEncoderSafeHandle, int, void*, int)
Perform a CTL function on a OpusMSEncoderSafeHandle.
Declaration
public static extern int opus_multistream_encoder_ctl(OpusMSEncoderSafeHandle st, int request, void* data, int data2)
Parameters
| Type | Name | Description |
|---|---|---|
| OpusMSEncoderSafeHandle | st | Multistream encoder state. |
| int | request | This and all remaining parameters should be replaced by one of the convenience macros in GenericCTL, EncoderCTL, or MultistreamCTL specific encoder and decoder CTLs. |
| void* | data | The input/output data. |
| int | data2 | The input data. |
Returns
| Type | Description |
|---|---|
| int |
opus_multistream_encoder_ctl(OpusMSEncoderSafeHandle, int, void*, void*)
Perform a CTL function on a OpusMSEncoderSafeHandle.
Declaration
public static extern int opus_multistream_encoder_ctl(OpusMSEncoderSafeHandle st, int request, void* data, void* data2)
Parameters
| Type | Name | Description |
|---|---|---|
| OpusMSEncoderSafeHandle | st | Multistream encoder state. |
| int | request | This and all remaining parameters should be replaced by one of the convenience macros in GenericCTL, EncoderCTL, or MultistreamCTL specific encoder and decoder CTLs. |
| void* | data | The input/output data. |
| void* | data2 | The input/output data. |
Returns
| Type | Description |
|---|---|
| int |
opus_multistream_encoder_destroy(IntPtr)
Frees an OpusMSEncoderSafeHandle allocated by opus_multistream_encoder_create(int, int, int, int, byte*, int, int*).
Declaration
public static extern void opus_multistream_encoder_destroy(IntPtr st)
Parameters
| Type | Name | Description |
|---|---|---|
| IntPtr | st | Multistream encoder state to be freed. |
opus_multistream_encoder_get_size(int, int)
Gets the size of an OpusMSEncoderSafeHandle structure.
Declaration
public static extern int opus_multistream_encoder_get_size(int streams, int coupled_streams)
Parameters
| Type | Name | Description |
|---|---|---|
| int | streams | The total number of streams to encode from the input. This must be no more than 255. |
| int | coupled_streams | Number of coupled (2 channel) streams to encode. This must be no larger than the total number of streams. Additionally, The total number of encoded channels (streams + coupled_streams) must be no more than 255. |
Returns
| Type | Description |
|---|---|
| int | The size in bytes on success, or a negative error code (see OpusErrorCodes) on error. |
opus_multistream_encoder_init(OpusMSEncoderSafeHandle, int, int, int, int, byte*, int)
Initialize a previously allocated OpusMSEncoderSafeHandle state.
Declaration
public static extern int opus_multistream_encoder_init(OpusMSEncoderSafeHandle st, int Fs, int channels, int streams, int coupled_streams, byte* mapping, int application)
Parameters
| Type | Name | Description |
|---|---|---|
| OpusMSEncoderSafeHandle | st | Multistream encoder state to initialize. |
| int | Fs | Sampling rate of the input signal (in Hz). This must be one of 8000, 12000, 16000, 24000, or 48000. |
| int | channels | Number of channels in the input signal. This must be at most 255. It may be greater than the number of coded channels (streams + coupled_streams). |
| int | streams | The total number of streams to encode from the input. This must be no more than the number of channels. |
| int | coupled_streams | Number of coupled (2 channel) streams to encode. This must be no larger than the total number of streams. Additionally, The total number of encoded channels (streams + coupled_streams) must be no more than the number of input channels. |
| byte* | mapping | Mapping from encoded channels to input channels, as described in Opus Multistream API. As an extra constraint, the multistream encoder does not allow encoding coupled streams for which one channel is unused since this is never a good idea. |
| int | application | The target encoder application. This must be one of the following: OPUS_APPLICATION_VOIP, OPUS_APPLICATION_AUDIO or OPUS_APPLICATION_RESTRICTED_LOWDELAY. |
Returns
| Type | Description |
|---|---|
| int | OPUS_OK on success, or an error code (see OpusErrorCodes) on failure. |
opus_multistream_packet_pad(byte*, int, int, int)
Pads a given Opus multi-stream packet to a larger size (possibly changing the TOC sequence).
Declaration
public static extern int opus_multistream_packet_pad(byte* data, int len, int new_len, int nb_streams)
Parameters
| Type | Name | Description |
|---|---|---|
| byte* | data | The buffer containing the packet to pad. |
| int | len | The size of the packet. This must be at least 1. |
| int | new_len | The desired size of the packet after padding. This must be at least 1. |
| int | nb_streams | The number of streams (not channels) in the packet. This must be at least as large as len. |
Returns
| Type | Description |
|---|---|
| int |
opus_multistream_packet_unpad(byte*, int, int)
Remove all padding from a given Opus multi-stream packet and rewrite the TOC sequence to minimize space usage.
Declaration
public static extern int opus_multistream_packet_unpad(byte* data, int len, int nb_streams)
Parameters
| Type | Name | Description |
|---|---|---|
| byte* | data | The buffer containing the packet to strip. |
| int | len | The size of the packet. This must be at least 1. |
| int | nb_streams | The number of streams (not channels) in the packet. This must be at least 1. |
Returns
| Type | Description |
|---|---|
| int | The new size of the output packet on success, or an OpusErrorCodes on failure. |
opus_multistream_surround_encoder_create(int, int, int, int*, int*, byte*, int, int*)
N.A.
Declaration
public static extern OpusMSEncoderSafeHandle opus_multistream_surround_encoder_create(int Fs, int channels, int mapping_family, int* streams, int* coupled_streams, byte* mapping, int application, int* error)
Parameters
| Type | Name | Description |
|---|---|---|
| int | Fs | |
| int | channels | |
| int | mapping_family | |
| int* | streams | |
| int* | coupled_streams | |
| byte* | mapping | |
| int | application | |
| int* | error |
Returns
| Type | Description |
|---|---|
| OpusMSEncoderSafeHandle |
opus_multistream_surround_encoder_get_size(int, int)
N.A.
Declaration
public static extern int opus_multistream_surround_encoder_get_size(int channels, int mapping_family)
Parameters
| Type | Name | Description |
|---|---|---|
| int | channels | |
| int | mapping_family |
Returns
| Type | Description |
|---|---|
| int |
opus_multistream_surround_encoder_init(OpusMSEncoderSafeHandle, int, int, int, int*, int*, byte*, int)
N.A.
Declaration
public static extern int opus_multistream_surround_encoder_init(OpusMSEncoderSafeHandle st, int Fs, int channels, int mapping_family, int* streams, int* coupled_streams, byte* mapping, int application)
Parameters
| Type | Name | Description |
|---|---|---|
| OpusMSEncoderSafeHandle | st | |
| int | Fs | |
| int | channels | |
| int | mapping_family | |
| int* | streams | |
| int* | coupled_streams | |
| byte* | mapping | |
| int | application |
Returns
| Type | Description |
|---|---|
| int |
opus_packet_get_bandwidth(byte*)
Gets the bandwidth of an Opus packet.
Declaration
public static extern int opus_packet_get_bandwidth(byte* data)
Parameters
| Type | Name | Description |
|---|---|---|
| byte* | data | Opus packet. |
Returns
| Type | Description |
|---|---|
| int |
opus_packet_get_nb_channels(byte*)
Gets the number of channels from an Opus packet.
Declaration
public static extern int opus_packet_get_nb_channels(byte* data)
Parameters
| Type | Name | Description |
|---|---|---|
| byte* | data | Opus packet. |
Returns
| Type | Description |
|---|---|
| int | Number of channels or OpusErrorCodes. |
opus_packet_get_nb_frames(byte*, int)
Gets the number of frames in an Opus packet.
Declaration
public static extern int opus_packet_get_nb_frames(byte* packet, int len)
Parameters
| Type | Name | Description |
|---|---|---|
| byte* | packet | Opus packet. |
| int | len | Length of packet. |
Returns
| Type | Description |
|---|---|
| int | Number of frames or OpusErrorCodes. |
opus_packet_get_nb_samples(byte*, int, int)
Gets the number of samples of an Opus packet.
Declaration
public static extern int opus_packet_get_nb_samples(byte* packet, int len, int Fs)
Parameters
| Type | Name | Description |
|---|---|---|
| byte* | packet | Opus packet. |
| int | len | Length of packet. |
| int | Fs | Sampling rate in Hz. This must be a multiple of 400, or inaccurate results will be returned. |
Returns
| Type | Description |
|---|---|
| int | Number of samples or OpusErrorCodes. |
opus_packet_get_samples_per_frame(byte*, int)
Gets the number of samples per frame from an Opus packet.
Declaration
public static extern int opus_packet_get_samples_per_frame(byte* data, int Fs)
Parameters
| Type | Name | Description |
|---|---|---|
| byte* | data | Opus packet. This must contain at least one byte of data. |
| int | Fs | Sampling rate in Hz. This must be a multiple of 400, or inaccurate results will be returned. |
Returns
| Type | Description |
|---|---|
| int | Number of samples per frame. |
opus_packet_has_lbrr(byte*, int)
Checks whether an Opus packet has LBRR.
Declaration
public static extern int opus_packet_has_lbrr(byte* packet, int len)
Parameters
| Type | Name | Description |
|---|---|---|
| byte* | packet | Opus packet. |
| int | len | Length of packet. |
Returns
| Type | Description |
|---|---|
| int | 1 is LBRR is present, 0 otherwise or OpusErrorCodes |
opus_packet_pad(byte*, int, int)
Pads a given Opus packet to a larger size (possibly changing the TOC sequence).
Declaration
public static extern int opus_packet_pad(byte* data, int len, int new_len)
Parameters
| Type | Name | Description |
|---|---|---|
| byte* | data | The buffer containing the packet to pad. |
| int | len | The size of the packet. This must be at least 1. |
| int | new_len | The desired size of the packet after padding. This must be at least as large as len. |
Returns
| Type | Description |
|---|---|
| int |
opus_packet_parse(byte*, int, byte*, byte*[], short[], int*)
Parse an opus packet into one or more frames.
Declaration
public static extern int opus_packet_parse(byte* data, int len, byte* out_toc, byte*[] frames, short[] size, int* payload_offset)
Parameters
| Type | Name | Description |
|---|---|---|
| byte* | data | Opus packet to be parsed. |
| int | len | size of data. |
| byte* | out_toc | TOC pointer. |
| byte*[] | frames | encapsulated frames. |
| short[] | size | sizes of the encapsulated frames. |
| int* | payload_offset | returns the position of the payload within the packet (in bytes). |
Returns
| Type | Description |
|---|---|
| int | number of frames. |
opus_packet_unpad(byte*, int)
Remove all padding from a given Opus packet and rewrite the TOC sequence to minimize space usage.
Declaration
public static extern int opus_packet_unpad(byte* data, int len)
Parameters
| Type | Name | Description |
|---|---|---|
| byte* | data | The buffer containing the packet to strip. |
| int | len | The size of the packet. This must be at least 1. |
Returns
| Type | Description |
|---|---|
| int | The new size of the output packet on success, or an OpusErrorCodes on failure. |
opus_pcm_soft_clip(float*, int, int, float*)
Applies soft-clipping to bring a float signal within the [-1,1] range.
Declaration
public static extern void opus_pcm_soft_clip(float* pcm, int frame_size, int channels, float* softclip_mem)
Parameters
| Type | Name | Description |
|---|---|---|
| float* | pcm | Input PCM and modified PCM. |
| int | frame_size | Number of samples per channel to process. |
| int | channels | Number of channels. |
| float* | softclip_mem | State memory for the soft clipping process (one float per channel, initialized to zero). |
opus_repacketizer_cat(OpusRepacketizerSafeHandle, byte*, int)
Add a packet to the current OpusRepacketizerSafeHandle state.
Declaration
public static extern int opus_repacketizer_cat(OpusRepacketizerSafeHandle rp, byte* data, int len)
Parameters
| Type | Name | Description |
|---|---|---|
| OpusRepacketizerSafeHandle | rp | The repacketizer state to which to add the packet. |
| byte* | data | The packet data. The application must ensure this pointer remains valid until the next call to opus_repacketizer_init(OpusRepacketizerSafeHandle) or opus_repacketizer_destroy(IntPtr). |
| int | len | The number of bytes in the packet data. |
Returns
| Type | Description |
|---|---|
| int |
opus_repacketizer_create()
Allocates memory and initializes the new OpusRepacketizerSafeHandle with opus_repacketizer_init(OpusRepacketizerSafeHandle).
Declaration
public static extern OpusRepacketizerSafeHandle opus_repacketizer_create()
Returns
| Type | Description |
|---|---|
| OpusRepacketizerSafeHandle |
opus_repacketizer_destroy(IntPtr)
Frees an OpusRepacketizerSafeHandle allocated by opus_repacketizer_create().
Declaration
public static extern void opus_repacketizer_destroy(IntPtr rp)
Parameters
| Type | Name | Description |
|---|---|---|
| IntPtr | rp | State to be freed. |
opus_repacketizer_get_nb_frames(OpusRepacketizerSafeHandle)
Return the total number of frames contained in packet data submitted to the OpusRepacketizerSafeHandle state so far via opus_repacketizer_cat(OpusRepacketizerSafeHandle, byte*, int) since the last call to opus_repacketizer_init(OpusRepacketizerSafeHandle) or opus_repacketizer_create().
Declaration
public static extern int opus_repacketizer_get_nb_frames(OpusRepacketizerSafeHandle rp)
Parameters
| Type | Name | Description |
|---|---|---|
| OpusRepacketizerSafeHandle | rp | The repacketizer state containing the frames. |
Returns
| Type | Description |
|---|---|
| int | The total number of frames contained in the packet data submitted to the repacketizer state. |
opus_repacketizer_get_size()
Gets the size of an OpusRepacketizerSafeHandle structure.
Declaration
public static extern int opus_repacketizer_get_size()
Returns
| Type | Description |
|---|---|
| int | The size in bytes. |
opus_repacketizer_init(OpusRepacketizerSafeHandle)
(Re)initializes a previously allocated OpusRepacketizerSafeHandle state.
Declaration
public static extern OpusRepacketizerSafeHandle opus_repacketizer_init(OpusRepacketizerSafeHandle rp)
Parameters
| Type | Name | Description |
|---|---|---|
| OpusRepacketizerSafeHandle | rp | The OpusRepacketizerSafeHandle state to (re)initialize. |
Returns
| Type | Description |
|---|---|
| OpusRepacketizerSafeHandle |
opus_repacketizer_out(OpusRepacketizerSafeHandle, byte*, int)
Construct a new packet from data previously submitted to the OpusRepacketizerSafeHandle state via opus_repacketizer_cat(OpusRepacketizerSafeHandle, byte*, int).
Declaration
public static extern int opus_repacketizer_out(OpusRepacketizerSafeHandle rp, byte* data, int maxlen)
Parameters
| Type | Name | Description |
|---|---|---|
| OpusRepacketizerSafeHandle | rp | The repacketizer state from which to construct the new packet. |
| byte* | data | The buffer in which to store the output packet. |
| int | maxlen | The maximum number of bytes to store in the output buffer. In order to guarantee success, this should be at least 1277opus_repacketizer_get_nb_frames(rp). However, 1opus_repacketizer_get_nb_frames(rp) plus the size of all packet data submitted to the repacketizer since the last call to opus_repacketizer_init() or opus_repacketizer_create() is also sufficient, and possibly much smaller. |
Returns
| Type | Description |
|---|---|
| int | The total size of the output packet on success, or an OpusErrorCodes on failure. |
opus_repacketizer_out_range(OpusRepacketizerSafeHandle, int, int, byte*, int)
Construct a new packet from data previously submitted to the OpusRepacketizerSafeHandle state via opus_repacketizer_cat(OpusRepacketizerSafeHandle, byte*, int).
Declaration
public static extern int opus_repacketizer_out_range(OpusRepacketizerSafeHandle rp, int begin, int end, byte* data, int maxlen)
Parameters
| Type | Name | Description |
|---|---|---|
| OpusRepacketizerSafeHandle | rp | The repacketizer state from which to construct the new packet. |
| int | begin | The index of the first frame in the current repacketizer state to include in the output. |
| int | end | One past the index of the last frame in the current repacketizer state to include in the output. |
| byte* | data | The buffer in which to store the output packet. |
| int | maxlen | The maximum number of bytes to store in the output buffer. In order to guarantee success, this should be at least 1276 for a single frame, or for multiple frames, 1277*(end-begin). However, 1*(end-begin) plus the size of all packet data submitted to the repacketizer since the last call to opus_repacketizer_init(OpusRepacketizerSafeHandle) or opus_repacketizer_create() is also sufficient, and possibly much smaller. |
Returns
| Type | Description |
|---|---|
| int | The total size of the output packet on success, or an OpusErrorCodes on failure. |
opus_strerror(int)
Converts an opus error code into a human-readable string.
Declaration
public static extern byte* opus_strerror(int error)
Parameters
| Type | Name | Description |
|---|---|---|
| int | error | Error number. |
Returns
| Type | Description |
|---|---|
| byte* | Error string. |