Package de.jarnbjo.ogg
Class OggPage
java.lang.Object
de.jarnbjo.ogg.OggPage
An instance of this class represents an ogg page read from an ogg file
or network stream. It has no public constructor, but instances can be
created by the create methods, supplying a JMF stream or
a RandomAccessFile
which is positioned at the beginning of an Ogg page.
Furthermore, the class provides methods for accessing the raw page data, as well as data attributes like segmenting information, sequence number, stream serial number, checksum and whether this page is the beginning or end of a logical bitstream (BOS, EOS) and if the page data starts with a continued packet or a fresh data packet.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic OggPagecreate(byte[] source) this method equals to create(byte[] source, false)static OggPagecreate(byte[] source, boolean skipData) This method is called to create a new OggPage instance based on the specified byte array.static OggPagecreate(InputStream source) this method equals to create(InputStream source, false)static OggPagecreate(InputStream source, boolean skipData) This method is called to read data from the current position in the specified InputStream and create a new OggPage instance based on the data read.static OggPagecreate(RandomAccessFile source) this method equals to create(RandomAccessFile source, false)static OggPagecreate(RandomAccessFile source, boolean skipData) This method is called to read data from the current position in the specified RandomAccessFile and create a new OggPage instance based on the data read.longReturns the absolute granule position of the last complete packet contained in this Ogg page, or -1 if the page contains a single packet, which is not completed on this page.byte[]getData()byte[]intReturn the check sum of this ogg page.intReturn the sequence number of this ogg page.int[]int[]byte[]intReturns the stream serial number of this ogg page.intbooleanisBos()booleanbooleanisEos()booleanisFresh()
-
Constructor Details
-
OggPage
protected OggPage()
-
-
Method Details
-
create
public static OggPage create(RandomAccessFile source) throws IOException, EndOfOggStreamException, OggFormatException this method equals to create(RandomAccessFile source, false)- Parameters:
source-- Returns:
- an ogg page created by reading data from the specified source
- Throws:
IOExceptionEndOfOggStreamExceptionOggFormatException- See Also:
-
create(RandomAccessFile, boolean)
-
create
public static OggPage create(RandomAccessFile source, boolean skipData) throws IOException, EndOfOggStreamException, OggFormatException This method is called to read data from the current position in the specified RandomAccessFile and create a new OggPage instance based on the data read. If the parameterskipDatais set totrue, the actual page segments (page data) is skipped and not read into memory. This mode is useful when scanning through an ogg file to build a seek table.- Parameters:
source- the source from which the ogg page is generatedskipData- if set totrue, the actual page data is not read into memory- Returns:
- an ogg page created by reading data from the specified source, starting at the current position
- Throws:
OggFormatException- if the data read from the specified source is not matching the specification for an ogg pageEndOfOggStreamException- if it is not possible to read an entire ogg page from the specified sourceIOException- if some other I/O error is detected when reading from the source- See Also:
-
create
public static OggPage create(InputStream source) throws IOException, EndOfOggStreamException, OggFormatException this method equals to create(InputStream source, false)- Parameters:
source-- Returns:
- an ogg page created by reading data from the specified source
- Throws:
IOExceptionEndOfOggStreamExceptionOggFormatException- See Also:
-
create(InputStream, boolean)
-
create
public static OggPage create(InputStream source, boolean skipData) throws IOException, EndOfOggStreamException, OggFormatException This method is called to read data from the current position in the specified InputStream and create a new OggPage instance based on the data read. If the parameterskipDatais set totrue, the actual page segments (page data) is skipped and not read into memory. This mode is useful when scanning through an ogg file to build a seek table.- Parameters:
source- the source from which the ogg page is generatedskipData- if set totrue, the actual page data is not read into memory- Returns:
- an ogg page created by reading data from the specified source, starting at the current position
- Throws:
OggFormatException- if the data read from the specified source is not matching the specification for an ogg pageEndOfOggStreamException- if it is not possible to read an entire ogg page from the specified sourceIOException- if some other I/O error is detected when reading from the source- See Also:
-
create
public static OggPage create(byte[] source) throws IOException, EndOfOggStreamException, OggFormatException this method equals to create(byte[] source, false)- Parameters:
source-- Returns:
- an ogg page created by reading data from the specified source
- Throws:
IOExceptionEndOfOggStreamExceptionOggFormatException- See Also:
-
create(byte[], boolean)
-
create
public static OggPage create(byte[] source, boolean skipData) throws IOException, EndOfOggStreamException, OggFormatException This method is called to create a new OggPage instance based on the specified byte array.- Parameters:
source- the source from which the ogg page is generatedskipData- if set totrue, the actual page data is not read into memory- Returns:
- an ogg page created by reading data from the specified source, starting at the current position
- Throws:
OggFormatException- if the data read from the specified source is not matching the specification for an ogg pageEndOfOggStreamException- if it is not possible to read an entire ogg page from the specified sourceIOException- if some other I/O error is detected when reading from the source- See Also:
-
getAbsoluteGranulePosition
public long getAbsoluteGranulePosition()Returns the absolute granule position of the last complete packet contained in this Ogg page, or -1 if the page contains a single packet, which is not completed on this page. For pages containing Vorbis data, this value is the sample index within the Vorbis stream. The Vorbis stream does not necessarily start with sample index 0.- Returns:
- the absolute granule position of the last packet completed on this page
-
getStreamSerialNumber
public int getStreamSerialNumber()Returns the stream serial number of this ogg page.- Returns:
- this page's serial number
-
getPageSequenceNumber
public int getPageSequenceNumber()Return the sequence number of this ogg page.- Returns:
- this page's sequence number
-
getPageCheckSum
public int getPageCheckSum()Return the check sum of this ogg page.- Returns:
- this page's check sum
-
getTotalLength
public int getTotalLength()- Returns:
- the total number of bytes in the page data
-
getData
public byte[] getData()- Returns:
- a ByteBuffer containing the page data
-
getHeader
public byte[] getHeader() -
getSegmentTable
public byte[] getSegmentTable() -
getSegmentOffsets
public int[] getSegmentOffsets() -
getSegmentLengths
public int[] getSegmentLengths() -
isContinued
public boolean isContinued()- Returns:
trueif this page begins with a continued packet
-
isFresh
public boolean isFresh()- Returns:
trueif this page begins with a fresh packet
-
isBos
public boolean isBos()- Returns:
trueif this page is the beginning of a logical stream
-
isEos
public boolean isEos()- Returns:
trueif this page is the end of a logical stream
-