Package org.xiph.speex
Class SpeexDecoder
- java.lang.Object
-
- org.xiph.speex.SpeexDecoder
-
public class SpeexDecoder extends java.lang.ObjectMain 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);
- Version:
- $Revision: 1.4 $
- Author:
- Jim Lawrence, helloNetwork.com, Marc Gimpel, Wimba S.A. (mgimpel@horizonwimba.com)
-
-
Field Summary
Fields Modifier and Type Field Description private Bitsbitsprivate intchannelsprivate float[]decodedDataprivate Decoderdecoderprivate intframeSizeprivate short[]outputDataprivate intoutputSizeprivate intsampleRatestatic java.lang.StringVERSIONVersion of the Speex Decoder
-
Constructor Summary
Constructors Constructor Description SpeexDecoder()Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetChannels()Returns the number of channels.intgetProcessedData(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.intgetProcessedData(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 readintgetProcessedDataByteSize()Returns the number of bytes processed and ready to be read.intgetSampleRate()Returns the sample rate.booleaninit(int mode, int sampleRate, int channels, boolean enhanced)Initialise the Speex Decoder.voidprocessData(boolean lost)This is where the actual decoding takes place.voidprocessData(byte[] data, int offset, int len)This is where the actual decoding takes place
-
-
-
Field Detail
-
VERSION
public static final java.lang.String VERSION
Version of the Speex Decoder- See Also:
- Constant Field Values
-
sampleRate
private int sampleRate
-
channels
private int channels
-
decodedData
private float[] decodedData
-
outputData
private short[] outputData
-
outputSize
private int outputSize
-
bits
private Bits bits
-
decoder
private Decoder decoder
-
frameSize
private int frameSize
-
-
Method Detail
-
init
public boolean init(int mode, int sampleRate, int channels, boolean enhanced)Initialise the Speex Decoder.- Parameters:
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.- Returns:
- true if initialisation successful.
-
getSampleRate
public int getSampleRate()
Returns the sample rate.- Returns:
- the sample rate.
-
getChannels
public int getChannels()
Returns the number of channels.- 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.- Parameters:
data-offset-- Returns:
- 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- Parameters:
data-offset-- Returns:
- the number of samples processed and just read.
-
getProcessedDataByteSize
public int getProcessedDataByteSize()
Returns the number of bytes processed and ready to be read.- Returns:
- the number of bytes processed and ready to be read.
-
processData
public void processData(byte[] data, int offset, int len) throws java.io.StreamCorruptedExceptionThis is where the actual decoding takes place- Parameters:
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).- Throws:
java.io.StreamCorruptedException- If the input stream is invalid.
-
processData
public void processData(boolean lost) throws java.io.StreamCorruptedExceptionThis is where the actual decoding takes place.- Parameters:
lost- - true if the Speex packet has been lost.- Throws:
java.io.StreamCorruptedException- If the input stream is invalid.
-
-