First ftyp Box Implementation

This commit is contained in:
Erik Zandvliet 2010-12-14 12:26:19 +01:00
parent e6b0cbe634
commit fce97a478c
7 changed files with 157 additions and 41 deletions

View file

@ -1,4 +1,7 @@
#include "boxheader.h"
#include <cstdio>
#include <cstring>
class Box {
public:
@ -9,50 +12,16 @@ class Box {
void SetBoxType(uint32_t BoxType);
uint32_t GetBoxType();
void SetPayload(uint32_t PayloadSize, uint8_t * Data);
void SetPayload(uint32_t Size, uint8_t * Data, uint32_t Index = 0);
uint32_t GetPayloadSize();
uint8_t * GetPayload();
uint8_t * GetPayload(uint32_t Index, uint32_t Size);
uint8_t * GetPayload(uint32_t Index, uint32_t & Size);
static uint8_t * uint32_to_uint8( uint32_t data );
private:
BoxHeader header;
uint8_t * Payload;
uint32_t PayloadSize;
};//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;
}