Global cleanups and standardization of code style.
This commit is contained in:
parent
51a9b4162c
commit
38ef8704f8
33 changed files with 4322 additions and 2824 deletions
289
lib/mp4.h
289
lib/mp4.h
|
@ -9,36 +9,36 @@
|
|||
#include "json.h"
|
||||
|
||||
/// Contains all MP4 format related code.
|
||||
namespace MP4{
|
||||
namespace MP4 {
|
||||
|
||||
class Box {
|
||||
class Box{
|
||||
public:
|
||||
Box(char * datapointer = 0, bool manage = true);
|
||||
~Box();
|
||||
std::string getType();
|
||||
bool isType( char* boxType );
|
||||
bool isType(const char* boxType);
|
||||
bool read(std::string & newData);
|
||||
long long int boxedSize();
|
||||
long long int payloadSize();
|
||||
char * asBox();
|
||||
char * payload();
|
||||
void clear();
|
||||
std::string toPrettyString( int indent = 0 );
|
||||
std::string toPrettyString(int 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( long newData, size_t index );
|
||||
long getInt24( size_t index );
|
||||
void setInt32( long newData, size_t index );
|
||||
long getInt32( size_t index );
|
||||
void setInt64( long long int newData, size_t index );
|
||||
long long int getInt64( size_t index );
|
||||
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(long newData, size_t index);
|
||||
long getInt24(size_t index);
|
||||
void setInt32(long newData, size_t index);
|
||||
long getInt32(size_t index);
|
||||
void setInt64(long long int newData, size_t index);
|
||||
long long int getInt64(size_t index);
|
||||
//string functions
|
||||
void setString(std::string newData, size_t index );
|
||||
void setString(char* newData, size_t size, size_t index );
|
||||
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
|
||||
|
@ -51,59 +51,63 @@ namespace MP4{
|
|||
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;///<The offset of the payload with regards to the data
|
||||
};//Box Class
|
||||
int payloadOffset; ///<The offset of the payload with regards to the data
|
||||
};
|
||||
//Box Class
|
||||
|
||||
struct afrt_runtable {
|
||||
long firstFragment;
|
||||
long long int firstTimestamp;
|
||||
long duration;
|
||||
long discontinuity;
|
||||
};//fragmentRun
|
||||
struct afrt_runtable{
|
||||
long firstFragment;
|
||||
long long int firstTimestamp;
|
||||
long duration;
|
||||
long discontinuity;
|
||||
};
|
||||
//fragmentRun
|
||||
|
||||
/// AFRT Box class
|
||||
class AFRT : public Box {
|
||||
class AFRT: public Box{
|
||||
public:
|
||||
AFRT();
|
||||
void setVersion( char newVersion );
|
||||
void setVersion(char newVersion);
|
||||
long getVersion();
|
||||
void setUpdate( long newUpdate );
|
||||
void setUpdate(long newUpdate);
|
||||
long getUpdate();
|
||||
void setTimeScale( long newScale );
|
||||
void setTimeScale(long newScale);
|
||||
long getTimeScale();
|
||||
long getQualityEntryCount();
|
||||
void setQualityEntry( std::string & newQuality, long no );
|
||||
const char * getQualityEntry( long no );
|
||||
void setQualityEntry(std::string & newQuality, long no);
|
||||
const char * getQualityEntry(long no);
|
||||
long getFragmentRunCount();
|
||||
void setFragmentRun( afrt_runtable newRun, long no );
|
||||
afrt_runtable getFragmentRun( long no );
|
||||
void setFragmentRun(afrt_runtable newRun, long no);
|
||||
afrt_runtable getFragmentRun(long no);
|
||||
std::string toPrettyString(int indent = 0);
|
||||
};//AFRT Box
|
||||
};
|
||||
//AFRT Box
|
||||
|
||||
struct asrt_runtable{
|
||||
long firstSegment;
|
||||
long fragmentsPerSegment;
|
||||
long firstSegment;
|
||||
long fragmentsPerSegment;
|
||||
};
|
||||
|
||||
/// ASRT Box class
|
||||
class ASRT : public Box {
|
||||
class ASRT: public Box{
|
||||
public:
|
||||
ASRT();
|
||||
void setVersion( char newVersion );
|
||||
void setVersion(char newVersion);
|
||||
long getVersion();
|
||||
void setUpdate( long newUpdate );
|
||||
void setUpdate(long newUpdate);
|
||||
long getUpdate();
|
||||
long getQualityEntryCount();
|
||||
void setQualityEntry( std::string & newQuality, long no );
|
||||
const char* getQualityEntry( long no );
|
||||
void setQualityEntry(std::string & newQuality, long no);
|
||||
const char* getQualityEntry(long no);
|
||||
long getSegmentRunEntryCount();
|
||||
void setSegmentRun( long firstSegment, long fragmentsPerSegment, long no );
|
||||
asrt_runtable getSegmentRun( long no );
|
||||
void setSegmentRun(long firstSegment, long fragmentsPerSegment, long no);
|
||||
asrt_runtable getSegmentRun(long no);
|
||||
std::string toPrettyString(int indent = 0);
|
||||
};//ASRT Box
|
||||
|
||||
};
|
||||
//ASRT Box
|
||||
|
||||
/// ABST Box class
|
||||
class ABST: public Box {
|
||||
class ABST: public Box{
|
||||
public:
|
||||
ABST();
|
||||
void setVersion(char newVersion);
|
||||
|
@ -143,61 +147,65 @@ namespace MP4{
|
|||
void setFragmentRunTable(AFRT & table, long no);
|
||||
AFRT & getFragmentRunTable(long no);
|
||||
std::string toPrettyString(long indent = 0);
|
||||
};//ABST Box
|
||||
|
||||
class MFHD : public Box {
|
||||
};
|
||||
//ABST Box
|
||||
|
||||
class MFHD: public Box{
|
||||
public:
|
||||
MFHD();
|
||||
void setSequenceNumber( long newSequenceNumber );
|
||||
void setSequenceNumber(long newSequenceNumber);
|
||||
long getSequenceNumber();
|
||||
std::string toPrettyString(int indent = 0);
|
||||
};//MFHD Box
|
||||
|
||||
class MOOF : public Box {
|
||||
};
|
||||
//MFHD Box
|
||||
|
||||
class MOOF: public Box{
|
||||
public:
|
||||
MOOF();
|
||||
long getContentCount();
|
||||
void setContent(Box & newContent, long no);
|
||||
Box & getContent(long no);
|
||||
std::string toPrettyString(int indent = 0);
|
||||
};//MOOF Box
|
||||
|
||||
class TRAF : public Box {
|
||||
};
|
||||
//MOOF Box
|
||||
|
||||
class TRAF: public Box{
|
||||
public:
|
||||
TRAF();
|
||||
long getContentCount();
|
||||
void setContent(Box & newContent, long no);
|
||||
Box & getContent(long no);
|
||||
std::string toPrettyString(int indent = 0);
|
||||
};//TRAF Box
|
||||
|
||||
struct trunSampleInformation {
|
||||
long sampleDuration;
|
||||
long sampleSize;
|
||||
long sampleFlags;
|
||||
long sampleOffset;
|
||||
};
|
||||
enum trunflags {
|
||||
trundataOffset = 0x00000001,
|
||||
//TRAF Box
|
||||
|
||||
struct trunSampleInformation{
|
||||
long sampleDuration;
|
||||
long sampleSize;
|
||||
long sampleFlags;
|
||||
long sampleOffset;
|
||||
};
|
||||
enum trunflags{
|
||||
trundataOffset = 0x00000001,
|
||||
trunfirstSampleFlags = 0x00000004,
|
||||
trunsampleDuration = 0x00000100,
|
||||
trunsampleSize = 0x00000200,
|
||||
trunsampleFlags = 0x00000400,
|
||||
trunsampleOffsets = 0x00000800
|
||||
trunsampleDuration = 0x00000100,
|
||||
trunsampleSize = 0x00000200,
|
||||
trunsampleFlags = 0x00000400,
|
||||
trunsampleOffsets = 0x00000800
|
||||
};
|
||||
enum sampleflags {
|
||||
noIPicture = 0x01000000,
|
||||
isIPicture = 0x02000000,
|
||||
enum sampleflags{
|
||||
noIPicture = 0x01000000,
|
||||
isIPicture = 0x02000000,
|
||||
noDisposable = 0x00400000,
|
||||
isDisposable = 0x00800000,
|
||||
isRedundant = 0x00100000,
|
||||
noRedundant = 0x00200000,
|
||||
noKeySample = 0x00010000,
|
||||
isKeySample = 0x00000000,
|
||||
isRedundant = 0x00100000,
|
||||
noRedundant = 0x00200000,
|
||||
noKeySample = 0x00010000,
|
||||
isKeySample = 0x00000000,
|
||||
MUST_BE_PRESENT = 0x1
|
||||
};
|
||||
std::string prettySampleFlags(long flag);
|
||||
class TRUN : public Box {
|
||||
class TRUN: public Box{
|
||||
public:
|
||||
TRUN();
|
||||
void setFlags(long newFlags);
|
||||
|
@ -212,7 +220,7 @@ namespace MP4{
|
|||
std::string toPrettyString(long indent = 0);
|
||||
};
|
||||
|
||||
enum tfhdflags {
|
||||
enum tfhdflags{
|
||||
tfhdBaseOffset = 0x000001,
|
||||
tfhdSampleDesc = 0x000002,
|
||||
tfhdSampleDura = 0x000008,
|
||||
|
@ -220,7 +228,7 @@ namespace MP4{
|
|||
tfhdSampleFlag = 0x000020,
|
||||
tfhdNoDuration = 0x010000,
|
||||
};
|
||||
class TFHD : public Box {
|
||||
class TFHD: public Box{
|
||||
public:
|
||||
TFHD();
|
||||
void setFlags(long newFlags);
|
||||
|
@ -240,73 +248,74 @@ namespace MP4{
|
|||
std::string toPrettyString(long indent = 0);
|
||||
};
|
||||
|
||||
struct afraentry {
|
||||
long long time;
|
||||
long long offset;
|
||||
struct afraentry{
|
||||
long long time;
|
||||
long long offset;
|
||||
};
|
||||
struct globalafraentry {
|
||||
long long time;
|
||||
long segment;
|
||||
long fragment;
|
||||
long long afraoffset;
|
||||
long long offsetfromafra;
|
||||
struct globalafraentry{
|
||||
long long time;
|
||||
long segment;
|
||||
long fragment;
|
||||
long long afraoffset;
|
||||
long long offsetfromafra;
|
||||
};
|
||||
class AFRA : public Box {
|
||||
public:
|
||||
AFRA();
|
||||
void setVersion(long newVersion);
|
||||
long getVersion();
|
||||
void setFlags(long newFlags);
|
||||
long getFlags();
|
||||
void setLongIDs(bool newVal);
|
||||
bool getLongIDs();
|
||||
void setLongOffsets(bool newVal);
|
||||
bool getLongOffsets();
|
||||
void setGlobalEntries(bool newVal);
|
||||
bool getGlobalEntries();
|
||||
void setTimeScale(long newVal);
|
||||
long getTimeScale();
|
||||
long getEntryCount();
|
||||
void setEntry(afraentry newEntry, long no);
|
||||
afraentry getEntry(long no);
|
||||
long getGlobalEntryCount();
|
||||
void setGlobalEntry(globalafraentry newEntry, long no);
|
||||
globalafraentry getGlobalEntry(long no);
|
||||
std::string toPrettyString(long indent = 0);
|
||||
};
|
||||
|
||||
class AVCC : public Box {
|
||||
class AFRA: public Box{
|
||||
public:
|
||||
AVCC();
|
||||
void setVersion( long newVersion );
|
||||
long getVersion( );
|
||||
void setProfile( long newProfile );
|
||||
long getProfile( );
|
||||
void setCompatibleProfiles( long newCompatibleProfiles );
|
||||
long getCompatibleProfiles( );
|
||||
void setLevel( long newLevel );
|
||||
long getLevel( );
|
||||
void setSPSNumber( long newSPSNumber );
|
||||
long getSPSNumber( );
|
||||
void setSPS( std::string newSPS );
|
||||
long getSPSLen( );
|
||||
char* getSPS( );
|
||||
void setPPSNumber( long newPPSNumber );
|
||||
long getPPSNumber( );
|
||||
void setPPS( std::string newPPS );
|
||||
long getPPSLen( );
|
||||
char* getPPS( );
|
||||
std::string asAnnexB( );
|
||||
void setPayload( std::string newPayload );
|
||||
AFRA();
|
||||
void setVersion(long newVersion);
|
||||
long getVersion();
|
||||
void setFlags(long newFlags);
|
||||
long getFlags();
|
||||
void setLongIDs(bool newVal);
|
||||
bool getLongIDs();
|
||||
void setLongOffsets(bool newVal);
|
||||
bool getLongOffsets();
|
||||
void setGlobalEntries(bool newVal);
|
||||
bool getGlobalEntries();
|
||||
void setTimeScale(long newVal);
|
||||
long getTimeScale();
|
||||
long getEntryCount();
|
||||
void setEntry(afraentry newEntry, long no);
|
||||
afraentry getEntry(long no);
|
||||
long getGlobalEntryCount();
|
||||
void setGlobalEntry(globalafraentry newEntry, long no);
|
||||
globalafraentry getGlobalEntry(long no);
|
||||
std::string toPrettyString(long indent = 0);
|
||||
};
|
||||
|
||||
class SDTP : public Box {
|
||||
|
||||
class AVCC: public Box{
|
||||
public:
|
||||
AVCC();
|
||||
void setVersion(long newVersion);
|
||||
long getVersion();
|
||||
void setProfile(long newProfile);
|
||||
long getProfile();
|
||||
void setCompatibleProfiles(long newCompatibleProfiles);
|
||||
long getCompatibleProfiles();
|
||||
void setLevel(long newLevel);
|
||||
long getLevel();
|
||||
void setSPSNumber(long newSPSNumber);
|
||||
long getSPSNumber();
|
||||
void setSPS(std::string newSPS);
|
||||
long getSPSLen();
|
||||
char* getSPS();
|
||||
void setPPSNumber(long newPPSNumber);
|
||||
long getPPSNumber();
|
||||
void setPPS(std::string newPPS);
|
||||
long getPPSLen();
|
||||
char* getPPS();
|
||||
std::string asAnnexB();
|
||||
void setPayload(std::string newPayload);
|
||||
std::string toPrettyString(long indent = 0);
|
||||
};
|
||||
|
||||
class SDTP: public Box{
|
||||
public:
|
||||
SDTP();
|
||||
void setVersion( long newVersion );
|
||||
long getVersion( );
|
||||
void setValue( long newValue, size_t index );
|
||||
long getValue( size_t index );
|
||||
void setVersion(long newVersion);
|
||||
long getVersion();
|
||||
void setValue(long newValue, size_t index);
|
||||
long getValue(size_t index);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue