From 1c69d2dbc808e89aba2e1c49c6bf62d9e073a9d2 Mon Sep 17 00:00:00 2001 From: Erik Zandvliet Date: Sun, 23 Jan 2011 15:52:20 +0100 Subject: [PATCH] [Stable] Interface contains an UpdateContents() function, which updates all the contents of the boxes --- MP4/box_dinf.cpp | 1 - MP4/box_dinf.h | 2 +- MP4/box_dref.cpp | 1 - MP4/box_dref.h | 2 +- MP4/box_mdia.cpp | 1 - MP4/box_mdia.h | 2 +- MP4/box_minf.cpp | 1 - MP4/box_minf.h | 2 +- MP4/box_moov.cpp | 1 - MP4/box_moov.h | 2 +- MP4/box_stbl.cpp | 1 - MP4/box_stbl.h | 2 +- MP4/box_stco.cpp | 2 +- MP4/box_stco.h | 2 +- MP4/box_stsc.cpp | 3 +-- MP4/box_stsc.h | 2 +- MP4/box_stsd.cpp | 1 - MP4/box_stsd.h | 2 +- MP4/box_stts.cpp | 3 +-- MP4/box_stts.h | 2 +- MP4/box_trak.cpp | 1 - MP4/interface.cpp | 27 +++++++++++++++++++++++++++ 22 files changed, 40 insertions(+), 23 deletions(-) diff --git a/MP4/box_dinf.cpp b/MP4/box_dinf.cpp index c33a94f3..cf3ca641 100644 --- a/MP4/box_dinf.cpp +++ b/MP4/box_dinf.cpp @@ -18,7 +18,6 @@ void Box_dinf::AddContent( Box * newcontent ) { Content = NULL; } Content = newcontent; - WriteContent(); } void Box_dinf::WriteContent( ) { diff --git a/MP4/box_dinf.h b/MP4/box_dinf.h index 8e1c15b8..626697e1 100644 --- a/MP4/box_dinf.h +++ b/MP4/box_dinf.h @@ -8,10 +8,10 @@ class Box_dinf { ~Box_dinf(); Box * GetBox(); void AddContent( Box * newcontent ); + void WriteContent( ); private: Box * Container; - void WriteContent( ); Box * Content; };//Box_ftyp Class diff --git a/MP4/box_dref.cpp b/MP4/box_dref.cpp index 3c639c22..08293eaf 100644 --- a/MP4/box_dref.cpp +++ b/MP4/box_dref.cpp @@ -21,7 +21,6 @@ void Box_dref::AddContent( Box * newcontent, uint32_t offset ) { delete Content[offset]; } Content[offset] = newcontent; - WriteContent(); } void Box_dref::WriteContent( ) { diff --git a/MP4/box_dref.h b/MP4/box_dref.h index 2851a9df..11495a13 100644 --- a/MP4/box_dref.h +++ b/MP4/box_dref.h @@ -8,11 +8,11 @@ class Box_dref { ~Box_dref(); Box * GetBox(); void AddContent( Box * newcontent, uint32_t offset = 0 ); + void WriteContent( ); private: Box * Container; void SetReserved( ); - void WriteContent( ); std::vector Content; };//Box_ftyp Class diff --git a/MP4/box_mdia.cpp b/MP4/box_mdia.cpp index dd6a73cb..3aefb44f 100644 --- a/MP4/box_mdia.cpp +++ b/MP4/box_mdia.cpp @@ -20,7 +20,6 @@ void Box_mdia::AddContent( Box * newcontent, uint32_t offset ) { delete Content[offset]; } Content[offset] = newcontent; - WriteContent(); } void Box_mdia::WriteContent( ) { diff --git a/MP4/box_mdia.h b/MP4/box_mdia.h index 1fb05728..b56c268a 100644 --- a/MP4/box_mdia.h +++ b/MP4/box_mdia.h @@ -8,10 +8,10 @@ class Box_mdia { ~Box_mdia(); Box * GetBox(); void AddContent( Box * newcontent, uint32_t offset = 0 ); + void WriteContent( ); private: Box * Container; - void WriteContent( ); std::vector Content; };//Box_ftyp Class diff --git a/MP4/box_minf.cpp b/MP4/box_minf.cpp index efee10ac..346c862f 100644 --- a/MP4/box_minf.cpp +++ b/MP4/box_minf.cpp @@ -20,7 +20,6 @@ void Box_minf::AddContent( Box * newcontent, uint32_t offset ) { delete Content[offset]; } Content[offset] = newcontent; - WriteContent(); } void Box_minf::WriteContent( ) { diff --git a/MP4/box_minf.h b/MP4/box_minf.h index 1c97e26b..567af57d 100644 --- a/MP4/box_minf.h +++ b/MP4/box_minf.h @@ -8,10 +8,10 @@ class Box_minf { ~Box_minf(); Box * GetBox(); void AddContent( Box * newcontent, uint32_t offset = 0 ); + void WriteContent( ); private: Box * Container; - void WriteContent( ); std::vector Content; };//Box_ftyp Class diff --git a/MP4/box_moov.cpp b/MP4/box_moov.cpp index a25ee419..eb0e2d18 100644 --- a/MP4/box_moov.cpp +++ b/MP4/box_moov.cpp @@ -20,7 +20,6 @@ void Box_moov::AddContent( Box * newcontent, uint32_t offset ) { delete Content[offset]; } Content[offset] = newcontent; - WriteContent(); } void Box_moov::WriteContent( ) { diff --git a/MP4/box_moov.h b/MP4/box_moov.h index b384c04b..08306ecd 100644 --- a/MP4/box_moov.h +++ b/MP4/box_moov.h @@ -8,10 +8,10 @@ class Box_moov { ~Box_moov(); Box * GetBox(); void AddContent( Box * newcontent, uint32_t offset = 0 ); + void WriteContent( ); private: Box * Container; - void WriteContent( ); std::vector Content; };//Box_ftyp Class diff --git a/MP4/box_stbl.cpp b/MP4/box_stbl.cpp index ac57e2e9..618cb9af 100644 --- a/MP4/box_stbl.cpp +++ b/MP4/box_stbl.cpp @@ -20,7 +20,6 @@ void Box_stbl::AddContent( Box * newcontent, uint32_t offset ) { delete Content[offset]; } Content[offset] = newcontent; - WriteContent(); } void Box_stbl::WriteContent( ) { diff --git a/MP4/box_stbl.h b/MP4/box_stbl.h index c76887f2..67ce1dda 100644 --- a/MP4/box_stbl.h +++ b/MP4/box_stbl.h @@ -8,10 +8,10 @@ class Box_stbl { ~Box_stbl(); Box * GetBox(); void AddContent( Box * newcontent, uint32_t offset = 0 ); + void WriteContent( ); private: Box * Container; - void WriteContent( ); std::vector Content; };//Box_ftyp Class diff --git a/MP4/box_stco.cpp b/MP4/box_stco.cpp index bd4c4b17..b0a6da0e 100644 --- a/MP4/box_stco.cpp +++ b/MP4/box_stco.cpp @@ -25,7 +25,7 @@ void Box_stco::AddOffset( uint32_t DataOffset, uint32_t Offset ) { } -void Box_stco::WriteOffsets( ) { +void Box_stco::WriteContent( ) { Container->ResetPayload(); SetReserved( ); if(!Offsets.empty()) { diff --git a/MP4/box_stco.h b/MP4/box_stco.h index a75b566b..e1d25862 100644 --- a/MP4/box_stco.h +++ b/MP4/box_stco.h @@ -8,10 +8,10 @@ class Box_stco { ~Box_stco(); Box * GetBox(); void AddOffset( uint32_t DataOffset, uint32_t Offset = 0 ); + void WriteContent( ); private: Box * Container; - void WriteOffsets( ); void SetReserved( ); std::vector Offsets; };//Box_ftyp Class diff --git a/MP4/box_stsc.cpp b/MP4/box_stsc.cpp index ef38e002..9d5a75eb 100644 --- a/MP4/box_stsc.cpp +++ b/MP4/box_stsc.cpp @@ -24,11 +24,10 @@ void Box_stsc::AddEntry( uint32_t FirstChunk, uint32_t SamplesPerChunk, uint32_t Entries[Offset].FirstChunk = FirstChunk; Entries[Offset].SamplesPerChunk = SamplesPerChunk; Entries[Offset].SampleDescIndex = SampleDescIndex; - WriteEntries( ); } -void Box_stsc::WriteEntries( ) { +void Box_stsc::WriteContent( ) { Container->ResetPayload(); SetReserved( ); if(!Entries.empty()) { diff --git a/MP4/box_stsc.h b/MP4/box_stsc.h index 6e1c77f2..c5a2358f 100644 --- a/MP4/box_stsc.h +++ b/MP4/box_stsc.h @@ -15,10 +15,10 @@ class Box_stsc { Box * GetBox(); void SetReserved( ); void AddEntry( uint32_t FirstChunk = 0, uint32_t SamplesPerChunk = 0, uint32_t SampleDescIndex = 0, uint32_t Offset = 0 ); + void WriteContent( ); private: Box * Container; - void WriteEntries( ); std::vector Entries; };//Box_ftyp Class diff --git a/MP4/box_stsd.cpp b/MP4/box_stsd.cpp index 0e91122d..2d6fc5e3 100644 --- a/MP4/box_stsd.cpp +++ b/MP4/box_stsd.cpp @@ -10,7 +10,6 @@ Box_stsd::~Box_stsd() { } Box * Box_stsd::GetBox() { - WriteContent(); return Container; } diff --git a/MP4/box_stsd.h b/MP4/box_stsd.h index 3cc33356..a9db47de 100644 --- a/MP4/box_stsd.h +++ b/MP4/box_stsd.h @@ -8,11 +8,11 @@ class Box_stsd { ~Box_stsd(); Box * GetBox(); void AddContent( Box * newcontent, uint32_t offset = 0 ); + void WriteContent(); private: Box * Container; void SetReserved(); - void WriteContent(); std::vector Content; };//Box_ftyp Class diff --git a/MP4/box_stts.cpp b/MP4/box_stts.cpp index 397d01ac..0905d675 100644 --- a/MP4/box_stts.cpp +++ b/MP4/box_stts.cpp @@ -23,11 +23,10 @@ void Box_stts::AddEntry( uint32_t SampleCount, uint32_t SampleDelta, uint32_t Of } Entries[Offset].SampleCount = SampleCount; Entries[Offset].SampleDelta = SampleDelta; - WriteEntries( ); } -void Box_stts::WriteEntries( ) { +void Box_stts::WriteContent( ) { Container->ResetPayload(); SetReserved( ); if(!Entries.empty()) { diff --git a/MP4/box_stts.h b/MP4/box_stts.h index 4f71c6b7..cf20740f 100644 --- a/MP4/box_stts.h +++ b/MP4/box_stts.h @@ -14,10 +14,10 @@ class Box_stts { Box * GetBox(); void SetReserved( ); void AddEntry( uint32_t SampleCount, uint32_t SampleDelta, uint32_t Offset = 0 ); + void WriteContent( ); private: Box * Container; - void WriteEntries( ); std::vector Entries; };//Box_ftyp Class diff --git a/MP4/box_trak.cpp b/MP4/box_trak.cpp index c7fef0a3..6ad6c53b 100644 --- a/MP4/box_trak.cpp +++ b/MP4/box_trak.cpp @@ -20,7 +20,6 @@ void Box_trak::AddContent( Box * newcontent, uint32_t offset ) { delete Content[offset]; } Content[offset] = newcontent; - WriteContent(); } void Box_trak::WriteContent( ) { diff --git a/MP4/interface.cpp b/MP4/interface.cpp index 9c93b5c1..884ca01a 100644 --- a/MP4/interface.cpp +++ b/MP4/interface.cpp @@ -125,3 +125,30 @@ uint8_t * Interface::GetContents( ) { memcpy(&Result[ftyp->GetBox( )->GetBoxedDataSize( )],moov->GetBox( )->GetBoxedData( ),moov->GetBox( )->GetBoxedDataSize( )); return Result; } + + +void Interface::UpdateContents( ) { + stsd_vide->WriteContent( ); + stco_vide->WriteContent( ); + stsc_vide->WriteContent( ); + stts_vide->WriteContent( ); + stbl_vide->WriteContent( ); + dref_vide->WriteContent( ); + dinf_vide->WriteContent( ); + minf_vide->WriteContent( ); + mdia_vide->WriteContent( ); + + stsd_soun->WriteContent( ); + stco_soun->WriteContent( ); + stsc_soun->WriteContent( ); + stts_soun->WriteContent( ); + stbl_soun->WriteContent( ); + dref_soun->WriteContent( ); + dinf_soun->WriteContent( ); + minf_soun->WriteContent( ); + mdia_soun->WriteContent( ); + + trak_vide->WriteContent( ); + + moov->WriteContent( ); +}