Tag Parser  8.0.0
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
Public Member Functions | Static Public Member Functions | List of all members
TagParser::OggPage Class Reference

The OggPage class is used to parse OGG pages. More...

#include <oggpage.h>

Public Member Functions

 OggPage ()
 Constructs a new OGG page. More...
 
 OggPage (std::istream &stream, uint64 startOffset, int32 maxSize)
 Constructs a new OggPage and instantly parses the header read from the specified stream at the specified startOffset. More...
 
void parseHeader (std::istream &stream, uint64 startOffset, int32 maxSize)
 Parses the header read from the specified stream at the specified startOffset. More...
 
uint64 startOffset () const
 Returns the start offset of the page. More...
 
byte streamStructureVersion () const
 Returns the stream structure version. More...
 
byte headerTypeFlag () const
 Returns the header type flag. More...
 
bool isContinued () const
 Returns whether this page is a continued packed (true) or a fresh packed (false). More...
 
bool isFirstpage () const
 Returns whether this page is the first page of the logical bitstream. More...
 
bool isLastPage () const
 Returns whether this page is the last page of the logical bitstream. More...
 
uint64 absoluteGranulePosition () const
 Returns the absolute granule position. More...
 
uint32 streamSerialNumber () const
 Returns the stream serial number. More...
 
bool matchesStreamSerialNumber (uint32 streamSerialNumber) const
 Returns whether the stream serial number of the current instance matches the specified one. More...
 
uint32 sequenceNumber () const
 Returns the page sequence number. More...
 
uint32 checksum () const
 Returns the page checksum. More...
 
byte segmentTableSize () const
 Returns the size of the segment table. More...
 
const std::vector< uint32 > & segmentSizes () const
 Returns the sizes of the segments of the page in byte. More...
 
uint32 headerSize () const
 Returns the header size in byte. More...
 
uint32 dataSize () const
 Returns the data size in byte. More...
 
uint32 totalSize () const
 Returns the total size of the page in byte. More...
 
uint64 dataOffset (byte segmentIndex=0) const
 Returns the data offset of the segment with the specified segmentIndex. More...
 

Static Public Member Functions

static uint32 computeChecksum (std::istream &stream, uint64 startOffset)
 Computes the actual checksum of the page read from the specified stream at the specified startOffset. More...
 
static void updateChecksum (std::iostream &stream, uint64 startOffset)
 Updates the checksum of the page read from the specified stream at the specified startOffset. More...
 
static uint32 makeSegmentSizeDenotation (std::ostream &stream, uint32 size)
 Writes the segment size denotation for the specified segment size to the specified stream. More...
 

Detailed Description

The OggPage class is used to parse OGG pages.

See also
http://www.xiph.org/ogg/doc/framing.html

Definition at line 14 of file oggpage.h.

Constructor & Destructor Documentation

◆ OggPage() [1/2]

TagParser::OggPage::OggPage ( )
inline

Constructs a new OGG page.

Definition at line 57 of file oggpage.h.

◆ OggPage() [2/2]

TagParser::OggPage::OggPage ( std::istream &  stream,
uint64  startOffset,
int32  maxSize 
)
inline

Constructs a new OggPage and instantly parses the header read from the specified stream at the specified startOffset.

Definition at line 73 of file oggpage.h.

Member Function Documentation

◆ absoluteGranulePosition()

uint64 TagParser::OggPage::absoluteGranulePosition ( ) const
inline

Returns the absolute granule position.

The position specified is the total samples encoded after including all packets finished on this page (packets begun on this page but continuing on to the next page do not count). The rationale here is that the position specified in the frame header of the last page tells how long the data coded by the bitstream is. A truncated stream will still return the proper number of samples that can be decoded fully.

A special value of '-1' (in two's complement) indicates that no packets finish on this page.

Definition at line 143 of file oggpage.h.

◆ checksum()

uint32 TagParser::OggPage::checksum ( ) const
inline

Returns the page checksum.

32 bit CRC value (direct algorithm, initial val and final XOR = 0, generator polynomial=0x04c11db7). The value is computed over the entire header (with the CRC field in the header set to zero) and then continued over the page. The CRC field is then filled with the computed value.

See also
This method returns the checksum denoted by the header. To compute the actual checksum use the computeChecksum() method.

Definition at line 190 of file oggpage.h.

◆ computeChecksum()

uint32 TagParser::OggPage::computeChecksum ( std::istream &  stream,
uint64  startOffset 
)
static

Computes the actual checksum of the page read from the specified stream at the specified startOffset.

Definition at line 75 of file oggpage.cpp.

◆ dataOffset()

uint64 TagParser::OggPage::dataOffset ( byte  segmentIndex = 0) const
inline

Returns the data offset of the segment with the specified segmentIndex.

This is the start offset plus the header size.

See also
startOffset()
headerSize()

Definition at line 249 of file oggpage.h.

◆ dataSize()

uint32 TagParser::OggPage::dataSize ( ) const
inline

Returns the data size in byte.

Definition at line 228 of file oggpage.h.

◆ headerSize()

uint32 TagParser::OggPage::headerSize ( ) const
inline

Returns the header size in byte.

This is 27 plus the number of segment entries in the segment table.

Definition at line 220 of file oggpage.h.

◆ headerTypeFlag()

byte TagParser::OggPage::headerTypeFlag ( ) const
inline

Returns the header type flag.

See also
isContinued()
isFirstpage()
isLastPage()

Definition at line 103 of file oggpage.h.

◆ isContinued()

bool TagParser::OggPage::isContinued ( ) const
inline

Returns whether this page is a continued packed (true) or a fresh packed (false).

Definition at line 111 of file oggpage.h.

◆ isFirstpage()

bool TagParser::OggPage::isFirstpage ( ) const
inline

Returns whether this page is the first page of the logical bitstream.

Definition at line 119 of file oggpage.h.

◆ isLastPage()

bool TagParser::OggPage::isLastPage ( ) const
inline

Returns whether this page is the last page of the logical bitstream.

Definition at line 127 of file oggpage.h.

◆ makeSegmentSizeDenotation()

uint32 TagParser::OggPage::makeSegmentSizeDenotation ( std::ostream &  stream,
uint32  size 
)
static

Writes the segment size denotation for the specified segment size to the specified stream.

Returns
Returns the number of bytes written.

Definition at line 124 of file oggpage.cpp.

◆ matchesStreamSerialNumber()

bool TagParser::OggPage::matchesStreamSerialNumber ( uint32  streamSerialNumber) const
inline

Returns whether the stream serial number of the current instance matches the specified one.

See also
streamSerialNumber()

Definition at line 165 of file oggpage.h.

◆ parseHeader()

void TagParser::OggPage::parseHeader ( std::istream &  stream,
uint64  startOffset,
int32  maxSize 
)

Parses the header read from the specified stream at the specified startOffset.

Exceptions
ThrowsInvalidDataException if the capture pattern is not present.
ThrowsTruncatedDataException if the header is truncated (according to maxSize).

Definition at line 25 of file oggpage.cpp.

◆ segmentSizes()

const std::vector< uint32 > & TagParser::OggPage::segmentSizes ( ) const
inline

Returns the sizes of the segments of the page in byte.

The lacing values for each packet segment physically appearing in this page are listed in contiguous order.

Definition at line 210 of file oggpage.h.

◆ segmentTableSize()

byte TagParser::OggPage::segmentTableSize ( ) const
inline

Returns the size of the segment table.

The number of segment entries to appear in the segment table.

Definition at line 200 of file oggpage.h.

◆ sequenceNumber()

uint32 TagParser::OggPage::sequenceNumber ( ) const
inline

Returns the page sequence number.

Page counter; lets us know if a page is lost (useful where packets span page boundaries).

Definition at line 175 of file oggpage.h.

◆ startOffset()

uint64 TagParser::OggPage::startOffset ( ) const
inline

Returns the start offset of the page.

The start offset has been specified when calling the parseHeader() method.

Definition at line 84 of file oggpage.h.

◆ streamSerialNumber()

uint32 TagParser::OggPage::streamSerialNumber ( ) const
inline

Returns the stream serial number.

Ogg allows for separate logical bitstreams to be mixed at page granularity in a physical bitstream. The most common case would be sequential arrangement, but it is possible to interleave pages for two separate bitstreams to be decoded concurrently. The serial number is the means by which pages physical pages are associated with a particular logical stream.

Definition at line 156 of file oggpage.h.

◆ streamStructureVersion()

byte TagParser::OggPage::streamStructureVersion ( ) const
inline

Returns the stream structure version.

Definition at line 92 of file oggpage.h.

◆ totalSize()

uint32 TagParser::OggPage::totalSize ( ) const
inline

Returns the total size of the page in byte.

Definition at line 236 of file oggpage.h.

◆ updateChecksum()

void TagParser::OggPage::updateChecksum ( std::iostream &  stream,
uint64  startOffset 
)
static

Updates the checksum of the page read from the specified stream at the specified startOffset.

Definition at line 112 of file oggpage.cpp.


The documentation for this class was generated from the following files: