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];
66 for(
bool hasIdentificationHeader =
false, hasCommentHeader =
false; iterator ; ++iterator) {
70 if(currentSize >= 8) {
73 const uint64 sig =
reader().readUInt64BE();
75 if((sig & 0x00ffffffffffff00u) == 0x00766F7262697300u) {
93 if(!hasIdentificationHeader) {
110 const auto &pages = iterator.
pages();
111 const auto firstPage = find_if(pages.cbegin(), pages.cend(), pred);
112 const auto lastPage = find_if(pages.crbegin(), pages.crend(), pred);
113 if(firstPage != pages.cend() && lastPage != pages.crend()) {
118 hasIdentificationHeader =
true;
125 if(!hasCommentHeader) {
127 hasCommentHeader =
true;
138 }
else if(sig == 0x4F70757348656164u) {
152 if(!hasIdentificationHeader) {
161 const auto &pages = iterator.
pages();
162 const auto firstPage = find_if(pages.cbegin(), pages.cend(), pred);
163 const auto lastPage = find_if(pages.crbegin(), pages.crend(), pred);
164 if(firstPage != pages.cend() && lastPage != pages.crend()) {
175 hasIdentificationHeader =
true;
180 }
else if(sig == 0x4F70757354616773u) {
196 if(!hasCommentHeader) {
198 hasCommentHeader =
true;
203 }
else if((sig & 0xFFFFFFFFFF000000u) == 0x7F464C4143000000u) {
218 if(!hasIdentificationHeader) {
228 const auto &pages = iterator.
pages();
229 const auto firstPage = find_if(pages.cbegin(), pages.cend(), pred);
230 const auto lastPage = find_if(pages.crbegin(), pages.crend(), pred);
231 if(firstPage != pages.cend() && lastPage != pages.crend()) {
236 hasIdentificationHeader =
true;
241 if(!hasCommentHeader) {
245 iterator.
read(buff, 4);
250 hasCommentHeader =
true;
259 }
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.