public class Opus
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
BANDWIDTH_FULLBAND
Opus fullband constant
|
static int |
BANDWIDTH_MEDIUMBAND
Opus mediumband constant
|
static int |
BANDWIDTH_NARROWBAND
Opus narrowband constant
|
static int |
BANDWIDTH_SUPERWIDEBAND
Opus superwideband constant
|
static int |
BANDWIDTH_WIDEBAND
Opus wideband constant
|
static int |
INVALID_PACKET
Opus constant for an invalid packet
|
static int |
MAX_PACKET
The maximum size of a packet we can create.
|
static int |
OPUS_AUTO
Constant used to set various settings to "automatic"
|
static int |
OPUS_OK
Constant usually indicating that no error occurred
|
Constructor and Description |
---|
Opus() |
Modifier and Type | Method and Description |
---|---|
static void |
assertOpusIsFunctional()
Asserts that the Opus class and the JNI library which supports
it are functional.
|
static int |
decode(long decoder,
byte[] input,
int inputOffset,
int inputLength,
byte[] output,
int outputOffset,
int outputFrameSize,
int decodeFEC)
Decodes an opus packet from input into output.
|
static long |
decoder_create(int Fs,
int channels)
Creates an OpusDecoder structure, returns a pointer to it or 0 on error.
|
static void |
decoder_destroy(long decoder)
Destroys an OpusDecoder, freeing it's resources.
|
static int |
decoder_get_nb_samples(long decoder,
byte[] packet,
int offset,
int length)
Returns the number of samples in an opus packet
|
static int |
decoder_get_size(int channels)
Returns the size in bytes required for an OpusDecoder structure.
|
static int |
encode(long encoder,
byte[] input,
int inputOffset,
int inputFrameSize,
byte[] output,
int outputOffset,
int outputLength)
Encodes the input from input into an opus packet in
output.
|
static long |
encoder_create(int Fs,
int channels)
Creates an OpusEncoder structure, returns a pointer to it casted to long.
|
static void |
encoder_destroy(long encoder)
Destroys an OpusEncoder, freeing it's resources.
|
static int |
encoder_get_bandwidth(long encoder)
Wrapper around the native opus_encoder_ctl function.
|
static int |
encoder_get_bitrate(long encoder)
Wrapper around the native opus_encoder_ctl function.
|
static int |
encoder_get_complexity(long encoder) |
static int |
encoder_get_dtx(long encoder)
Wrapper around the native opus_encoder_ctl function.
|
static int |
encoder_get_inband_fec(long encoder)
Wrapper around the native opus_encoder_ctl function.
|
static int |
encoder_get_size(int channels)
Returns the size in bytes required for an OpusEncoder structure.
|
static int |
encoder_get_vbr_constraint(long encoder)
Wrapper around the native opus_encoder_ctl function.
|
static int |
encoder_get_vbr(long encoder)
Wrapper around the native opus_encoder_ctl function.
|
static int |
encoder_set_bandwidth(long encoder,
int bandwidth)
Wrapper around the native opus_encoder_ctl function.
|
static int |
encoder_set_bitrate(long encoder,
int bitrate)
Wrapper around the native opus_encoder_ctl function.
|
static int |
encoder_set_complexity(long encoder,
int complexity)
Wrapper around the native opus_encoder_ctl function.
|
static int |
encoder_set_dtx(long encoder,
int dtx)
Wrapper around the native opus_encoder_ctl function.
|
static int |
encoder_set_force_channels(long encoder,
int forcechannels)
Wrapper around the native opus_encoder_ctl function.
|
static int |
encoder_set_inband_fec(long encoder,
int inbandFEC)
Wrapper around the native opus_encoder_ctl function.
|
static int |
encoder_set_max_bandwidth(long encoder,
int maxBandwidth)
Wrapper around the native opus_encoder_ctl function.
|
static int |
encoder_set_packet_loss_perc(long encoder,
int packetLossPerc)
Wrapper around the native opus_encoder_ctl function.
|
static int |
encoder_set_vbr_constraint(long encoder,
int use_cvbr)
Wrapper around the native opus_encoder_ctl function.
|
static int |
encoder_set_vbr(long encoder,
int vbr)
Wrapper around the native opus_encoder_ctl function.
|
static int |
packet_get_bandwidth(byte[] data,
int offset)
Returns the audio bandwidth of an Opus packet, one of
BANDWIDTH_FULLBAND, BANDWIDTH_MEDIUMBAND,
BANDWIDTH_NARROWBAND, BANDWIDTH_SUPERWIDEBAND or
BANDWIDTH_WIDEBAND, or INVALID_PACKET on error.
|
static int |
packet_get_nb_channels(byte[] data,
int offset)
Returns the number of channels encoded in an Opus packet.
|
static int |
packet_get_nb_frames(byte[] packet,
int offset,
int length)
Returns the number of frames in an Opus packet.
|
public static final int BANDWIDTH_FULLBAND
public static final int BANDWIDTH_MEDIUMBAND
public static final int BANDWIDTH_NARROWBAND
public static final int BANDWIDTH_SUPERWIDEBAND
public static final int BANDWIDTH_WIDEBAND
public static final int INVALID_PACKET
public static final int MAX_PACKET
public static final int OPUS_AUTO
public static final int OPUS_OK
public static void assertOpusIsFunctional()
public static int decode(long decoder, byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset, int outputFrameSize, int decodeFEC)
decoder
- the OpusDecoder state to perform the decodinginput
- an array of bytes which represents the input
payload to decode. If null, indicates packet loss.inputOffset
- the offset in input at which the payload to
be decoded beginsinputLength
- the length in bytes in input beginning at
inputOffset of the payload to be decodedoutput
- an array of bytes into which the decoded signal is
to be outputoutputOffset
- the offset in output at which the output of
the decoded signal is to beginoutputFrameSize
- the number of samples per channel output
beginning at outputOffset of the maximum space available for
output of the decoded signaldecodeFEC
- 0 to decode the packet normally, 1 to decode the FEC
data in the packetpublic static long decoder_create(int Fs, int channels)
Fs
- Sample rate to decode tochannels
- number of channels to decode to(1/2)public static void decoder_destroy(long decoder)
decoder
- Address of the structure (as returned from decoder_create)public static int decoder_get_nb_samples(long decoder, byte[] packet, int offset, int length)
decoder
- The decoder to use.packet
- Array holding the packet.offset
- Offset into packet where the actual packet begins.length
- Length of the packet.public static int decoder_get_size(int channels)
channels
- number of channels (1/2)public static int encode(long encoder, byte[] input, int inputOffset, int inputFrameSize, byte[] output, int outputOffset, int outputLength)
encoder
- The encoder to use.input
- Array containing PCM encoded input.inputOffset
- Offset to use into the input arrayinputFrameSize
- The number of samples per channel in input.output
- Array where the encoded packet will be stored.outputOffset
- outputLength
- The number of available bytes in output.public static long encoder_create(int Fs, int channels)
Fs
- Sample rate of the input PCMchannels
- number of channels in the input (1/2)public static void encoder_destroy(long encoder)
encoder
- Address of the structure (as returned from encoder_create)public static int encoder_get_bandwidth(long encoder)
encoder
- The encoder to usepublic static int encoder_get_bitrate(long encoder)
encoder
- The encoder to usepublic static int encoder_get_complexity(long encoder)
public static int encoder_get_dtx(long encoder)
encoder
- The encoder to usepublic static int encoder_get_inband_fec(long encoder)
encoder
- The encoder to usepublic static int encoder_get_size(int channels)
channels
- number of channels (1/2)public static int encoder_get_vbr(long encoder)
encoder
- The encoder to usepublic static int encoder_get_vbr_constraint(long encoder)
encoder
- The encoder to usepublic static int encoder_set_bandwidth(long encoder, int bandwidth)
encoder
- The encoder to usebandwidth
- The bandwidth to set, should be one of
BANDWIDTH_FULLBAND, BANDWIDTH_MEDIUMBAND,
BANDWIDTH_NARROWBAND, BANDWIDTH_SUPERWIDEBAND or
BANDWIDTH_WIDEBAND.public static int encoder_set_bitrate(long encoder, int bitrate)
encoder
- The encoder to usebitrate
- The bitrate to setpublic static int encoder_set_complexity(long encoder, int complexity)
encoder
- The encoder to usecomplexity
- The complexity level, from 1 to 10public static int encoder_set_dtx(long encoder, int dtx)
encoder
- The encoder to usedtx
- 0 to turn DTX off, non-zero to turn it onpublic static int encoder_set_force_channels(long encoder, int forcechannels)
encoder
- The encoder to useforcechannels
- Number of channelspublic static int encoder_set_inband_fec(long encoder, int inbandFEC)
encoder
- The encoder to useinbandFEC
- 0 to turn FEC off, non-zero to turn it on.public static int encoder_set_max_bandwidth(long encoder, int maxBandwidth)
encoder
- The encoder to usemaxBandwidth
- The maximum bandwidth to use, should be one of
BANDWIDTH_FULLBAND, BANDWIDTH_MEDIUMBAND,
BANDWIDTH_NARROWBAND, BANDWIDTH_SUPERWIDEBAND or
BANDWIDTH_WIDEBANDpublic static int encoder_set_packet_loss_perc(long encoder, int packetLossPerc)
encoder
- The encoder to usepacketLossPerc
- public static int encoder_set_vbr(long encoder, int vbr)
encoder
- The encoder to usevbr
- 0 to turn VBR off, non-zero to turn it on.public static int encoder_set_vbr_constraint(long encoder, int use_cvbr)
encoder
- The encoder to useuse_cvbr
- 0 to turn VBR constraint off, non-zero to turn it on.public static int packet_get_bandwidth(byte[] data, int offset)
data
- Array holding the packet.offset
- Offset into packet where the actual packet begins.public static int packet_get_nb_channels(byte[] data, int offset)
data
- Array holding the packet.offset
- Offset into packet where the actual packet begins.public static int packet_get_nb_frames(byte[] packet, int offset, int length)
packet
- Array holding the packet.offset
- Offset into packet where the actual packet begins.length
- Length of the packet.
Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under Apache license.