From 4742862b08978c7260a2b412dda05573f20e292b Mon Sep 17 00:00:00 2001 From: Erik Zandvliet Date: Mon, 24 Jan 2011 13:11:57 +0100 Subject: [PATCH] Adding stco and mdat functionality --- MP4/box_avcC.h | 2 +- MP4/box_esds.h | 2 +- MP4/box_stco.cpp | 4 ++++ MP4/box_stco.h | 1 + MP4/interface.cpp | 17 +++++++++++++++++ MP4/interface.h | 2 ++ 6 files changed, 26 insertions(+), 2 deletions(-) diff --git a/MP4/box_avcC.h b/MP4/box_avcC.h index ba465832..6a9563ff 100644 --- a/MP4/box_avcC.h +++ b/MP4/box_avcC.h @@ -6,7 +6,7 @@ class Box_avcC { Box_avcC( ); ~Box_avcC(); Box * GetBox(); - void SetDataReferenceIndex( uint16_t DataReferenceIndex = 0 ); + void SetDataReferenceIndex( uint16_t DataReferenceIndex = 1 ); void SetWidth( uint16_t Width = 0 ); void SetHeight( uint16_t Height = 0 ); void SetResolution ( uint32_t Horizontal = 0x00480000, uint32_t Vertical = 0x00480000 ); diff --git a/MP4/box_esds.h b/MP4/box_esds.h index 3cbeee5f..295a3a88 100644 --- a/MP4/box_esds.h +++ b/MP4/box_esds.h @@ -6,7 +6,7 @@ class Box_esds { Box_esds( ); ~Box_esds(); Box * GetBox(); - void SetDataReferenceIndex( uint16_t DataReferenceIndex = 0); + void SetDataReferenceIndex( uint16_t DataReferenceIndex = 1); void SetChannelCount( uint16_t Count = 2 ); void SetSampleSize( uint16_t Size = 16 ); private: diff --git a/MP4/box_stco.cpp b/MP4/box_stco.cpp index b0a6da0e..50759d7c 100644 --- a/MP4/box_stco.cpp +++ b/MP4/box_stco.cpp @@ -35,3 +35,7 @@ void Box_stco::WriteContent( ) { } Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Offsets.size()),4); } + +void Box_stco::SetOffsets( std::vector NewOffsets ) { + Offsets = NewOffsets; +} diff --git a/MP4/box_stco.h b/MP4/box_stco.h index e1d25862..56d64e29 100644 --- a/MP4/box_stco.h +++ b/MP4/box_stco.h @@ -8,6 +8,7 @@ class Box_stco { ~Box_stco(); Box * GetBox(); void AddOffset( uint32_t DataOffset, uint32_t Offset = 0 ); + void SetOffsets( std::vector NewOffsets ); void WriteContent( ); private: Box * Container; diff --git a/MP4/interface.cpp b/MP4/interface.cpp index 070e9c75..f0a7f18c 100644 --- a/MP4/interface.cpp +++ b/MP4/interface.cpp @@ -244,6 +244,9 @@ void Interface::SetStaticDefaults() { // 'soun' = 0x736F756E hdlr_soun->SetHandlerType( 0x736F756E ); hdlr_vide->SetName( "Audio Track" ); +// Set Track ID's + tkhd_vide->SetTrackID( 1 ); + tkhd_soun->SetTrackID( 2 ); } void Interface::AddSTTSEntry( uint32_t SampleCount, uint32_t SampleDelta, uint32_t Track ) { @@ -344,3 +347,17 @@ void Interface::WriteSTSC( uint32_t Track ) { break; } } + +void Interface::SetOffsets( std::vector NewOffsets, uint32_t Track ) { + switch( Track ) { + case 1: + stco_vide->SetOffsets( NewOffsets ); + break; + case 2: + stco_soun->SetOffsets( NewOffsets ); + break; + default; + fprintf( stderr, "WARNING: Track %d does not exist, Offsets not written\n", Track ); + break; + } +} diff --git a/MP4/interface.h b/MP4/interface.h index d6753f34..7cc28366 100644 --- a/MP4/interface.h +++ b/MP4/interface.h @@ -16,6 +16,8 @@ class Interface { void EmptySTTS( uint32_t Track ); void AddSTSCEntry( uint32_t FirstChunk, uint32_t SamplesPerChunk, uint32_t Track ); void EmptySTSC( uint32_t Track ); + void SetOffsets( std::vector NewOffsets, uint32_t Track ); + void SetData( uint8_t * Data, uint32_t DataSize ); private: void SetStaticDefaults(); void UpdateContents();