org.xiph.speex
Class SpeexDecoder
java.lang.Object
org.xiph.speex.SpeexDecoder
public class SpeexDecoder
extends java.lang.Object
Main Speex Decoder class.
This class decodes the given Speex packets into PCM 16bit samples.
Here's an example that decodes and recovers one Speex packet.
SpeexDecoder speexDecoder = new SpeexDecoder();
speexDecoder.processData(data, packetOffset, packetSize);
byte[] decoded = new byte[speexDecoder.getProcessedBataByteSize()];
speexDecoder.getProcessedData(decoded, 0);
- Jim Lawrence, helloNetwork.com
- Marc Gimpel, Wimba S.A. (mgimpel@horizonwimba.com)
int | getChannels() - Returns the number of channels.
|
int | getProcessedData(byte[] data, int offset) - Pull the decoded data out into a byte array at the given offset
and returns the number of bytes processed and just read.
|
int | getProcessedData(short[] data, int offset) - Pull the decoded data out into a short array at the given offset
and returns tne number of shorts processed and just read
|
int | getProcessedDataByteSize() - Returns the number of bytes processed and ready to be read.
|
int | getSampleRate() - Returns the sample rate.
|
boolean | init(int mode, int sampleRate, int channels, boolean enhanced) - Initialise the Speex Decoder.
|
void | processData(boolean lost) - This is where the actual decoding takes place.
|
void | processData(byte[] data, int offset, int len) - This is where the actual decoding takes place
|
VERSION
public static final String VERSION
Version of the Speex Decoder
channels
private int channels
decodedData
private float[] decodedData
frameSize
private int frameSize
outputData
private short[] outputData
outputSize
private int outputSize
sampleRate
private int sampleRate
SpeexDecoder
public SpeexDecoder()
Constructor
getChannels
public int getChannels()
Returns the number of channels.
getProcessedData
public int getProcessedData(byte[] data,
int offset)
Pull the decoded data out into a byte array at the given offset
and returns the number of bytes processed and just read.
- the number of bytes processed and just read.
getProcessedData
public int getProcessedData(short[] data,
int offset)
Pull the decoded data out into a short array at the given offset
and returns tne number of shorts processed and just read
- the number of samples processed and just read.
getProcessedDataByteSize
public int getProcessedDataByteSize()
Returns the number of bytes processed and ready to be read.
- the number of bytes processed and ready to be read.
getSampleRate
public int getSampleRate()
Returns the sample rate.
init
public boolean init(int mode,
int sampleRate,
int channels,
boolean enhanced)
Initialise the Speex Decoder.
mode
- the mode of the decoder (0=NB, 1=WB, 2=UWB).sampleRate
- the number of samples per second.channels
- the number of audio channels (1=mono, 2=stereo, ...).enhanced
- whether to enable perceptual enhancement or not.
- true if initialisation successful.
processData
public void processData(boolean lost)
throws StreamCorruptedException
This is where the actual decoding takes place.
lost
- - true if the Speex packet has been lost.
processData
public void processData(byte[] data,
int offset,
int len)
throws StreamCorruptedException
This is where the actual decoding takes place
data
- - the Speex data (frame) to decode.
If it is null, the packet is supposed lost.offset
- - the offset from which to start reading the data.len
- - the length of data to read (Speex frame size).
Copyright © 1999-2004 Wimba S.A. All Rights Reserved.