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 double AP4_BytesToDoubleBE(const unsigned char* bytes);
00045 AP4_UI64 AP4_BytesToUInt64BE(const unsigned char* bytes);
00046 AP4_UI32 AP4_BytesToUInt32BE(const unsigned char* bytes);
00047 AP4_UI32 AP4_BytesToUInt24BE(const unsigned char* bytes);
00048 AP4_UI16 AP4_BytesToUInt16BE(const unsigned char* bytes);
00049 AP4_SI32 AP4_BytesToInt32BE(const unsigned char* bytes);
00050 AP4_SI16 AP4_BytesToInt16BE(const unsigned char* bytes);
00051
00052 void AP4_BytesFromDoubleBE(unsigned char* bytes, double value);
00053 void AP4_BytesFromUInt64BE(unsigned char* bytes, AP4_UI64 value);
00054 void AP4_BytesFromUInt32BE(unsigned char* bytes, AP4_UI32 value);
00055 void AP4_BytesFromUInt24BE(unsigned char* bytes, AP4_UI32 value);
00056 void AP4_BytesFromUInt16BE(unsigned char* bytes, AP4_UI16 value);
00057 unsigned long AP4_DurationMsFromUnits(unsigned long units,
00058 unsigned long units_per_second);
00059 unsigned long AP4_ConvertTime(unsigned long time_value,
00060 unsigned long from_time_scale,
00061 unsigned long to_time_scale);
00062
00063
00064
00065
00066 #if defined (AP4_CONFIG_HAVE_STDIO_H)
00067 #include <stdio.h>
00068 #endif
00069
00070 #if defined (AP4_CONFIG_HAVE_SNPRINTF)
00071 #define AP4_FormatString AP4_snprintf
00072 #else
00073 int AP4_FormatString(char* str, AP4_Size size, const char* format, ...);
00074 #endif
00075 #if defined(AP4_CONFIG_HAVE_VSNPRINTF)
00076 #define AP4_FormatStringVN(s,c,f,a) AP4_vsnprintf(s,c,f,a)
00077 #else
00078 extern int AP4_FormatStringVN(char *buffer, size_t count, const char *format, va_list argptr);
00079 #endif
00080
00081 #if defined (AP4_CONFIG_HAVE_STRING_H)
00082 #include <string.h>
00083 #define AP4_StringLength(x) strlen(x)
00084 #define AP4_CopyMemory(x,y,z) memcpy(x,y,z)
00085 #define AP4_SetMemory(x,y,z) memset(x,y,z)
00086 #define AP4_CompareStrings(x,y) strcmp(x,y)
00087 #endif
00088
00089 void AP4_FormatFourChars(char* str, AP4_UI32 value);
00090 void AP4_FormatFourCharsPrintable(char* str, AP4_UI32 value);
00091 AP4_Result
00092 AP4_ParseHex(const char* hex, unsigned char* bytes, unsigned int count);
00093 AP4_Result
00094 AP4_SplitArgs(char* arg, char*& arg0, char*& arg1, char*& arg2);
00095 AP4_Result
00096 AP4_SplitArgs(char* arg, char*& arg0, char*& arg1);
00097
00098
00099
00100
00101 class AP4_PrintInspector : public AP4_AtomInspector {
00102 public:
00103 AP4_PrintInspector(AP4_ByteStream& stream);
00104 ~AP4_PrintInspector();
00105
00106
00107 void StartElement(const char* name, const char* info);
00108 void EndElement();
00109 void AddField(const char* name, AP4_UI32 value, FormatHint hint);
00110 void AddField(const char* name, const char* value, FormatHint hint);
00111 void AddField(const char* name, const unsigned char* bytes, AP4_Size size, FormatHint hint);
00112
00113 private:
00114
00115 AP4_ByteStream* m_Stream;
00116 AP4_Cardinal m_Indent;
00117 };
00118
00119
00120 #endif // _AP4_UTILS_H_