From 29a24a54531b1233d29b4160d00b6a326a246edd Mon Sep 17 00:00:00 2001 From: Oswald de Bruin Date: Mon, 10 Jun 2013 13:42:17 +0200 Subject: [PATCH] ogg edits --- lib/ogg.cpp | 36 ++++++++++++++++++++++++++++++++---- lib/ogg.h | 7 +++++-- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/lib/ogg.cpp b/lib/ogg.cpp index 21454aa3..bc6dc338 100644 --- a/lib/ogg.cpp +++ b/lib/ogg.cpp @@ -14,11 +14,11 @@ namespace OGG{ } bool Page::read(std::string & newData){ - dataSum = 0; //datasize = 0; if (newData.size()<27){ return false; } + dataSum = 0; if (!checkDataSize(27)){ return false; } @@ -175,19 +175,47 @@ namespace OGG{ return data + 27 + getPageSegments(); } + bool Page::typeBOS(){ + if (getHeaderType() & 0x02){ + return true; + } + return false; + } + + bool Page::typeEOS(){ + if (getHeaderType() & 0x04){ + return true; + } + return false; + } + + bool Page::typeContinue(){ + if (getHeaderType() & 0x01){ + return true; + } + return false; + } + + bool Page::typeNone(){ + if (getHeaderType() & 0x07 == 0x00){ + return true; + } + return false; + } + std::string Page::toPrettyString(){ std::stringstream r; r << "Size(" << getPageSize() << ")(" << dataSum << ")" << std::endl; r << "Magic_Number: " << std::string(data, 4) << std::endl; r << "Version: " << (int)getVersion() << std::endl; r << "Header_type: " << std::hex << (int)getHeaderType() << std::dec; - if (getHeaderType() & 0x01){ + if (typeContinue()){ r << " continued"; } - if (getHeaderType() & 0x02){ + if (typeBOS()){ r << " bos"; } - if (getHeaderType() & 0x04){ + if (typeEOS()){ r << " eos"; } r << std::endl; diff --git a/lib/ogg.h b/lib/ogg.h index 39a6a13b..e9a363d8 100644 --- a/lib/ogg.h +++ b/lib/ogg.h @@ -1,7 +1,7 @@ #include #include #include -#include