89 lines
2.6 KiB
C++
89 lines
2.6 KiB
C++
#include "box.cpp"
|
|
#include <string>
|
|
|
|
class Box_rtmp {
|
|
public:
|
|
Box_rtmp( );
|
|
~Box_rtmp();
|
|
Box * GetBox();
|
|
void SetDataReferenceIndex( uint16_t NewIndex = 0 );
|
|
void SetHintTrackVersion( uint16_t NewVersion = 1 );
|
|
void SetHighestCompatibleVersion( uint16_t NewVersion = 1 );
|
|
void SetMaxPacketSize( uint16_t NewSize = 0xFFFF );
|
|
void AddContent( Box * newcontent );
|
|
void WriteContent( );
|
|
private:
|
|
void SetReserved( );
|
|
void SetDefaults( );
|
|
uint16_t CurrentReferenceIndex;
|
|
uint16_t CurrentHintTrackVersion;
|
|
uint16_t CurrentHighestCompatibleVersion;
|
|
uint16_t CurrentMaxPacketSize;
|
|
|
|
Box * Container;
|
|
Box * Content;
|
|
};//Box_ftyp Class
|
|
|
|
Box_rtmp::Box_rtmp( ) {
|
|
Container = new Box( 0x72746D70 );
|
|
SetReserved();
|
|
SetDefaults();
|
|
}
|
|
|
|
Box_rtmp::~Box_rtmp() {
|
|
delete Container;
|
|
}
|
|
|
|
Box * Box_rtmp::GetBox() {
|
|
return Container;
|
|
}
|
|
|
|
void Box_rtmp::SetReserved( ) {
|
|
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));
|
|
}
|
|
|
|
void Box_rtmp::SetDefaults( ) {
|
|
SetDataReferenceIndex( );
|
|
SetHintTrackVersion( );
|
|
SetHighestCompatibleVersion( );
|
|
SetMaxPacketSize( );
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
void Box_rtmp::AddContent( Box * newcontent ) {
|
|
if(Content) {
|
|
delete Content;
|
|
Content = NULL;
|
|
}
|
|
Content = newcontent;
|
|
}
|
|
|
|
void Box_rtmp::WriteContent( ) {
|
|
Container->ResetPayload( );
|
|
SetReserved( );
|
|
std::string serializedbox = "";
|
|
serializedbox.append((char*)Content->GetBoxedData(),Content->GetBoxedDataSize());
|
|
Container->SetPayload((uint32_t)serializedbox.size(),(uint8_t*)serializedbox.c_str(),14);
|
|
}
|