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_META_DATA_H_
00030 #define _AP4_META_DATA_H_
00031
00032
00033
00034
00035 #include "Ap4Atom.h"
00036 #include "Ap4AtomFactory.h"
00037 #include "Ap4String.h"
00038 #include "Ap4Array.h"
00039 #include "Ap4List.h"
00040
00041
00042
00043
00044 class AP4_MoovAtom;
00045 class AP4_DataBuffer;
00046 class AP4_ContainerAtom;
00047 class AP4_DataAtom;
00048
00049
00050
00051
00052 const AP4_Atom::Type AP4_ATOM_TYPE_DATA = AP4_ATOM_TYPE('d','a','t','a');
00053 const AP4_Atom::Type AP4_ATOM_TYPE_MEAN = AP4_ATOM_TYPE('m','e','a','n');
00054 const AP4_Atom::Type AP4_ATOM_TYPE_NAME = AP4_ATOM_TYPE('n','a','m','e');
00055 const AP4_Atom::Type AP4_ATOM_TYPE_dddd = AP4_ATOM_TYPE('-','-','-','-');
00056 const AP4_Atom::Type AP4_ATOM_TYPE_cNAM = AP4_ATOM_TYPE('©','n','a','m');
00057 const AP4_Atom::Type AP4_ATOM_TYPE_cART = AP4_ATOM_TYPE('©','A','R','T');
00058 const AP4_Atom::Type AP4_ATOM_TYPE_cCOM = AP4_ATOM_TYPE('©','c','o','m');
00059 const AP4_Atom::Type AP4_ATOM_TYPE_cWRT = AP4_ATOM_TYPE('©','w','r','t');
00060 const AP4_Atom::Type AP4_ATOM_TYPE_cALB = AP4_ATOM_TYPE('©','a','l','b');
00061 const AP4_Atom::Type AP4_ATOM_TYPE_cGEN = AP4_ATOM_TYPE('©','g','e','n');
00062 const AP4_Atom::Type AP4_ATOM_TYPE_cGRP = AP4_ATOM_TYPE('©','g','r','p');
00063 const AP4_Atom::Type AP4_ATOM_TYPE_cDAY = AP4_ATOM_TYPE('©','d','a','y');
00064 const AP4_Atom::Type AP4_ATOM_TYPE_cTOO = AP4_ATOM_TYPE('©','t','o','o');
00065 const AP4_Atom::Type AP4_ATOM_TYPE_cCMT = AP4_ATOM_TYPE('©','c','m','t');
00066 const AP4_Atom::Type AP4_ATOM_TYPE_cLYR = AP4_ATOM_TYPE('©','l','y','r');
00067 const AP4_Atom::Type AP4_ATOM_TYPE_CPRT = AP4_ATOM_TYPE('c','p','r','t');
00068 const AP4_Atom::Type AP4_ATOM_TYPE_TRKN = AP4_ATOM_TYPE('t','r','k','n');
00069 const AP4_Atom::Type AP4_ATOM_TYPE_DISK = AP4_ATOM_TYPE('d','i','s','k');
00070 const AP4_Atom::Type AP4_ATOM_TYPE_COVR = AP4_ATOM_TYPE('c','o','v','r');
00071 const AP4_Atom::Type AP4_ATOM_TYPE_DESC = AP4_ATOM_TYPE('d','e','s','c');
00072 const AP4_Atom::Type AP4_ATOM_TYPE_GNRE = AP4_ATOM_TYPE('g','n','r','e');
00073 const AP4_Atom::Type AP4_ATOM_TYPE_CPIL = AP4_ATOM_TYPE('c','p','i','l');
00074 const AP4_Atom::Type AP4_ATOM_TYPE_TMPO = AP4_ATOM_TYPE('t','m','p','o');
00075 const AP4_Atom::Type AP4_ATOM_TYPE_RTNG = AP4_ATOM_TYPE('r','t','n','g');
00076 const AP4_Atom::Type AP4_ATOM_TYPE_apID = AP4_ATOM_TYPE('a','p','I','D');
00077 const AP4_Atom::Type AP4_ATOM_TYPE_cnID = AP4_ATOM_TYPE('c','n','I','D');
00078 const AP4_Atom::Type AP4_ATOM_TYPE_atID = AP4_ATOM_TYPE('a','t','I','D');
00079 const AP4_Atom::Type AP4_ATOM_TYPE_plID = AP4_ATOM_TYPE('p','l','I','D');
00080 const AP4_Atom::Type AP4_ATOM_TYPE_geID = AP4_ATOM_TYPE('g','e','I','D');
00081 const AP4_Atom::Type AP4_ATOM_TYPE_sfID = AP4_ATOM_TYPE('s','f','I','D');
00082 const AP4_Atom::Type AP4_ATOM_TYPE_akID = AP4_ATOM_TYPE('a','k','I','D');
00083 const AP4_Atom::Type AP4_ATOM_TYPE_aART = AP4_ATOM_TYPE('a','A','R','T');
00084 const AP4_Atom::Type AP4_ATOM_TYPE_TVNN = AP4_ATOM_TYPE('t','v','n','n');
00085 const AP4_Atom::Type AP4_ATOM_TYPE_TVSH = AP4_ATOM_TYPE('t','v','s','h');
00086 const AP4_Atom::Type AP4_ATOM_TYPE_TVEN = AP4_ATOM_TYPE('t','v','e','n');
00087 const AP4_Atom::Type AP4_ATOM_TYPE_TVSN = AP4_ATOM_TYPE('t','v','s','n');
00088 const AP4_Atom::Type AP4_ATOM_TYPE_TVES = AP4_ATOM_TYPE('t','v','e','s');
00089 const AP4_Atom::Type AP4_ATOM_TYPE_STIK = AP4_ATOM_TYPE('s','t','i','k');
00090 const AP4_Atom::Type AP4_ATOM_TYPE_PGAP = AP4_ATOM_TYPE('p','g','a','p');
00091
00092
00093
00094
00095 class AP4_MetaData {
00096 public:
00097 typedef enum {
00098 DATA_TYPE_BINARY = 0,
00099 DATA_TYPE_STRING_UTF8 = 1,
00100 DATA_TYPE_STRING_UTF16 = 2,
00101 DATA_TYPE_STRING_MAC_ENCODED = 3,
00102 DATA_TYPE_JPEG = 14,
00103 DATA_TYPE_SIGNED_INT_BE = 21,
00104 DATA_TYPE_FLOAT32_BE = 22,
00105 DATA_TYPE_FLOAT64_BE = 23
00106 } DataType;
00107
00108 typedef enum {
00109 LANGUAGE_ENGLISH = 0
00110 } Language;
00111
00112 class Key {
00113 public:
00114
00115 Key(const char* name, const char* ns) :
00116 m_Name(name), m_Namespace(ns) {}
00117
00118
00119 const char* GetNamespace() { return m_Namespace.GetChars(); }
00120 const char* GetName() { return m_Name.GetChars(); }
00121
00122 private:
00123
00124 const AP4_String m_Name;
00125 const AP4_String m_Namespace;
00126 };
00127
00128 class Value {
00129 public:
00130
00131 typedef enum {
00132 TYPE_STRING,
00133 TYPE_BINARY,
00134 TYPE_INTEGER
00135 } Type;
00136
00137 typedef enum {
00138 MEANING_UNKNOWN,
00139 MEANING_ID3_GENRE,
00140 MEANING_BOOLEAN
00141 } Meaning;
00142
00143
00144 virtual ~Value() {}
00145
00146
00147 Type GetType() { return m_Type; }
00148 Meaning GetMeaning() { return m_Meaning; }
00149 virtual AP4_String ToString() = 0;
00150 virtual AP4_Result ToBytes(AP4_DataBuffer& bytes) = 0;
00151 virtual long ToInteger() = 0;
00152
00153 protected:
00154
00155 Value(Type type, Meaning meaning = MEANING_UNKNOWN) :
00156 m_Type(type), m_Meaning(meaning) {}
00157
00158
00159 Type m_Type;
00160 Meaning m_Meaning;
00161 };
00162
00163 class KeyInfo {
00164 public:
00165
00166 const char* name;
00167 const char* description;
00168 AP4_UI32 four_cc;
00169 Value::Type value_type;
00170 };
00171
00172 class Entry {
00173 public:
00174
00175 Entry(const char* name, const char* ns, Value* value) :
00176 m_Key(name, ns), m_Value(value) {}
00177
00178
00179 ~Entry() { delete m_Value; }
00180
00181
00182 Key m_Key;
00183 Value* m_Value;
00184 };
00185
00186
00187 static AP4_Array<KeyInfo> KeysInfos;
00188
00189
00190 AP4_MetaData(AP4_MoovAtom* moov);
00191
00192
00193 ~AP4_MetaData();
00194
00195
00196 const AP4_List<Entry>& GetEntries() const { return m_Entries; }
00197
00198
00199 AP4_Result AddEntries(AP4_ContainerAtom* atom);
00200
00201 private:
00202
00203 AP4_List<Entry> m_Entries;
00204 };
00205
00206
00207
00208
00209 class AP4_MetaDataAtomTypeHandler : public AP4_AtomFactory::TypeHandler
00210 {
00211 public:
00212
00213 AP4_MetaDataAtomTypeHandler(AP4_AtomFactory* atom_factory) :
00214 m_AtomFactory(atom_factory) {}
00215 virtual AP4_Result CreateAtom(AP4_Atom::Type type,
00216 AP4_UI32 size,
00217 AP4_ByteStream& stream,
00218 AP4_Atom::Type context,
00219 AP4_Atom*& atom);
00220
00221 private:
00222
00223 bool IsMetaDataType(AP4_Atom::Type type);
00224
00225
00226 AP4_AtomFactory* m_AtomFactory;
00227 };
00228
00229
00230
00231
00232 class AP4_MetaDataTag
00233 {
00234 public:
00235
00236
00237 virtual ~AP4_MetaDataTag() {}
00238
00239
00240 virtual AP4_Result Write(AP4_ByteStream& stream);
00241 virtual AP4_Result Inspect(AP4_AtomInspector& inspector);
00242
00243 protected:
00244
00245 AP4_MetaDataTag(AP4_UI32 data_type,
00246 AP4_UI32 data_lang,
00247 AP4_Size size,
00248 AP4_ByteStream& stream);
00249
00250 };
00251
00252
00253
00254
00255 class AP4_StringAtom : public AP4_Atom
00256 {
00257 public:
00258
00259 AP4_StringAtom(Type type, AP4_UI32 size, AP4_ByteStream& stream);
00260
00261
00262 virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
00263 virtual AP4_Result WriteFields(AP4_ByteStream& stream);
00264
00265
00266 const AP4_String& GetValue() { return m_Value; }
00267
00268 private:
00269
00270
00271
00272 AP4_UI32 m_Reserved;
00273 AP4_String m_Value;
00274 };
00275
00276
00277
00278
00279 class AP4_DataAtom : public AP4_Atom
00280 {
00281 public:
00282
00283 AP4_DataAtom(AP4_UI32 size, AP4_ByteStream& stream);
00284
00285
00286 ~AP4_DataAtom();
00287
00288
00289 virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
00290 virtual AP4_Result WriteFields(AP4_ByteStream& stream);
00291
00292
00293 AP4_MetaData::DataType GetDataType() { return m_DataType; }
00294 AP4_MetaData::Language GetDataLang() { return m_DataLang; }
00295
00296
00297 AP4_Result LoadString(AP4_String*& string);
00298 AP4_Result LoadBytes(AP4_DataBuffer& bytes);
00299 AP4_Result LoadInteger(long& value);
00300
00301 private:
00302
00303 AP4_MetaData::DataType m_DataType;
00304 AP4_MetaData::Language m_DataLang;
00305 AP4_ByteStream* m_Source;
00306 };
00307
00308
00309
00310
00311 class AP4_AtomMetaDataValue : public AP4_MetaData::Value
00312 {
00313 public:
00314
00315 AP4_AtomMetaDataValue(AP4_DataAtom* data_atom, AP4_UI32 parent_type);
00316
00317
00318 virtual AP4_String ToString();
00319 virtual AP4_Result ToBytes(AP4_DataBuffer& bytes);
00320 virtual long ToInteger();
00321
00322 private:
00323
00324 static AP4_MetaData::Value::Type MapDataType(AP4_MetaData::DataType data_type);
00325
00326
00327 AP4_DataAtom* m_DataAtom;
00328 };
00329
00330 #endif // _AP4_META_DATA_H_