public class OpusDecoder extends Object
| Constructor and Description |
|---|
OpusDecoder(int Fs,
int channels)
Allocates and initializes a decoder state.
|
| Modifier and Type | Method and Description |
|---|---|
int |
decode(byte[] in_data,
int in_data_offset,
int len,
byte[] out_pcm,
int out_pcm_offset,
int frame_size,
boolean decode_fec)
Decodes an Opus packet.
|
int |
decode(byte[] in_data,
int in_data_offset,
int len,
short[] out_pcm,
int out_pcm_offset,
int frame_size,
boolean decode_fec)
Decodes an Opus packet.
|
OpusBandwidth |
getBandwidth()
Getter for the field
bandwidth. |
int |
getFinalRange()
getFinalRange.
|
int |
getGain()
getGain.
|
int |
getLastPacketDuration()
getLastPacketDuration.
|
int |
getPitch()
getPitch.
|
int |
getSampleRate()
getSampleRate.
|
void |
resetState()
resetState.
|
void |
setGain(int value)
setGain.
|
public OpusDecoder(int Fs,
int channels)
throws OpusException
Fs - Sample rate to decode at (Hz). This must be one of 8000, 12000,
16000, 24000, or 48000.channels - Number of channels (1 or 2) to decode.OpusExceptionpublic int decode(byte[] in_data,
int in_data_offset,
int len,
short[] out_pcm,
int out_pcm_offset,
int frame_size,
boolean decode_fec)
throws OpusException
in_data - The input payload. This may be NULL if that previous packet was lost in transit (when PLC is enabled)in_data_offset - The offset to use when reading the input payload. Usually 0len - The number of bytes in the payload (the packet size)out_pcm - A buffer to put the output PCM, in a short array. The output size is (# of samples) * (# of channels).
You can use the OpusPacketInfo helpers to get a hint of the frame size before you decode the packet if you need exact sizing.out_pcm_offset - The offset to use when writing to the output bufferframe_size - The number of samples (per channel) of available space in the output PCM buf.
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 the audio that is missing, otherwise the decoder will
not be in an optimal state to decode the next incoming packet. For the PLC and FEC cases, frame_size *must*
be a multiple of 2.5 ms.decode_fec - Indicates that we want to recreate the PREVIOUS (lost) packet using FEC data from THIS packet. Using this packet
recovery scheme, you will actually decode this packet twice, first with decode_fec TRUE and then again with FALSE. If FEC data is not
available in this packet, the decoder will simply generate a best-effort recreation of the lost packet. In that case,
the length of frame_size must be EXACTLY the length of the audio that was lost, or else the decoder will be in an inconsistent state.OpusExceptionpublic int decode(byte[] in_data,
int in_data_offset,
int len,
byte[] out_pcm,
int out_pcm_offset,
int frame_size,
boolean decode_fec)
throws OpusException
in_data - The input payload. This may be NULL if that previous packet was lost in transit (when PLC is enabled)in_data_offset - The offset to use when reading the input payload. Usually 0len - The number of bytes in the payload (the packet size)out_pcm - A buffer to put the output PCM, in a byte array. The output size is (# of samples) * (# of channels) * 2.
You can use the OpusPacketInfo helpers to get a hint of the frame size before you decode the packet if you need exact sizing.out_pcm_offset - The offset to use when writing to the output bufferframe_size - The number of samples (per channel) of available space in the output PCM buf.
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 the audio that is missing, otherwise the decoder will
not be in an optimal state to decode the next incoming packet. For the PLC and FEC cases, frame_size *must*
be a multiple of 2.5 ms.decode_fec - Indicates that we want to recreate the PREVIOUS (lost) packet using FEC data from THIS packet. Using this packet
recovery scheme, you will actually decode this packet twice, first with decode_fec TRUE and then again with FALSE. If FEC data is not
available in this packet, the decoder will simply generate a best-effort recreation of the lost packet. In that case, the
length of frame_size must be EXACTLY the length of the audio that was lost, or else the decoder will be in an inconsistent state.OpusExceptionpublic OpusBandwidth getBandwidth()
Getter for the field bandwidth.
OpusBandwidth objectpublic int getFinalRange()
getFinalRange.
public int getSampleRate()
getSampleRate.
public int getPitch()
getPitch.
public int getGain()
getGain.
public void setGain(int value)
setGain.
value - a intpublic int getLastPacketDuration()
getLastPacketDuration.
public void resetState()
resetState.
Copyright © 2024. All rights reserved.