From 8093e14ce7617f67e75989268b477cad936cca06 Mon Sep 17 00:00:00 2001 From: Erik Zandvliet Date: Tue, 14 Dec 2010 10:41:15 +0100 Subject: [PATCH] Start MP4 Box container implementation --- MP4/box.h | 58 +++++++++++++++++++++++++++++++++++++++++++++++++ MP4/boxheader.h | 4 ++++ 2 files changed, 62 insertions(+) create mode 100644 MP4/box.h create mode 100644 MP4/boxheader.h diff --git a/MP4/box.h b/MP4/box.h new file mode 100644 index 00000000..bab440b6 --- /dev/null +++ b/MP4/box.h @@ -0,0 +1,58 @@ +#include "boxheader.h" + +class Box { + public: + Box(); + Box(uint32_t BoxType); + ~Box(); + + void SetBoxType(uint32_t BoxType); + uint32_t GetBoxType(); + + void SetPayload(uint32_t PayloadSize, uint8_t * Data); + uint8_t * GetPayload(); + uint8_t * GetPayload(uint32_t Index, uint32_t Size); + private: + BoxHeader header; + uint8_t * Payload; +};//Box Class + +Box::Box() { + Payload = NULL; +} + +Box::Box(uint32_t BoxType) { + header.BoxType = BoxType; + Payload = NULL; +} + +Box::~Box() { +} + +void Box::SetBoxType(uint32_t BoxType) { + header.BoxType = BoxType; +} + +uint32_t Box::GetBoxType() { + return header.BoxType; +} + +void Box::SetPayload(uint32_t PayloadSize, uint8_t * Data ) { + if ( Payload != NULL ) { delete Payload; } + Payload = new uint8_t[PayloadSize]; + memcpy( Payload, Data, PayloadSize ); + header.TotalSize = PayloadSize + 8; +} + +uint8_t * Box::GetPayload() { + uint8_t * temp = new uint8_t[header.TotalSize - 8]; + memcpy( temp, Payload, header.TotalSize - 8 ); + return temp; +} + +uint8_t * Box::GetPayload(uint32_t Index, uint32_t Size) { + if( + uint8_t * temp = new uint8_t[header.TotalSize - 8]; + memcpy( temp, Payload, header.TotalSize - 8 ); + return temp; +} diff --git a/MP4/boxheader.h b/MP4/boxheader.h new file mode 100644 index 00000000..b3dbc501 --- /dev/null +++ b/MP4/boxheader.h @@ -0,0 +1,4 @@ +struct BoxHeader { + uint32_t TotalSize; + uint32_t BoxType; +};//BoxHeader struct