Package com.microej.audiomockoggvorbis
Class OggVorbisAudioDecoder
java.lang.Object
com.microej.audiomockoggvorbis.OggVorbisAudioDecoder
- All Implemented Interfaces:
com.microej.audiomockdecoder.AudioDecoder
public class OggVorbisAudioDecoder
extends Object
implements com.microej.audiomockdecoder.AudioDecoder
AudioDecoder implementation that decodes Ogg Vorbis streams using the JOrbis library.
Typical usage:
- Call
setInputStream(InputStream)with the Ogg Vorbis stream. - Call
setParameters(int[])with the sample rate and channel count. - Call
getOutputFormat()to retrieve the configuredAudioFormat. - Call
getNextFrame()repeatedly to obtain decoded PCM frames.
getNextFrame().- Since:
- 3.0.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetName()byte[]Decodes and returns the next available PCM frame from the Ogg Vorbis stream.Returns the outputAudioFormatpreviously configured viasetParameters(int[])orsetOutputFormat(AudioFormat).voidsetInputStream(InputStream inputStream) Sets the Ogg Vorbis input stream to decode.voidsetOutputFormat(AudioFormat newAudioFormat) Overrides the outputAudioFormatdirectly.voidsetParameters(int[] params) Configures the outputAudioFormatfrom the given parameters.
-
Constructor Details
-
OggVorbisAudioDecoder
public OggVorbisAudioDecoder()Creates anOggVorbisAudioDecoderand initializes the JOgg sync state.- Since:
- 3.0.0
-
-
Method Details
-
getName
- Specified by:
getNamein interfacecom.microej.audiomockdecoder.AudioDecoder
-
setInputStream
Sets the Ogg Vorbis input stream to decode.Must be called before
getNextFrame().- Specified by:
setInputStreamin interfacecom.microej.audiomockdecoder.AudioDecoder- Parameters:
inputStream- the input stream providing the Ogg Vorbis encoded audio data.- Since:
- 3.0.0
-
setParameters
public void setParameters(int[] params) Configures the outputAudioFormatfrom the given parameters.params[0]is the sample rate in Hz andparams[1]is the number of channels.- Specified by:
setParametersin interfacecom.microej.audiomockdecoder.AudioDecoder- Parameters:
params- an array whereparams[0]is the sample rate (Hz) andparams[1]is the channel count.- Since:
- 3.0.0
-
getOutputFormat
Returns the outputAudioFormatpreviously configured viasetParameters(int[])orsetOutputFormat(AudioFormat).- Specified by:
getOutputFormatin interfacecom.microej.audiomockdecoder.AudioDecoder- Returns:
- the configured output format.
- Since:
- 3.0.0
-
setOutputFormat
Overrides the outputAudioFormatdirectly.- Specified by:
setOutputFormatin interfacecom.microej.audiomockdecoder.AudioDecoder- Parameters:
newAudioFormat- the new output format to use.- Since:
- 3.0.0
-
getNextFrame
Decodes and returns the next available PCM frame from the Ogg Vorbis stream.On the first call, the three Vorbis header packets are read from the stream and the JOrbis DSP state is initialised. Subsequent calls decode audio data pages.
setInputStream(InputStream)andsetParameters(int[])must have been called before the first invocation.- Specified by:
getNextFramein interfacecom.microej.audiomockdecoder.AudioDecoder- Returns:
- a byte array containing the next decoded PCM frame, or an empty array when the current page yields no output yet.
- Throws:
IOException- if an error occurs while reading or decoding the stream.- Since:
- 3.0.0
-