Package org.apache.tika.parser.mp3
Class AudioFrame
java.lang.Object
org.apache.tika.parser.mp3.AudioFrame
- All Implemented Interfaces:
MP3Frame
An Audio Frame in an MP3 file. These come after the ID3v2 tags in the file.
Currently, only the header is processed, not the raw audio data.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Constant for audio layer 1.static final int
Constant for audio layer 2.static final int
Constant for audio layer 3.static final int
Constant for the MPEG version 1.static final int
Constant for the MPEG version 2.static final int
Constant for the MPEG version 2.5. -
Constructor Summary
ConstructorDescriptionAudioFrame
(int mpegVersion, int layer, int bitRate, int sampleRate, int channels, int length, float duration) Creates a new instance ofAudioFrame
and initializes all properties.AudioFrame
(int h1, int h2, int h3, int h4, InputStream in) Deprecated.Use the constructor which is passed all values directly.AudioFrame
(InputStream stream, ContentHandler handler) Deprecated.Use the constructor which is passed all values directly. -
Method Summary
Modifier and TypeMethodDescriptionint
Get the bit rate in bit per second.int
Get the number of channels (1=mono, 2=stereo)float
Returns the duration in milliseconds.int
getLayer()
Get the audio layer code.int
Returns the frame length in bytes.int
Get the sampling rate, in Hzint
Get the version code.static boolean
isAudioHeader
(int h1, int h2, int h3, int h4) Does this appear to be a 4 byte audio frame header?
-
Field Details
-
MPEG_V1
public static final int MPEG_V1Constant for the MPEG version 1.- See Also:
-
MPEG_V2
public static final int MPEG_V2Constant for the MPEG version 2.- See Also:
-
MPEG_V2_5
public static final int MPEG_V2_5Constant for the MPEG version 2.5.- See Also:
-
LAYER_1
public static final int LAYER_1Constant for audio layer 1.- See Also:
-
LAYER_2
public static final int LAYER_2Constant for audio layer 2.- See Also:
-
LAYER_3
public static final int LAYER_3Constant for audio layer 3.- See Also:
-
-
Constructor Details
-
AudioFrame
@Deprecated public AudioFrame(InputStream stream, ContentHandler handler) throws IOException, SAXException, TikaException Deprecated.Use the constructor which is passed all values directly.- Throws:
IOException
SAXException
TikaException
-
AudioFrame
Deprecated.Use the constructor which is passed all values directly.- Throws:
IOException
-
AudioFrame
public AudioFrame(int mpegVersion, int layer, int bitRate, int sampleRate, int channels, int length, float duration) Creates a new instance ofAudioFrame
and initializes all properties.- Parameters:
mpegVersion
- the code for the MPEG versionlayer
- the code for the layerbitRate
- the bit rate (in bps)sampleRate
- the sample rate (in samples per second)channels
- the number of channelslength
- the frame length (in bytes)duration
- the duration of this frame (in milliseconds)
-
-
Method Details
-
isAudioHeader
public static boolean isAudioHeader(int h1, int h2, int h3, int h4) Does this appear to be a 4 byte audio frame header? -
getVersion
-
getSampleRate
public int getSampleRate()Get the sampling rate, in Hz -
getChannels
public int getChannels()Get the number of channels (1=mono, 2=stereo) -
getVersionCode
public int getVersionCode()Get the version code.- Returns:
- the version code (one of the
MPEG
constants)
-
getLayer
public int getLayer()Get the audio layer code.- Returns:
- the audio layer (one of the
LAYER
constants)
-
getBitRate
public int getBitRate()Get the bit rate in bit per second.- Returns:
- the bit rate
-
getLength
public int getLength()Returns the frame length in bytes.- Returns:
- the frame length
-
getDuration
public float getDuration()Returns the duration in milliseconds.- Returns:
- the duration
-