From 17d6a047571323f060a89958c94d9b0a59533577 Mon Sep 17 00:00:00 2001 From: Erik Zandvliet Date: Mon, 7 Feb 2011 10:03:48 +0100 Subject: [PATCH] AFRA box finished and added to interface --- MP4/Makefile | 2 +- MP4/box_afra.cpp | 12 ++++++++++-- MP4/box_includes.h | 1 + MP4/interface.cpp | 4 +++- MP4/interface.h | 1 + 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/MP4/Makefile b/MP4/Makefile index 313b55e0..b7e7c585 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 box_amhp.cpp box_mvex.cpp box_trex.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 box_trex.cpp box_afra.cpp OBJ = $(SRC:.cpp=.o) OUT = Boxtest INCLUDES = diff --git a/MP4/box_afra.cpp b/MP4/box_afra.cpp index 97684abf..6488e707 100644 --- a/MP4/box_afra.cpp +++ b/MP4/box_afra.cpp @@ -30,13 +30,21 @@ void Box_afra::SetTimeScale( uint32_t Scale ) { Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Scale),5); } +void Box_afra::AddEntry( uint32_t Time, uint32_t SampleOffset, uint32_t Offset ) { + if(Offset >= Entries.size()) { + Entries.resize(Offset+1); + } + Entries[Offset].Time = Time; + Entries[Offset].Offset = SampleOffset; +} + void Box_afra::WriteContent( ) { Container->ResetPayload(); SetReserved( ); if(!Entries.empty()) { for(int32_t i = Entries.size() -1; i >= 0; i--) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Entries[i].SampleDelta),(i*12)+21); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Entries[i].SampleCount),(i*12)+17); + Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Entries[i].Offset),(i*12)+21); + Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Entries[i].Time),(i*12)+17); Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),(i*12)+13); } } diff --git a/MP4/box_includes.h b/MP4/box_includes.h index e3f668b3..ae110f17 100644 --- a/MP4/box_includes.h +++ b/MP4/box_includes.h @@ -26,3 +26,4 @@ #include "box_amhp.h" #include "box_mvex.h" #include "box_trex.h" +#include "box_afra.h" diff --git a/MP4/interface.cpp b/MP4/interface.cpp index 89e15018..5bae85b9 100644 --- a/MP4/interface.cpp +++ b/MP4/interface.cpp @@ -45,12 +45,14 @@ Interface::Interface() { mvex = new Box_mvex(); trex_vide = new Box_trex(); trex_soun = new Box_trex(); + afra = new Box_afra(); //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( afra ) { delete afra; afra = NULL; } if( trex_vide ) { delete trex_vide; trex_vide = NULL; } if( trex_soun ) { delete trex_soun; trex_soun = NULL; } if( mvex ) { delete mvex; mvex = NULL; } @@ -148,7 +150,7 @@ uint8_t * Interface::GetContents( ) { uint32_t Ftyp_Size = ftyp->GetBox( )->GetBoxedDataSize( ); uint32_t Moov_Size = moov->GetBox( )->GetBoxedDataSize( ); uint32_t Rtmp_Size = rtmp->GetBox( )->GetBoxedDataSize( ); - memcpy(Result,ftyp->GetBox( )->GetBoxedData( ),Ftyp_Size( )); + memcpy(Result,ftyp->GetBox( )->GetBoxedData( ),Ftyp_Size); memcpy(&Result[Ftyp_Size],moov->GetBox( )->GetBoxedData( ),Moov_Size); memcpy(&Result[Ftyp_Size+Moov_Size],rtmp->GetBox( )->GetBoxedData( ),Rtmp_Size); return Result; diff --git a/MP4/interface.h b/MP4/interface.h index 3e544aa8..7dc2ed64 100644 --- a/MP4/interface.h +++ b/MP4/interface.h @@ -72,5 +72,6 @@ class Interface { Box_mvex * mvex; Box_trex * trex_vide; Box_trex * trex_soun; + Box_afra * afra; };//Interface class