Initialised boxes with default values as depicted in MP4 documentation

This commit is contained in:
Oswald de Bruin 2013-05-22 15:59:21 +02:00 committed by Erik Zandvliet
parent 7b6eb6ad26
commit 6d6b001ec9
2 changed files with 92 additions and 19 deletions

View file

@ -556,6 +556,9 @@ namespace MP4 {
return true; return true;
} }
fullBox::fullBox(){
}
void fullBox::setVersion(char newVersion){ void fullBox::setVersion(char newVersion){
setInt8(newVersion, 0); setInt8(newVersion, 0);
} }
@ -579,6 +582,10 @@ namespace MP4 {
return r.str(); return r.str();
} }
containerBox::containerBox(){
}
uint32_t containerBox::getContentCount(){ uint32_t containerBox::getContentCount(){
int res = 0; int res = 0;
int tempLoc = 0; int tempLoc = 0;
@ -2342,6 +2349,8 @@ namespace MP4 {
FTYP::FTYP(){ FTYP::FTYP(){
memcpy(data + 4, "ftyp", 4); memcpy(data + 4, "ftyp", 4);
setMajorBrand(0);
setMinorVersion(0);
} }
void FTYP::setMajorBrand(uint32_t newMajorBrand){ void FTYP::setMajorBrand(uint32_t newMajorBrand){
@ -2519,6 +2528,7 @@ namespace MP4 {
HDLR::HDLR(){ HDLR::HDLR(){
memcpy(data + 4, "hdlr", 4); memcpy(data + 4, "hdlr", 4);
setName("");
} }
void HDLR::setSize(uint32_t newSize){ void HDLR::setSize(uint32_t newSize){
@ -2770,8 +2780,11 @@ namespace MP4 {
} }
DREF::DREF(){ DREF::DREF(char v, uint32_t f){
memcpy(data + 4, "dref", 4); memcpy(data + 4, "dref", 4);
setVersion(v);
setFlags(f);
setInt32(0,4);
} }
uint32_t DREF::getEntryCount(){ uint32_t DREF::getEntryCount(){
@ -2822,8 +2835,27 @@ namespace MP4 {
return r.str(); return r.str();
} }
MVHD::MVHD(){ MVHD::MVHD(char v, uint32_t f){
memcpy(data + 4, "mvhd", 4); memcpy(data + 4, "mvhd", 4);
setVersion(v);
setFlags(f);
setCreationTime(0);
setModificationTime(0);
setTimeScale(1000);
setDuration(0);
setRate(0x00010000);
setVolume(0x0100);
setMatrix(0x00010000,0);
/*setMatrix(0,1);
setMatrix(0,2);
setMatrix(0,3);*/
setMatrix(0x00010000,4);
/*setMatrix(0,5);
setMatrix(0,6);
setMatrix(0,7);*/
//fills automatically with zero's
setMatrix(0x40000000,8);
setTrackID(0);
} }
void MVHD::setCreationTime(uint64_t newCreationTime){ void MVHD::setCreationTime(uint64_t newCreationTime){
@ -3191,8 +3223,23 @@ namespace MP4 {
return r.str(); return r.str();
} }
TKHD::TKHD(){ TKHD::TKHD(char v, uint32_t f){
memcpy(data + 4, "tkhd", 4); memcpy(data + 4, "tkhd", 4);
setVersion(v);
setFlags(f);
setCreationTime(0);
setModificationTime(0);
setTrackID(0);
setDuration(0);
setLayer(0);
setAlternateGroup(0);
setVolume(0x0100);
setMatrix(0x00010000,0);
setMatrix(0x00010000,4);
//fills automatically with zero's
setMatrix(0x40000000,8);
setWidth(0);
setHeight(0);
} }
void TKHD::setCreationTime(uint64_t newCreationTime){ void TKHD::setCreationTime(uint64_t newCreationTime){
@ -3387,8 +3434,20 @@ namespace MP4 {
return r.str(); return r.str();
} }
MDHD::MDHD(){ MDHD::MDHD(char v, uint32_t f){
memcpy(data + 4, "mdhd", 4); memcpy(data + 4, "mdhd", 4);
setVersion(v);
setFlags(f);
setCreationTime(0);
setModificationTime(0);
setTimeScale(1000);
setDuration(0);
setLanguage(0);
if (v==0){
setInt16(0,22);
}else{
setInt16(0,34);
}
} }
void MDHD::setCreationTime(uint64_t newCreationTime){ void MDHD::setCreationTime(uint64_t newCreationTime){
@ -3459,7 +3518,7 @@ namespace MP4 {
if (getVersion() == 0){ if (getVersion() == 0){
setInt16(newLanguage & 0x7F, 20); setInt16(newLanguage & 0x7F, 20);
}else{ }else{
setInt16(newLanguage & 0x7F, 20); setInt16(newLanguage & 0x7F, 32);
} }
} }
@ -3467,7 +3526,7 @@ namespace MP4 {
if (getVersion() == 0){ if (getVersion() == 0){
return getInt16(20) & 0x7F; return getInt16(20) & 0x7F;
}else{ }else{
return getInt16(20) & 0x7F; return getInt16(32) & 0x7F;
} }
} }
@ -3485,6 +3544,7 @@ namespace MP4 {
STTS::STTS(){ STTS::STTS(){
memcpy(data + 4, "stts", 4); memcpy(data + 4, "stts", 4);
setEntryCount(0);
} }
void STTS::setEntryCount(uint32_t newEntryCount){ void STTS::setEntryCount(uint32_t newEntryCount){
@ -3581,8 +3641,11 @@ namespace MP4 {
} }
STSC::STSC(){ STSC::STSC(char v, uint32_t f){
memcpy(data + 4, "stsc", 4); memcpy(data + 4, "stsc", 4);
setVersion(v);
setFlags(f);
setEntryCount(0);
} }
void STSC::setEntryCount(uint32_t newEntryCount){ void STSC::setEntryCount(uint32_t newEntryCount){
@ -3633,8 +3696,11 @@ namespace MP4 {
return r.str(); return r.str();
} }
STCO::STCO(){ STCO::STCO(char v, uint32_t f){
memcpy(data + 4, "stco", 4); memcpy(data + 4, "stco", 4);
setVersion(v);
setFlags(f);
setEntryCount(0);
} }
void STCO::setEntryCount(uint32_t newEntryCount){ void STCO::setEntryCount(uint32_t newEntryCount){
@ -4024,8 +4090,11 @@ namespace MP4 {
return toPrettyVisualString(indent, "[avc1] Advanced Video Codec 1"); return toPrettyVisualString(indent, "[avc1] Advanced Video Codec 1");
} }
STSD::STSD(){ STSD::STSD(char v, uint32_t f){
memcpy(data + 4, "stsd", 4); memcpy(data + 4, "stsd", 4);
setVersion(v);
setFlags(f);
setEntryCount(0);
} }
void STSD::setEntryCount (uint32_t newEntryCount){ void STSD::setEntryCount (uint32_t newEntryCount){
@ -4103,8 +4172,11 @@ namespace MP4 {
return toPrettyContainerString(indent, std::string("[udta] User Data Box")); return toPrettyContainerString(indent, std::string("[udta] User Data Box"));
} }
STSS::STSS(){ STSS::STSS(char v, uint32_t f){
memcpy(data + 4, "stss", 4); memcpy(data + 4, "stss", 4);
setVersion(v);
setFlags(f);
setEntryCount(0);
} }
void STSS::setEntryCount(uint32_t newVal){ void STSS::setEntryCount(uint32_t newVal){

View file

@ -58,6 +58,7 @@ namespace MP4 {
class fullBox: public Box{ class fullBox: public Box{
public: public:
fullBox();
void setVersion(char newVersion); void setVersion(char newVersion);
char getVersion(); char getVersion();
void setFlags(uint32_t newFlags); void setFlags(uint32_t newFlags);
@ -67,7 +68,7 @@ namespace MP4 {
class containerBox: public Box{ class containerBox: public Box{
public: public:
//containerBox(); containerBox();
uint32_t getContentCount(); uint32_t getContentCount();
void setContent(Box & newContent, uint32_t no); void setContent(Box & newContent, uint32_t no);
Box & getContent(uint32_t no); Box & getContent(uint32_t no);
@ -520,7 +521,7 @@ namespace MP4 {
class DREF: public fullBox{ class DREF: public fullBox{
public: public:
DREF(); DREF(char v = 1, uint32_t = 0);
uint32_t getEntryCount(); uint32_t getEntryCount();
void setDataEntry(fullBox & newDataEntry, size_t index); void setDataEntry(fullBox & newDataEntry, size_t index);
Box & getDataEntry(size_t index); Box & getDataEntry(size_t index);
@ -529,7 +530,7 @@ namespace MP4 {
class MVHD: public fullBox{ class MVHD: public fullBox{
public: public:
MVHD(); MVHD(char v = 1, uint32_t f = 0);
void setCreationTime(uint64_t newCreationTime); void setCreationTime(uint64_t newCreationTime);
uint64_t getCreationTime(); uint64_t getCreationTime();
void setModificationTime(uint64_t newModificationTime); void setModificationTime(uint64_t newModificationTime);
@ -580,7 +581,7 @@ namespace MP4 {
class TKHD: public fullBox{ class TKHD: public fullBox{
public: public:
TKHD(); TKHD(char v = 1, uint32_t f = 0);
void setCreationTime(uint64_t newCreationTime); void setCreationTime(uint64_t newCreationTime);
uint64_t getCreationTime(); uint64_t getCreationTime();
void setModificationTime(uint64_t newModificationTime); void setModificationTime(uint64_t newModificationTime);
@ -611,7 +612,7 @@ namespace MP4 {
class MDHD: public fullBox{ class MDHD: public fullBox{
public: public:
MDHD(); MDHD(char v = 1, uint32_t f = 0);
void setCreationTime(uint64_t newCreationTime); void setCreationTime(uint64_t newCreationTime);
uint64_t getCreationTime(); uint64_t getCreationTime();
void setModificationTime(uint64_t newModificationTime); void setModificationTime(uint64_t newModificationTime);
@ -664,7 +665,7 @@ namespace MP4 {
class STSC: public fullBox{ class STSC: public fullBox{
public: public:
STSC(); STSC(char v = 1, uint32_t f = 0);
void setEntryCount(uint32_t newEntryCount); void setEntryCount(uint32_t newEntryCount);
uint32_t getEntryCount(); uint32_t getEntryCount();
void setSTSCEntry(STSCEntry newSTSCEntry, uint32_t no); void setSTSCEntry(STSCEntry newSTSCEntry, uint32_t no);
@ -674,7 +675,7 @@ namespace MP4 {
class STCO: public fullBox{ class STCO: public fullBox{
public: public:
STCO(); STCO(char v = 1, uint32_t f = 0);
void setEntryCount(uint32_t newEntryCount); void setEntryCount(uint32_t newEntryCount);
uint32_t getEntryCount(); uint32_t getEntryCount();
void setChunkOffset(uint32_t newChunkOffset, uint32_t no); void setChunkOffset(uint32_t newChunkOffset, uint32_t no);
@ -786,7 +787,7 @@ namespace MP4 {
class STSD: public fullBox{ class STSD: public fullBox{
public: public:
STSD(); STSD(char v = 1, uint32_t f = 0);
void setEntryCount (uint32_t newEntryCount); void setEntryCount (uint32_t newEntryCount);
uint32_t getEntryCount(); uint32_t getEntryCount();
void setEntry(Box & newContent, uint32_t no); void setEntry(Box & newContent, uint32_t no);
@ -808,7 +809,7 @@ namespace MP4 {
class STSS: public fullBox{ class STSS: public fullBox{
public: public:
STSS(); STSS(char v = 1, uint32_t f = 0);
void setEntryCount(uint32_t newVal); void setEntryCount(uint32_t newVal);
uint32_t getEntryCount(); uint32_t getEntryCount();
void setSampleNumber(uint32_t newVal, uint32_t index); void setSampleNumber(uint32_t newVal, uint32_t index);