Package javazoom.jl.decoder
Class Bitstream
java.lang.Object
javazoom.jl.decoder.Bitstream
- All Implemented Interfaces:
BitstreamErrors
,JavaLayerErrors
The
Bistream
class is responsible for parsing
an MPEG audio bitstream.
REVIEW: much of the parsing currently occurs in the
various decoders. This should be moved into this class and associated
inner classes.-
Field Summary
Fields inherited from interface javazoom.jl.decoder.BitstreamErrors
BITSTREAM_LAST, INVALIDFRAME, STREAM_EOF, STREAM_ERROR, UNEXPECTED_EOF, UNKNOWN_ERROR, UNKNOWN_SAMPLE_RATE
Fields inherited from interface javazoom.jl.decoder.JavaLayerErrors
BITSTREAM_ERROR, DECODER_ERROR
-
Constructor Summary
ConstructorsConstructorDescriptionBitstream
(InputStream in) Construct a IBitstream that reads data from a given InputStream. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close the Bitstream.void
Close MP3 frame.int
get_bits
(int number_of_bits) Read bits from buffer into the lower bits of an unsigned int.Return raw ID3v2 frames + header.int
Return position of the first audio header.boolean
isSyncCurrentPosition
(int syncmode) Determines if the next 4 bytes of the stream represent a frame header.boolean
isSyncMark
(int headerstring, int syncmode, int word) protected BitstreamException
newBitstreamException
(int errorcode) protected BitstreamException
newBitstreamException
(int errorcode, Throwable throwable) int
readBits
(int n) int
readCheckedBits
(int n) Reads and parses the next frame from the input source.void
Unreads the bytes read from the frame.
-
Constructor Details
-
Bitstream
Construct a IBitstream that reads data from a given InputStream.- Parameters:
in
- The InputStream to read from.
-
-
Method Details
-
header_pos
public int header_pos()Return position of the first audio header.- Returns:
- size of ID3v2 tag frames.
-
getRawID3v2
Return raw ID3v2 frames + header.- Returns:
- ID3v2 InputStream or null if ID3v2 frames are not available.
-
close
Close the Bitstream.- Throws:
BitstreamException
-
readFrame
Reads and parses the next frame from the input source.- Returns:
- the Header describing details of the frame read, or null if the end of the stream has been reached.
- Throws:
BitstreamException
-
unreadFrame
Unreads the bytes read from the frame.- Throws:
BitstreamException
-
closeFrame
public void closeFrame()Close MP3 frame. -
isSyncCurrentPosition
Determines if the next 4 bytes of the stream represent a frame header.- Throws:
BitstreamException
-
readBits
public int readBits(int n) -
readCheckedBits
public int readCheckedBits(int n) -
newBitstreamException
-
newBitstreamException
-
isSyncMark
public boolean isSyncMark(int headerstring, int syncmode, int word) -
get_bits
public int get_bits(int number_of_bits) Read bits from buffer into the lower bits of an unsigned int. The LSB contains the latest read bit of the stream. (1 invalid input: '<'= number_of_bits invalid input: '<'= 16)
-