STCO-box added

This commit is contained in:
Erik Zandvliet 2011-01-01 20:39:20 +01:00
parent c93a0bb815
commit 9a1de4042e
2 changed files with 55 additions and 0 deletions

37
MP4/box_stco.cpp Normal file
View file

@ -0,0 +1,37 @@
#include "box_stco.h"
Box_stco::Box_stco( ) {
Container = new Box( 0x7374636F );
SetReserved();
}
Box_stco::~Box_stco() {
delete Container;
}
Box * Box_stco::GetBox() {
return Container;
}
void Box_stco::SetReserved( ) {
Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0));
}
void Box_stco::AddOffset( uint32_t DataOffset, uint32_t Offset ) {
if(Offset >= Offsets.size()) {
Offsets.resize(Offset+1);
}
Offsets[Offset] = DataOffset;
}
void Box_stco::WriteOffsets( ) {
Container->ResetPayload();
SetReserved( );
if(!Offsets.empty()) {
for(int32_t i = Offsets.size() -1; i >= 0; i--) {
Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Offsets[i]),(i*4)+8);
}
}
Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Offsets.size()),4);
}

18
MP4/box_stco.h Normal file
View file

@ -0,0 +1,18 @@
#include "box.h"
#include <string>
#include <vector>
class Box_stco {
public:
Box_stco( );
~Box_stco();
Box * GetBox();
void SetReserved( );
void AddOffset( uint32_t DataOffset, uint32_t Offset = 0 );
private:
Box * Container;
void WriteOffsets( );
std::vector<uint32_t> Offsets;
};//Box_ftyp Class