org.jaudiotagger.audio.ogg
Class OggVorbisTagReader

java.lang.Object
  extended by org.jaudiotagger.audio.ogg.OggVorbisTagReader

public class OggVorbisTagReader
extends java.lang.Object

Read Vorbis Comment Tag within ogg

Vorbis is the audiostream within an ogg file, Vorbis uses VorbisComments as its tag


Nested Class Summary
static class OggVorbisTagReader.OggVorbisHeaderSizes
          Find the length of the raw packet data and the start position of the ogg page header they start in for the two OggVorbisHeader we need to know about when writing data (sizes included vorbis header)
 
Field Summary
static java.util.logging.Logger logger
           
private  VorbisCommentReader vorbisCommentReader
           
 
Constructor Summary
OggVorbisTagReader()
           
OggVorbisTagReader(Fix fix)
           
 
Method Summary
private  byte[] convertToVorbisCommentPacket(OggPageHeader startVorbisCommentPage, java.io.RandomAccessFile raf)
          The Vorbis Comment may span multiple pages so we we need to identify the pages they contain and then extract the packet data from the pages
 byte[] convertToVorbisSetupHeaderPacket(long fileOffsetOfStartingOggPage, java.io.RandomAccessFile raf)
          The Vorbis Setup Header may span multiple(2) pages, athough it doesnt normally.
 byte[] convertToVorbisSetupHeaderPacketAndAdditionalPackets(long fileOffsetOfStartingOggPage, java.io.RandomAccessFile raf)
          The Vorbis Setup Header may span multiple(2) pages, athough it doesnt normally.
 boolean isVorbisCommentHeader(byte[] headerData)
          Is this a Vorbis Comment header, check

Note this check only applies to Vorbis Comments embedded within an OggVorbis File which is why within here

 boolean isVorbisSetupHeader(byte[] headerData)
          Is this a Vorbis SetupHeader check
 Tag read(java.io.RandomAccessFile raf)
          Read the Logical VorbisComment Tag from the file

 OggVorbisTagReader.OggVorbisHeaderSizes readOggVorbisHeaderSizes(java.io.RandomAccessFile raf)
          Calculate the size of the packet data for the comment and setup headers
 int readOggVorbisRawSize(java.io.RandomAccessFile raf)
          Retrieve the Size of the VorbisComment packet including the oggvorbis header
 byte[] readRawPacketData(java.io.RandomAccessFile raf)
          Retrieve the raw VorbisComment packet data, does not include the OggVorbis header
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

public static java.util.logging.Logger logger

vorbisCommentReader

private VorbisCommentReader vorbisCommentReader
Constructor Detail

OggVorbisTagReader

public OggVorbisTagReader()

OggVorbisTagReader

public OggVorbisTagReader(Fix fix)
Method Detail

read

public Tag read(java.io.RandomAccessFile raf)
         throws CannotReadException,
                java.io.IOException
Read the Logical VorbisComment Tag from the file

Read the CommenyTag, within an OggVorbis file the VorbisCommentTag is mandatory

Parameters:
raf -
Returns:
Throws:
CannotReadException
java.io.IOException

readOggVorbisRawSize

public int readOggVorbisRawSize(java.io.RandomAccessFile raf)
                         throws CannotReadException,
                                java.io.IOException
Retrieve the Size of the VorbisComment packet including the oggvorbis header

Parameters:
raf -
Returns:
Throws:
CannotReadException
java.io.IOException

readRawPacketData

public byte[] readRawPacketData(java.io.RandomAccessFile raf)
                         throws CannotReadException,
                                java.io.IOException
Retrieve the raw VorbisComment packet data, does not include the OggVorbis header

Parameters:
raf -
Returns:
Throws:
CannotReadException - if unable to find vorbiscomment header
java.io.IOException

isVorbisCommentHeader

public boolean isVorbisCommentHeader(byte[] headerData)
Is this a Vorbis Comment header, check

Note this check only applies to Vorbis Comments embedded within an OggVorbis File which is why within here

Parameters:
headerData -
Returns:
true if the headerData matches a VorbisComment header i.e is a Vorbis header of type COMMENT_HEADER

isVorbisSetupHeader

public boolean isVorbisSetupHeader(byte[] headerData)
Is this a Vorbis SetupHeader check

Parameters:
headerData -
Returns:
true if matches vorbis setupheader

convertToVorbisCommentPacket

private byte[] convertToVorbisCommentPacket(OggPageHeader startVorbisCommentPage,
                                            java.io.RandomAccessFile raf)
                                     throws java.io.IOException,
                                            CannotReadException
The Vorbis Comment may span multiple pages so we we need to identify the pages they contain and then extract the packet data from the pages

Parameters:
startVorbisCommentPage -
raf -
Returns:
Throws:
CannotReadException
java.io.IOException

convertToVorbisSetupHeaderPacket

public byte[] convertToVorbisSetupHeaderPacket(long fileOffsetOfStartingOggPage,
                                               java.io.RandomAccessFile raf)
                                        throws java.io.IOException,
                                               CannotReadException
The Vorbis Setup Header may span multiple(2) pages, athough it doesnt normally. We pass the start of the file offset of the OggPage it belongs on, it probably won't be first packet.

Parameters:
fileOffsetOfStartingOggPage -
raf -
Returns:
Throws:
CannotReadException
java.io.IOException

convertToVorbisSetupHeaderPacketAndAdditionalPackets

public byte[] convertToVorbisSetupHeaderPacketAndAdditionalPackets(long fileOffsetOfStartingOggPage,
                                                                   java.io.RandomAccessFile raf)
                                                            throws java.io.IOException,
                                                                   CannotReadException
The Vorbis Setup Header may span multiple(2) pages, athough it doesnt normally. We pass the start of the file offset of the OggPage it belongs on, it probably won't be first packet, also returns any addditional packets that immediately follow the setup header in original file

Parameters:
fileOffsetOfStartingOggPage -
raf -
Returns:
Throws:
CannotReadException
java.io.IOException

readOggVorbisHeaderSizes

public OggVorbisTagReader.OggVorbisHeaderSizes readOggVorbisHeaderSizes(java.io.RandomAccessFile raf)
                                                                 throws CannotReadException,
                                                                        java.io.IOException
Calculate the size of the packet data for the comment and setup headers

Parameters:
raf -
Returns:
Throws:
CannotReadException
java.io.IOException