From b85be8b76c20a4abef4b2f13afddb17a1f98ec76 Mon Sep 17 00:00:00 2001 From: Erik Zandvliet Date: Sun, 6 Feb 2011 14:34:59 +0100 Subject: [PATCH] TREX box completed and added to interface --- MP4/Makefile | 2 +- MP4/box_ftyp.cpp | 1 + MP4/box_includes.h | 1 + MP4/box_trex.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++++ MP4/box_trex.h | 16 ++++++++++++++++ MP4/interface.cpp | 6 +++++- MP4/interface.h | 2 ++ 7 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 MP4/box_trex.cpp create mode 100644 MP4/box_trex.h diff --git a/MP4/Makefile b/MP4/Makefile index 74f4256a..313b55e0 100644 --- a/MP4/Makefile +++ b/MP4/Makefile @@ -1,4 +1,4 @@ -SRC = box_avcC.cpp box.cpp box_dinf.cpp box_dref.cpp box_esds.cpp box_ftyp.cpp box_hdlr.cpp box_hmhd.cpp box_mdhd.cpp box_mdia.cpp box_minf.cpp box_moov.cpp box_mvhd.cpp box_nmhd.cpp box_smhd.cpp box_stbl.cpp box_stco.cpp box_stsc.cpp box_stsd.cpp box_stts.cpp box_tkhd.cpp box_trak.cpp box_url.cpp box_vmhd.cpp main.cpp interface.cpp box_mdat.cpp box_rtmp.cpp box_amhp.cpp box_mvex.cpp +SRC = box_avcC.cpp box.cpp box_dinf.cpp box_dref.cpp box_esds.cpp box_ftyp.cpp box_hdlr.cpp box_hmhd.cpp box_mdhd.cpp box_mdia.cpp box_minf.cpp box_moov.cpp box_mvhd.cpp box_nmhd.cpp box_smhd.cpp box_stbl.cpp box_stco.cpp box_stsc.cpp box_stsd.cpp box_stts.cpp box_tkhd.cpp box_trak.cpp box_url.cpp box_vmhd.cpp main.cpp interface.cpp box_mdat.cpp box_rtmp.cpp box_amhp.cpp box_mvex.cpp box_trex.cpp OBJ = $(SRC:.cpp=.o) OUT = Boxtest INCLUDES = diff --git a/MP4/box_ftyp.cpp b/MP4/box_ftyp.cpp index 67262dc5..db91dc8e 100644 --- a/MP4/box_ftyp.cpp +++ b/MP4/box_ftyp.cpp @@ -2,6 +2,7 @@ Box_ftyp::Box_ftyp( ) { Container = new Box( 0x66747970 ); + SetDefaults( ); } Box_ftyp::~Box_ftyp() { diff --git a/MP4/box_includes.h b/MP4/box_includes.h index f447e29a..e3f668b3 100644 --- a/MP4/box_includes.h +++ b/MP4/box_includes.h @@ -25,3 +25,4 @@ #include "box_rtmp.h" #include "box_amhp.h" #include "box_mvex.h" +#include "box_trex.h" diff --git a/MP4/box_trex.cpp b/MP4/box_trex.cpp new file mode 100644 index 00000000..49c6e768 --- /dev/null +++ b/MP4/box_trex.cpp @@ -0,0 +1,44 @@ +#include "box_trex.h" + +Box_trex::Box_trex( ) { + Container = new Box( 0x74726578 ); + SetReserved( ); + SetDefaults( ); +} + +Box_trex::~Box_trex() { + delete Container; +} + +Box * Box_trex::GetBox() { + return Container; +} + +void Box_trex::SetDefaults( ) { + SetTrackID( ); + SetSampleDescriptionIndex( ); + SetSampleDuration( ); + SetSampleSize( ); +} + +void Box_trex::SetReserved( ) { + Container->SetPayload((uint32_t)2,Box::uint16_to_uint8(1),22); + Container->SetPayload((uint32_t)2,Box::uint16_to_uint8(0),20); + Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0)); +} + +void Box_trex::SetTrackID( uint32_t Id ) { + Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Id),4); +} + +void Box_trex::SetSampleDescriptionIndex( uint32_t Index ) { + Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Index),8); +} + +void Box_trex::SetSampleDuration( uint32_t Duration ) { + Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Duration),12); +} + +void Box_trex::SetSampleSize( uint32_t Size ) { + Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Size),16); +} diff --git a/MP4/box_trex.h b/MP4/box_trex.h new file mode 100644 index 00000000..4fd6bc8a --- /dev/null +++ b/MP4/box_trex.h @@ -0,0 +1,16 @@ +#include "box.h" + +class Box_trex { + public: + Box_trex( ); + ~Box_trex(); + Box * GetBox(); + void SetTrackID( uint32_t Id = 0 ); + void SetSampleDescriptionIndex( uint32_t Index = 0 ); + void SetSampleDuration( uint32_t Duration = 0 ); + void SetSampleSize( uint32_t Size = 0 ); + private: + void SetReserved( ); + void SetDefaults( ); + Box * Container; +};//Box_ftyp Class diff --git a/MP4/interface.cpp b/MP4/interface.cpp index e71a97ad..c8bb11f9 100644 --- a/MP4/interface.cpp +++ b/MP4/interface.cpp @@ -43,12 +43,16 @@ Interface::Interface() { rtmp = new Box_rtmp(); amhp = new Box_amhp(); mvex = new Box_mvex(); + trex_vide = new Box_trex(); + trex_soun = new Box_trex(); //Set some values we already know won't change once the boxes have been created SetStaticDefaults(); } Interface::~Interface() { //Deleting the boxes if they still exist. + if( trex_vide ) { delete trex_vide; trex_vide = NULL; } + if( trex_soun ) { delete trex_soun; trex_soun = NULL; } if( mvex ) { delete mvex; mvex = NULL; } if( amhp ) { delete amhp; amhp = NULL; } if( rtmp ) { delete rtmp; rtmp = NULL; } @@ -191,7 +195,7 @@ bool Interface::AllBoxesExist() { minf_vide && vmhd_vide && dinf_vide && dref_vide && url_vide && stbl_vide && stts_vide && stsc_vide && stco_vide && stsd_vide && avcC_vide && trak_soun && tkhd_soun && mdia_soun && mdhd_soun && hdlr_soun && minf_soun && smhd_soun && dinf_soun && dref_soun && url_soun && stbl_soun && stts_soun && stsc_soun && - stco_soun && stsd_soun && esds_soun && rtmp && amhp ); + stco_soun && stsd_soun && esds_soun && rtmp && amhp && mvex && trex_vide && trex_soun ); } void Interface::SetWidth( uint16_t NewWidth ) { diff --git a/MP4/interface.h b/MP4/interface.h index 2ede0927..3e544aa8 100644 --- a/MP4/interface.h +++ b/MP4/interface.h @@ -70,5 +70,7 @@ class Interface { Box_rtmp * rtmp; Box_amhp * amhp; Box_mvex * mvex; + Box_trex * trex_vide; + Box_trex * trex_soun; };//Interface class