TRUN box finished
This commit is contained in:
parent
aa352fbe60
commit
ff93aedb98
3 changed files with 72 additions and 2 deletions
|
@ -40,8 +40,8 @@ void Box_tfhd::WriteContent( ) {
|
||||||
Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(curTrackId),4);
|
Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(curTrackId),4);
|
||||||
curoffset = 8;
|
curoffset = 8;
|
||||||
if( curBaseDataOffset ) {
|
if( curBaseDataOffset ) {
|
||||||
Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(curTrackId),curoffset);
|
Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),curoffset);
|
||||||
Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(curTrackId),curoffset+4);
|
Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(curBaseDataOffset),curoffset+4);
|
||||||
curoffset += 8;
|
curoffset += 8;
|
||||||
}
|
}
|
||||||
if( curSampleDescriptionIndex ) {
|
if( curSampleDescriptionIndex ) {
|
||||||
|
|
45
MP4/box_trun.cpp
Normal file
45
MP4/box_trun.cpp
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
#include "box_trun.h"
|
||||||
|
|
||||||
|
Box_trun::Box_trun( ) {
|
||||||
|
Container = new Box( 0x74666864 );
|
||||||
|
SetDefaults( );
|
||||||
|
}
|
||||||
|
|
||||||
|
Box_trun::~Box_trun() {
|
||||||
|
delete Container;
|
||||||
|
}
|
||||||
|
|
||||||
|
Box * Box_trun::GetBox() {
|
||||||
|
return Container;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Box_trun::SetDataOffset( uint32_t Offset ) {
|
||||||
|
curDataOffset = Offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Box_trun::WriteContent( ) {
|
||||||
|
uint32_t curoffset;
|
||||||
|
uint32_t flags = 0 & ( curDataOffset ? 0x1 : 0 ) & ( setSampleDuration ? 0x100 : 0 ) & ( setSampleSize ? 0x200 : 0 );
|
||||||
|
Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(flags));
|
||||||
|
Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(SampleInfo.size()),4);
|
||||||
|
curoffset = 8;
|
||||||
|
if( curDataOffset ) {
|
||||||
|
Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(curDataOffset),curoffset);
|
||||||
|
curoffset += 4;
|
||||||
|
}
|
||||||
|
for( uint32_t i = 0; i < SampleInfo.size(); i++ ) {
|
||||||
|
if( setSampleDuration ) {
|
||||||
|
Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(SampleInfo[i].SampleDuration),curoffset);
|
||||||
|
curoffset += 4;
|
||||||
|
}
|
||||||
|
if( setSampleSize ) {
|
||||||
|
Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(SampleInfo[i].SampleSize),curoffset);
|
||||||
|
curoffset += 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Box_trun::SetDefaults( ) {
|
||||||
|
setSampleDuration = false;
|
||||||
|
setSampleSize = false;
|
||||||
|
}
|
25
MP4/box_trun.h
Normal file
25
MP4/box_trun.h
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
#include "box.h"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
struct trun_sampleinformationstructure {
|
||||||
|
uint32_t SampleDuration;
|
||||||
|
uint32_t SampleSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
class Box_tfhd {
|
||||||
|
public:
|
||||||
|
Box_tfhd( );
|
||||||
|
~Box_tfhd();
|
||||||
|
Box * GetBox();
|
||||||
|
void SetDataOffset( uint32_t Offset = 0 );
|
||||||
|
void AddSampleInformation( uint32_t SampleDuration = 0, uint32_t SampleSize = 0, uint32_t Offset = 0 );
|
||||||
|
void WriteContent( );
|
||||||
|
private:
|
||||||
|
void SetDefaults( );
|
||||||
|
bool setSampleDuration;
|
||||||
|
bool setSampleSize;
|
||||||
|
uint32_t curDataOffset;
|
||||||
|
std::vector<trun_sampleinformationstructure> SampleInfo;
|
||||||
|
Box * Container;
|
||||||
|
};//Box_ftyp Class
|
||||||
|
|
Loading…
Add table
Reference in a new issue