Tag Parser 12.1.0
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
Loading...
Searching...
No Matches
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.
 
 OggPage (std::istream &stream, std::uint64_t startOffset, std::int32_t maxSize)
 Constructs a new OggPage and instantly parses the header read from the specified stream at the specified startOffset.
 
void parseHeader (std::istream &stream, std::uint64_t startOffset, std::int32_t maxSize)
 Parses the header read from the specified stream at the specified startOffset.
 
std::uint64_t startOffset () const
 Returns the start offset of the page.
 
std::uint8_t streamStructureVersion () const
 Returns the stream structure version.
 
std::uint8_t headerTypeFlag () const
 Returns the header type flag.
 
bool isContinued () const
 Returns whether this page is a continued packed (true) or a fresh packed (false).
 
bool isFirstpage () const
 Returns whether this page is the first page of the logical bitstream.
 
bool isLastPage () const
 Returns whether this page is the last page of the logical bitstream.
 
bool isLastSegmentUnconcluded () const
 Returns whether the last segment is unconcluded (the last lacing value of the last segment is 0xFF).
 
std::uint64_t absoluteGranulePosition () const
 Returns the absolute granule position.
 
std::uint32_t streamSerialNumber () const
 Returns the stream serial number.
 
bool matchesStreamSerialNumber (std::uint32_t streamSerialNumber) const
 Returns whether the stream serial number of the current instance matches the specified one.
 
std::uint32_t sequenceNumber () const
 Returns the page sequence number.
 
std::uint32_t checksum () const
 Returns the page checksum.
 
std::uint8_t segmentTableSize () const
 Returns the size of the segment table.
 
const std::vector< std::uint32_t > & segmentSizes () const
 Returns the sizes of the segments of the page in byte.
 
std::uint32_t headerSize () const
 Returns the header size in byte.
 
std::uint32_t dataSize () const
 Returns the data size in byte.
 
std::uint32_t totalSize () const
 Returns the total size of the page in byte.
 
std::uint64_t dataOffset (std::vector< std::uint32_t >::size_type segmentIndex=0) const
 Returns the data offset of the segment with the specified segmentIndex.
 

Static Public Member Functions

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

Detailed Description

The OggPage class is used to parse OGG pages.

See also
http://www.xiph.org/ogg/doc/framing.html
Todo:
Add field for additional flags in v11.

Definition at line 13 of file oggpage.h.

Constructor & Destructor Documentation

◆ OggPage() [1/2]

TagParser::OggPage::OggPage ( )
inline

Constructs a new OGG page.

Definition at line 58 of file oggpage.h.

◆ OggPage() [2/2]

TagParser::OggPage::OggPage ( std::istream &  stream,
std::uint64_t  startOffset,
std::int32_t  maxSize 
)
inline

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

Definition at line 75 of file oggpage.h.

Member Function Documentation

◆ absoluteGranulePosition()

std::uint64_t 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 153 of file oggpage.h.

◆ checksum()

std::uint32_t 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 200 of file oggpage.h.

◆ computeChecksum()

std::uint32_t TagParser::OggPage::computeChecksum ( std::istream &  stream,
std::uint64_t  startOffset 
)
static

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

Definition at line 79 of file oggpage.cpp.

◆ dataOffset()

std::uint64_t TagParser::OggPage::dataOffset ( std::vector< std::uint32_t >::size_type  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 259 of file oggpage.h.

◆ dataSize()

std::uint32_t TagParser::OggPage::dataSize ( ) const
inline

Returns the data size in byte.

Definition at line 238 of file oggpage.h.

◆ headerSize()

std::uint32_t 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 230 of file oggpage.h.

◆ headerTypeFlag()

std::uint8_t TagParser::OggPage::headerTypeFlag ( ) const
inline

Returns the header type flag.

See also
isContinued()
isFirstpage()
isLastPage()

Definition at line 105 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 113 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 121 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 129 of file oggpage.h.

◆ isLastSegmentUnconcluded()

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

Returns whether the last segment is unconcluded (the last lacing value of the last segment is 0xFF).

Definition at line 137 of file oggpage.h.

◆ makeSegmentSizeDenotation()

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

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

Returns
Returns the number of bytes written.
Deprecated:
This function is unused and should be removed in v11.

Definition at line 129 of file oggpage.cpp.

◆ matchesStreamSerialNumber()

bool TagParser::OggPage::matchesStreamSerialNumber ( std::uint32_t  streamSerialNumber) const
inline

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

See also
streamSerialNumber()

Definition at line 175 of file oggpage.h.

◆ parseHeader()

void TagParser::OggPage::parseHeader ( std::istream &  stream,
std::uint64_t  startOffset,
std::int32_t  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 27 of file oggpage.cpp.

◆ segmentSizes()

const std::vector< std::uint32_t > & 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 220 of file oggpage.h.

◆ segmentTableSize()

std::uint8_t 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 210 of file oggpage.h.

◆ sequenceNumber()

std::uint32_t 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 185 of file oggpage.h.

◆ startOffset()

std::uint64_t 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 86 of file oggpage.h.

◆ streamSerialNumber()

std::uint32_t 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 166 of file oggpage.h.

◆ streamStructureVersion()

std::uint8_t TagParser::OggPage::streamStructureVersion ( ) const
inline

Returns the stream structure version.

Definition at line 94 of file oggpage.h.

◆ totalSize()

std::uint32_t TagParser::OggPage::totalSize ( ) const
inline

Returns the total size of the page in byte.

Definition at line 246 of file oggpage.h.

◆ updateChecksum()

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

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

Definition at line 116 of file oggpage.cpp.


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