From 1ac23854b75a5f056c3c86f3d4f3957a511c25c6 Mon Sep 17 00:00:00 2001 From: Erik Zandvliet Date: Sun, 6 Feb 2011 13:39:28 +0100 Subject: [PATCH] AMHP box finished, MVEX box created, both added to interface --- MP4/Makefile | 2 +- MP4/box_amhp.cpp | 2 +- MP4/box_includes.h | 2 ++ MP4/box_mvex.cpp | 36 ++++++++++++++++++++++++++++++++++++ MP4/box_mvex.h | 17 +++++++++++++++++ MP4/interface.cpp | 13 ++++++++++++- MP4/interface.h | 2 ++ 7 files changed, 71 insertions(+), 3 deletions(-) create mode 100644 MP4/box_mvex.cpp create mode 100644 MP4/box_mvex.h diff --git a/MP4/Makefile b/MP4/Makefile index 18f0e3ab..74f4256a 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 +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 OBJ = $(SRC:.cpp=.o) OUT = Boxtest INCLUDES = diff --git a/MP4/box_amhp.cpp b/MP4/box_amhp.cpp index a2f040c3..af04b413 100644 --- a/MP4/box_amhp.cpp +++ b/MP4/box_amhp.cpp @@ -17,7 +17,7 @@ void Box_amhp::SetReserved( ) { Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0)); } -void Box_amhp::AddEntry( uint8_t HintTrackMode, uint8_t Settings, uint8_t TrailerDefaultSize, uint32_t Offset = 0 ) { +void Box_amhp::AddEntry( uint8_t HintTrackMode, uint8_t Settings, uint8_t TrailerDefaultSize, uint32_t Offset ) { if(Offset >= Entries.size()) { Entries.resize(Offset+1); } diff --git a/MP4/box_includes.h b/MP4/box_includes.h index 80cb9c7d..f447e29a 100644 --- a/MP4/box_includes.h +++ b/MP4/box_includes.h @@ -23,3 +23,5 @@ #include "box_vmhd.h" #include "box_mdat.h" #include "box_rtmp.h" +#include "box_amhp.h" +#include "box_mvex.h" diff --git a/MP4/box_mvex.cpp b/MP4/box_mvex.cpp new file mode 100644 index 00000000..a12399da --- /dev/null +++ b/MP4/box_mvex.cpp @@ -0,0 +1,36 @@ +#include "box_mvex.h" + +Box_mvex::Box_mvex( ) { + Container = new Box( 0x6D866578 ); +} + +Box_mvex::~Box_mvex() { + delete Container; +} + +Box * Box_mvex::GetBox() { + return Container; +} + +void Box_mvex::AddContent( Box * newcontent, uint32_t offset ) { + if( offset >= Content.size() ) { + Content.resize(offset+1); + } + if( Content[offset] ) { + delete Content[offset]; + } + Content[offset] = newcontent; +} + +void Box_mvex::WriteContent( ) { + Container->ResetPayload( ); + Box * current; + std::string serializedbox = ""; + for( uint32_t i = 0; i < Content.size(); i++ ) { + current=Content[i]; + if( current ) { + serializedbox.append((char*)current->GetBoxedData(),current->GetBoxedDataSize()); + } + } + Container->SetPayload((uint32_t)serializedbox.size(),(uint8_t*)serializedbox.c_str()); +} diff --git a/MP4/box_mvex.h b/MP4/box_mvex.h new file mode 100644 index 00000000..f02c5ce9 --- /dev/null +++ b/MP4/box_mvex.h @@ -0,0 +1,17 @@ +#include "box.h" +#include +#include + +class Box_mvex { + public: + Box_mvex(); + ~Box_mvex(); + Box * GetBox(); + void AddContent( Box * newcontent, uint32_t offset = 0 ); + void WriteContent( ); + private: + Box * Container; + + std::vector Content; +};//Box_ftyp Class + diff --git a/MP4/interface.cpp b/MP4/interface.cpp index 1ea6e8f7..e71a97ad 100644 --- a/MP4/interface.cpp +++ b/MP4/interface.cpp @@ -41,12 +41,16 @@ Interface::Interface() { stsd_soun = new Box_stsd(); esds_soun = new Box_esds(); rtmp = new Box_rtmp(); + amhp = new Box_amhp(); + mvex = new Box_mvex(); //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( mvex ) { delete mvex; mvex = NULL; } + if( amhp ) { delete amhp; amhp = NULL; } if( rtmp ) { delete rtmp; rtmp = NULL; } if( esds_soun ) { delete esds_soun; esds_soun = NULL; } if( stsd_soun ) { delete stsd_soun; stsd_soun = NULL; } @@ -122,6 +126,8 @@ void Interface::link( ) { moov->AddContent(trak_soun->GetBox(),2); moov->AddContent(trak_vide->GetBox(),1); moov->AddContent(mvhd->GetBox()); + + rtmp->AddContent(amhp->GetBox()); } uint32_t Interface::GetContentSize( ) { @@ -175,6 +181,9 @@ void Interface::UpdateContents( ) { trak_vide->WriteContent( ); moov->WriteContent( ); + + amhp->WriteContent( ); + rtmp->WriteContent( ); } bool Interface::AllBoxesExist() { @@ -182,7 +191,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 ); + stco_soun && stsd_soun && esds_soun && rtmp && amhp ); } void Interface::SetWidth( uint16_t NewWidth ) { @@ -254,6 +263,8 @@ void Interface::SetStaticDefaults() { // Set Track ID's tkhd_vide->SetTrackID( 1 ); tkhd_soun->SetTrackID( 2 ); +// Set amhp entry + amhp->AddEntry( 1, 0, 0 ); } void Interface::AddSTTSEntry( uint32_t SampleCount, uint32_t SampleDelta, uint32_t Track ) { diff --git a/MP4/interface.h b/MP4/interface.h index beb6c162..2ede0927 100644 --- a/MP4/interface.h +++ b/MP4/interface.h @@ -68,5 +68,7 @@ class Interface { Box_stsd * stsd_soun; Box_esds * esds_soun; Box_rtmp * rtmp; + Box_amhp * amhp; + Box_mvex * mvex; };//Interface class