Interface IOpusEncoder
An opus encoder interface.
Inherited Members
Namespace: OpusSharp.Core.Interfaces
Assembly: OpusSharp.Core.dll
Syntax
public interface IOpusEncoder : IDisposable
Methods
| Edit this page View SourceCtl(EncoderCTL)
Performs a ctl request.
Declaration
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 |
Ctl(EncoderCTL, int)
Performs a ctl request.
Declaration
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 |
Ctl(GenericCTL)
Performs a ctl request.
Declaration
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 |
Ctl(GenericCTL, int)
Performs a ctl set request.
Declaration
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 |
Ctl<T>(EncoderCTL, int, ref T)
Performs a ctl request.
Declaration
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 |
Ctl<T>(EncoderCTL, ref T)
Performs a ctl request.
Declaration
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 |
Ctl<T>(EncoderCTL, ref T, int)
Performs a ctl request.
Declaration
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 |
Ctl<T>(GenericCTL, ref T)
Performs a ctl request.
Declaration
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 |
Ctl<T, T2>(EncoderCTL, ref T, ref T2)
Performs a ctl request.
Declaration
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 |
Encode(byte[], int, byte[], int)
Encodes a pcm frame.
Declaration
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 |
Encode(short[], int, byte[], int)
Encodes a pcm frame.
Declaration
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 |
Encode(int[], int, byte[], int)
Encodes a pcm frame.
Declaration
int Encode(int[] input, int frame_size, byte[] output, int max_data_bytes)
Parameters
| Type | Name | Description |
|---|---|---|
| int[] | input | Input signal (interleaved if 2 channels). length is frame_sizechannelssizeof(int). |
| 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 |
Encode(float[], int, byte[], int)
Encodes a floating point pcm frame.
Declaration
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 |