00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef _AP4_UTILS_H_
00030 #define _AP4_UTILS_H_
00031
00032
00033
00034
00035 #include "Ap4Config.h"
00036 #include "Ap4Types.h"
00037 #include "Ap4Results.h"
00038 #include "Ap4Config.h"
00039 #include "Ap4Atom.h"
00040
00041
00042
00043
00044 #define MIN(a,b) (a<b)?a:b
00045 #define MAX(a,b) (a>b)?a:b
00046
00047
00048
00049
00050 AP4_UI64 AP4_BytesToUInt64BE(const unsigned char* bytes);
00051 AP4_UI32 AP4_BytesToUInt32BE(const unsigned char* bytes);
00052 AP4_UI32 AP4_BytesToUInt24BE(const unsigned char* bytes);
00053 AP4_UI16 AP4_BytesToUInt16BE(const unsigned char* bytes);
00054
00055 AP4_SI32 AP4_BytesToInt32BE(const unsigned char* bytes);
00056 AP4_SI16 AP4_BytesToInt16BE(const unsigned char* bytes);
00057
00058 void AP4_BytesFromUInt64BE(unsigned char* bytes, AP4_UI64 value);
00059 void AP4_BytesFromUInt32BE(unsigned char* bytes, AP4_UI32 value);
00060 void AP4_BytesFromUInt24BE(unsigned char* bytes, AP4_UI32 value);
00061 void AP4_BytesFromUInt16BE(unsigned char* bytes, AP4_UI16 value);
00062 unsigned long AP4_DurationMsFromUnits(unsigned long units,
00063 unsigned long units_per_second);
00064 unsigned long AP4_ConvertTime(unsigned long time_value,
00065 unsigned long from_time_scale,
00066 unsigned long to_time_scale);
00067
00068
00069
00070
00071 #if defined (AP4_CONFIG_HAVE_STDIO_H)
00072 #include <stdio.h>
00073 #endif
00074
00075 #if defined (AP4_CONFIG_HAVE_SNPRINTF)
00076 #define AP4_FormatString AP4_snprintf
00077 #else
00078 int AP4_FormatString(char* str, AP4_Size size, const char* format, ...);
00079 #endif
00080 #if defined(AP4_CONFIG_HAVE_VSNPRINTF)
00081 #define AP4_FormatStringVN(s,c,f,a) AP4_vsnprintf(s,c,f,a)
00082 #else
00083 extern int AP4_FormatStringVN(char *buffer, size_t count, const char *format, va_list argptr);
00084 #endif
00085
00086 #if defined (AP4_CONFIG_HAVE_STRING_H)
00087 #include <string.h>
00088 #define AP4_StringLength(x) strlen(x)
00089 #define AP4_CopyMemory(x,y,z) memcpy(x,y,z)
00090 #define AP4_SetMemory(x,y,z) memset(x,y,z)
00091 #define AP4_CompareStrings(x,y) strcmp(x,y)
00092 #endif
00093
00094 void AP4_FormatFourChars(char* str, AP4_UI32 value);
00095 void AP4_FormatFourCharsPrintable(char* str, AP4_UI32 value);
00096 AP4_Result
00097 AP4_ParseHex(const char* hex, unsigned char* bytes, unsigned int count);
00098 AP4_Result
00099 AP4_SplitArgs(char* arg, char*& arg0, char*& arg1, char*& arg2);
00100 AP4_Result
00101 AP4_SplitArgs(char* arg, char*& arg0, char*& arg1);
00102
00103
00104
00105
00106 class AP4_PrintInspector : public AP4_AtomInspector {
00107 public:
00108 AP4_PrintInspector(AP4_ByteStream& stream);
00109 ~AP4_PrintInspector();
00110
00111
00112 void StartElement(const char* name, const char* info);
00113 void EndElement();
00114 void AddField(const char* name, AP4_UI32 value, FormatHint hint);
00115 void AddField(const char* name, const char* value, FormatHint hint);
00116 void AddField(const char* name, const unsigned char* bytes, AP4_Size size, FormatHint hint);
00117
00118 private:
00119
00120 AP4_ByteStream* m_Stream;
00121 AP4_Cardinal m_Indent;
00122 };
00123
00124
00125 #endif // _AP4_UTILS_H_