STSC en STTS boxes
This commit is contained in:
parent
9a1de4042e
commit
0fcc1c483d
4 changed files with 129 additions and 0 deletions
42
MP4/box_stsc.cpp
Normal file
42
MP4/box_stsc.cpp
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
#include "box_stsc.h"
|
||||||
|
|
||||||
|
Box_stsc::Box_stsc( ) {
|
||||||
|
Container = new Box( 0x73747363 );
|
||||||
|
SetReserved();
|
||||||
|
}
|
||||||
|
|
||||||
|
Box_stsc::~Box_stsc() {
|
||||||
|
delete Container;
|
||||||
|
}
|
||||||
|
|
||||||
|
Box * Box_stsc::GetBox() {
|
||||||
|
return Container;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Box_stsc::SetReserved( ) {
|
||||||
|
Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Box_stsc::AddEntry( uint32_t FirstChunk, uint32_t SamplesPerChunk, uint32_t SampleDescIndex, uint32_t Offset = 0 ) {
|
||||||
|
if(Offset >= Entries.size()) {
|
||||||
|
Entries.resize(Offset+1);
|
||||||
|
}
|
||||||
|
Entries[Offset].FirstChunk = FirstChunk;
|
||||||
|
Entries[Offset].SamplesPerChunk = SamplesPerChunk;
|
||||||
|
Entries[Offset].SampleDescIndex = SampleDescIndex;
|
||||||
|
WriteEntries( );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Box_stsc::WriteEntries( ) {
|
||||||
|
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(Entries[i].SampleDescIndex),(i*12)+16);
|
||||||
|
Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Entries[i].SamplesPerChunk),(i*12)+12);
|
||||||
|
Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Entries[i].FirstChunk),(i*12)+8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Offsets.size()),4);
|
||||||
|
}
|
24
MP4/box_stsc.h
Normal file
24
MP4/box_stsc.h
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
#include "box.h"
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
struct stsc_record {
|
||||||
|
uint32_t FirstChunk;
|
||||||
|
uint32_t SamplesPerChunk;
|
||||||
|
uint32_t SampleDescIndex;
|
||||||
|
};//stsc_record
|
||||||
|
|
||||||
|
class Box_stsc {
|
||||||
|
public:
|
||||||
|
Box_stsc( );
|
||||||
|
~Box_stsc();
|
||||||
|
Box * GetBox();
|
||||||
|
void SetReserved( );
|
||||||
|
void AddEntry( uint32_t FirstChunk, uint32_t SamplesPerChunk, uint32_t SampleDescIndex, uint32_t Offset = 0 );
|
||||||
|
private:
|
||||||
|
Box * Container;
|
||||||
|
|
||||||
|
void WriteEntries( );
|
||||||
|
std::vector<stsc_record> Entries;
|
||||||
|
};//Box_ftyp Class
|
||||||
|
|
40
MP4/box_stts.cpp
Normal file
40
MP4/box_stts.cpp
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
#include "box_stts.h"
|
||||||
|
|
||||||
|
Box_stts::Box_stts( ) {
|
||||||
|
Container = new Box( 0x73747473 );
|
||||||
|
SetReserved();
|
||||||
|
}
|
||||||
|
|
||||||
|
Box_stts::~Box_stsc() {
|
||||||
|
delete Container;
|
||||||
|
}
|
||||||
|
|
||||||
|
Box * Box_stts::GetBox() {
|
||||||
|
return Container;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Box_stts::SetReserved( ) {
|
||||||
|
Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Box_stts::AddEntry( uint32_t SampleCount, uint32_t SamplesDelta, uint32_t Offset = 0 ) {
|
||||||
|
if(Offset >= Entries.size()) {
|
||||||
|
Entries.resize(Offset+1);
|
||||||
|
}
|
||||||
|
Entries[Offset].SampleCount = SampleCount;
|
||||||
|
Entries[Offset].SampleDelta = SampleDelta;
|
||||||
|
WriteEntries( );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Box_stts::WriteEntries( ) {
|
||||||
|
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(Entries[i].SampleDelta),(i*8)+12);
|
||||||
|
Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Entries[i].SampleCount),(i*8)+8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Offsets.size()),4);
|
||||||
|
}
|
23
MP4/box_stts.h
Normal file
23
MP4/box_stts.h
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
#include "box.h"
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
struct stts_record {
|
||||||
|
uint32_t SampleCount;
|
||||||
|
uint32_t SampleDelta;
|
||||||
|
};//stsc_record
|
||||||
|
|
||||||
|
class Box_stts {
|
||||||
|
public:
|
||||||
|
Box_stsc( );
|
||||||
|
~Box_stsc();
|
||||||
|
Box * GetBox();
|
||||||
|
void SetReserved( );
|
||||||
|
void AddEntry( uint32_t SampleCount, uint32_t SampleDelta, uint32_t Offset = 0 );
|
||||||
|
private:
|
||||||
|
Box * Container;
|
||||||
|
|
||||||
|
void WriteEntries( );
|
||||||
|
std::vector<stts_record> Entries;
|
||||||
|
};//Box_ftyp Class
|
||||||
|
|
Loading…
Add table
Reference in a new issue