1 #ifndef TAG_PARSER_OGGITERATOR_H 2 #define TAG_PARSER_OGGITERATOR_H 13 OggIterator(std::istream &stream, uint64 startOffset, uint64 streamSize);
15 void clear(std::istream &stream, uint64 startOffset, uint64 streamSize);
16 std::istream &stream();
17 void setStream(std::istream &stream);
18 uint64 startOffset()
const;
19 uint64 streamSize()
const;
24 void previousSegment();
25 const std::vector<OggPage> &pages()
const;
26 const OggPage ¤tPage()
const;
27 uint64 currentPageOffset()
const;
28 std::vector<OggPage>::size_type currentPageIndex()
const;
29 void setPageIndex(std::vector<OggPage>::size_type index);
30 void setSegmentIndex(std::vector<uint32>::size_type index);
31 std::vector<uint32>::size_type currentSegmentIndex()
const;
32 uint64 currentSegmentOffset()
const;
33 uint64 currentCharacterOffset()
const;
35 uint32 currentSegmentSize()
const;
36 void setFilter(uint32 streamSerialId);
38 bool isLastPageFetched()
const;
39 void read(
char *buffer, std::size_t count);
40 size_t readAll(
char *buffer, std::size_t max);
41 void ignore(std::size_t count = 1);
42 bool bytesRemaining(std::size_t atLeast)
const;
43 bool resyncAt(uint64 offset);
45 operator bool()
const;
53 bool matchesFilter(
const OggPage &page);
55 std::istream *m_stream;
58 std::vector<OggPage> m_pages;
59 std::vector<OggPage>::size_type m_page;
60 std::vector<uint32>::size_type m_segment;
72 , m_startOffset(startOffset)
73 , m_streamSize(streamSize)
78 , m_hasIdFilter(false)
108 return m_startOffset;
133 return m_pages[m_page];
142 return m_pages[m_page].startOffset();
155 inline OggIterator::operator bool()
const 157 return m_page < m_pages.size() && m_segment < m_pages[m_page].segmentSizes().size();
174 const OggPage &page = m_pages[m_page = index];
186 const OggPage &page = m_pages[m_page];
187 m_offset = page.
dataOffset(m_segment = index);
213 return m_offset + m_bytesRead;
231 return m_pages[m_page].segmentSizes()[m_segment];
244 m_hasIdFilter =
true;
245 m_idFilter = streamSerialId;
254 m_hasIdFilter =
false;
262 return (m_pages.empty() ? m_startOffset : m_pages.back().startOffset() + m_pages.back().totalSize()) >= m_streamSize;
314 inline bool OggIterator::matchesFilter(
const OggPage &page)
321 #endif // TAG_PARSER_OGGITERATOR_H uint64 dataOffset(byte segmentIndex=0) const
Returns the data offset of the segment with the specified segmentIndex.
void previousSegment()
Decreases the current position by one segment.
uint64 streamSize() const
Returns the stream size (which has been specified when constructing the iterator).
The OggIterator class helps iterating through all segments of an OGG bitstream.
const OggPage & currentPage() const
Returns the current OGG page.
uint64 currentCharacterOffset() const
Returns the offset of the current character in the input stream if the iterator is valid; otherwise a...
void removeFilter()
Removes a previously set filter.
uint64 currentSegmentOffset() const
Returns the start offset of the current segment in the input stream if the iterator is valid; otherwi...
void nextSegment()
Increases the current position by one segment.
uint64 startOffset() const
Returns the start offset of the page.
std::vector< uint32 >::size_type currentSegmentIndex() const
Returns the index of the current segment (in the current page) if the iterator is valid; otherwise an...
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...
uint64 tellg() const
Same as currentCharacterOffset(); only provided for compliance with std::istream. ...
bool bytesRemaining(std::size_t atLeast) const
Returns whether there are atLeast bytes remaining.
const std::vector< OggPage > & pages() const
Returns a vector of containing the OGG pages that have been fetched yet.
void setStream(std::istream &stream)
Sets the stream.
uint32 streamSerialNumber() const
Returns the stream serial number.
void setPageIndex(std::vector< OggPage >::size_type index)
Sets the current page index.
OggIterator(std::istream &stream, uint64 startOffset, uint64 streamSize)
Constructs a new iterator for the specified stream of streamSize bytes at the specified startOffset...
uint64 currentPageOffset() const
Returns the start offset of the current OGG page.
void setFilter(uint32 streamSerialId)
Allows to filter pages by the specified streamSerialId.
std::istream & stream()
Returns the stream.
OggIterator & operator++()
Increments the current position by one segment if the iterator is valid; otherwise nothing happens...
uint32 headerSize() const
Returns the header size in byte.
OggIterator & operator--()
Decrements the current position by one segment if the iterator is valid; otherwise nothing happens...
The OggPage class is used to parse OGG pages.
void setSegmentIndex(std::vector< uint32 >::size_type index)
Sets the current segment index.
bool isLastPageFetched() const
Returns whether the last page has already been fetched.
uint64 startOffset() const
Returns the start offset (which has been specified when constructing the iterator).
uint32 currentSegmentSize() const
Returns the size of the current segment.
Contains all classes and functions of the TagInfo library.
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.