1#ifndef TAG_PARSER_OGGITERATOR_H
2#define TAG_PARSER_OGGITERATOR_H
25 const std::vector<OggPage> &
pages()
const;
26 std::vector<OggPage> &
pages();
30 void setPageIndex(std::vector<OggPage>::size_type index);
35 std::uint64_t
tellg()
const;
39 void setFilter(std::uint32_t streamSerialId);
42 void read(
char *buffer, std::size_t count);
43 std::size_t
readAll(
char *buffer, std::size_t max);
44 void ignore(std::size_t count = 1);
48 operator bool()
const;
56 bool matchesFilter(
const OggPage &page);
58 std::istream *m_stream;
59 std::uint64_t m_startOffset;
60 std::uint64_t m_streamSize;
61 std::vector<OggPage> m_pages;
62 std::vector<OggPage>::size_type m_page;
63 std::vector<std::uint32_t>::size_type m_segment;
64 std::uint64_t m_offset;
65 std::uint64_t m_bytesRead;
67 std::uint32_t m_idFilter;
81 , m_hasIdFilter(false)
111 return m_startOffset;
144 return m_pages[m_page];
166inline OggIterator::operator bool()
const
168 return m_page < m_pages.size() && m_segment < m_pages[m_page].segmentSizes().size();
166inline OggIterator::operator bool()
const {
…}
185 const OggPage &page = m_pages[m_page = index];
197 const OggPage &page = m_pages[m_page];
198 m_offset = page.
dataOffset(m_segment = index);
224 return m_offset + m_bytesRead;
242 return m_pages[m_page].segmentSizes()[m_segment];
271 m_hasIdFilter =
true;
272 m_idFilter = streamSerialId;
281 m_hasIdFilter =
false;
289 return (m_pages.empty() ? m_startOffset : m_pages.back().startOffset() + m_pages.back().totalSize()) >= m_streamSize;
342inline bool OggIterator::matchesFilter(
const OggPage &page)
void nextPage()
Increases the current position by one page.
void setSegmentIndex(std::vector< std::uint32_t >::size_type index)
Sets the current segment index.
std::uint64_t currentCharacterOffset() const
Returns the offset of the current character in the input stream if the iterator is valid; otherwise a...
bool bytesRemaining(std::size_t atLeast) const
Returns whether there are atLeast bytes remaining.
void read(char *buffer, std::size_t count)
Reads count bytes from the Ogg stream and writes it to the specified buffer.
std::uint64_t remainingBytesInCurrentSegment() const
Returns the number of bytes left to read in the current segment.
void removeFilter()
Removes a previously set filter.
std::uint64_t tellg() const
Same as currentCharacterOffset(); only provided for compliance with std::istream.
OggIterator(std::istream &stream, std::uint64_t startOffset, std::uint64_t streamSize)
Constructs a new iterator for the specified stream of streamSize bytes at the specified startOffset.
void setStream(std::istream &stream)
Sets the stream.
OggIterator & operator++()
Increments the current position by one segment if the iterator is valid; otherwise nothing happens.
std::vector< std::uint32_t >::size_type currentSegmentIndex() const
Returns the index of the current segment (in the current page) if the iterator is valid; otherwise an...
OggIterator & operator--()
Decrements the current position by one segment if the iterator is valid; otherwise nothing happens.
std::size_t readAll(char *buffer, std::size_t max)
Reads all bytes from the Ogg stream and writes it to the specified buffer.
void clear(std::istream &stream, std::uint64_t startOffset, std::uint64_t streamSize)
Sets the stream and related parameters and clears all available pages.
void previousPage()
Decreases the current position by one page.
std::uint64_t currentSegmentOffset() const
Returns the start offset of the current segment in the input stream if the iterator is valid; otherwi...
std::uint64_t currentPageOffset() const
Returns the start offset of the current Ogg page.
const OggPage & currentPage() const
Returns the current Ogg page.
const std::vector< OggPage > & pages() const
Returns a vector of containing the Ogg pages that have been fetched yet.
bool resyncAt(std::uint64_t offset)
Fetches the next page at the specified offset.
std::istream & stream()
Returns the stream.
std::uint64_t startOffset() const
Returns the start offset (which has been specified when constructing the iterator).
std::uint64_t bytesReadFromCurrentSegment() const
Returns the number of bytes read from the current segment.
void setPageIndex(std::vector< OggPage >::size_type index)
Sets the current page index.
std::vector< OggPage >::size_type currentPageIndex() const
Returns the index of the current page if the iterator is valid; otherwise an undefined index is retur...
std::uint32_t currentSegmentSize() const
Returns the size of the current segment.
void nextSegment()
Increases the current position by one segment.
void reset()
Resets the iterator to point at the first segment of the first page (matching the filter if set).
void setFilter(std::uint32_t streamSerialId)
Allows to filter pages by the specified streamSerialId.
void ignore(std::size_t count=1)
Advances the position of the next character to be read from the Ogg stream by count bytes.
void previousSegment()
Decreases the current position by one segment.
bool isLastPageFetched() const
Returns whether the last page has already been fetched.
std::uint64_t streamSize() const
Returns the stream size (which has been specified when constructing the iterator).
The OggPage class is used to parse Ogg pages.
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.
std::uint32_t streamSerialNumber() const
Returns the stream serial number.
std::uint64_t startOffset() const
Returns the start offset of the page.
std::uint32_t headerSize() const
Returns the header size in byte.
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.
Contains all classes and functions of the TagInfo library.