From 8abe080cdc9756870f61c88a3769d919c8a07919 Mon Sep 17 00:00:00 2001 From: Erik Zandvliet Date: Mon, 7 Feb 2011 21:08:00 +0100 Subject: [PATCH] ABST box update --- MP4/box_abst.cpp | 60 ++++++++++++++++++++++++++++++++++++++++++++++++ MP4/box_abst.h | 4 ++++ 2 files changed, 64 insertions(+) diff --git a/MP4/box_abst.cpp b/MP4/box_abst.cpp index 607b9d12..38464807 100644 --- a/MP4/box_abst.cpp +++ b/MP4/box_abst.cpp @@ -12,6 +12,10 @@ Box * Box_abst::GetBox() { return Container; } +void Box_abst::SetBootstrapVersion( uint32_t Version ) { + curBootstrapInfoVersion = Version; +} + void Box_abst::SetProfile( uint8_t Profile ) { curProfile = Profile; } @@ -81,3 +85,59 @@ void Box_abst::AddFragmentRunTable( Box * newFragment, uint32_t Offset ) { } FragmentRunTables[Offset] = newFragment; } + + +void Box_abst::SetDefaults( ) { + SetProfile( ); + SetLive( ); + SetUpdate( ); + SetTimeScale( ); + SetMediaTime( ); + SetSMPTE( ); + SetMovieIdentfier( ); + SetDRM( ); + SetMetaData( ); +} + +void SetReserved( ) { + Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0)); +} + +void Box_abst::WriteContent( ) { + Container->ResetPayload( ); + SetReserved( ); + Box * current; + std::string serializedSegments = ""; + int SegmentAmount = 0; + for( uint32_t i = 0; i < SegmentRunTables.size(); i++ ) { + current=SegmentRunTables[i]; + if( current ) { + SegmentAmount ++; + serializedSegments.append((char*)current->GetBoxedata(),current->GetBoxedDataSize()); + } + } + std::string serializedFragments = ""; + int FragmentAmount = 0; + for( uint32_t i = 0; i < FragmentRunTables.size(); i++ ) { + current=FragmentRunTables[i]; + if( current ) { + FragmentAmount ++; + serializedFragments.append((char*)current->GetBoxedata(),current->GetBoxedDataSize()); + } + } + //NO_OFFSET + uint8_t * temp = new uint8_t[1]; + temp[0] = 0 & ( curProfile << 6 ) & ( (uint8_t)isLive << 7 ) & ( (uint8_t)isUpdate << 7 ); + Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(curBootstrapInfoVersion),4); + Container->SetPayload((uint32_t)1,temp,8); + Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(curTimeScale),9); + Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),13); + Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(curMediaTime),17); + Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),21); + Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(curSMPTE),25); + Container->SetPayload((uint32_t)curMovieIdentifier.size(),(uint8_t*)curMovieIdentifier.c_str(),29); + + //CalcOffsets + Container->SetPayload((uint32_t)serializedSegments.size(),(uint8_t*)serializedSegments.c_str()); + Container->SetPayload((uint32_t)serializedFragments.size(),(uint8_t*)serializedFragments.c_str()); +} diff --git a/MP4/box_abst.h b/MP4/box_abst.h index e6ec5985..39c9cd6f 100644 --- a/MP4/box_abst.h +++ b/MP4/box_abst.h @@ -15,6 +15,7 @@ class Box_abst { Box_abst( ); ~Box_abst(); Box * GetBox(); + void SetBootstrapVersion( uint32_t Version = 1 ); void SetProfile( uint8_t Profile = 0 ); void SetLive( bool Live = true ); void SetUpdate( bool Update = false ); @@ -29,6 +30,9 @@ class Box_abst { void AddSegmentRunTable( Box * newSegment, uint32_t Offset = 0 ); void AddFragmentRunTable( Box * newFragment, uint32_t Offset = 0 ); private: + void SetDefaults( ); + void SetReserved( ); + uint32_t curBootstrapInfoVersion; uint8_t curProfile; bool isLive; bool isUpdate;