bool COggFile::Read(OggPage& page, bool fFull, HANDLE hBreak) { memset(&page.m_hdr, 0, sizeof(page.m_hdr)); page.m_lens.RemoveAll(); page.SetCount(0); if(!Read(page.m_hdr, hBreak)) return(false); int pagelen = 0, packetlen = 0; for(BYTE i = 0; i < page.m_hdr.number_page_segments; i++) { BYTE b; if(S_OK != ByteRead(&b, 1)) return(false); packetlen += b; if(1/*b < 0xff*/) {page.m_lens.AddTail(packetlen); pagelen += packetlen; packetlen = 0;} } if(fFull) { page.SetCount(pagelen); if(S_OK != ByteRead(page.GetData(), page.GetCount())) return(false); } else { Seek(GetPos() + pagelen); page.m_lens.RemoveAll(); } return(true); }
bool CDSMSplitterFile::Read(__int64 len, BYTE& id, CMediaType& mt) { id = (BYTE)BitRead(8); ByteRead((BYTE*)&mt.majortype, sizeof(mt.majortype)); ByteRead((BYTE*)&mt.subtype, sizeof(mt.subtype)); mt.bFixedSizeSamples = (BOOL)BitRead(1); mt.bTemporalCompression = (BOOL)BitRead(1); mt.lSampleSize = (ULONG)BitRead(30); ByteRead((BYTE*)&mt.formattype, sizeof(mt.formattype)); len -= 5 + sizeof(GUID)*3; ASSERT(len >= 0); if(len > 0) {mt.AllocFormatBuffer((LONG)len); ByteRead(mt.Format(), mt.FormatLength());} else mt.ResetFormatBuffer(); return true; }
bool CDSMSplitterFile::Read(__int64 len, Packet* p, bool fData) { if (!p) { return false; } p->TrackNumber = (DWORD)BitRead(8); p->bSyncPoint = (BOOL)BitRead(1); bool fSign = !!BitRead(1); int iTimeStamp = (int)BitRead(3); int iDuration = (int)BitRead(3); if (fSign && !iTimeStamp) { ASSERT(!iDuration); p->rtStart = Packet::INVALID_TIME; p->rtStop = Packet::INVALID_TIME + 1; } else { p->rtStart = (REFERENCE_TIME)BitRead(iTimeStamp<<3) * (fSign ? -1 : 1); p->rtStop = p->rtStart + BitRead(iDuration<<3); } if (fData) { p->SetCount((INT_PTR)len - (2 + iTimeStamp + iDuration)); ByteRead(p->GetData(), p->GetCount()); } return true; }
bool CDSMSplitterFile::Read(__int64 len, CStreamInfoMap& im) { while (len >= 5) { CStringA key; ByteRead((BYTE*)key.GetBufferSetLength(4), 4); len -= 4; len -= Read(len, im[key]); } return len == 0; }
bool CDSMSplitterFile::Read(__int64 len, IDSMResourceBagImpl& res) { BYTE compression = (BYTE)BitRead(2); BYTE reserved = (BYTE)BitRead(6); len--; CDSMResource r; len -= Read(len, r.name); len -= Read(len, r.desc); len -= Read(len, r.mime); if(compression != 0) return false; // TODO r.data.SetCount(len); ByteRead(r.data.GetData(), r.data.GetCount()); res += r; return true; }
bool COggFile::Sync(HANDLE hBreak) { __int64 start = GetPos(); DWORD dw; for(__int64 i = 0, j = hBreak ? GetLength() - start : 65536; i < j && S_OK == ByteRead((BYTE*)&dw, sizeof(dw)) && ((i&0xffff) || !hBreak || WaitForSingleObject(hBreak, 0) != WAIT_OBJECT_0); i++, Seek(start + i)) { if(dw == 'SggO') { Seek(start + i); return(true); } } Seek(start); return(false); }
bool COggFile::Read(OggPageHeader& hdr, HANDLE hBreak) { return Sync(hBreak) && S_OK == ByteRead((BYTE*)&hdr, sizeof(hdr)) && hdr.capture_pattern == 'SggO'; }