lameonj.decoder.std
Interface Decoder

All Known Subinterfaces:
GenericDecoder, StreamDecoder

public interface Decoder

This object represents a decoding task. Is the base interface of the MP3 decoder object oriented API using the LAME standard API.


Method Summary
 void close()
          Closes this decoder task.
 void fixWAVHeader(java.lang.String wavPath)
          Modifies the header of the specified WAV file fixing invalid data saved by writeWAVHeader(OutputStream).
 mp3data_struct getMP3DataStruct()
          Returns the mp3data_struct object with header information of the MP3 data being decoded.
 int getPCMDataSize()
          Returns the number of bytes of PCM data decoded at the moment.
 boolean isClosed()
          Informs whether this decoder task is closed (finished).
 boolean isMP3HeaderComplete()
          Informs whether parsed MP3 header data is enough to build the header of a WAV file.
 void writeDecodedFrame(PCMFrame frame, java.io.OutputStream output)
          Writes the specified PCM frame to the specified stream.
 void writeWAVHeader(java.io.OutputStream output)
          Writes on the specified stream a WAV header with the information provided by the mp3data_struct object of this decoding task.
 

Method Detail

getMP3DataStruct

mp3data_struct getMP3DataStruct()
Returns the
mp3data_struct
object with header information of the MP3 data being decoded.

Returns:
the object with MP3 header info. Null if MP3 header has not been processed.

getPCMDataSize

int getPCMDataSize()
Returns the number of bytes of PCM data decoded at the moment.

Returns:
the amount of PCM data decoded in bytes.
See Also:
fixWAVHeader(String)

isMP3HeaderComplete

boolean isMP3HeaderComplete()
Informs whether parsed MP3 header data is enough to build the header of a WAV file.

Current implementation returns false if mp3data_struct.getTotalframes() returns 0. For instance only MP3 files with Xing header save the number of MP3 frames contained. The total number of frames is used to calculate the data size in bytes of the PCM data to build a WAV file.

Returns:
true if MP3 header is complete.
See Also:
fixWAVHeader(String)

writeWAVHeader

void writeWAVHeader(java.io.OutputStream output)
Writes on the specified stream a WAV header with the information provided by the mp3data_struct object of this decoding task.

Even though MP3 header data is not complete, the WAV header is written with incomplete information (PCM data size is 0). This WAV invalid header can be fixed later calling fixWAVHeader(String) after the decoding task finishes.

Parameters:
output - the stream to write the WAV header.
See Also:
isMP3HeaderComplete()

fixWAVHeader

void fixWAVHeader(java.lang.String wavPath)
Modifies the header of the specified WAV file fixing invalid data saved by writeWAVHeader(OutputStream).

You do not need this method if isMP3HeaderComplete() returns true.

This method must be called after this decoding task has finished (is closed).

The value returned by getPCMDataSize() is used to fix the WAV header.

Parameters:
wavPath - the path of the WAV file.

writeDecodedFrame

void writeDecodedFrame(PCMFrame frame,
                       java.io.OutputStream output)
Writes the specified PCM frame to the specified stream.

Parameters:
frame - the PCM frame to save.
output - the output stream to write the frame.

isClosed

boolean isClosed()
Informs whether this decoder task is closed (finished).

Returns:
true if this decoder is closed.

close

void close()
Closes this decoder task. A closed/finished decoder task cannot be reused.



Copyright © 2006-2008 Jose Maria Arranz. All Rights Reserved.