AFRA box created, RTMP box updated
This commit is contained in:
parent
763028f3f6
commit
9981841406
4 changed files with 82 additions and 2 deletions
44
MP4/box_afra.cpp
Normal file
44
MP4/box_afra.cpp
Normal file
|
@ -0,0 +1,44 @@
|
|||
#include "box_afra.h"
|
||||
|
||||
Box_afra::Box_afra( ) {
|
||||
Container = new Box( 0x61667261 );
|
||||
SetReserved( );
|
||||
SetDefaults( );
|
||||
}
|
||||
|
||||
Box_afra::~Box_afra() {
|
||||
delete Container;
|
||||
}
|
||||
|
||||
Box * Box_afra::GetBox() {
|
||||
return Container;
|
||||
}
|
||||
|
||||
void Box_afra::SetDefaults( ) {
|
||||
SetTimeScale( );
|
||||
}
|
||||
|
||||
void Box_afra::SetReserved( ) {
|
||||
uint8_t * temp = new uint8_t[1];
|
||||
temp[0] = 0;
|
||||
Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),1);
|
||||
Container->SetPayload((uint32_t)1,temp);
|
||||
}
|
||||
|
||||
void Box_afra::SetTimeScale( uint32_t Scale ) {
|
||||
CurrentTimeScale = Scale;
|
||||
Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Scale),5);
|
||||
}
|
||||
|
||||
void Box_afra::WriteContent( ) {
|
||||
Container->ResetPayload();
|
||||
SetReserved( );
|
||||
if(!Entries.empty()) {
|
||||
for(int32_t i = Entries.size() -1; i >= 0; i--) {
|
||||
Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Entries[i].SampleDelta),(i*12)+21);
|
||||
Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Entries[i].SampleCount),(i*12)+17);
|
||||
Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),(i*12)+13);
|
||||
}
|
||||
}
|
||||
Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Entries.size()),9);
|
||||
}
|
24
MP4/box_afra.h
Normal file
24
MP4/box_afra.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
#include "box.h"
|
||||
#include <vector>
|
||||
|
||||
struct afra_record {
|
||||
uint32_t Time;
|
||||
uint32_t Offset;
|
||||
};//afra_record
|
||||
|
||||
class Box_afra {
|
||||
public:
|
||||
Box_afra( );
|
||||
~Box_afra();
|
||||
Box * GetBox();
|
||||
void SetTimeScale( uint32_t Scale = 1 );
|
||||
void AddEntry( uint32_t Time = 0, uint32_t SampleOffset = 0, uint32_t Offset = 0 );
|
||||
void WriteContent( );
|
||||
private:
|
||||
void SetReserved( );
|
||||
void SetDefaults( );
|
||||
|
||||
Box * Container;
|
||||
uint32_t CurrentTimeScale;
|
||||
std::vector<afra_record> Entries;
|
||||
};//Box_ftyp Class
|
|
@ -15,7 +15,11 @@ Box * Box_rtmp::GetBox() {
|
|||
}
|
||||
|
||||
void Box_rtmp::SetReserved( ) {
|
||||
Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0));
|
||||
Container->SetPayload((uint32_t)2,Box::uint16_to_uint8(CurrentMaxPacketSize),12);
|
||||
Container->SetPayload((uint32_t)2,Box::uint16_to_uint8(CurrentHighestCompatibleVersion),10);
|
||||
Container->SetPayload((uint32_t)2,Box::uint16_to_uint8(CurrentHintTrackVersion),8);
|
||||
Container->SetPayload((uint32_t)2,Box::uint16_to_uint8(CurrentReferenceIndex),6);
|
||||
Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),2);
|
||||
Container->SetPayload((uint32_t)2,Box::uint16_to_uint8(0));
|
||||
}
|
||||
|
||||
|
@ -27,16 +31,20 @@ void Box_rtmp::SetDefaults( ) {
|
|||
}
|
||||
|
||||
void Box_rtmp::SetDataReferenceIndex( uint16_t NewIndex ) {
|
||||
CurrentReferenceIndex = NewIndex;
|
||||
Container->SetPayload((uint32_t)2,Box::uint16_to_uint8(NewIndex),6);
|
||||
}
|
||||
void Box_rtmp::SetHintTrackVersion( uint16_t NewVersion ) {
|
||||
CurrentHintTrackVersion = NewVersion;
|
||||
Container->SetPayload((uint32_t)2,Box::uint16_to_uint8(NewVersion),8);
|
||||
}
|
||||
void Box_rtmp::SetHighestCompatibleVersion( uint16_t NewVersion ) {
|
||||
CurrentHighestCompatibleVersion = NewVersion;
|
||||
Container->SetPayload((uint32_t)2,Box::uint16_to_uint8(NewVersion),10);
|
||||
}
|
||||
|
||||
void Box_rtmp::SetMaxPacketSize( uint16_t NewSize ) {
|
||||
CurrentMaxPacketSize = NewSize;
|
||||
Container->SetPayload((uint32_t)2,Box::uint16_to_uint8(NewSize),12);
|
||||
}
|
||||
|
||||
|
@ -50,7 +58,7 @@ void Box_rtmp::AddContent( Box * newcontent ) {
|
|||
|
||||
void Box_rtmp::WriteContent( ) {
|
||||
Container->ResetPayload( );
|
||||
SetDefaults( );
|
||||
SetReserved( );
|
||||
std::string serializedbox = "";
|
||||
serializedbox.append((char*)Content->GetBoxedData(),Content->GetBoxedDataSize());
|
||||
Container->SetPayload((uint32_t)serializedbox.size(),(uint8_t*)serializedbox.c_str(),14);
|
||||
|
|
|
@ -15,6 +15,10 @@ class Box_rtmp {
|
|||
private:
|
||||
void SetReserved( );
|
||||
void SetDefaults( );
|
||||
uint16_t CurrentReferenceIndex;
|
||||
uint16_t CurrentHintTrackVersion;
|
||||
uint16_t CurrentHighestCompatibleVersion;
|
||||
uint16_t CurrentMaxPacketSize;
|
||||
|
||||
Box * Container;
|
||||
Box * Content;
|
||||
|
|
Loading…
Add table
Reference in a new issue