#pragma once #include #include #include #include #include #include #include #include #include #include #include #include "json.h" #include "dtsc.h" /// Contains all MP4 format related code. namespace MP4 { struct keyPart{ public: bool operator < (const keyPart& rhs) const { if (time < rhs.time){ return true; } if (time == rhs.time){ if (trackID < rhs.trackID){ return true; } } return false; } long long int trackID; long long int size; long long int time; long long int len; std::deque parts; long long int partsize; }; class DTSC2MP4Converter{ public: std::string DTSCMeta2MP4Header(DTSC::Meta & metaData); void parseDTSC(JSON::Value mediaPart); bool sendReady(); std::string sendString(); std::string purgeBuffer(); std::set keyParts; private: //long long unsigned int curKey;//the key chunk we are currently searching for in keyParts //long long unsigned int curPart;//current part in current key std::map > trackBuffer; std::string stringBuffer; }; class Box{ public: Box(char * datapointer = 0, bool manage = true); ~Box(); std::string getType(); bool isType(const char* boxType); bool read(std::string & newData); uint64_t boxedSize(); uint64_t payloadSize(); char * asBox(); char * payload(); void clear(); std::string toPrettyString(uint32_t indent = 0); protected: //integer functions void setInt8(char newData, size_t index); char getInt8(size_t index); void setInt16(short newData, size_t index); short getInt16(size_t index); void setInt24(uint32_t newData, size_t index); uint32_t getInt24(size_t index); void setInt32(uint32_t newData, size_t index); uint32_t getInt32(size_t index); void setInt64(uint64_t newData, size_t index); uint64_t getInt64(size_t index); //string functions void setString(std::string newData, size_t index); void setString(char* newData, size_t size, size_t index); char * getString(size_t index); size_t getStringLen(size_t index); //box functions Box & getBox(size_t index); size_t getBoxLen(size_t index); void setBox(Box & newEntry, size_t index); //data functions bool reserve(size_t position, size_t current, size_t wanted); //internal variables char * data; ///< Holds the data of this box int data_size; ///< Currently reserved size bool managed; ///< If false, will not attempt to resize/free the data pointer. int payloadOffset; ///