Adding stco and mdat functionality

This commit is contained in:
Erik Zandvliet 2011-01-24 13:11:57 +01:00
parent 2c177c4689
commit 4742862b08
6 changed files with 26 additions and 2 deletions

View file

@ -6,7 +6,7 @@ class Box_avcC {
Box_avcC( );
~Box_avcC();
Box * GetBox();
void SetDataReferenceIndex( uint16_t DataReferenceIndex = 0 );
void SetDataReferenceIndex( uint16_t DataReferenceIndex = 1 );
void SetWidth( uint16_t Width = 0 );
void SetHeight( uint16_t Height = 0 );
void SetResolution ( uint32_t Horizontal = 0x00480000, uint32_t Vertical = 0x00480000 );

View file

@ -6,7 +6,7 @@ class Box_esds {
Box_esds( );
~Box_esds();
Box * GetBox();
void SetDataReferenceIndex( uint16_t DataReferenceIndex = 0);
void SetDataReferenceIndex( uint16_t DataReferenceIndex = 1);
void SetChannelCount( uint16_t Count = 2 );
void SetSampleSize( uint16_t Size = 16 );
private:

View file

@ -35,3 +35,7 @@ void Box_stco::WriteContent( ) {
}
Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Offsets.size()),4);
}
void Box_stco::SetOffsets( std::vector<uint32_t> NewOffsets ) {
Offsets = NewOffsets;
}

View file

@ -8,6 +8,7 @@ class Box_stco {
~Box_stco();
Box * GetBox();
void AddOffset( uint32_t DataOffset, uint32_t Offset = 0 );
void SetOffsets( std::vector<uint32_t> NewOffsets );
void WriteContent( );
private:
Box * Container;

View file

@ -244,6 +244,9 @@ void Interface::SetStaticDefaults() {
// 'soun' = 0x736F756E
hdlr_soun->SetHandlerType( 0x736F756E );
hdlr_vide->SetName( "Audio Track" );
// Set Track ID's
tkhd_vide->SetTrackID( 1 );
tkhd_soun->SetTrackID( 2 );
}
void Interface::AddSTTSEntry( uint32_t SampleCount, uint32_t SampleDelta, uint32_t Track ) {
@ -344,3 +347,17 @@ void Interface::WriteSTSC( uint32_t Track ) {
break;
}
}
void Interface::SetOffsets( std::vector<uint32_t> NewOffsets, uint32_t Track ) {
switch( Track ) {
case 1:
stco_vide->SetOffsets( NewOffsets );
break;
case 2:
stco_soun->SetOffsets( NewOffsets );
break;
default;
fprintf( stderr, "WARNING: Track %d does not exist, Offsets not written\n", Track );
break;
}
}

View file

@ -16,6 +16,8 @@ class Interface {
void EmptySTTS( uint32_t Track );
void AddSTSCEntry( uint32_t FirstChunk, uint32_t SamplesPerChunk, uint32_t Track );
void EmptySTSC( uint32_t Track );
void SetOffsets( std::vector<uint32_t> NewOffsets, uint32_t Track );
void SetData( uint8_t * Data, uint32_t DataSize );
private:
void SetStaticDefaults();
void UpdateContents();