4 #include "../vorbis/vorbispackagetypes.h" 5 #include "../vorbis/vorbisidentificationheader.h" 7 #include "../opus/opusidentificationheader.h" 9 #include "../flac/flactooggmappingheader.h" 11 #include "../mediafileinfo.h" 12 #include "../exceptions.h" 13 #include "../mediaformat.h" 15 #include <c++utilities/chrono/timespan.h> 34 OggStream::OggStream(
OggContainer &container, vector<OggPage>::size_type startPage) :
35 AbstractTrack(container.stream(), container.m_iterator.pages()[startPage].startOffset()),
36 m_startPage(startPage),
37 m_container(container),
38 m_currentSequenceNumber(0)
49 static const string context(
"parsing OGG page header");
53 const OggPage &firstPage = iterator.
pages()[m_startPage];
65 for(
bool hasIdentificationHeader =
false, hasCommentHeader =
false; iterator && (!hasIdentificationHeader || !hasCommentHeader); ++iterator) {
67 if(currentSize >= 8) {
70 const uint64 sig =
reader().readUInt64BE();
72 if((sig & 0x00ffffffffffff00u) == 0x00766F7262697300u) {
90 if(!hasIdentificationHeader) {
107 const auto &pages = iterator.
pages();
108 const auto firstPage = find_if(pages.cbegin(), pages.cend(), pred);
109 const auto lastPage = find_if(pages.crbegin(), pages.crend(), pred);
110 if(firstPage != pages.cend() && lastPage != pages.crend()) {
115 hasIdentificationHeader =
true;
122 if(!hasCommentHeader) {
124 hasCommentHeader =
true;
135 }
else if(sig == 0x4F70757348656164u) {
149 if(!hasIdentificationHeader) {
158 const auto &pages = iterator.
pages();
159 const auto firstPage = find_if(pages.cbegin(), pages.cend(), pred);
160 const auto lastPage = find_if(pages.crbegin(), pages.crend(), pred);
161 if(firstPage != pages.cend() && lastPage != pages.crend()) {
172 hasIdentificationHeader =
true;
177 }
else if(sig == 0x4F70757354616773u) {
193 if(!hasCommentHeader) {
195 hasCommentHeader =
true;
200 }
else if((sig & 0xFFFFFFFFFF000000u) == 0x7F464C4143000000u) {
215 if(!hasIdentificationHeader) {
225 const auto &pages = iterator.
pages();
226 const auto firstPage = find_if(pages.cbegin(), pages.cend(), pred);
227 const auto lastPage = find_if(pages.crbegin(), pages.crend(), pred);
228 if(firstPage != pages.cend() && lastPage != pages.crend()) {
233 hasIdentificationHeader =
true;
238 if(!hasCommentHeader) {
242 iterator.
read(buff, 4);
247 hasCommentHeader =
true;
256 }
else if((sig & 0x00ffffffffffff00u) == 0x007468656F726100u) {
bool matchesStreamSerialNumber(uint32 streamSerialNumber) const
Returns whether the stream serial number of the current instance matches the specified one...
uint32 streamSerialNumber() const
Returns the stream serial number.
The OggPage class is used to parse OGG pages.
byte streamStructureVersion() const
Returns the stream structure version.
uint64 absoluteGranulePosition() const
Returns the absolute granule position.