public class MPEGFrameHeader
extends java.lang.Object
The audio portion of an .mp3 file is stored in MPEG audio frames as shown below. Each MPEG audio frame
begins with an MPEG frame header.
The header has a fixed length of 4 bytes, and optionally contains a 2 byte CRC directly following it, before the side information
.
Modifier and Type | Field and Description |
---|---|
static int |
FRAME_HEADER_SIZE
mpeg audio frame headers are 4 bytes (32 bits) in length
|
Constructor and Description |
---|
MPEGFrameHeader()
default constructor.
|
MPEGFrameHeader(byte[] bytes,
java.io.InputStream inputStream)
constructor used for parsing existing .mp3 files.
|
MPEGFrameHeader(java.io.InputStream inputStream)
constructor used for parsing existing .mp3 files.
|
Modifier and Type | Method and Description |
---|---|
int |
getBitrate()
gets the bit rate (in kilobits per second - kbps), which specifies how many kb are used to represent the audio data for each second of playback.
|
ChannelMode |
getChannelMode()
gets the channel mode (mono or stereo) of this .mp3 file.
|
java.lang.String |
getCodec()
gets the Codec used to encode the .mp3 file.
|
byte[] |
getCRC()
gets the optional CRC for the mpeg audio frame.
|
int |
getFrameSize()
gets the size (in bytes) of the mpeg audio frame.
|
int |
getFrequency()
gets the frequency (in herz - hz), which specifies how many times per second the audio is sampled and stored as a number in the .mp3 file.
|
Layer |
getLayer()
gets the MPEG layer of this .mp3 file.
|
java.lang.String |
getModeExtension()
sets the description of the mode extension of this mpeg audio frame.
|
MPEGVersion |
getMPEGVersion()
gets the MPEG version of this .mp3 file.
|
int |
getNumSamples()
gets the number of audio samples stored in the mpeg audio frame.
|
int |
getSideInfoSize()
get the size (in bytes) of the
side information that directly follows the MPEG frame header in the mpeg audio frame . |
int |
getSize()
gets the size of the mpeg audio frame header and includes the optional CRC if present.
|
boolean |
isCopyrighted()
gets whether this audio is copyrighted.
|
boolean |
isOriginalMedia()
gets whether this .mp3 file was created from the original media.
|
boolean |
isProtectedByCRC()
gets whether this mpeg audio frame has a CRC.
|
java.lang.String |
toString()
gets a string representation of the mpeg audio frame header.
|
public static final int FRAME_HEADER_SIZE
public MPEGFrameHeader()
public MPEGFrameHeader(java.io.InputStream inputStream) throws java.io.IOException, ParseException
inputStream
- input stream to read in the mpeg audio frame from the binary .mp3 file.java.io.IOException
- if there is an error while reading the mpeg frame header.ParseException
- if an invalid value is detected while parsing the mpeg frame header's raw bytes.public MPEGFrameHeader(byte[] bytes, java.io.InputStream inputStream) throws java.io.IOException, ParseException
bytes
- bytes read in from the previous attempt to find the mpeg frame header.inputStream
- input stream to read in the mpeg audio frame CRC from the binary .mp3 file.java.io.IOException
- if there is an error while reading the mpeg frame header.ParseException
- if an invalid value is detected while parsing the mpeg frame header's raw bytes.public int getSize()
public MPEGVersion getMPEGVersion()
public Layer getLayer()
public java.lang.String getCodec()
public int getBitrate()
public int getFrequency()
public ChannelMode getChannelMode()
public java.lang.String getModeExtension()
public boolean isProtectedByCRC()
public boolean isCopyrighted()
public boolean isOriginalMedia()
public int getNumSamples()
public int getFrameSize()
public int getSideInfoSize()
side information
that directly follows the MPEG frame header in the mpeg audio frame
.public byte[] getCRC()
public java.lang.String toString()
toString
in class java.lang.Object