From 26fedaac9c6280562a8e23a5fa2ea849bf05b3d9 Mon Sep 17 00:00:00 2001 From: Erik Zandvliet Date: Mon, 7 Feb 2011 10:48:14 +0100 Subject: [PATCH] MOOF and TRAF boxes created --- MP4/box_abst.h | 4 ++++ MP4/box_moof.cpp | 36 ++++++++++++++++++++++++++++++++++++ MP4/box_moof.h | 17 +++++++++++++++++ MP4/box_traf.cpp | 36 ++++++++++++++++++++++++++++++++++++ MP4/box_traf.h | 17 +++++++++++++++++ 5 files changed, 110 insertions(+) create mode 100644 MP4/box_moof.cpp create mode 100644 MP4/box_moof.h create mode 100644 MP4/box_traf.cpp create mode 100644 MP4/box_traf.h diff --git a/MP4/box_abst.h b/MP4/box_abst.h index 5346b8cc..fc6a9755 100644 --- a/MP4/box_abst.h +++ b/MP4/box_abst.h @@ -5,6 +5,10 @@ class Box_abst { Box_abst( ); ~Box_abst(); Box * GetBox(); + private: + uint8_t curProfile; + bool isLive; + bool isUpdate; Box * Container; };//Box_ftyp Class diff --git a/MP4/box_moof.cpp b/MP4/box_moof.cpp new file mode 100644 index 00000000..637db850 --- /dev/null +++ b/MP4/box_moof.cpp @@ -0,0 +1,36 @@ +#include "box_moof.h" + +Box_moof::Box_moof( ) { + Container = new Box( 0x6D6F6F66 ); +} + +Box_moof::~Box_moof() { + delete Container; +} + +Box * Box_moof::GetBox() { + return Container; +} + +void Box_moof::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_moof::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_moof.h b/MP4/box_moof.h new file mode 100644 index 00000000..c3c091ac --- /dev/null +++ b/MP4/box_moof.h @@ -0,0 +1,17 @@ +#include "box.h" +#include +#include + +class Box_moof { + public: + Box_moof(); + ~Box_moof(); + 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/box_traf.cpp b/MP4/box_traf.cpp new file mode 100644 index 00000000..4959c37f --- /dev/null +++ b/MP4/box_traf.cpp @@ -0,0 +1,36 @@ +#include "box_traf.h" + +Box_traf::Box_traf( ) { + Container = new Box( 0x74726166 ); +} + +Box_traf::~Box_traf() { + delete Container; +} + +Box * Box_traf::GetBox() { + return Container; +} + +void Box_traf::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_traf::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_traf.h b/MP4/box_traf.h new file mode 100644 index 00000000..f9a1c996 --- /dev/null +++ b/MP4/box_traf.h @@ -0,0 +1,17 @@ +#include "box.h" +#include +#include + +class Box_traf { + public: + Box_traf(); + ~Box_traf(); + Box * GetBox(); + void AddContent( Box * newcontent, uint32_t offset = 0 ); + void WriteContent( ); + private: + Box * Container; + + std::vector Content; +};//Box_ftyp Class +