Bijna klaar!

This commit is contained in:
Thulinma 2011-02-16 21:42:40 +01:00
parent 5ca7a72b86
commit a3fd7a5a43
84 changed files with 879 additions and 969 deletions

View file

@ -20,14 +20,14 @@ enum {HANDLER_NONE, HANDLER_PROGRESSIVE, HANDLER_FLASH, HANDLER_APPLE, HANDLER_M
#define DEFAULT_PORT 80
#include "../util/server_setup.cpp"
#include "../util/http_parser.cpp"
#include "../MP4/interface.h"
#include "../util/MP4/interface.cpp"
static const std::string base64_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
std::string base64_encode(std::string const input) {
std::string ret;
unsigned int in_len = input.size();
char quad[4], triple[3];
int i, x, n = 3;
unsigned int i, x, n = 3;
for (x = 0; x < in_len; x = x + 3){
if ((in_len - x) / 3 == 0){n = (in_len - x) % 3;}
for (i=0; i < 3; i++){triple[i] = '0';}
@ -96,8 +96,7 @@ int mainHandler(int CONN_fd){
int Segment = -1;
int ReqFragment = -1;
int temp;
int CurrentFragment = -1;
Interface * Flash_Interface = new Interface;
//int CurrentFragment = -1; later herbruiken?
while (!socketError && !All_Hell_Broke_Loose){
//only parse input if available or not yet init'ed
@ -106,7 +105,7 @@ int mainHandler(int CONN_fd){
if (HTTP_R.ReadSocket(CONN_fd)){
handler = HANDLER_PROGRESSIVE;
if ((HTTP_R.url.find("Seg") != std::string::npos) && (HTTP_R.url.find("Frag") != std::string::npos)){handler = HANDLER_FLASH;}
if (HTTP_R.url.find("f4m") != std::string:npos){handler = HANDLER_FLASH;}
if (HTTP_R.url.find("f4m") != std::string::npos){handler = HANDLER_FLASH;}
if (HTTP_R.url == "/crossdomain.xml"){
handler = HANDLER_NONE;
HTTP_S.Clean();
@ -119,7 +118,7 @@ int mainHandler(int CONN_fd){
#endif
}
if(handler == HANDLER_FLASH){
if (HTTP_R.url.find("f4m") == std::string:npos){
if (HTTP_R.url.find("f4m") == std::string::npos){
Movie = HTTP_R.url.substr(1);
Movie = Movie.substr(0,Movie.find("/"));
Quality = HTTP_R.url.substr( HTTP_R.url.find("/",1)+1 );
@ -137,8 +136,8 @@ int mainHandler(int CONN_fd){
#endif
HTTP_S.Clean();
HTTP_S.SetHeader("Content-Type","video/mp4");
//ERIK: Help, plox?
//HTTP_S.SetBody();//Wrap de FlashBuf?
HTTP_S.SetBody(Interface::mdatFold(FlashBuf));
FlashBuf = "";
std::string tmpresp = HTTP_S.BuildResponse("200", "OK");
DDV_write(tmpresp.c_str(), tmpresp.size(), CONN_fd);//schrijf de HTTP response header
}else{
@ -200,17 +199,9 @@ int mainHandler(int CONN_fd){
case -1: break;//not ready yet
default:
if (FLV_GetPacket(tag, ss)){//able to read a full packet?
//ERIK: "tag" bevat nu een FLV tag (video, audio, of metadata), de header hebben we al weggelezen, np.
//ERIK: Dit is het punt waarop je eventueel data mag/kan gaan sturen en/of parsen. Leef je uit.
//ERIK: je kan een HTTP_S gebruiken om je HTTP request op te bouwen (via SetBody, SetHeader, etc)
//ERIK: en dan met de .BuildResponse("200", "OK"); call een std::string met de hele response maken, klaar voor versturen
//ERIK: Note: hergebruik echter NIET de HTTP_R die ik al heb gemaakt hierboven, want er kunnen meerdere requests binnenkomen!
if (handler == HANDLER_FLASH){
if(tag->data[0] != 0x12 ) {
FlashBuf.append(tag->data,tag->len);
//JARON:er is een Interface * Flash_Interface aangemaakt, met de functie Setmdat( std::string )
//JARON:kun je data setten( de hele string in 1 keer ) en met Getmdat krijg je de boxed
//JARON:versie als string terug.
} else {
FlashMeta = "";
FlashMeta.append(tag->data,tag->len);

View file

@ -1,36 +0,0 @@
#pragma once
#include "boxheader.h"
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
class Box {
public:
Box();
Box(uint32_t BoxType);
~Box();
void SetBoxType(uint32_t BoxType);
uint32_t GetBoxType();
void SetPayload(uint32_t Size, uint8_t * Data, uint32_t Index = 0);
uint32_t GetPayloadSize();
uint8_t * GetPayload();
uint8_t * GetPayload(uint32_t Index, uint32_t & Size);
uint32_t GetBoxedDataSize();
uint8_t * GetBoxedData( );
static uint8_t * uint32_to_uint8( uint32_t data );
static uint8_t * uint16_to_uint8( uint16_t data );
static uint8_t * uint8_to_uint8( uint8_t data );
BoxHeader GetHeader( );
void ResetPayload( );
private:
BoxHeader header;
uint8_t * Payload;
uint32_t PayloadSize;
};//Box Class

View file

@ -1,51 +0,0 @@
#include "box.h"
#include <string>
#include <vector>
struct abst_serverentry {
std::string ServerBaseUrl;
};//abst_serverentry
struct abst_qualityentry {
std::string QualityModifier;
};//abst_qualityentry
class Box_abst {
public:
Box_abst( );
~Box_abst();
Box * GetBox();
void SetBootstrapVersion( uint32_t Version = 1 );
void SetProfile( uint8_t Profile = 0 );
void SetLive( bool Live = true );
void SetUpdate( bool Update = false );
void SetTimeScale( uint32_t Scale = 1000 );
void SetMediaTime( uint32_t Time = 0 );
void SetSMPTE( uint32_t Smpte = 0 );
void SetMovieIdentifier( std::string Identifier = "" );
void SetDRM( std::string Drm = "" );
void SetMetaData( std::string MetaData = "" );
void AddServerEntry( std::string Url = "", uint32_t Offset = 0 );
void AddQualityEntry( std::string Quality = "", uint32_t Offset = 0 );
void AddSegmentRunTable( Box * newSegment, uint32_t Offset = 0 );
void AddFragmentRunTable( Box * newFragment, uint32_t Offset = 0 );
void WriteContent( );
private:
void SetDefaults( );
void SetReserved( );
uint32_t curBootstrapInfoVersion;
uint8_t curProfile;
bool isLive;
bool isUpdate;
uint32_t curTimeScale;
uint32_t curMediatime;//write as uint64_t
uint32_t curSMPTE;//write as uint64_t
std::string curMovieIdentifier;
std::string curDRM;
std::string curMetaData;
std::vector<abst_serverentry> Servers;
std::vector<abst_qualityentry> Qualities;
std::vector<Box *> SegmentRunTables;
std::vector<Box *> FragmentRunTables;
Box * Container;
};//Box_ftyp Class

View file

@ -1,24 +0,0 @@
#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

View file

@ -1,29 +0,0 @@
#include "box.h"
#include <string>
#include <vector>
struct afrt_fragmentrunentry {
uint32_t FirstFragment;
uint32_t FirstFragmentTimestamp; //write as uint64_t
uint32_t FragmentDuration;
uint8_t DiscontinuityIndicator;//if FragmentDuration == 0
};//afrt_fragmentrunentry
class Box_afrt {
public:
Box_afrt( );
~Box_afrt();
Box * GetBox();
void SetUpdate( bool Update = false );
void SetTimeScale( uint32_t Scale = 1000 );
void AddQualityEntry( std::string Quality = "", uint32_t Offset = 0 );
void AddFragmentRunEntry( uint32_t FirstFragment = 0, uint32_t FirstFragmentTimestamp = 0, uint32_t FragmentsDuration = 1, uint8_t Discontinuity = 0, uint32_t Offset = 0 );
void WriteContent( );
private:
void SetDefaults( );
bool isUpdate;
uint32_t curTimeScale;
std::vector<std::string> QualitySegmentUrlModifiers;
std::vector<afrt_fragmentrunentry> FragmentRunEntryTable;
Box * Container;
};//Box_ftyp Class

View file

@ -1,24 +0,0 @@
#include "box.h"
#include <string>
#include <vector>
struct amhp_record {
uint8_t HintTrackMode;
uint8_t Settings;
uint8_t TrailerDefaultSize;
};//stsc_record
class Box_amhp {
public:
Box_amhp( );
~Box_amhp();
Box * GetBox();
void SetReserved( );
void AddEntry( uint8_t HintTrackMode, uint8_t Settings, uint8_t TrailerDefaultSize, uint32_t Offset = 0 );
void WriteContent( );
private:
Box * Container;
std::vector<amhp_record> Entries;
};//Box_ftyp Class

View file

@ -1,25 +0,0 @@
#include "box.h"
#include <string>
#include <vector>
struct asrt_segmentrunentry {
uint32_t FirstSegment;
uint32_t FragmentsPerSegment;
};//abst_qualityentry
class Box_asrt {
public:
Box_asrt( );
~Box_asrt();
Box * GetBox();
void SetUpdate( bool Update = false );
void AddQualityEntry( std::string Quality = "", uint32_t Offset = 0 );
void AddSegmentRunEntry( uint32_t FirstSegment = 0, uint32_t FragmentsPerSegment = 100, uint32_t Offset = 0 );
void WriteContent( );
private:
void SetDefaults( );
bool isUpdate;
std::vector<std::string> QualitySegmentUrlModifiers;
std::vector<asrt_segmentrunentry> SegmentRunEntryTable;
Box * Container;
};//Box_ftyp Class

View file

@ -1,22 +0,0 @@
#include "box.h"
#include <string>
class Box_avcC {
public:
Box_avcC( );
~Box_avcC();
Box * GetBox();
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 );
void SetFrameCount ( uint16_t FrameCount = 1 );
void SetCompressorName ( std::string CompressorName = "");
void SetDepth ( uint16_t Depth = 0x0018 );
private:
Box * Container;
void SetReserved( );
void SetDefaults( );
};//Box_ftyp Class

View file

@ -1,17 +0,0 @@
#include "box.h"
#include <vector>
#include <string>
class Box_dinf {
public:
Box_dinf();
~Box_dinf();
Box * GetBox();
void AddContent( Box * newcontent );
void WriteContent( );
private:
Box * Container;
Box * Content;
};//Box_ftyp Class

View file

@ -1,18 +0,0 @@
#include "box.h"
#include <vector>
#include <string>
class Box_dref {
public:
Box_dref();
~Box_dref();
Box * GetBox();
void AddContent( Box * newcontent, uint32_t offset = 0 );
void WriteContent( );
private:
Box * Container;
void SetReserved( );
std::vector<Box *> Content;
};//Box_ftyp Class

View file

@ -1,18 +0,0 @@
#include "box.h"
#include <string>
class Box_esds {
public:
Box_esds( );
~Box_esds();
Box * GetBox();
void SetDataReferenceIndex( uint16_t DataReferenceIndex = 1);
void SetChannelCount( uint16_t Count = 2 );
void SetSampleSize( uint16_t Size = 16 );
private:
Box * Container;
void SetReserved( );
void SetDefaults( );
};//Box_ftyp Class

View file

@ -1,14 +0,0 @@
#include "box.h"
class Box_ftyp {
public:
Box_ftyp( );
~Box_ftyp();
Box * GetBox();
void SetMajorBrand( uint32_t MajorBrand = 0x66347620 );
void SetMinorBrand( uint32_t MinorBrand = 0x1 );
private:
void SetDefaults( );
Box * Container;
};//Box_ftyp Class

View file

@ -1,17 +0,0 @@
#include "box.h"
#include <string>
class Box_hdlr {
public:
Box_hdlr( );
~Box_hdlr();
Box * GetBox();
void SetHandlerType( uint32_t HandlerType = 0 );
void SetName ( std::string Name = "" );
private:
Box * Container;
void SetReserved( );
void SetDefaults( );
uint32_t CurrentHandlerType;
};//Box_ftyp Class

View file

@ -1,17 +0,0 @@
#include "box.h"
class Box_hmhd {
public:
Box_hmhd( );
~Box_hmhd();
Box * GetBox();
void SetMaxPDUSize( uint16_t Size = 0 );
void SetAvgPDUSize( uint16_t Size = 0 );
void SetMaxBitRate( uint32_t Rate = 0 );
void SetAvgBitRate( uint32_t Rate = 0 );
private:
Box * Container;
void SetReserved( );
void SetDefaults( );
};//Box_ftyp Class

View file

@ -1,37 +0,0 @@
#include "box_abst.h"
#include "box_afra.h"
#include "box_afrt.h"
#include "box_amhp.h"
#include "box_asrt.h"
#include "box_avcC.h"
#include "box_dinf.h"
#include "box_dref.h"
#include "box_esds.h"
#include "box_ftyp.h"
#include "box_hdlr.h"
#include "box_hmhd.h"
#include "box_mdat.h"
#include "box_mdhd.h"
#include "box_mdia.h"
#include "box_mfhd.h"
#include "box_minf.h"
#include "box_moof.h"
#include "box_moov.h"
#include "box_mvex.h"
#include "box_mvhd.h"
#include "box_nmhd.h"
#include "box_rtmp.h"
#include "box_smhd.h"
#include "box_stbl.h"
#include "box_stco.h"
#include "box_stsc.h"
#include "box_stsd.h"
#include "box_stts.h"
#include "box_tfhd.h"
#include "box_tkhd.h"
#include "box_traf.h"
#include "box_trak.h"
#include "box_trex.h"
#include "box_trun.h"
#include "box_url.h"
#include "box_vmhd.h"

View file

@ -1,14 +0,0 @@
#include "box.h"
#include <vector>
#include <string>
class Box_mdat {
public:
Box_mdat();
~Box_mdat();
Box * GetBox();
void SetContent( uint8_t * NewData, uint32_t DataLength , uint32_t offset = 0 );
private:
Box * Container;
};//Box_ftyp Class

View file

@ -1,21 +0,0 @@
#include "box.h"
#include <ctime>
#define SECONDS_DIFFERENCE 2082844800
class Box_mdhd {
public:
Box_mdhd( );
~Box_mdhd();
Box * GetBox();
void SetCreationTime( uint32_t TimeStamp = 0 );
void SetModificationTime( uint32_t TimeStamp = 0 );
void SetTimeScale( uint32_t TimeUnits = 0 );
void SetDurationTime( uint32_t TimeUnits = 0 );
void SetLanguage( uint8_t Firstchar = 'n', uint8_t Secondchar = 'l', uint8_t Thirdchar = 'd' );
private:
void SetReserved();
void SetDefaults();
Box * Container;
};//Box_ftyp Class

View file

@ -1,17 +0,0 @@
#include "box.h"
#include <vector>
#include <string>
class Box_mdia {
public:
Box_mdia();
~Box_mdia();
Box * GetBox();
void AddContent( Box * newcontent, uint32_t offset = 0 );
void WriteContent( );
private:
Box * Container;
std::vector<Box *> Content;
};//Box_ftyp Class

View file

@ -1,14 +0,0 @@
#include "box.h"
class Box_mfhd {
public:
Box_mfhd( );
~Box_mfhd();
Box * GetBox();
void SetSequenceNumber( uint32_t SequenceNumber = 1 );
private:
void SetDefaults( );
void SetReserved( );
Box * Container;
};//Box_ftyp Class

View file

@ -1,17 +0,0 @@
#include "box.h"
#include <vector>
#include <string>
class Box_minf {
public:
Box_minf();
~Box_minf();
Box * GetBox();
void AddContent( Box * newcontent, uint32_t offset = 0 );
void WriteContent( );
private:
Box * Container;
std::vector<Box *> Content;
};//Box_ftyp Class

View file

@ -1,17 +0,0 @@
#include "box.h"
#include <vector>
#include <string>
class Box_moof {
public:
Box_moof();
~Box_moof();
Box * GetBox();
void AddContent( Box * newcontent, uint32_t offset = 0 );
void WriteContent( );
private:
Box * Container;
std::vector<Box *> Content;
};//Box_ftyp Class

View file

@ -1,17 +0,0 @@
#include "box.h"
#include <vector>
#include <string>
class Box_moov {
public:
Box_moov();
~Box_moov();
Box * GetBox();
void AddContent( Box * newcontent, uint32_t offset = 0 );
void WriteContent( );
private:
Box * Container;
std::vector<Box *> Content;
};//Box_ftyp Class

View file

@ -1,17 +0,0 @@
#include "box.h"
#include <vector>
#include <string>
class Box_mvex {
public:
Box_mvex();
~Box_mvex();
Box * GetBox();
void AddContent( Box * newcontent, uint32_t offset = 0 );
void WriteContent( );
private:
Box * Container;
std::vector<Box *> Content;
};//Box_ftyp Class

View file

@ -1,24 +0,0 @@
#include "box.h"
#include <ctime>
#define SECONDS_DIFFERENCE 2082844800
class Box_mvhd {
public:
Box_mvhd( );
~Box_mvhd();
Box * GetBox();
void SetCreationTime( uint32_t TimeStamp = 0 );
void SetModificationTime( uint32_t TimeStamp = 0 );
void SetTimeScale( uint32_t TimeUnits = 1 );
void SetDurationTime( uint32_t TimeUnits = 0 );
void SetRate( uint32_t Rate = 0x00010000 );
void SetVolume( uint16_t Volume = 0x0100 );
void SetNextTrackID( uint32_t TrackID = 0xFFFFFFFF );
private:
void SetReserved();
void SetDefaults();
Box * Container;
};//Box_ftyp Class

View file

@ -1,12 +0,0 @@
#include "box.h"
class Box_nmhd {
public:
Box_nmhd( );
~Box_nmhd();
Box * GetBox();
private:
Box * Container;
void SetReserved( );
};//Box_ftyp Class

View file

@ -1,26 +0,0 @@
#include "box.h"
#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

View file

@ -1,12 +0,0 @@
#include "box.h"
class Box_smhd {
public:
Box_smhd( );
~Box_smhd();
Box * GetBox();
private:
Box * Container;
void SetReserved( );
};//Box_ftyp Class

View file

@ -1,17 +0,0 @@
#include "box.h"
#include <vector>
#include <string>
class Box_stbl {
public:
Box_stbl();
~Box_stbl();
Box * GetBox();
void AddContent( Box * newcontent, uint32_t offset = 0 );
void WriteContent( );
private:
Box * Container;
std::vector<Box *> Content;
};//Box_ftyp Class

View file

@ -1,19 +0,0 @@
#include "box.h"
#include <string>
#include <vector>
class Box_stco {
public:
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;
void SetReserved( );
std::vector<uint32_t> Offsets;
};//Box_ftyp Class

View file

@ -1,24 +0,0 @@
#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 = 0, uint32_t SamplesPerChunk = 0, uint32_t SampleDescIndex = 0, uint32_t Offset = 0 );
void WriteContent( );
private:
Box * Container;
std::vector<stsc_record> Entries;
};//Box_ftyp Class

View file

@ -1,18 +0,0 @@
#include "box.h"
#include <vector>
#include <string>
class Box_stsd {
public:
Box_stsd( );
~Box_stsd();
Box * GetBox();
void AddContent( Box * newcontent, uint32_t offset = 0 );
void WriteContent();
private:
Box * Container;
void SetReserved();
std::vector<Box *> Content;
};//Box_ftyp Class

View file

@ -1,23 +0,0 @@
#include "box.h"
#include <string>
#include <vector>
struct stts_record {
uint32_t SampleCount;
uint32_t SampleDelta;
};//stsc_record
class Box_stts {
public:
Box_stts( );
~Box_stts();
Box * GetBox();
void SetReserved( );
void AddEntry( uint32_t SampleCount, uint32_t SampleDelta, uint32_t Offset = 0 );
void WriteContent( );
private:
Box * Container;
std::vector<stts_record> Entries;
};//Box_ftyp Class

View file

@ -1,23 +0,0 @@
#include "box.h"
class Box_tfhd {
public:
Box_tfhd( );
~Box_tfhd();
Box * GetBox();
void SetTrackID( uint32_t TrackID = 0 );
void SetBaseDataOffset( uint32_t Offset = 0 );//write as uint64_t
void SetSampleDescriptionIndex( uint32_t Index = 0 );
void SetDefaultSampleDuration( uint32_t Duration = 0 );
void SetDefaultSampleSize( uint32_t Size = 0 );
void WriteContent( );
private:
void SetDefaults( );
uint32_t curTrackID;
uint32_t curBaseDataOffset;
uint32_t curSampleDescriptionIndex;
uint32_t curDefaultSampleDuration;
uint32_t curDefaultSampleSize;
Box * Container;
};//Box_ftyp Class

View file

@ -1,27 +0,0 @@
#include "box.h"
#include <ctime>
#define SECONDS_DIFFERENCE 2082844800
class Box_tkhd {
public:
Box_tkhd( );
~Box_tkhd();
Box * GetBox();
void SetCreationTime( uint32_t TimeStamp = 0 );
void SetModificationTime( uint32_t TimeStamp = 0 );
void SetDurationTime( uint32_t TimeUnits = 0 );
void SetWidth( uint16_t Width = 0 );
void SetHeight( uint16_t Height = 0 );
void SetFlags( bool Bit0 = true, bool Bit1 = true, bool Bit2 = true );
void SetVersion( uint32_t Version = 0 );
void SetTrackID( uint32_t TrackID = 0 );
private:
void SetReserved();
void SetDefaults();
Box * Container;
uint32_t CurrentFlags;
uint32_t CurrentVersion;
};//Box_ftyp Class

View file

@ -1,17 +0,0 @@
#include "box.h"
#include <vector>
#include <string>
class Box_traf {
public:
Box_traf();
~Box_traf();
Box * GetBox();
void AddContent( Box * newcontent, uint32_t offset = 0 );
void WriteContent( );
private:
Box * Container;
std::vector<Box *> Content;
};//Box_ftyp Class

View file

@ -1,17 +0,0 @@
#include "box.h"
#include <vector>
#include <string>
class Box_trak {
public:
Box_trak();
~Box_trak();
Box * GetBox();
void AddContent( Box * newcontent, uint32_t offset = 0 );
void WriteContent( );
private:
Box * Container;
std::vector<Box *> Content;
};//Box_ftyp Class

View file

@ -1,16 +0,0 @@
#include "box.h"
class Box_trex {
public:
Box_trex( );
~Box_trex();
Box * GetBox();
void SetTrackID( uint32_t Id = 0 );
void SetSampleDescriptionIndex( uint32_t Index = 0 );
void SetSampleDuration( uint32_t Duration = 0 );
void SetSampleSize( uint32_t Size = 0 );
private:
void SetReserved( );
void SetDefaults( );
Box * Container;
};//Box_ftyp Class

View file

@ -1,25 +0,0 @@
#include "box.h"
#include <vector>
struct trun_sampleinformationstructure {
uint32_t SampleDuration;
uint32_t SampleSize;
};
class Box_trun {
public:
Box_trun( );
~Box_trun();
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

View file

@ -1,11 +0,0 @@
#include "box.h"
class Box_url {
public:
Box_url( );
~Box_url();
Box * GetBox();
private:
Box * Container;
};//Box_ftyp Class

View file

@ -1,15 +0,0 @@
#include "box.h"
class Box_vmhd {
public:
Box_vmhd( );
~Box_vmhd();
Box * GetBox();
void SetGraphicsMode( uint16_t GraphicsMode = 0 );
void SetOpColor( uint16_t Red = 0, uint16_t Green = 0, uint16_t Blue = 0);
private:
Box * Container;
void SetReserved( );
void SetDefaults( );
};//Box_ftyp Class

View file

@ -1,7 +0,0 @@
#include <stdint.h>
#include <cstdlib>
struct BoxHeader {
uint32_t TotalSize;
uint32_t BoxType;
};//BoxHeader struct

View file

@ -1,92 +0,0 @@
#include "box_includes.h"
#include <string>
class Interface {
public:
Interface();
~Interface();
void link();
uint32_t GetContentSize();
uint8_t * GetContents();
void SetWidth( uint16_t NewWidth );
void SetHeight( uint16_t NewHeight );
void SetDurationTime( uint32_t NewDuration, uint32_t Track );
void SetTimeScale( uint32_t NewUnitsPerSecond, uint32_t Track );
void AddSTTSEntry( uint32_t SampleCount, uint32_t SampleDelta, uint32_t Track );
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( std::string data );
std::string GenerateLiveBootstrap( uint32_t CurMediaTime );
private:
void SetStaticDefaults();
void UpdateContents();
void WriteSTTS( uint32_t Track );
void WriteSTSC( uint32_t Track );
bool AllBoxesExist();
uint16_t Width;
uint16_t Height;
std::vector<uint32_t> Duration;
std::vector<uint32_t> UnitsPerSecond;
std::vector<stts_record> sttsvide;
std::vector<stts_record> sttssoun;
std::vector<stsc_record> stscvide;
std::vector<stsc_record> stscsoun;
Box_ftyp * ftyp;
Box_moov * moov;
Box_mvhd * mvhd;
Box_trak * trak_vide;
Box_tkhd * tkhd_vide;
Box_mdia * mdia_vide;
Box_mdhd * mdhd_vide;
Box_hdlr * hdlr_vide;
Box_minf * minf_vide;
Box_vmhd * vmhd_vide;
Box_dinf * dinf_vide;
Box_dref * dref_vide;
Box_url * url_vide;
Box_stbl * stbl_vide;
Box_stts * stts_vide;
Box_stsc * stsc_vide;
Box_stco * stco_vide;
Box_stsd * stsd_vide;
Box_avcC * avcC_vide;
Box_trak * trak_soun;
Box_tkhd * tkhd_soun;
Box_mdia * mdia_soun;
Box_mdhd * mdhd_soun;
Box_hdlr * hdlr_soun;
Box_minf * minf_soun;
Box_smhd * smhd_soun;
Box_dinf * dinf_soun;
Box_dref * dref_soun;
Box_url * url_soun;
Box_stbl * stbl_soun;
Box_stts * stts_soun;
Box_stsc * stsc_soun;
Box_stco * stco_soun;
Box_stsd * stsd_soun;
Box_esds * esds_soun;
Box_rtmp * rtmp;
Box_amhp * amhp;
Box_mvex * mvex;
Box_trex * trex_vide;
Box_trex * trex_soun;
Box_afra * afra;
Box_abst * abst;
Box_asrt * asrt;
Box_afrt * afrt;
Box_moof * moof;
Box_mfhd * mfhd;
Box_traf * traf_vide;
Box_tfhd * tfhd_vide;
Box_trun * trun_vide;
Box_traf * traf_soun;
Box_tfhd * tfhd_soun;
Box_trun * trun_soun;
};//Interface class

View file

@ -1,4 +1,40 @@
#include "box.h"
#pragma once
#include <stdint.h>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
struct BoxHeader {
uint32_t TotalSize;
uint32_t BoxType;
};//BoxHeader struct
class Box {
public:
Box();
Box(uint32_t BoxType);
~Box();
void SetBoxType(uint32_t BoxType);
uint32_t GetBoxType();
void SetPayload(uint32_t Size, uint8_t * Data, uint32_t Index = 0);
uint32_t GetPayloadSize();
uint8_t * GetPayload();
uint8_t * GetPayload(uint32_t Index, uint32_t & Size);
uint32_t GetBoxedDataSize();
uint8_t * GetBoxedData( );
static uint8_t * uint32_to_uint8( uint32_t data );
static uint8_t * uint16_to_uint8( uint16_t data );
static uint8_t * uint8_to_uint8( uint8_t data );
BoxHeader GetHeader( );
void ResetPayload( );
private:
BoxHeader header;
uint8_t * Payload;
uint32_t PayloadSize;
};//Box Class
Box::Box() {
Payload = NULL;

View file

@ -1,4 +1,54 @@
#include "box_abst.h"
#include "box.cpp"
#include <string>
#include <vector>
struct abst_serverentry {
std::string ServerBaseUrl;
};//abst_serverentry
struct abst_qualityentry {
std::string QualityModifier;
};//abst_qualityentry
class Box_abst {
public:
Box_abst( );
~Box_abst();
Box * GetBox();
void SetBootstrapVersion( uint32_t Version = 1 );
void SetProfile( uint8_t Profile = 0 );
void SetLive( bool Live = true );
void SetUpdate( bool Update = false );
void SetTimeScale( uint32_t Scale = 1000 );
void SetMediaTime( uint32_t Time = 0 );
void SetSMPTE( uint32_t Smpte = 0 );
void SetMovieIdentifier( std::string Identifier = "" );
void SetDRM( std::string Drm = "" );
void SetMetaData( std::string MetaData = "" );
void AddServerEntry( std::string Url = "", uint32_t Offset = 0 );
void AddQualityEntry( std::string Quality = "", uint32_t Offset = 0 );
void AddSegmentRunTable( Box * newSegment, uint32_t Offset = 0 );
void AddFragmentRunTable( Box * newFragment, uint32_t Offset = 0 );
void WriteContent( );
private:
void SetDefaults( );
void SetReserved( );
uint32_t curBootstrapInfoVersion;
uint8_t curProfile;
bool isLive;
bool isUpdate;
uint32_t curTimeScale;
uint32_t curMediatime;//write as uint64_t
uint32_t curSMPTE;//write as uint64_t
std::string curMovieIdentifier;
std::string curDRM;
std::string curMetaData;
std::vector<abst_serverentry> Servers;
std::vector<abst_qualityentry> Qualities;
std::vector<Box *> SegmentRunTables;
std::vector<Box *> FragmentRunTables;
Box * Container;
};//Box_ftyp Class
Box_abst::Box_abst( ) {
Container = new Box( 0x61627374 );

View file

@ -1,4 +1,27 @@
#include "box_afra.h"
#include "box.cpp"
#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
Box_afra::Box_afra( ) {
Container = new Box( 0x61667261 );

View file

@ -1,4 +1,32 @@
#include "box_afrt.h"
#include "box.cpp"
#include <string>
#include <vector>
struct afrt_fragmentrunentry {
uint32_t FirstFragment;
uint32_t FirstFragmentTimestamp; //write as uint64_t
uint32_t FragmentDuration;
uint8_t DiscontinuityIndicator;//if FragmentDuration == 0
};//afrt_fragmentrunentry
class Box_afrt {
public:
Box_afrt( );
~Box_afrt();
Box * GetBox();
void SetUpdate( bool Update = false );
void SetTimeScale( uint32_t Scale = 1000 );
void AddQualityEntry( std::string Quality = "", uint32_t Offset = 0 );
void AddFragmentRunEntry( uint32_t FirstFragment = 0, uint32_t FirstFragmentTimestamp = 0, uint32_t FragmentsDuration = 1, uint8_t Discontinuity = 0, uint32_t Offset = 0 );
void WriteContent( );
private:
void SetDefaults( );
bool isUpdate;
uint32_t curTimeScale;
std::vector<std::string> QualitySegmentUrlModifiers;
std::vector<afrt_fragmentrunentry> FragmentRunEntryTable;
Box * Container;
};//Box_ftyp Class
Box_afrt::Box_afrt( ) {
Container = new Box( 0x61667274 );

View file

@ -1,4 +1,26 @@
#include "box_amhp.h"
#include "box.cpp"
#include <string>
#include <vector>
struct amhp_record {
uint8_t HintTrackMode;
uint8_t Settings;
uint8_t TrailerDefaultSize;
};//stsc_record
class Box_amhp {
public:
Box_amhp( );
~Box_amhp();
Box * GetBox();
void SetReserved( );
void AddEntry( uint8_t HintTrackMode, uint8_t Settings, uint8_t TrailerDefaultSize, uint32_t Offset = 0 );
void WriteContent( );
private:
Box * Container;
std::vector<amhp_record> Entries;
};//Box_ftyp Class
Box_amhp::Box_amhp( ) {
Container = new Box( 0x616D6870 );

View file

@ -1,4 +1,28 @@
#include "box_asrt.h"
#include "box.cpp"
#include <string>
#include <vector>
struct asrt_segmentrunentry {
uint32_t FirstSegment;
uint32_t FragmentsPerSegment;
};//abst_qualityentry
class Box_asrt {
public:
Box_asrt( );
~Box_asrt();
Box * GetBox();
void SetUpdate( bool Update = false );
void AddQualityEntry( std::string Quality = "", uint32_t Offset = 0 );
void AddSegmentRunEntry( uint32_t FirstSegment = 0, uint32_t FragmentsPerSegment = 100, uint32_t Offset = 0 );
void WriteContent( );
private:
void SetDefaults( );
bool isUpdate;
std::vector<std::string> QualitySegmentUrlModifiers;
std::vector<asrt_segmentrunentry> SegmentRunEntryTable;
Box * Container;
};//Box_ftyp Class
Box_asrt::Box_asrt( ) {
Container = new Box( 0x61737274 );

View file

@ -1,4 +1,24 @@
#include "box_avcC.h"
#include "box.cpp"
#include <string>
class Box_avcC {
public:
Box_avcC( );
~Box_avcC();
Box * GetBox();
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 );
void SetFrameCount ( uint16_t FrameCount = 1 );
void SetCompressorName ( std::string CompressorName = "");
void SetDepth ( uint16_t Depth = 0x0018 );
private:
Box * Container;
void SetReserved( );
void SetDefaults( );
};//Box_ftyp Class
Box_avcC::Box_avcC( ) {
Container = new Box( 0x61766343 );

View file

@ -1,4 +1,19 @@
#include "box_dinf.h"
#include "box.cpp"
#include <vector>
#include <string>
class Box_dinf {
public:
Box_dinf();
~Box_dinf();
Box * GetBox();
void AddContent( Box * newcontent );
void WriteContent( );
private:
Box * Container;
Box * Content;
};//Box_ftyp Class
Box_dinf::Box_dinf( ) {
Container = new Box( 0x64696E66 );

View file

@ -1,4 +1,20 @@
#include "box_dref.h"
#include "box.cpp"
#include <vector>
#include <string>
class Box_dref {
public:
Box_dref();
~Box_dref();
Box * GetBox();
void AddContent( Box * newcontent, uint32_t offset = 0 );
void WriteContent( );
private:
Box * Container;
void SetReserved( );
std::vector<Box *> Content;
};//Box_ftyp Class
Box_dref::Box_dref( ) {
Container = new Box( 0x64726566 );

View file

@ -1,4 +1,20 @@
#include "box_esds.h"
#include "box.cpp"
#include <string>
class Box_esds {
public:
Box_esds( );
~Box_esds();
Box * GetBox();
void SetDataReferenceIndex( uint16_t DataReferenceIndex = 1);
void SetChannelCount( uint16_t Count = 2 );
void SetSampleSize( uint16_t Size = 16 );
private:
Box * Container;
void SetReserved( );
void SetDefaults( );
};//Box_ftyp Class
Box_esds::Box_esds( ) {
Container = new Box( 0x65736473 );

View file

@ -1,4 +1,16 @@
#include "box_ftyp.h"
#include "box.cpp"
class Box_ftyp {
public:
Box_ftyp( );
~Box_ftyp();
Box * GetBox();
void SetMajorBrand( uint32_t MajorBrand = 0x66347620 );
void SetMinorBrand( uint32_t MinorBrand = 0x1 );
private:
void SetDefaults( );
Box * Container;
};//Box_ftyp Class
Box_ftyp::Box_ftyp( ) {
Container = new Box( 0x66747970 );

View file

@ -1,4 +1,19 @@
#include "box_hdlr.h"
#include "box.cpp"
#include <string>
class Box_hdlr {
public:
Box_hdlr( );
~Box_hdlr();
Box * GetBox();
void SetHandlerType( uint32_t HandlerType = 0 );
void SetName ( std::string Name = "" );
private:
Box * Container;
void SetReserved( );
void SetDefaults( );
uint32_t CurrentHandlerType;
};//Box_ftyp Class
Box_hdlr::Box_hdlr( ) {
Container = new Box( 0x68646C72 );

View file

@ -1,4 +1,19 @@
#include "box_hmhd.h"
#include "box.cpp"
class Box_hmhd {
public:
Box_hmhd( );
~Box_hmhd();
Box * GetBox();
void SetMaxPDUSize( uint16_t Size = 0 );
void SetAvgPDUSize( uint16_t Size = 0 );
void SetMaxBitRate( uint32_t Rate = 0 );
void SetAvgBitRate( uint32_t Rate = 0 );
private:
Box * Container;
void SetReserved( );
void SetDefaults( );
};//Box_ftyp Class
Box_hmhd::Box_hmhd( ) {
Container = new Box( 0x686D6864 );

37
util/MP4/box_includes.h Normal file
View file

@ -0,0 +1,37 @@
#include "box_abst.cpp"
#include "box_afra.cpp"
#include "box_afrt.cpp"
#include "box_amhp.cpp"
#include "box_asrt.cpp"
#include "box_avcC.cpp"
#include "box_dinf.cpp"
#include "box_dref.cpp"
#include "box_esds.cpp"
#include "box_ftyp.cpp"
#include "box_hdlr.cpp"
#include "box_hmhd.cpp"
#include "box_mdat.cpp"
#include "box_mdhd.cpp"
#include "box_mdia.cpp"
#include "box_mfhd.cpp"
#include "box_minf.cpp"
#include "box_moof.cpp"
#include "box_moov.cpp"
#include "box_mvex.cpp"
#include "box_mvhd.cpp"
#include "box_nmhd.cpp"
#include "box_rtmp.cpp"
#include "box_smhd.cpp"
#include "box_stbl.cpp"
#include "box_stco.cpp"
#include "box_stsc.cpp"
#include "box_stsd.cpp"
#include "box_stts.cpp"
#include "box_tfhd.cpp"
#include "box_tkhd.cpp"
#include "box_traf.cpp"
#include "box_trak.cpp"
#include "box_trex.cpp"
#include "box_trun.cpp"
#include "box_url.cpp"
#include "box_vmhd.cpp"

View file

@ -1,4 +1,16 @@
#include "box_mdat.h"
#include "box.cpp"
#include <vector>
#include <string>
class Box_mdat {
public:
Box_mdat();
~Box_mdat();
Box * GetBox();
void SetContent( uint8_t * NewData, uint32_t DataLength , uint32_t offset = 0 );
private:
Box * Container;
};//Box_ftyp Class
Box_mdat::Box_mdat( ) {
Container = new Box( 0x6D646174 );

View file

@ -1,4 +1,23 @@
#include "box_mdhd.h"
#include "box.cpp"
#include <ctime>
#define SECONDS_DIFFERENCE 2082844800
class Box_mdhd {
public:
Box_mdhd( );
~Box_mdhd();
Box * GetBox();
void SetCreationTime( uint32_t TimeStamp = 0 );
void SetModificationTime( uint32_t TimeStamp = 0 );
void SetTimeScale( uint32_t TimeUnits = 0 );
void SetDurationTime( uint32_t TimeUnits = 0 );
void SetLanguage( uint8_t Firstchar = 'n', uint8_t Secondchar = 'l', uint8_t Thirdchar = 'd' );
private:
void SetReserved();
void SetDefaults();
Box * Container;
};//Box_ftyp Class
Box_mdhd::Box_mdhd( ) {
Container = new Box( 0x6D646864 );

View file

@ -1,4 +1,19 @@
#include "box_mdia.h"
#include "box.cpp"
#include <vector>
#include <string>
class Box_mdia {
public:
Box_mdia();
~Box_mdia();
Box * GetBox();
void AddContent( Box * newcontent, uint32_t offset = 0 );
void WriteContent( );
private:
Box * Container;
std::vector<Box *> Content;
};//Box_ftyp Class
Box_mdia::Box_mdia( ) {
Container = new Box( 0x6D646961 );

View file

@ -1,4 +1,16 @@
#include "box_mfhd.h"
#include "box.cpp"
class Box_mfhd {
public:
Box_mfhd( );
~Box_mfhd();
Box * GetBox();
void SetSequenceNumber( uint32_t SequenceNumber = 1 );
private:
void SetDefaults( );
void SetReserved( );
Box * Container;
};//Box_ftyp Class
Box_mfhd::Box_mfhd( ) {
Container = new Box( 0x6D666864 );

View file

@ -1,4 +1,19 @@
#include "box_minf.h"
#include "box.cpp"
#include <vector>
#include <string>
class Box_minf {
public:
Box_minf();
~Box_minf();
Box * GetBox();
void AddContent( Box * newcontent, uint32_t offset = 0 );
void WriteContent( );
private:
Box * Container;
std::vector<Box *> Content;
};//Box_ftyp Class
Box_minf::Box_minf( ) {
Container = new Box( 0x6D696E66 );

View file

@ -1,4 +1,19 @@
#include "box_moof.h"
#include "box.cpp"
#include <vector>
#include <string>
class Box_moof {
public:
Box_moof();
~Box_moof();
Box * GetBox();
void AddContent( Box * newcontent, uint32_t offset = 0 );
void WriteContent( );
private:
Box * Container;
std::vector<Box *> Content;
};//Box_ftyp Class
Box_moof::Box_moof( ) {
Container = new Box( 0x6D6F6F66 );

View file

@ -1,4 +1,19 @@
#include "box_moov.h"
#include "box.cpp"
#include <vector>
#include <string>
class Box_moov {
public:
Box_moov();
~Box_moov();
Box * GetBox();
void AddContent( Box * newcontent, uint32_t offset = 0 );
void WriteContent( );
private:
Box * Container;
std::vector<Box *> Content;
};//Box_ftyp Class
Box_moov::Box_moov( ) {
Container = new Box( 0x6D6F6F76 );

View file

@ -1,4 +1,19 @@
#include "box_mvex.h"
#include "box.cpp"
#include <vector>
#include <string>
class Box_mvex {
public:
Box_mvex();
~Box_mvex();
Box * GetBox();
void AddContent( Box * newcontent, uint32_t offset = 0 );
void WriteContent( );
private:
Box * Container;
std::vector<Box *> Content;
};//Box_ftyp Class
Box_mvex::Box_mvex( ) {
Container = new Box( 0x6D866578 );

View file

@ -1,4 +1,26 @@
#include "box_mvhd.h"
#include "box.cpp"
#include <ctime>
#define SECONDS_DIFFERENCE 2082844800
class Box_mvhd {
public:
Box_mvhd( );
~Box_mvhd();
Box * GetBox();
void SetCreationTime( uint32_t TimeStamp = 0 );
void SetModificationTime( uint32_t TimeStamp = 0 );
void SetTimeScale( uint32_t TimeUnits = 1 );
void SetDurationTime( uint32_t TimeUnits = 0 );
void SetRate( uint32_t Rate = 0x00010000 );
void SetVolume( uint16_t Volume = 0x0100 );
void SetNextTrackID( uint32_t TrackID = 0xFFFFFFFF );
private:
void SetReserved();
void SetDefaults();
Box * Container;
};//Box_ftyp Class
Box_mvhd::Box_mvhd( ) {
Container = new Box( 0x6D766864 );

View file

@ -1,4 +1,14 @@
#include "box_nmhd.h"
#include "box.cpp"
class Box_nmhd {
public:
Box_nmhd( );
~Box_nmhd();
Box * GetBox();
private:
Box * Container;
void SetReserved( );
};//Box_ftyp Class
Box_nmhd::Box_nmhd( ) {
Container = new Box( 0x6E6D6864 );

View file

@ -1,4 +1,28 @@
#include "box_rtmp.h"
#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 );

View file

@ -1,4 +1,14 @@
#include "box_smhd.h"
#include "box.cpp"
class Box_smhd {
public:
Box_smhd( );
~Box_smhd();
Box * GetBox();
private:
Box * Container;
void SetReserved( );
};//Box_ftyp Class
Box_smhd::Box_smhd( ) {
Container = new Box( 0x736D6864 );

View file

@ -1,4 +1,19 @@
#include "box_stbl.h"
#include "box.cpp"
#include <vector>
#include <string>
class Box_stbl {
public:
Box_stbl();
~Box_stbl();
Box * GetBox();
void AddContent( Box * newcontent, uint32_t offset = 0 );
void WriteContent( );
private:
Box * Container;
std::vector<Box *> Content;
};//Box_ftyp Class
Box_stbl::Box_stbl( ) {
Container = new Box( 0x7374626C );

View file

@ -1,4 +1,21 @@
#include "box_stco.h"
#include "box.cpp"
#include <string>
#include <vector>
class Box_stco {
public:
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;
void SetReserved( );
std::vector<uint32_t> Offsets;
};//Box_ftyp Class
Box_stco::Box_stco( ) {
Container = new Box( 0x7374636F );

View file

@ -1,4 +1,26 @@
#include "box_stsc.h"
#include "box.cpp"
#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 = 0, uint32_t SamplesPerChunk = 0, uint32_t SampleDescIndex = 0, uint32_t Offset = 0 );
void WriteContent( );
private:
Box * Container;
std::vector<stsc_record> Entries;
};//Box_ftyp Class
Box_stsc::Box_stsc( ) {
Container = new Box( 0x73747363 );

View file

@ -1,4 +1,20 @@
#include "box_stsd.h"
#include "box.cpp"
#include <vector>
#include <string>
class Box_stsd {
public:
Box_stsd( );
~Box_stsd();
Box * GetBox();
void AddContent( Box * newcontent, uint32_t offset = 0 );
void WriteContent();
private:
Box * Container;
void SetReserved();
std::vector<Box *> Content;
};//Box_ftyp Class
Box_stsd::Box_stsd( ) {
Container = new Box( 0x73747364 );

View file

@ -1,4 +1,25 @@
#include "box_stts.h"
#include "box.cpp"
#include <string>
#include <vector>
struct stts_record {
uint32_t SampleCount;
uint32_t SampleDelta;
};//stsc_record
class Box_stts {
public:
Box_stts( );
~Box_stts();
Box * GetBox();
void SetReserved( );
void AddEntry( uint32_t SampleCount, uint32_t SampleDelta, uint32_t Offset = 0 );
void WriteContent( );
private:
Box * Container;
std::vector<stts_record> Entries;
};//Box_ftyp Class
Box_stts::Box_stts( ) {
Container = new Box( 0x73747473 );

View file

@ -1,4 +1,25 @@
#include "box_tfhd.h"
#include "box.cpp"
class Box_tfhd {
public:
Box_tfhd( );
~Box_tfhd();
Box * GetBox();
void SetTrackID( uint32_t TrackID = 0 );
void SetBaseDataOffset( uint32_t Offset = 0 );//write as uint64_t
void SetSampleDescriptionIndex( uint32_t Index = 0 );
void SetDefaultSampleDuration( uint32_t Duration = 0 );
void SetDefaultSampleSize( uint32_t Size = 0 );
void WriteContent( );
private:
void SetDefaults( );
uint32_t curTrackID;
uint32_t curBaseDataOffset;
uint32_t curSampleDescriptionIndex;
uint32_t curDefaultSampleDuration;
uint32_t curDefaultSampleSize;
Box * Container;
};//Box_ftyp Class
Box_tfhd::Box_tfhd( ) {
Container = new Box( 0x74666864 );

View file

@ -1,4 +1,29 @@
#include "box_tkhd.h"
#include "box.cpp"
#include <ctime>
#define SECONDS_DIFFERENCE 2082844800
class Box_tkhd {
public:
Box_tkhd( );
~Box_tkhd();
Box * GetBox();
void SetCreationTime( uint32_t TimeStamp = 0 );
void SetModificationTime( uint32_t TimeStamp = 0 );
void SetDurationTime( uint32_t TimeUnits = 0 );
void SetWidth( uint16_t Width = 0 );
void SetHeight( uint16_t Height = 0 );
void SetFlags( bool Bit0 = true, bool Bit1 = true, bool Bit2 = true );
void SetVersion( uint32_t Version = 0 );
void SetTrackID( uint32_t TrackID = 0 );
private:
void SetReserved();
void SetDefaults();
Box * Container;
uint32_t CurrentFlags;
uint32_t CurrentVersion;
};//Box_ftyp Class
Box_tkhd::Box_tkhd( ) {
Container = new Box( 0x746B6864 );

View file

@ -1,4 +1,19 @@
#include "box_traf.h"
#include "box.cpp"
#include <vector>
#include <string>
class Box_traf {
public:
Box_traf();
~Box_traf();
Box * GetBox();
void AddContent( Box * newcontent, uint32_t offset = 0 );
void WriteContent( );
private:
Box * Container;
std::vector<Box *> Content;
};//Box_ftyp Class
Box_traf::Box_traf( ) {
Container = new Box( 0x74726166 );

View file

@ -1,4 +1,19 @@
#include "box_trak.h"
#include "box.cpp"
#include <vector>
#include <string>
class Box_trak {
public:
Box_trak();
~Box_trak();
Box * GetBox();
void AddContent( Box * newcontent, uint32_t offset = 0 );
void WriteContent( );
private:
Box * Container;
std::vector<Box *> Content;
};//Box_ftyp Class
Box_trak::Box_trak( ) {
Container = new Box( 0x7472616B );

View file

@ -1,4 +1,19 @@
#include "box_trex.h"
#include "box.cpp"
class Box_trex {
public:
Box_trex( );
~Box_trex();
Box * GetBox();
void SetTrackID( uint32_t Id = 0 );
void SetSampleDescriptionIndex( uint32_t Index = 0 );
void SetSampleDuration( uint32_t Duration = 0 );
void SetSampleSize( uint32_t Size = 0 );
private:
void SetReserved( );
void SetDefaults( );
Box * Container;
};//Box_ftyp Class
Box_trex::Box_trex( ) {
Container = new Box( 0x74726578 );

View file

@ -1,4 +1,27 @@
#include "box_trun.h"
#include "box.cpp"
#include <vector>
struct trun_sampleinformationstructure {
uint32_t SampleDuration;
uint32_t SampleSize;
};
class Box_trun {
public:
Box_trun( );
~Box_trun();
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
Box_trun::Box_trun( ) {
Container = new Box( 0x74666864 );

View file

@ -1,4 +1,13 @@
#include "box_url.h"
#include "box.cpp"
class Box_url {
public:
Box_url( );
~Box_url();
Box * GetBox();
private:
Box * Container;
};//Box_ftyp Class
Box_url::Box_url( ) {
Container = new Box( 0x75726C20 );

View file

@ -1,4 +1,17 @@
#include "box_vmhd.h"
#include "box.cpp"
class Box_vmhd {
public:
Box_vmhd( );
~Box_vmhd();
Box * GetBox();
void SetGraphicsMode( uint16_t GraphicsMode = 0 );
void SetOpColor( uint16_t Red = 0, uint16_t Green = 0, uint16_t Blue = 0);
private:
Box * Container;
void SetReserved( );
void SetDefaults( );
};//Box_ftyp Class
Box_vmhd::Box_vmhd( ) {
Container = new Box( 0x766D6864 );

View file

@ -1,4 +1,93 @@
#include "interface.h"
#include "box_includes.h"
#include <string>
class Interface {
public:
Interface();
~Interface();
void link();
uint32_t GetContentSize();
uint8_t * GetContents();
void SetWidth( uint16_t NewWidth );
void SetHeight( uint16_t NewHeight );
void SetDurationTime( uint32_t NewDuration, uint32_t Track );
void SetTimeScale( uint32_t NewUnitsPerSecond, uint32_t Track );
void AddSTTSEntry( uint32_t SampleCount, uint32_t SampleDelta, uint32_t Track );
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( std::string data );
std::string GenerateLiveBootstrap( uint32_t CurMediaTime );
static std::string mdatFold(std::string data);
private:
void SetStaticDefaults();
void UpdateContents();
void WriteSTTS( uint32_t Track );
void WriteSTSC( uint32_t Track );
bool AllBoxesExist();
uint16_t Width;
uint16_t Height;
std::vector<uint32_t> Duration;
std::vector<uint32_t> UnitsPerSecond;
std::vector<stts_record> sttsvide;
std::vector<stts_record> sttssoun;
std::vector<stsc_record> stscvide;
std::vector<stsc_record> stscsoun;
Box_ftyp * ftyp;
Box_moov * moov;
Box_mvhd * mvhd;
Box_trak * trak_vide;
Box_tkhd * tkhd_vide;
Box_mdia * mdia_vide;
Box_mdhd * mdhd_vide;
Box_hdlr * hdlr_vide;
Box_minf * minf_vide;
Box_vmhd * vmhd_vide;
Box_dinf * dinf_vide;
Box_dref * dref_vide;
Box_url * url_vide;
Box_stbl * stbl_vide;
Box_stts * stts_vide;
Box_stsc * stsc_vide;
Box_stco * stco_vide;
Box_stsd * stsd_vide;
Box_avcC * avcC_vide;
Box_trak * trak_soun;
Box_tkhd * tkhd_soun;
Box_mdia * mdia_soun;
Box_mdhd * mdhd_soun;
Box_hdlr * hdlr_soun;
Box_minf * minf_soun;
Box_smhd * smhd_soun;
Box_dinf * dinf_soun;
Box_dref * dref_soun;
Box_url * url_soun;
Box_stbl * stbl_soun;
Box_stts * stts_soun;
Box_stsc * stsc_soun;
Box_stco * stco_soun;
Box_stsd * stsd_soun;
Box_esds * esds_soun;
Box_rtmp * rtmp;
Box_amhp * amhp;
Box_mvex * mvex;
Box_trex * trex_vide;
Box_trex * trex_soun;
Box_afra * afra;
Box_abst * abst;
Box_asrt * asrt;
Box_afrt * afrt;
Box_moof * moof;
Box_mfhd * mfhd;
Box_traf * traf_vide;
Box_tfhd * tfhd_vide;
Box_trun * trun_vide;
Box_traf * traf_soun;
Box_tfhd * tfhd_soun;
Box_trun * trun_soun;
};//Interface class
Interface::Interface() {
//Initializing local data
@ -485,12 +574,10 @@ std::string Interface::GenerateLiveBootstrap( uint32_t CurMediaTime ) {
return Result;
}
void Interface::Setmdat( std::string data ) {
mdat->SetContent( data.c_str(), data.size( ) );
}
std::string Interface::Getmdat( ) {
std::string Interface::mdatFold(std::string data){
static Box_mdat * mdat = new Box_mdat;
std::string Result;
Result.append( (char*)mdat->GetBox( )->GetBoxedData( ), (int)mdat->GetBox( )->GetBoxedDataSize( ) );
mdat->SetContent((uint8_t*)data.c_str(), data.size());
Result.append((char*)mdat->GetBox()->GetBoxedData(), (int)mdat->GetBox()->GetBoxedDataSize());
return Result;
}