Added extra needed functions to ogg lib
This commit is contained in:
parent
c3d116d3db
commit
5d85548360
2 changed files with 40 additions and 7 deletions
34
lib/ogg.cpp
34
lib/ogg.cpp
|
@ -193,21 +193,35 @@ namespace OGG{
|
|||
return segmentTableDeque;
|
||||
}
|
||||
|
||||
static void STerrMSG(){
|
||||
std::cerr << "Segments too big, create a continue page" << std::endl;
|
||||
}
|
||||
|
||||
bool Page::setSegmentTable(std::vector<unsigned int> layout){
|
||||
unsigned int place = 0;
|
||||
char table[255];
|
||||
for (unsigned int i = 0; i < layout.size(); i++){
|
||||
while (layout[i]>=255){
|
||||
if (place >= 255) return false;
|
||||
if (place >= 255){
|
||||
STerrMSG();
|
||||
return false;
|
||||
}
|
||||
table[place] = 255;
|
||||
layout[i] -= 255;
|
||||
place++;
|
||||
}
|
||||
if (place >= 255) return false;
|
||||
if (place >= 255){
|
||||
STerrMSG();
|
||||
return false;
|
||||
}
|
||||
table[place] = layout[i];
|
||||
place++;
|
||||
}
|
||||
setSegmentTable(table,place);
|
||||
dataSum=0;
|
||||
for (unsigned int i = 0; i < layout.size(); i++){
|
||||
dataSum += layout[i];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -418,4 +432,20 @@ namespace OGG{
|
|||
int Page::getPayloadSize(){
|
||||
return dataSum;
|
||||
}
|
||||
|
||||
void Page::clear(){
|
||||
memset(data,0,27);
|
||||
datasize = 0;
|
||||
dataSum = 0;
|
||||
codec = "";
|
||||
segmentTableDeque.clear();
|
||||
}
|
||||
|
||||
bool Page::setPayload(char* newData, unsigned int length){
|
||||
if(!checkDataSize(27 + getPageSegments() + length)){//check if size available in memory
|
||||
return false;
|
||||
}
|
||||
memcpy(data + 27 + getPageSegments(), newData, length);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
13
lib/ogg.h
13
lib/ogg.h
|
@ -40,13 +40,16 @@ namespace OGG{
|
|||
bool typeNone();
|
||||
std::string toPrettyString(size_t indent = 0);
|
||||
void setInternalCodec(std::string myCodec);
|
||||
long unsigned int calcChecksum();
|
||||
void clear();
|
||||
|
||||
bool setPayload(char* newData, unsigned int length);
|
||||
private:
|
||||
std::deque<unsigned int> segmentTableDeque;
|
||||
long unsigned int calcChecksum();
|
||||
char* data;
|
||||
unsigned int datasize;
|
||||
unsigned int dataSum;
|
||||
char* data;//pointer to the beginning of the Page data
|
||||
unsigned int datasize;//size of the complete page
|
||||
unsigned int dataSum;//size of the total segments
|
||||
bool checkDataSize(unsigned int size);
|
||||
std::string codec;
|
||||
std::string codec;//codec in the page
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue