Tag Parser 12.5.0
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
|
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 packet (true) or a fresh packet (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. | |
|
inline |
|
inline |
|
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.
|
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.
|
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.
|
inline |
Returns the data offset of the segment with the specified segmentIndex.
This is the start offset plus the header size.
|
inline |
|
inline |
|
inline |
Returns the header type flag.
|
inline |
|
inline |
|
inline |
|
inline |
|
static |
Writes the segment size denotation for the specified segment size to the specified stream.
Definition at line 129 of file oggpage.cpp.
|
inline |
Returns whether the stream serial number of the current instance matches the specified one.
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.
Throws | InvalidDataException if the capture pattern is not present. |
Throws | TruncatedDataException if the header is truncated (according to maxSize). |
Definition at line 27 of file oggpage.cpp.
|
inline |
|
inline |
|
inline |
|
inline |
Returns the start offset of the page.
The start offset has been specified when calling the parseHeader() method.
|
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.
|
inline |
|
inline |
|
static |
Updates the checksum of the page read from the specified stream at the specified startOffset.
Definition at line 116 of file oggpage.cpp.