MP4 rework
This commit is contained in:
parent
266248a67e
commit
f5293ea29f
6 changed files with 362 additions and 242 deletions
37
lib/mp4.cpp
37
lib/mp4.cpp
|
@ -65,13 +65,25 @@ namespace MP4 {
|
|||
}
|
||||
}
|
||||
|
||||
void Box::copyFrom(const Box & rs){
|
||||
clear();
|
||||
if (data) {
|
||||
free(data);
|
||||
data = 0;
|
||||
}
|
||||
data = (char*)malloc(rs.data_size);
|
||||
memcpy(data, rs.data, rs.data_size);
|
||||
data_size = rs.data_size;
|
||||
managed = true;
|
||||
payloadOffset = rs.payloadOffset;
|
||||
}
|
||||
/// Returns the values at byte positions 4 through 7.
|
||||
std::string Box::getType() {
|
||||
return std::string(data + 4, 4);
|
||||
}
|
||||
|
||||
/// Returns true if the given 4-byte boxtype is equal to the values at byte positions 4 through 7.
|
||||
bool Box::isType(const char * boxType) {
|
||||
bool Box::isType(const char * boxType) const {
|
||||
return !memcmp(boxType, data + 4, 4);
|
||||
}
|
||||
|
||||
|
@ -742,6 +754,29 @@ namespace MP4 {
|
|||
return getBox(tempLoc);
|
||||
}
|
||||
|
||||
Box containerBox::getChild(const char * boxName){
|
||||
uint32_t count = getContentCount();
|
||||
for (uint32_t i = 0; i < count; i++){
|
||||
Box & thisChild = getContent(i);
|
||||
if (thisChild.isType(boxName)){
|
||||
return Box(thisChild.asBox(), false);
|
||||
}
|
||||
}
|
||||
return Box((char*)"\000\000\000\010erro", false);
|
||||
}
|
||||
|
||||
std::deque<Box> containerBox::getChildren(const char * boxName){
|
||||
std::deque<Box> res;
|
||||
uint32_t count = getContentCount();
|
||||
for (uint32_t i = 0; i < count; i++){
|
||||
Box & thisChild = getContent(i);
|
||||
if (thisChild.isType(boxName)){
|
||||
res.push_back(Box(thisChild.asBox(), false));
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
std::string containerBox::toPrettyString(uint32_t indent) {
|
||||
std::stringstream r;
|
||||
r << std::string(indent, ' ') << "[" << getType() << "] Container Box (" << boxedSize() << ")" << std::endl;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue