Initialised boxes with default values as depicted in MP4 documentation
This commit is contained in:
parent
7b6eb6ad26
commit
6d6b001ec9
2 changed files with 92 additions and 19 deletions
92
lib/mp4.cpp
92
lib/mp4.cpp
|
@ -556,6 +556,9 @@ namespace MP4 {
|
|||
return true;
|
||||
}
|
||||
|
||||
fullBox::fullBox(){
|
||||
}
|
||||
|
||||
void fullBox::setVersion(char newVersion){
|
||||
setInt8(newVersion, 0);
|
||||
}
|
||||
|
@ -579,6 +582,10 @@ namespace MP4 {
|
|||
return r.str();
|
||||
}
|
||||
|
||||
containerBox::containerBox(){
|
||||
|
||||
}
|
||||
|
||||
uint32_t containerBox::getContentCount(){
|
||||
int res = 0;
|
||||
int tempLoc = 0;
|
||||
|
@ -2342,6 +2349,8 @@ namespace MP4 {
|
|||
|
||||
FTYP::FTYP(){
|
||||
memcpy(data + 4, "ftyp", 4);
|
||||
setMajorBrand(0);
|
||||
setMinorVersion(0);
|
||||
}
|
||||
|
||||
void FTYP::setMajorBrand(uint32_t newMajorBrand){
|
||||
|
@ -2519,6 +2528,7 @@ namespace MP4 {
|
|||
|
||||
HDLR::HDLR(){
|
||||
memcpy(data + 4, "hdlr", 4);
|
||||
setName("");
|
||||
}
|
||||
|
||||
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);
|
||||
setVersion(v);
|
||||
setFlags(f);
|
||||
setInt32(0,4);
|
||||
}
|
||||
|
||||
uint32_t DREF::getEntryCount(){
|
||||
|
@ -2822,8 +2835,27 @@ namespace MP4 {
|
|||
return r.str();
|
||||
}
|
||||
|
||||
MVHD::MVHD(){
|
||||
MVHD::MVHD(char v, uint32_t f){
|
||||
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){
|
||||
|
@ -3191,8 +3223,23 @@ namespace MP4 {
|
|||
return r.str();
|
||||
}
|
||||
|
||||
TKHD::TKHD(){
|
||||
TKHD::TKHD(char v, uint32_t f){
|
||||
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){
|
||||
|
@ -3387,8 +3434,20 @@ namespace MP4 {
|
|||
return r.str();
|
||||
}
|
||||
|
||||
MDHD::MDHD(){
|
||||
MDHD::MDHD(char v, uint32_t f){
|
||||
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){
|
||||
|
@ -3459,7 +3518,7 @@ namespace MP4 {
|
|||
if (getVersion() == 0){
|
||||
setInt16(newLanguage & 0x7F, 20);
|
||||
}else{
|
||||
setInt16(newLanguage & 0x7F, 20);
|
||||
setInt16(newLanguage & 0x7F, 32);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3467,7 +3526,7 @@ namespace MP4 {
|
|||
if (getVersion() == 0){
|
||||
return getInt16(20) & 0x7F;
|
||||
}else{
|
||||
return getInt16(20) & 0x7F;
|
||||
return getInt16(32) & 0x7F;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3485,6 +3544,7 @@ namespace MP4 {
|
|||
|
||||
STTS::STTS(){
|
||||
memcpy(data + 4, "stts", 4);
|
||||
setEntryCount(0);
|
||||
}
|
||||
|
||||
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);
|
||||
setVersion(v);
|
||||
setFlags(f);
|
||||
setEntryCount(0);
|
||||
}
|
||||
|
||||
void STSC::setEntryCount(uint32_t newEntryCount){
|
||||
|
@ -3633,8 +3696,11 @@ namespace MP4 {
|
|||
return r.str();
|
||||
}
|
||||
|
||||
STCO::STCO(){
|
||||
STCO::STCO(char v, uint32_t f){
|
||||
memcpy(data + 4, "stco", 4);
|
||||
setVersion(v);
|
||||
setFlags(f);
|
||||
setEntryCount(0);
|
||||
}
|
||||
|
||||
void STCO::setEntryCount(uint32_t newEntryCount){
|
||||
|
@ -4024,8 +4090,11 @@ namespace MP4 {
|
|||
return toPrettyVisualString(indent, "[avc1] Advanced Video Codec 1");
|
||||
}
|
||||
|
||||
STSD::STSD(){
|
||||
STSD::STSD(char v, uint32_t f){
|
||||
memcpy(data + 4, "stsd", 4);
|
||||
setVersion(v);
|
||||
setFlags(f);
|
||||
setEntryCount(0);
|
||||
}
|
||||
|
||||
void STSD::setEntryCount (uint32_t newEntryCount){
|
||||
|
@ -4103,8 +4172,11 @@ namespace MP4 {
|
|||
return toPrettyContainerString(indent, std::string("[udta] User Data Box"));
|
||||
}
|
||||
|
||||
STSS::STSS(){
|
||||
STSS::STSS(char v, uint32_t f){
|
||||
memcpy(data + 4, "stss", 4);
|
||||
setVersion(v);
|
||||
setFlags(f);
|
||||
setEntryCount(0);
|
||||
}
|
||||
|
||||
void STSS::setEntryCount(uint32_t newVal){
|
||||
|
|
19
lib/mp4.h
19
lib/mp4.h
|
@ -58,6 +58,7 @@ namespace MP4 {
|
|||
|
||||
class fullBox: public Box{
|
||||
public:
|
||||
fullBox();
|
||||
void setVersion(char newVersion);
|
||||
char getVersion();
|
||||
void setFlags(uint32_t newFlags);
|
||||
|
@ -67,7 +68,7 @@ namespace MP4 {
|
|||
|
||||
class containerBox: public Box{
|
||||
public:
|
||||
//containerBox();
|
||||
containerBox();
|
||||
uint32_t getContentCount();
|
||||
void setContent(Box & newContent, uint32_t no);
|
||||
Box & getContent(uint32_t no);
|
||||
|
@ -520,7 +521,7 @@ namespace MP4 {
|
|||
|
||||
class DREF: public fullBox{
|
||||
public:
|
||||
DREF();
|
||||
DREF(char v = 1, uint32_t = 0);
|
||||
uint32_t getEntryCount();
|
||||
void setDataEntry(fullBox & newDataEntry, size_t index);
|
||||
Box & getDataEntry(size_t index);
|
||||
|
@ -529,7 +530,7 @@ namespace MP4 {
|
|||
|
||||
class MVHD: public fullBox{
|
||||
public:
|
||||
MVHD();
|
||||
MVHD(char v = 1, uint32_t f = 0);
|
||||
void setCreationTime(uint64_t newCreationTime);
|
||||
uint64_t getCreationTime();
|
||||
void setModificationTime(uint64_t newModificationTime);
|
||||
|
@ -580,7 +581,7 @@ namespace MP4 {
|
|||
|
||||
class TKHD: public fullBox{
|
||||
public:
|
||||
TKHD();
|
||||
TKHD(char v = 1, uint32_t f = 0);
|
||||
void setCreationTime(uint64_t newCreationTime);
|
||||
uint64_t getCreationTime();
|
||||
void setModificationTime(uint64_t newModificationTime);
|
||||
|
@ -611,7 +612,7 @@ namespace MP4 {
|
|||
|
||||
class MDHD: public fullBox{
|
||||
public:
|
||||
MDHD();
|
||||
MDHD(char v = 1, uint32_t f = 0);
|
||||
void setCreationTime(uint64_t newCreationTime);
|
||||
uint64_t getCreationTime();
|
||||
void setModificationTime(uint64_t newModificationTime);
|
||||
|
@ -664,7 +665,7 @@ namespace MP4 {
|
|||
|
||||
class STSC: public fullBox{
|
||||
public:
|
||||
STSC();
|
||||
STSC(char v = 1, uint32_t f = 0);
|
||||
void setEntryCount(uint32_t newEntryCount);
|
||||
uint32_t getEntryCount();
|
||||
void setSTSCEntry(STSCEntry newSTSCEntry, uint32_t no);
|
||||
|
@ -674,7 +675,7 @@ namespace MP4 {
|
|||
|
||||
class STCO: public fullBox{
|
||||
public:
|
||||
STCO();
|
||||
STCO(char v = 1, uint32_t f = 0);
|
||||
void setEntryCount(uint32_t newEntryCount);
|
||||
uint32_t getEntryCount();
|
||||
void setChunkOffset(uint32_t newChunkOffset, uint32_t no);
|
||||
|
@ -786,7 +787,7 @@ namespace MP4 {
|
|||
|
||||
class STSD: public fullBox{
|
||||
public:
|
||||
STSD();
|
||||
STSD(char v = 1, uint32_t f = 0);
|
||||
void setEntryCount (uint32_t newEntryCount);
|
||||
uint32_t getEntryCount();
|
||||
void setEntry(Box & newContent, uint32_t no);
|
||||
|
@ -808,7 +809,7 @@ namespace MP4 {
|
|||
|
||||
class STSS: public fullBox{
|
||||
public:
|
||||
STSS();
|
||||
STSS(char v = 1, uint32_t f = 0);
|
||||
void setEntryCount(uint32_t newVal);
|
||||
uint32_t getEntryCount();
|
||||
void setSampleNumber(uint32_t newVal, uint32_t index);
|
||||
|
|
Loading…
Add table
Reference in a new issue