fi.helsinki.cs.ohtu.mpeg2.audio.mpa
Class MP123Header

java.lang.Object
  extended by fi.helsinki.cs.ohtu.mpeg2.audio.mpa.MP123Header

public class MP123Header
extends java.lang.Object

Represents an MPEG-1 audio frame header as described in the section 2.4.1.2 of ISO/IEC 11172-3.


Nested Class Summary
static class MP123Header.Layer
          Represents the MPEG-1 audio layer.
static class MP123Header.ModeExtension
          Represents the mode extension.
 
Field Summary
private  int bitrate
           
private  boolean copyrighted
           
private  boolean crcProtected
           
private  boolean isMpeg2
           
private  MP123Header.Layer layer
           
private  AudioEncoder.Mode mode
           
private  MP123Header.ModeExtension modeExt
           
private  boolean original
           
private  boolean padding
           
private  AudioEncoder.SampleRate srate
           
 
Constructor Summary
MP123Header()
          Creates a new MP123Header instance with default values.
MP123Header(MP123Header.Layer layer, AudioEncoder.Mode mode, AudioEncoder.SampleRate srate, int bitrate)
          Creates a new MP123Header instance with given parameters.
 
Method Summary
 int getBitrate()
          Returns the bitrate.
 MP123Header.Layer getLayer()
          Returns the layer.
 AudioEncoder.Mode getMode()
          Returns the mode.
 MP123Header.ModeExtension getModeExtension()
          Returns the mode extension.
 AudioEncoder.SampleRate getSampleRate()
          Returns the sample rate.
 boolean isCopyrighted()
          Returns wheter the audio is copyrighted.
 boolean isCRCProtected()
          Returns whether the CRC protection is on.
 boolean isOriginal()
          Returns whether the audio is an original.
 boolean isPadded()
          Returns whether the padding flag is set.
 void setBitrate(int bitrate)
          Sets the bitrate.
 void setCopyrighted(boolean copyrighted)
          Sets whether the audio is copyrighted.
 void setCRCProtection(boolean crcProtected)
          Sets whether the CRC protection is on.
 void setLayer(MP123Header.Layer layer)
          Sets the layer.
 void setMode(AudioEncoder.Mode mode)
          Sets the mode.
 void setModeExtension(MP123Header.ModeExtension modeExt)
          Sets the mode extension.
 void setOriginal(boolean original)
          Sets whether the audio is original.
 void setPadding(boolean padding)
          Sets whether the padding is on.
 void setSampleRate(AudioEncoder.SampleRate srate)
          Sets the sample rate.
 void writeTo(BitOutputStream stream)
          Writes the header to the given stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

layer

private MP123Header.Layer layer

mode

private AudioEncoder.Mode mode

modeExt

private MP123Header.ModeExtension modeExt

srate

private AudioEncoder.SampleRate srate

crcProtected

private boolean crcProtected

padding

private boolean padding

copyrighted

private boolean copyrighted

original

private boolean original

isMpeg2

private boolean isMpeg2

bitrate

private int bitrate
Constructor Detail

MP123Header

public MP123Header()
Creates a new MP123Header instance with default values. The defaults: the layer is Layer.LAYER_1, the mode is Mode.SINGLE_CHANNEL, the sample rate is SampleRate.SRATE_48000, the bitrate is 128kbit/s, CRC protection is off, padding is off, not original, not copyrighted.


MP123Header

public MP123Header(MP123Header.Layer layer,
                   AudioEncoder.Mode mode,
                   AudioEncoder.SampleRate srate,
                   int bitrate)
Creates a new MP123Header instance with given parameters.

Parameters:
layer - MPEG-1 audio layer
mode - the mode
srate - the sampling rate
bitrate - the bitrate
Method Detail

isCRCProtected

public boolean isCRCProtected()
Returns whether the CRC protection is on.

Returns:
true iff the CRC protection is on

isPadded

public boolean isPadded()
Returns whether the padding flag is set.

Returns:
true iff the padding flag is set

isOriginal

public boolean isOriginal()
Returns whether the audio is an original.

Returns:
true iff the audio is original

isCopyrighted

public boolean isCopyrighted()
Returns wheter the audio is copyrighted.

Returns:
true iff the audio is copyrighted

getMode

public AudioEncoder.Mode getMode()
Returns the mode.

Returns:
the mode

getModeExtension

public MP123Header.ModeExtension getModeExtension()
Returns the mode extension.

Returns:
the mode extension

getLayer

public MP123Header.Layer getLayer()
Returns the layer.

Returns:
the layer

getSampleRate

public AudioEncoder.SampleRate getSampleRate()
Returns the sample rate.

Returns:
the sample rate

getBitrate

public int getBitrate()
Returns the bitrate.

Returns:
the bitrate

setBitrate

public void setBitrate(int bitrate)
Sets the bitrate.

Parameters:
bitrate - the bitrate

setMode

public void setMode(AudioEncoder.Mode mode)
Sets the mode.

Parameters:
mode - the mode

setModeExtension

public void setModeExtension(MP123Header.ModeExtension modeExt)
Sets the mode extension.

Parameters:
modeExt - the mode extension

setLayer

public void setLayer(MP123Header.Layer layer)
Sets the layer.

Parameters:
layer - the layer

setSampleRate

public void setSampleRate(AudioEncoder.SampleRate srate)
Sets the sample rate.

Parameters:
srate - the sample rate

setPadding

public void setPadding(boolean padding)
Sets whether the padding is on.

Parameters:
padding - if true, the padding is set on; otherwise it is set off

setCRCProtection

public void setCRCProtection(boolean crcProtected)
Sets whether the CRC protection is on.

Parameters:
crcProtected - if true, the CRC protection is set on; otherwise it is set off

setOriginal

public void setOriginal(boolean original)
Sets whether the audio is original.

Parameters:
original - if true, the audio is original; otherwise it is not

setCopyrighted

public void setCopyrighted(boolean copyrighted)
Sets whether the audio is copyrighted.

Parameters:
copyrighted - if true, the audio is copyrighted; otherwise it is not

writeTo

public void writeTo(BitOutputStream stream)
             throws java.io.IOException
Writes the header to the given stream.

Parameters:
stream - the stream to write this header to
Throws:
java.io.IOException