From 755fcd00c6b3324d993196deba70e1faca2f2248 Mon Sep 17 00:00:00 2001 From: Erik Zandvliet Date: Sat, 22 Jan 2011 12:38:00 +0100 Subject: [PATCH] [STABLE] all boxes compile, hint media header box added --- MP4/Makefile | 2 +- MP4/box_hmhd.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ MP4/box_hmhd.h | 17 +++++++++++++++++ MP4/box_mvhd.cpp | 2 +- MP4/box_tkhd.cpp | 20 ++++++++++---------- MP4/main.cpp | 4 ++-- 6 files changed, 73 insertions(+), 14 deletions(-) create mode 100644 MP4/box_hmhd.cpp create mode 100644 MP4/box_hmhd.h diff --git a/MP4/Makefile b/MP4/Makefile index 6c4e47cd..1e4587bd 100644 --- a/MP4/Makefile +++ b/MP4/Makefile @@ -1,4 +1,4 @@ -SRC = box.cpp box_ftyp.cpp box_h264.cpp box_stbl.cpp box_stco.cpp box_stsc.cpp box_stsd.cpp box_stts.cpp box_url.cpp box_dref.cpp box_dinf.cpp box_minf.cpp box_vmhd.cpp box_hdlr.cpp box_trak.cpp box_moov.cpp box_mdia.cpp box_mdhd.cpp main.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 OBJ = $(SRC:.cpp=.o) OUT = Boxtest INCLUDES = diff --git a/MP4/box_hmhd.cpp b/MP4/box_hmhd.cpp new file mode 100644 index 00000000..f2737b76 --- /dev/null +++ b/MP4/box_hmhd.cpp @@ -0,0 +1,42 @@ +#include "box_hmhd.h" + +Box_hmhd::Box_hmhd( ) { + Container = new Box( 0x686D6864 ); + SetDefaults(); + SetReserved(); +} + +Box_hmhd::~Box_hmhd() { + delete Container; +} + +Box * Box_hmhd::GetBox() { + return Container; +} + +void Box_hmhd::SetMaxPDUSize( uint16_t Size ) { + Container->SetPayload((uint32_t)2,Box::uint16_to_uint8(Size),4); +} + +void Box_hmhd::SetAvgPDUSize( uint16_t Size ) { + Container->SetPayload((uint32_t)2,Box::uint16_to_uint8(Size),6); +} + +void Box_hmhd::SetMaxBitRate( uint32_t Rate ) { + Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Rate),8); +} + +void Box_hmhd::SetAvgBitRate( uint32_t Rate ) { + Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Rate),12); +} + +void Box_hmhd::SetReserved( ) { + Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),16); + Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0)); +} +void Box_hmhd::SetDefaults( ) { + SetAvgBitRate( ); + SetMaxBitRate( ); + SetAvgPDUSize( ); + SetMaxPDUSize( ); +} diff --git a/MP4/box_hmhd.h b/MP4/box_hmhd.h new file mode 100644 index 00000000..14253b20 --- /dev/null +++ b/MP4/box_hmhd.h @@ -0,0 +1,17 @@ +#include "box.h" + +class Box_hmhd { + public: + Box_hmhd( ); + ~Box_hmhd(); + Box * GetBox(); + void SetMaxPDUSize( uint16_t Size = 0 ); + void SetAvgPDUSize( uint16_t Size = 0 ); + void SetMaxBitRate( uint32_t Rate = 0 ); + void SetAvgBitRate( uint32_t Rate = 0 ); + private: + Box * Container; + void SetReserved( ); + void SetDefaults( ); +};//Box_ftyp Class + diff --git a/MP4/box_mvhd.cpp b/MP4/box_mvhd.cpp index 1592d387..d479c132 100644 --- a/MP4/box_mvhd.cpp +++ b/MP4/box_mvhd.cpp @@ -47,7 +47,7 @@ void Box_mvhd::SetRate( uint32_t Rate ) { } void Box_mvhd::SetVolume( uint16_t Volume ) { - Container->SetPayload((uint32_t)4,Box::uint16_to_uint8(Rate),24); + Container->SetPayload((uint32_t)4,Box::uint16_to_uint8(Volume),24); } void Box_mvhd::SetNextTrackID( uint32_t TrackID ) { diff --git a/MP4/box_tkhd.cpp b/MP4/box_tkhd.cpp index 8a032b01..b274f832 100644 --- a/MP4/box_tkhd.cpp +++ b/MP4/box_tkhd.cpp @@ -39,15 +39,15 @@ void Box_tkhd::SetDurationTime( uint32_t TimeUnits ) { } void Box_tkhd::SetReserved() { - Container->SetPayload((uint32_t)4,Box::uint16_to_uint8(0x40000000),68); - Container->SetPayload((uint32_t)4,Box::uint16_to_uint8(0),64); - Container->SetPayload((uint32_t)4,Box::uint16_to_uint8(0),60); - Container->SetPayload((uint32_t)4,Box::uint16_to_uint8(0),56); - Container->SetPayload((uint32_t)4,Box::uint16_to_uint8(0x10000),52); - Container->SetPayload((uint32_t)4,Box::uint16_to_uint8(0),48); - Container->SetPayload((uint32_t)4,Box::uint16_to_uint8(0),44); - Container->SetPayload((uint32_t)4,Box::uint16_to_uint8(0),40); - Container->SetPayload((uint32_t)4,Box::uint16_to_uint8(0x10000),36); + Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0x40000000),68); + Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),64); + Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),60); + Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),56); + Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0x10000),52); + Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),48); + Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),44); + Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),40); + Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0x10000),36); Container->SetPayload((uint32_t)4,Box::uint16_to_uint8(0),34); Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),28); Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),24); @@ -75,7 +75,7 @@ void Box_tkhd::SetWidth( uint32_t Width ) { } void Box_tkhd::SetHeight( uint32_t Height ) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Width),76); + Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Height),76); } void Box_tkhd::SetDefaults() { diff --git a/MP4/main.cpp b/MP4/main.cpp index 23b45efa..9e7c44a8 100644 --- a/MP4/main.cpp +++ b/MP4/main.cpp @@ -1,10 +1,10 @@ #include -#include "box_h264.h" +#include "box_avcC.h" #include "box_stsd.h" #include int main() { - Box_h264 * Testing = new Box_h264(); + Box_avcC * Testing = new Box_avcC(); Testing->SetCompressorName( "Test123" ); std::cout << "H264::Size: " << Testing->GetBox()->GetHeader().TotalSize << "\n"; Box_stsd * Testsample = new Box_stsd();