diff --git a/Connector_HTTP/main.cpp b/Connector_HTTP/main.cpp index af91a4c3..7b5f0a73 100644 --- a/Connector_HTTP/main.cpp +++ b/Connector_HTTP/main.cpp @@ -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); diff --git a/MP4/box.h b/MP4/box.h deleted file mode 100644 index 67b73dc2..00000000 --- a/MP4/box.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once -#include "boxheader.h" -#include -#include -#include -#include - -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 - diff --git a/MP4/box_abst.h b/MP4/box_abst.h deleted file mode 100644 index 4f4b379c..00000000 --- a/MP4/box_abst.h +++ /dev/null @@ -1,51 +0,0 @@ -#include "box.h" -#include -#include - -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 Servers; - std::vector Qualities; - std::vector SegmentRunTables; - std::vector FragmentRunTables; - Box * Container; -};//Box_ftyp Class diff --git a/MP4/box_afra.h b/MP4/box_afra.h deleted file mode 100644 index 2115cb89..00000000 --- a/MP4/box_afra.h +++ /dev/null @@ -1,24 +0,0 @@ -#include "box.h" -#include - -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 Entries; -};//Box_ftyp Class diff --git a/MP4/box_afrt.h b/MP4/box_afrt.h deleted file mode 100644 index 215e7977..00000000 --- a/MP4/box_afrt.h +++ /dev/null @@ -1,29 +0,0 @@ -#include "box.h" -#include -#include - -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 QualitySegmentUrlModifiers; - std::vector FragmentRunEntryTable; - Box * Container; -};//Box_ftyp Class diff --git a/MP4/box_amhp.h b/MP4/box_amhp.h deleted file mode 100644 index c96fad11..00000000 --- a/MP4/box_amhp.h +++ /dev/null @@ -1,24 +0,0 @@ -#include "box.h" -#include -#include - -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 Entries; -};//Box_ftyp Class - diff --git a/MP4/box_asrt.h b/MP4/box_asrt.h deleted file mode 100644 index f5b78e9b..00000000 --- a/MP4/box_asrt.h +++ /dev/null @@ -1,25 +0,0 @@ -#include "box.h" -#include -#include - -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 QualitySegmentUrlModifiers; - std::vector SegmentRunEntryTable; - Box * Container; -};//Box_ftyp Class diff --git a/MP4/box_avcC.h b/MP4/box_avcC.h deleted file mode 100644 index 6a9563ff..00000000 --- a/MP4/box_avcC.h +++ /dev/null @@ -1,22 +0,0 @@ -#include "box.h" -#include - -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 - diff --git a/MP4/box_dinf.h b/MP4/box_dinf.h deleted file mode 100644 index 626697e1..00000000 --- a/MP4/box_dinf.h +++ /dev/null @@ -1,17 +0,0 @@ -#include "box.h" -#include -#include - -class Box_dinf { - public: - Box_dinf(); - ~Box_dinf(); - Box * GetBox(); - void AddContent( Box * newcontent ); - void WriteContent( ); - private: - Box * Container; - - Box * Content; -};//Box_ftyp Class - diff --git a/MP4/box_dref.h b/MP4/box_dref.h deleted file mode 100644 index 11495a13..00000000 --- a/MP4/box_dref.h +++ /dev/null @@ -1,18 +0,0 @@ -#include "box.h" -#include -#include - -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 Content; -};//Box_ftyp Class - diff --git a/MP4/box_esds.h b/MP4/box_esds.h deleted file mode 100644 index 295a3a88..00000000 --- a/MP4/box_esds.h +++ /dev/null @@ -1,18 +0,0 @@ -#include "box.h" -#include - -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 - diff --git a/MP4/box_ftyp.h b/MP4/box_ftyp.h deleted file mode 100644 index 2a7ac9cd..00000000 --- a/MP4/box_ftyp.h +++ /dev/null @@ -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 - diff --git a/MP4/box_hdlr.h b/MP4/box_hdlr.h deleted file mode 100644 index c12cfa12..00000000 --- a/MP4/box_hdlr.h +++ /dev/null @@ -1,17 +0,0 @@ -#include "box.h" -#include - -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 - diff --git a/MP4/box_hmhd.h b/MP4/box_hmhd.h deleted file mode 100644 index 14253b20..00000000 --- a/MP4/box_hmhd.h +++ /dev/null @@ -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 - diff --git a/MP4/box_includes.h b/MP4/box_includes.h deleted file mode 100644 index 7cf1223a..00000000 --- a/MP4/box_includes.h +++ /dev/null @@ -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" diff --git a/MP4/box_mdat.h b/MP4/box_mdat.h deleted file mode 100644 index c44f605a..00000000 --- a/MP4/box_mdat.h +++ /dev/null @@ -1,14 +0,0 @@ -#include "box.h" -#include -#include - -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 - diff --git a/MP4/box_mdhd.h b/MP4/box_mdhd.h deleted file mode 100644 index b71b9cf5..00000000 --- a/MP4/box_mdhd.h +++ /dev/null @@ -1,21 +0,0 @@ -#include "box.h" -#include - -#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 - diff --git a/MP4/box_mdia.h b/MP4/box_mdia.h deleted file mode 100644 index b56c268a..00000000 --- a/MP4/box_mdia.h +++ /dev/null @@ -1,17 +0,0 @@ -#include "box.h" -#include -#include - -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 Content; -};//Box_ftyp Class - diff --git a/MP4/box_mfhd.h b/MP4/box_mfhd.h deleted file mode 100644 index f33bef0c..00000000 --- a/MP4/box_mfhd.h +++ /dev/null @@ -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 - diff --git a/MP4/box_minf.h b/MP4/box_minf.h deleted file mode 100644 index 567af57d..00000000 --- a/MP4/box_minf.h +++ /dev/null @@ -1,17 +0,0 @@ -#include "box.h" -#include -#include - -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 Content; -};//Box_ftyp Class - diff --git a/MP4/box_moof.h b/MP4/box_moof.h deleted file mode 100644 index c3c091ac..00000000 --- a/MP4/box_moof.h +++ /dev/null @@ -1,17 +0,0 @@ -#include "box.h" -#include -#include - -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 Content; -};//Box_ftyp Class - diff --git a/MP4/box_moov.h b/MP4/box_moov.h deleted file mode 100644 index 08306ecd..00000000 --- a/MP4/box_moov.h +++ /dev/null @@ -1,17 +0,0 @@ -#include "box.h" -#include -#include - -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 Content; -};//Box_ftyp Class - diff --git a/MP4/box_mvex.h b/MP4/box_mvex.h deleted file mode 100644 index f02c5ce9..00000000 --- a/MP4/box_mvex.h +++ /dev/null @@ -1,17 +0,0 @@ -#include "box.h" -#include -#include - -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 Content; -};//Box_ftyp Class - diff --git a/MP4/box_mvhd.h b/MP4/box_mvhd.h deleted file mode 100644 index b84a446d..00000000 --- a/MP4/box_mvhd.h +++ /dev/null @@ -1,24 +0,0 @@ -#include "box.h" -#include - -#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 - diff --git a/MP4/box_nmhd.h b/MP4/box_nmhd.h deleted file mode 100644 index c8a62469..00000000 --- a/MP4/box_nmhd.h +++ /dev/null @@ -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 - diff --git a/MP4/box_rtmp.h b/MP4/box_rtmp.h deleted file mode 100644 index 4693b203..00000000 --- a/MP4/box_rtmp.h +++ /dev/null @@ -1,26 +0,0 @@ -#include "box.h" -#include - -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 - diff --git a/MP4/box_smhd.h b/MP4/box_smhd.h deleted file mode 100644 index 12338c53..00000000 --- a/MP4/box_smhd.h +++ /dev/null @@ -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 - diff --git a/MP4/box_stbl.h b/MP4/box_stbl.h deleted file mode 100644 index 67ce1dda..00000000 --- a/MP4/box_stbl.h +++ /dev/null @@ -1,17 +0,0 @@ -#include "box.h" -#include -#include - -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 Content; -};//Box_ftyp Class - diff --git a/MP4/box_stco.h b/MP4/box_stco.h deleted file mode 100644 index 56d64e29..00000000 --- a/MP4/box_stco.h +++ /dev/null @@ -1,19 +0,0 @@ -#include "box.h" -#include -#include - -class Box_stco { - public: - Box_stco( ); - ~Box_stco(); - Box * GetBox(); - void AddOffset( uint32_t DataOffset, uint32_t Offset = 0 ); - void SetOffsets( std::vector NewOffsets ); - void WriteContent( ); - private: - Box * Container; - - void SetReserved( ); - std::vector Offsets; -};//Box_ftyp Class - diff --git a/MP4/box_stsc.h b/MP4/box_stsc.h deleted file mode 100644 index c5a2358f..00000000 --- a/MP4/box_stsc.h +++ /dev/null @@ -1,24 +0,0 @@ -#include "box.h" -#include -#include - -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 Entries; -};//Box_ftyp Class - diff --git a/MP4/box_stsd.h b/MP4/box_stsd.h deleted file mode 100644 index a9db47de..00000000 --- a/MP4/box_stsd.h +++ /dev/null @@ -1,18 +0,0 @@ -#include "box.h" -#include -#include - -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 Content; -};//Box_ftyp Class - diff --git a/MP4/box_stts.h b/MP4/box_stts.h deleted file mode 100644 index cf20740f..00000000 --- a/MP4/box_stts.h +++ /dev/null @@ -1,23 +0,0 @@ -#include "box.h" -#include -#include - -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 Entries; -};//Box_ftyp Class - diff --git a/MP4/box_tfhd.h b/MP4/box_tfhd.h deleted file mode 100644 index bc4987d8..00000000 --- a/MP4/box_tfhd.h +++ /dev/null @@ -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 - diff --git a/MP4/box_tkhd.h b/MP4/box_tkhd.h deleted file mode 100644 index 3a9e2bc4..00000000 --- a/MP4/box_tkhd.h +++ /dev/null @@ -1,27 +0,0 @@ -#include "box.h" -#include - -#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 - diff --git a/MP4/box_traf.h b/MP4/box_traf.h deleted file mode 100644 index f9a1c996..00000000 --- a/MP4/box_traf.h +++ /dev/null @@ -1,17 +0,0 @@ -#include "box.h" -#include -#include - -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 Content; -};//Box_ftyp Class - diff --git a/MP4/box_trak.h b/MP4/box_trak.h deleted file mode 100644 index a986925c..00000000 --- a/MP4/box_trak.h +++ /dev/null @@ -1,17 +0,0 @@ -#include "box.h" -#include -#include - -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 Content; -};//Box_ftyp Class - diff --git a/MP4/box_trex.h b/MP4/box_trex.h deleted file mode 100644 index 4fd6bc8a..00000000 --- a/MP4/box_trex.h +++ /dev/null @@ -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 diff --git a/MP4/box_trun.h b/MP4/box_trun.h deleted file mode 100644 index a03a1df4..00000000 --- a/MP4/box_trun.h +++ /dev/null @@ -1,25 +0,0 @@ -#include "box.h" -#include - -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 SampleInfo; - Box * Container; -};//Box_ftyp Class - diff --git a/MP4/box_url.h b/MP4/box_url.h deleted file mode 100644 index 20379a17..00000000 --- a/MP4/box_url.h +++ /dev/null @@ -1,11 +0,0 @@ -#include "box.h" - -class Box_url { - public: - Box_url( ); - ~Box_url(); - Box * GetBox(); - private: - Box * Container; -};//Box_ftyp Class - diff --git a/MP4/box_vmhd.h b/MP4/box_vmhd.h deleted file mode 100644 index 36eaf76b..00000000 --- a/MP4/box_vmhd.h +++ /dev/null @@ -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 - diff --git a/MP4/boxheader.h b/MP4/boxheader.h deleted file mode 100644 index 70b674c3..00000000 --- a/MP4/boxheader.h +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include - -struct BoxHeader { - uint32_t TotalSize; - uint32_t BoxType; -};//BoxHeader struct diff --git a/MP4/interface.h b/MP4/interface.h deleted file mode 100644 index ee7baf34..00000000 --- a/MP4/interface.h +++ /dev/null @@ -1,92 +0,0 @@ -#include "box_includes.h" - -#include - -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 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 Duration; - std::vector UnitsPerSecond; - std::vector sttsvide; - std::vector sttssoun; - std::vector stscvide; - std::vector 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 - diff --git a/MP4/Makefile b/util/MP4/Makefile similarity index 100% rename from MP4/Makefile rename to util/MP4/Makefile diff --git a/MP4/box.cpp b/util/MP4/box.cpp similarity index 73% rename from MP4/box.cpp rename to util/MP4/box.cpp index 93a55575..458ba15d 100644 --- a/MP4/box.cpp +++ b/util/MP4/box.cpp @@ -1,4 +1,40 @@ -#include "box.h" +#pragma once + +#include +#include +#include +#include +#include +#include + +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; diff --git a/MP4/box_abst.cpp b/util/MP4/box_abst.cpp similarity index 77% rename from MP4/box_abst.cpp rename to util/MP4/box_abst.cpp index dbfd6526..be97f99a 100644 --- a/MP4/box_abst.cpp +++ b/util/MP4/box_abst.cpp @@ -1,4 +1,54 @@ -#include "box_abst.h" +#include "box.cpp" +#include +#include + +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 Servers; + std::vector Qualities; + std::vector SegmentRunTables; + std::vector FragmentRunTables; + Box * Container; +};//Box_ftyp Class Box_abst::Box_abst( ) { Container = new Box( 0x61627374 ); diff --git a/MP4/box_afra.cpp b/util/MP4/box_afra.cpp similarity index 71% rename from MP4/box_afra.cpp rename to util/MP4/box_afra.cpp index 6488e707..103c2c40 100644 --- a/MP4/box_afra.cpp +++ b/util/MP4/box_afra.cpp @@ -1,4 +1,27 @@ -#include "box_afra.h" +#include "box.cpp" +#include + +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 Entries; +};//Box_ftyp Class Box_afra::Box_afra( ) { Container = new Box( 0x61667261 ); diff --git a/MP4/box_afrt.cpp b/util/MP4/box_afrt.cpp similarity index 74% rename from MP4/box_afrt.cpp rename to util/MP4/box_afrt.cpp index b42c1195..67365d7e 100644 --- a/MP4/box_afrt.cpp +++ b/util/MP4/box_afrt.cpp @@ -1,4 +1,32 @@ -#include "box_afrt.h" +#include "box.cpp" +#include +#include + +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 QualitySegmentUrlModifiers; + std::vector FragmentRunEntryTable; + Box * Container; +};//Box_ftyp Class Box_afrt::Box_afrt( ) { Container = new Box( 0x61667274 ); diff --git a/MP4/box_amhp.cpp b/util/MP4/box_amhp.cpp similarity index 69% rename from MP4/box_amhp.cpp rename to util/MP4/box_amhp.cpp index af04b413..761da82a 100644 --- a/MP4/box_amhp.cpp +++ b/util/MP4/box_amhp.cpp @@ -1,4 +1,26 @@ -#include "box_amhp.h" +#include "box.cpp" +#include +#include + +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 Entries; +};//Box_ftyp Class Box_amhp::Box_amhp( ) { Container = new Box( 0x616D6870 ); diff --git a/MP4/box_asrt.cpp b/util/MP4/box_asrt.cpp similarity index 73% rename from MP4/box_asrt.cpp rename to util/MP4/box_asrt.cpp index 73f207ed..a6ba2fbb 100644 --- a/MP4/box_asrt.cpp +++ b/util/MP4/box_asrt.cpp @@ -1,4 +1,28 @@ -#include "box_asrt.h" +#include "box.cpp" +#include +#include + +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 QualitySegmentUrlModifiers; + std::vector SegmentRunEntryTable; + Box * Container; +};//Box_ftyp Class Box_asrt::Box_asrt( ) { Container = new Box( 0x61737274 ); diff --git a/MP4/box_avcC.cpp b/util/MP4/box_avcC.cpp similarity index 76% rename from MP4/box_avcC.cpp rename to util/MP4/box_avcC.cpp index 596d3077..90bc6fe0 100644 --- a/MP4/box_avcC.cpp +++ b/util/MP4/box_avcC.cpp @@ -1,4 +1,24 @@ -#include "box_avcC.h" +#include "box.cpp" +#include + +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 ); diff --git a/MP4/box_dinf.cpp b/util/MP4/box_dinf.cpp similarity index 67% rename from MP4/box_dinf.cpp rename to util/MP4/box_dinf.cpp index cf3ca641..d8d4d243 100644 --- a/MP4/box_dinf.cpp +++ b/util/MP4/box_dinf.cpp @@ -1,4 +1,19 @@ -#include "box_dinf.h" +#include "box.cpp" +#include +#include + +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 ); diff --git a/MP4/box_dref.cpp b/util/MP4/box_dref.cpp similarity index 73% rename from MP4/box_dref.cpp rename to util/MP4/box_dref.cpp index 08293eaf..cc6a2f5a 100644 --- a/MP4/box_dref.cpp +++ b/util/MP4/box_dref.cpp @@ -1,4 +1,20 @@ -#include "box_dref.h" +#include "box.cpp" +#include +#include + +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 Content; +};//Box_ftyp Class Box_dref::Box_dref( ) { Container = new Box( 0x64726566 ); diff --git a/MP4/box_esds.cpp b/util/MP4/box_esds.cpp similarity index 70% rename from MP4/box_esds.cpp rename to util/MP4/box_esds.cpp index d4f0de18..7253f07d 100644 --- a/MP4/box_esds.cpp +++ b/util/MP4/box_esds.cpp @@ -1,4 +1,20 @@ -#include "box_esds.h" +#include "box.cpp" +#include + +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 ); diff --git a/MP4/box_ftyp.cpp b/util/MP4/box_ftyp.cpp similarity index 63% rename from MP4/box_ftyp.cpp rename to util/MP4/box_ftyp.cpp index db91dc8e..97ba9c3a 100644 --- a/MP4/box_ftyp.cpp +++ b/util/MP4/box_ftyp.cpp @@ -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 ); diff --git a/MP4/box_hdlr.cpp b/util/MP4/box_hdlr.cpp similarity index 75% rename from MP4/box_hdlr.cpp rename to util/MP4/box_hdlr.cpp index 48fa1de2..5926740c 100644 --- a/MP4/box_hdlr.cpp +++ b/util/MP4/box_hdlr.cpp @@ -1,4 +1,19 @@ -#include "box_hdlr.h" +#include "box.cpp" +#include + +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 ); diff --git a/MP4/box_hmhd.cpp b/util/MP4/box_hmhd.cpp similarity index 71% rename from MP4/box_hmhd.cpp rename to util/MP4/box_hmhd.cpp index f2737b76..8733b822 100644 --- a/MP4/box_hmhd.cpp +++ b/util/MP4/box_hmhd.cpp @@ -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 ); diff --git a/util/MP4/box_includes.h b/util/MP4/box_includes.h new file mode 100644 index 00000000..2b796702 --- /dev/null +++ b/util/MP4/box_includes.h @@ -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" diff --git a/MP4/box_mdat.cpp b/util/MP4/box_mdat.cpp similarity index 52% rename from MP4/box_mdat.cpp rename to util/MP4/box_mdat.cpp index 2a060568..258585aa 100644 --- a/MP4/box_mdat.cpp +++ b/util/MP4/box_mdat.cpp @@ -1,4 +1,16 @@ -#include "box_mdat.h" +#include "box.cpp" +#include +#include + +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 ); diff --git a/MP4/box_mdhd.cpp b/util/MP4/box_mdhd.cpp similarity index 75% rename from MP4/box_mdhd.cpp rename to util/MP4/box_mdhd.cpp index a0e75979..ed143270 100644 --- a/MP4/box_mdhd.cpp +++ b/util/MP4/box_mdhd.cpp @@ -1,4 +1,23 @@ -#include "box_mdhd.h" +#include "box.cpp" +#include + +#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 ); diff --git a/MP4/box_mdia.cpp b/util/MP4/box_mdia.cpp similarity index 71% rename from MP4/box_mdia.cpp rename to util/MP4/box_mdia.cpp index 3aefb44f..553137a7 100644 --- a/MP4/box_mdia.cpp +++ b/util/MP4/box_mdia.cpp @@ -1,4 +1,19 @@ -#include "box_mdia.h" +#include "box.cpp" +#include +#include + +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 Content; +};//Box_ftyp Class Box_mdia::Box_mdia( ) { Container = new Box( 0x6D646961 ); diff --git a/MP4/box_mfhd.cpp b/util/MP4/box_mfhd.cpp similarity index 65% rename from MP4/box_mfhd.cpp rename to util/MP4/box_mfhd.cpp index a44830c4..2680ab0a 100644 --- a/MP4/box_mfhd.cpp +++ b/util/MP4/box_mfhd.cpp @@ -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 ); diff --git a/MP4/box_minf.cpp b/util/MP4/box_minf.cpp similarity index 71% rename from MP4/box_minf.cpp rename to util/MP4/box_minf.cpp index 346c862f..ebde6c56 100644 --- a/MP4/box_minf.cpp +++ b/util/MP4/box_minf.cpp @@ -1,4 +1,19 @@ -#include "box_minf.h" +#include "box.cpp" +#include +#include + +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 Content; +};//Box_ftyp Class Box_minf::Box_minf( ) { Container = new Box( 0x6D696E66 ); diff --git a/MP4/box_moof.cpp b/util/MP4/box_moof.cpp similarity index 71% rename from MP4/box_moof.cpp rename to util/MP4/box_moof.cpp index 637db850..1b18a9e5 100644 --- a/MP4/box_moof.cpp +++ b/util/MP4/box_moof.cpp @@ -1,4 +1,19 @@ -#include "box_moof.h" +#include "box.cpp" +#include +#include + +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 Content; +};//Box_ftyp Class Box_moof::Box_moof( ) { Container = new Box( 0x6D6F6F66 ); diff --git a/MP4/box_moov.cpp b/util/MP4/box_moov.cpp similarity index 71% rename from MP4/box_moov.cpp rename to util/MP4/box_moov.cpp index eb0e2d18..84542977 100644 --- a/MP4/box_moov.cpp +++ b/util/MP4/box_moov.cpp @@ -1,4 +1,19 @@ -#include "box_moov.h" +#include "box.cpp" +#include +#include + +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 Content; +};//Box_ftyp Class Box_moov::Box_moov( ) { Container = new Box( 0x6D6F6F76 ); diff --git a/MP4/box_mvex.cpp b/util/MP4/box_mvex.cpp similarity index 71% rename from MP4/box_mvex.cpp rename to util/MP4/box_mvex.cpp index a12399da..8d6725ac 100644 --- a/MP4/box_mvex.cpp +++ b/util/MP4/box_mvex.cpp @@ -1,4 +1,19 @@ -#include "box_mvex.h" +#include "box.cpp" +#include +#include + +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 Content; +};//Box_ftyp Class Box_mvex::Box_mvex( ) { Container = new Box( 0x6D866578 ); diff --git a/MP4/box_mvhd.cpp b/util/MP4/box_mvhd.cpp similarity index 82% rename from MP4/box_mvhd.cpp rename to util/MP4/box_mvhd.cpp index d479c132..8055abe5 100644 --- a/MP4/box_mvhd.cpp +++ b/util/MP4/box_mvhd.cpp @@ -1,4 +1,26 @@ -#include "box_mvhd.h" +#include "box.cpp" +#include + +#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 ); diff --git a/MP4/box_nmhd.cpp b/util/MP4/box_nmhd.cpp similarity index 60% rename from MP4/box_nmhd.cpp rename to util/MP4/box_nmhd.cpp index 61149267..d874d1ed 100644 --- a/MP4/box_nmhd.cpp +++ b/util/MP4/box_nmhd.cpp @@ -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 ); diff --git a/MP4/box_rtmp.cpp b/util/MP4/box_rtmp.cpp similarity index 73% rename from MP4/box_rtmp.cpp rename to util/MP4/box_rtmp.cpp index 9b628c07..980c7ef3 100644 --- a/MP4/box_rtmp.cpp +++ b/util/MP4/box_rtmp.cpp @@ -1,4 +1,28 @@ -#include "box_rtmp.h" +#include "box.cpp" +#include + +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 ); diff --git a/MP4/box_smhd.cpp b/util/MP4/box_smhd.cpp similarity index 65% rename from MP4/box_smhd.cpp rename to util/MP4/box_smhd.cpp index 78eca779..6b6f9d9f 100644 --- a/MP4/box_smhd.cpp +++ b/util/MP4/box_smhd.cpp @@ -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 ); diff --git a/MP4/box_stbl.cpp b/util/MP4/box_stbl.cpp similarity index 71% rename from MP4/box_stbl.cpp rename to util/MP4/box_stbl.cpp index 618cb9af..44a8d129 100644 --- a/MP4/box_stbl.cpp +++ b/util/MP4/box_stbl.cpp @@ -1,4 +1,19 @@ -#include "box_stbl.h" +#include "box.cpp" +#include +#include + +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 Content; +};//Box_ftyp Class Box_stbl::Box_stbl( ) { Container = new Box( 0x7374626C ); diff --git a/MP4/box_stco.cpp b/util/MP4/box_stco.cpp similarity index 68% rename from MP4/box_stco.cpp rename to util/MP4/box_stco.cpp index 50759d7c..434cede8 100644 --- a/MP4/box_stco.cpp +++ b/util/MP4/box_stco.cpp @@ -1,4 +1,21 @@ -#include "box_stco.h" +#include "box.cpp" +#include +#include + +class Box_stco { + public: + Box_stco( ); + ~Box_stco(); + Box * GetBox(); + void AddOffset( uint32_t DataOffset, uint32_t Offset = 0 ); + void SetOffsets( std::vector NewOffsets ); + void WriteContent( ); + private: + Box * Container; + + void SetReserved( ); + std::vector Offsets; +};//Box_ftyp Class Box_stco::Box_stco( ) { Container = new Box( 0x7374636F ); diff --git a/MP4/box_stsc.cpp b/util/MP4/box_stsc.cpp similarity index 68% rename from MP4/box_stsc.cpp rename to util/MP4/box_stsc.cpp index 9d5a75eb..ea8edd33 100644 --- a/MP4/box_stsc.cpp +++ b/util/MP4/box_stsc.cpp @@ -1,4 +1,26 @@ -#include "box_stsc.h" +#include "box.cpp" +#include +#include + +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 Entries; +};//Box_ftyp Class Box_stsc::Box_stsc( ) { Container = new Box( 0x73747363 ); diff --git a/MP4/box_stsd.cpp b/util/MP4/box_stsd.cpp similarity index 74% rename from MP4/box_stsd.cpp rename to util/MP4/box_stsd.cpp index 2d6fc5e3..233fa584 100644 --- a/MP4/box_stsd.cpp +++ b/util/MP4/box_stsd.cpp @@ -1,4 +1,20 @@ -#include "box_stsd.h" +#include "box.cpp" +#include +#include + +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 Content; +};//Box_ftyp Class Box_stsd::Box_stsd( ) { Container = new Box( 0x73747364 ); diff --git a/MP4/box_stts.cpp b/util/MP4/box_stts.cpp similarity index 68% rename from MP4/box_stts.cpp rename to util/MP4/box_stts.cpp index 0905d675..e16c42c0 100644 --- a/MP4/box_stts.cpp +++ b/util/MP4/box_stts.cpp @@ -1,4 +1,25 @@ -#include "box_stts.h" +#include "box.cpp" +#include +#include + +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 Entries; +};//Box_ftyp Class Box_stts::Box_stts( ) { Container = new Box( 0x73747473 ); diff --git a/MP4/box_tfhd.cpp b/util/MP4/box_tfhd.cpp similarity index 73% rename from MP4/box_tfhd.cpp rename to util/MP4/box_tfhd.cpp index 5fcefcc3..57ed10dc 100644 --- a/MP4/box_tfhd.cpp +++ b/util/MP4/box_tfhd.cpp @@ -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 ); diff --git a/MP4/box_tkhd.cpp b/util/MP4/box_tkhd.cpp similarity index 80% rename from MP4/box_tkhd.cpp rename to util/MP4/box_tkhd.cpp index 06900356..c8f5c1e7 100644 --- a/MP4/box_tkhd.cpp +++ b/util/MP4/box_tkhd.cpp @@ -1,4 +1,29 @@ -#include "box_tkhd.h" +#include "box.cpp" +#include + +#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 ); diff --git a/MP4/box_traf.cpp b/util/MP4/box_traf.cpp similarity index 71% rename from MP4/box_traf.cpp rename to util/MP4/box_traf.cpp index 4959c37f..fb794578 100644 --- a/MP4/box_traf.cpp +++ b/util/MP4/box_traf.cpp @@ -1,4 +1,19 @@ -#include "box_traf.h" +#include "box.cpp" +#include +#include + +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 Content; +};//Box_ftyp Class Box_traf::Box_traf( ) { Container = new Box( 0x74726166 ); diff --git a/MP4/box_trak.cpp b/util/MP4/box_trak.cpp similarity index 71% rename from MP4/box_trak.cpp rename to util/MP4/box_trak.cpp index 6ad6c53b..b33bb5bd 100644 --- a/MP4/box_trak.cpp +++ b/util/MP4/box_trak.cpp @@ -1,4 +1,19 @@ -#include "box_trak.h" +#include "box.cpp" +#include +#include + +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 Content; +};//Box_ftyp Class Box_trak::Box_trak( ) { Container = new Box( 0x7472616B ); diff --git a/MP4/box_trex.cpp b/util/MP4/box_trex.cpp similarity index 72% rename from MP4/box_trex.cpp rename to util/MP4/box_trex.cpp index 49c6e768..16369795 100644 --- a/MP4/box_trex.cpp +++ b/util/MP4/box_trex.cpp @@ -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 ); diff --git a/MP4/box_trun.cpp b/util/MP4/box_trun.cpp similarity index 66% rename from MP4/box_trun.cpp rename to util/MP4/box_trun.cpp index 489d7cc3..1010f2da 100644 --- a/MP4/box_trun.cpp +++ b/util/MP4/box_trun.cpp @@ -1,4 +1,27 @@ -#include "box_trun.h" +#include "box.cpp" +#include + +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 SampleInfo; + Box * Container; +};//Box_ftyp Class Box_trun::Box_trun( ) { Container = new Box( 0x74666864 ); diff --git a/MP4/box_url.cpp b/util/MP4/box_url.cpp similarity index 59% rename from MP4/box_url.cpp rename to util/MP4/box_url.cpp index 44a0d3b3..8287f7c3 100644 --- a/MP4/box_url.cpp +++ b/util/MP4/box_url.cpp @@ -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 ); diff --git a/MP4/box_vmhd.cpp b/util/MP4/box_vmhd.cpp similarity index 69% rename from MP4/box_vmhd.cpp rename to util/MP4/box_vmhd.cpp index 30b73759..6dd5fb8e 100644 --- a/MP4/box_vmhd.cpp +++ b/util/MP4/box_vmhd.cpp @@ -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 ); diff --git a/MP4/interface.cpp b/util/MP4/interface.cpp similarity index 84% rename from MP4/interface.cpp rename to util/MP4/interface.cpp index 1db31472..6e81a6d6 100644 --- a/MP4/interface.cpp +++ b/util/MP4/interface.cpp @@ -1,4 +1,93 @@ -#include "interface.h" +#include "box_includes.h" + +#include + +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 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 Duration; + std::vector UnitsPerSecond; + std::vector sttsvide; + std::vector sttssoun; + std::vector stscvide; + std::vector 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; } diff --git a/MP4/main.cpp b/util/MP4/main.cpp similarity index 100% rename from MP4/main.cpp rename to util/MP4/main.cpp