DTSC2OGG page in lib now, not yet header making

This commit is contained in:
Oswald Auguste de Bruin 2013-08-09 15:29:38 +02:00 committed by Thulinma
parent 6c4d9d96aa
commit b85ceb9fc5
2 changed files with 29 additions and 2 deletions

View file

@ -456,5 +456,31 @@ namespace OGG{
}
memcpy(data + 27 + getPageSegments(), newData, length);
return true;
}
}
void Page::readDTSCVector(std::vector <JSON::Value> DTSCVec, unsigned int serial, unsigned int sequence){
clear();
setVersion();
if (DTSCVec[0]["OggCont"]){
setHeaderType(1);//headertype 1 = Continue Page
}else if (DTSCVec[0]["OggEOS"]){
setHeaderType(4);//headertype 4 = end of stream
}else{
setHeaderType(0);//headertype 0 = normal
}
setGranulePosition(DTSCVec[0]["granule"].asInt());
setBitstreamSerialNumber(serial);
setPageSequenceNumber(sequence);
std::vector<unsigned int> curSegTable;
std::string pageBuffer;
for (unsigned int i = 0; i < DTSCVec.size(); i++){
curSegTable.push_back(DTSCVec[i]["data"].asString().size());
pageBuffer += DTSCVec[i]["data"].asString();
}
setSegmentTable(curSegTable);
setPayload((char*)pageBuffer.c_str(), pageBuffer.size());
setCRCChecksum(calcChecksum());
}
}

View file

@ -5,6 +5,7 @@
#include"dtsc.h"
#include "theora.h"
#include "vorbis.h"
#include "json.h"
namespace OGG{
class Page{
@ -31,7 +32,6 @@ namespace OGG{
std::deque<unsigned int> & getSegmentTableDeque();
bool setSegmentTable(std::vector<unsigned int> layout);
void setSegmentTable(char* newVal, unsigned int length);
char* getPage();//returns complete page with header
unsigned long int getPageSize();
char* getFullPayload();//returns all segments in the page
@ -45,6 +45,7 @@ namespace OGG{
long unsigned int calcChecksum();
bool clear();
bool setPayload(char* newData, unsigned int length);
void readDTSCVector(std::vector <JSON::Value> DTSCVec, unsigned int serial, unsigned int sequence);
private:
std::deque<unsigned int> segmentTableDeque;
char* data;//pointer to the beginning of the Page data