public class OpusEncoder extends Object
OpusEncoder class.
| Constructor and Description |
|---|
OpusEncoder(int Fs,
int channels,
OpusApplication application)
Allocates and initializes an encoder state.
|
| Modifier and Type | Method and Description |
|---|---|
int |
encode(byte[] in_pcm,
int pcm_offset,
int frame_size,
byte[] out_data,
int out_data_offset,
int max_data_bytes)
Encodes an Opus frame, putting the output into a specified data buffer
|
int |
encode(short[] in_pcm,
int pcm_offset,
int frame_size,
byte[] out_data,
int out_data_offset,
int max_data_bytes)
Encodes an Opus frame, putting the output into a specified data buffer
|
OpusApplication |
getApplication()
Getter for the field
application. |
OpusBandwidth |
getBandwidth()
Getter for the field
bandwidth. |
int |
getBitrate()
getBitrate.
|
int |
getComplexity()
getComplexity.
|
boolean |
getEnableAnalysis()
getEnableAnalysis.
|
OpusFramesize |
getExpertFrameDuration()
getExpertFrameDuration.
|
int |
getFinalRange()
getFinalRange.
|
int |
getForceChannels()
getForceChannels.
|
OpusMode |
getForceMode()
getForceMode.
|
boolean |
getIsLFE()
getIsLFE.
|
int |
getLookahead()
getLookahead.
|
int |
getLSBDepth()
getLSBDepth.
|
OpusBandwidth |
getMaxBandwidth()
getMaxBandwidth.
|
int |
getPacketLossPercent()
getPacketLossPercent.
|
boolean |
getPredictionDisabled()
getPredictionDisabled.
|
int |
getSampleRate()
getSampleRate.
|
OpusSignal |
getSignalType()
getSignalType.
|
boolean |
getUseConstrainedVBR()
getUseConstrainedVBR.
|
boolean |
getUseDTX()
getUseDTX.
|
boolean |
getUseInbandFEC()
getUseInbandFEC.
|
boolean |
getUseVBR()
getUseVBR.
|
void |
resetState()
resetState.
|
void |
setApplication(OpusApplication value)
Setter for the field
application. |
void |
setBandwidth(OpusBandwidth value)
Setter for the field
bandwidth. |
void |
setBitrate(int value)
setBitrate.
|
void |
setComplexity(int value)
setComplexity.
|
void |
setEnableAnalysis(boolean value)
setEnableAnalysis.
|
void |
setExpertFrameDuration(OpusFramesize value)
setExpertFrameDuration.
|
void |
setForceChannels(int value)
setForceChannels.
|
void |
setForceMode(OpusMode value)
setForceMode.
|
void |
setIsLFE(boolean value)
setIsLFE.
|
void |
setLSBDepth(int value)
setLSBDepth.
|
void |
setMaxBandwidth(OpusBandwidth value)
setMaxBandwidth.
|
void |
setPacketLossPercent(int value)
setPacketLossPercent.
|
void |
setPredictionDisabled(boolean value)
setPredictionDisabled.
|
void |
setSignalType(OpusSignal value)
setSignalType.
|
void |
setUseConstrainedVBR(boolean value)
setUseConstrainedVBR.
|
void |
setUseDTX(boolean value)
setUseDTX.
|
void |
setUseInbandFEC(boolean value)
setUseInbandFEC.
|
void |
setUseVBR(boolean value)
setUseVBR.
|
public OpusEncoder(int Fs,
int channels,
OpusApplication application)
throws OpusException
Fs - Sampling rate of input signal (Hz). This must be one of 8000,
12000, 16000, 24000, or 48000.channels - Number of channels (1 or 2) in input signalapplication - There are three coding modes:
OPUS_APPLICATION_VOIP gives best quality at a given bitrate for voice
signals. It enhances the input signal by high-pass filtering and
emphasizing formants and harmonics.Optionally it includes in-band forward
error correction to protect against packet loss. Use this mode for
typical VoIP applications. Because of the enhancement, even at high
bitrates the output may sound different from the input.
OPUS_APPLICATION_AUDIO gives best quality at a given bitrate for most
non-voice signals like music. Use this mode for music and mixed
(music/voice) content, broadcast, and applications requiring less than 15
ms of coding delay.
OPUS_APPLICATION_RESTRICTED_LOWDELAY configures low-delay mode that
disables the speech-optimized mode in exchange for slightly reduced
delay. This mode can only be set on an newly initialized or freshly reset
encoder because it changes the codec delay.OpusExceptionpublic void resetState()
resetState.
public int encode(short[] in_pcm,
int pcm_offset,
int frame_size,
byte[] out_data,
int out_data_offset,
int max_data_bytes)
throws OpusException
in_pcm - 16-bit input signal (Interleaved if stereo), in a short array. Length should be at least frame_size * channelspcm_offset - Offset to use when reading the in_pcm bufferframe_size - The number of samples _per channel_ in the inpus signal. The frame size must be a valid Opus framesize for the given sample rate.
For example, at 48Khz the permitted values are 120, 240, 480, 960, 1920, and 2880. Passing in a duration of less than 10ms
(480 samples at 48Khz) will prevent the encoder from using FEC, DTX, or hybrid modes.out_data - Destination buffer for the output payload. This must contain at least max_data_bytesout_data_offset - The offset to use when writing to the output data buffermax_data_bytes - The maximum amount of space allocated 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 setBitrate for that)OpusExceptionpublic int encode(byte[] in_pcm,
int pcm_offset,
int frame_size,
byte[] out_data,
int out_data_offset,
int max_data_bytes)
throws OpusException
in_pcm - 16-bit input signal (Interleaved if stereo), in a little endian byte array. Length should be at least frame_size * channels * 2pcm_offset - Offset to use when reading the in_pcm bufferframe_size - The number of samples _per channel_ in the inpus signal. The frame size must be a valid Opus framesize for the given sample rate.
For example, at 48Khz the permitted values are 120, 240, 480, 960, 1920, and 2880. Passing in a duration of less than 10ms
(480 samples at 48Khz) will prevent the encoder from using FEC, DTX, or hybrid modes.out_data - Destination buffer for the output payload. This must contain at least max_data_bytesout_data_offset - The offset to use when writing to the output data buffermax_data_bytes - The maximum amount of space allocated 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 setBitrate for that)OpusExceptionpublic OpusApplication getApplication()
Getter for the field application.
OpusApplication objectpublic void setApplication(OpusApplication value)
Setter for the field application.
value - a OpusApplication objectpublic int getBitrate()
getBitrate.
public void setBitrate(int value)
setBitrate.
value - a intpublic int getForceChannels()
getForceChannels.
public void setForceChannels(int value)
setForceChannels.
value - a intpublic OpusBandwidth getMaxBandwidth()
getMaxBandwidth.
OpusBandwidth objectpublic void setMaxBandwidth(OpusBandwidth value)
setMaxBandwidth.
value - a OpusBandwidth objectpublic OpusBandwidth getBandwidth()
Getter for the field bandwidth.
OpusBandwidth objectpublic void setBandwidth(OpusBandwidth value)
Setter for the field bandwidth.
value - a OpusBandwidth objectpublic boolean getUseDTX()
getUseDTX.
public void setUseDTX(boolean value)
setUseDTX.
value - a booleanpublic int getComplexity()
getComplexity.
public void setComplexity(int value)
setComplexity.
value - a intpublic boolean getUseInbandFEC()
getUseInbandFEC.
public void setUseInbandFEC(boolean value)
setUseInbandFEC.
value - a booleanpublic int getPacketLossPercent()
getPacketLossPercent.
public void setPacketLossPercent(int value)
setPacketLossPercent.
value - a intpublic boolean getUseVBR()
getUseVBR.
public void setUseVBR(boolean value)
setUseVBR.
value - a booleanpublic boolean getUseConstrainedVBR()
getUseConstrainedVBR.
public void setUseConstrainedVBR(boolean value)
setUseConstrainedVBR.
value - a booleanpublic OpusSignal getSignalType()
getSignalType.
OpusSignal objectpublic void setSignalType(OpusSignal value)
setSignalType.
value - a OpusSignal objectpublic int getLookahead()
getLookahead.
public int getSampleRate()
getSampleRate.
public int getFinalRange()
getFinalRange.
public int getLSBDepth()
getLSBDepth.
public void setLSBDepth(int value)
setLSBDepth.
value - a intpublic OpusFramesize getExpertFrameDuration()
getExpertFrameDuration.
OpusFramesize objectpublic void setExpertFrameDuration(OpusFramesize value)
setExpertFrameDuration.
value - a OpusFramesize objectpublic void setForceMode(OpusMode value)
setForceMode.
value - a OpusMode objectpublic boolean getIsLFE()
getIsLFE.
public void setIsLFE(boolean value)
setIsLFE.
value - a booleanpublic boolean getPredictionDisabled()
getPredictionDisabled.
public void setPredictionDisabled(boolean value)
setPredictionDisabled.
value - a booleanpublic boolean getEnableAnalysis()
getEnableAnalysis.
public void setEnableAnalysis(boolean value)
setEnableAnalysis.
value - a booleanCopyright © 2024. All rights reserved.