STSD added

This commit is contained in:
Oswald de Bruin 2013-04-29 15:23:08 +02:00 committed by Erik Zandvliet
parent 450fb82a4d
commit 6a2145387c
2 changed files with 77 additions and 1 deletions

View file

@ -241,6 +241,9 @@ namespace MP4 {
case 0x7374737A:
return ((STSZ*)this)->toPrettyString(indent);
break;
case 0x73747364:
return ((STSD*)this)->toPrettyString(indent);
break;
case 0x75756964:
return ((UUID*)this)->toPrettyString(indent);
break;
@ -3639,6 +3642,69 @@ namespace MP4 {
return r.str();
}
STSD::STSD(){
memcpy(data + 4, "stsd", 4);
}
void STSD::setEntryCount (uint32_t newEntryCount){
setInt32(newEntryCount, 4);
}
uint32_t STSD::getEntryCount(){
return getInt32(4);
}
void STSD::setEntry(Box & newContent, uint32_t no){
int tempLoc = 8;
int entryCount = getEntryCount();
for (int i = 0; i < no; i++){
if (i < entryCount){
tempLoc += getBoxLen(tempLoc);
}else{
if ( !reserve(tempLoc, 0, (no - entryCount) * 8)){
return;
}
memset(data + tempLoc, 0, (no - entryCount) * 8);
tempLoc += (no - entryCount) * 8;
break;
}
}
setBox(newContent, tempLoc);
if (getEntryCount() < no){
setEntryCount(no);
}
}
Box & STSD::getEntry(uint32_t no){
static Box ret = Box((char*)"\000\000\000\010erro", false);
if (no > getEntryCount()){
return ret;
}
int i = 0;
int tempLoc = 8;
while (i < no){
tempLoc += getBoxLen(tempLoc);
i++;
}
return getBox(tempLoc);
}
std::string STSD::toPrettyString(uint32_t indent){
std::stringstream r;
r << std::string(indent, ' ') << "[stsd] Sample Description Box (" << boxedSize() << ")" << std::endl;
r << fullBox::toPrettyString(indent);
r << std::string(indent + 1, ' ') << "EntrySize: " << getEntryCount() << std::endl;
Box curBox;
int tempLoc = 0;
int contentCount = getEntryCount();
for (int i = 0; i < contentCount; i++){
curBox = getEntry(i);
r << curBox.toPrettyString(indent + 1);
tempLoc += getBoxLen(tempLoc);
}
return r.str();
}
static char c2hex(int c){
if (c >= '0' && c <= '9') return c - '0';
if (c >= 'a' && c <= 'f') return c - 'a' + 10;

View file

@ -685,7 +685,17 @@ namespace MP4 {
uint32_t getEntrySize(uint32_t no);
std::string toPrettyString(uint32_t indent = 0);
};
class STSD: public fullBox{
public:
STSD();
void setEntryCount (uint32_t newEntryCount);
uint32_t getEntryCount();
void setEntry(Box & newContent, uint32_t no);
Box & getEntry(uint32_t no);
std::string toPrettyString(uint32_t indent = 0);
};
class UUID: public Box{
public:
UUID();