- Main Page
- Classes
- Files

# Ap4MetaData.h

Go to the documentation of this file.

    00001 /*****************************************************************
    00002 |
    00003 |    AP4 - MetaData
    00004 |
    00005 |    Copyright 2002-2008 Gilles Boccon-Gibod & Julien Boeuf
    00006 |
    00007 |
    00008 |    This file is part of Bento4/AP4 (MP4 Atom Processing Library).
    00009 |
    00010 |    Unless you have obtained Bento4 under a difference license,
    00011 |    this version of Bento4 is Bento4|GPL.
    00012 |    Bento4|GPL is free software; you can redistribute it and/or modify
    00013 |    it under the terms of the GNU General Public License as published by
    00014 |    the Free Software Foundation; either version 2, or (at your option)
    00015 |    any later version.
    00016 |
    00017 |    Bento4|GPL is distributed in the hope that it will be useful,
    00018 |    but WITHOUT ANY WARRANTY; without even the implied warranty of
    00019 |    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00020 |    GNU General Public License for more details.
    00021 |
    00022 |    You should have received a copy of the GNU General Public License
    00023 |    along with Bento4|GPL; see the file COPYING.  If not, write to the
    00024 |    Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
    00025 |    02111-1307, USA.
    00026 |
    00027 ****************************************************************/
    00028
    00029 #ifndef _AP4_META_DATA_H_
    00030 #define _AP4_META_DATA_H_
    00031
    00032 /*----------------------------------------------------------------------
    00033 |   includes
    00034 +---------------------------------------------------------------------*/
    00035 #include "Ap4Atom.h"
    00036 #include "Ap4AtomFactory.h"
    00037 #include "Ap4String.h"
    00038 #include "Ap4Array.h"
    00039 #include "Ap4List.h"
    00040
    00041 /*----------------------------------------------------------------------
    00042 |   class references
    00043 +---------------------------------------------------------------------*/
    00044 class AP4_File;
    00045 class AP4_MoovAtom;
    00046 class AP4_DataBuffer;
    00047 class AP4_ContainerAtom;
    00048 class AP4_DataAtom;
    00049 class AP4_3GppLocalizedStringAtom;
    00050 class AP4_DcfStringAtom;
    00051 class AP4_DcfdAtom;
    00052
    00053 /*----------------------------------------------------------------------
    00054 |   metadata keys
    00055 +---------------------------------------------------------------------*/
    00056 const AP4_Atom::Type AP4_ATOM_TYPE_DATA = AP4_ATOM_TYPE('d','a','t','a'); // data
    00057 const AP4_Atom::Type AP4_ATOM_TYPE_MEAN = AP4_ATOM_TYPE('m','e','a','n'); // namespace
    00058 const AP4_Atom::Type AP4_ATOM_TYPE_NAME = AP4_ATOM_TYPE('n','a','m','e'); // name
    00059 const AP4_Atom::Type AP4_ATOM_TYPE_dddd = AP4_ATOM_TYPE('-','-','-','-'); // free form
    00060 const AP4_Atom::Type AP4_ATOM_TYPE_cNAM = AP4_ATOM_TYPE(0xA9,'n','a','m'); // name
    00061 const AP4_Atom::Type AP4_ATOM_TYPE_cART = AP4_ATOM_TYPE(0xA9,'A','R','T'); // artist
    00062 const AP4_Atom::Type AP4_ATOM_TYPE_cCOM = AP4_ATOM_TYPE(0xA9,'c','o','m'); // composer
    00063 const AP4_Atom::Type AP4_ATOM_TYPE_cWRT = AP4_ATOM_TYPE(0xA9,'w','r','t'); // writer
    00064 const AP4_Atom::Type AP4_ATOM_TYPE_cALB = AP4_ATOM_TYPE(0xA9,'a','l','b'); // album
    00065 const AP4_Atom::Type AP4_ATOM_TYPE_cGEN = AP4_ATOM_TYPE(0xA9,'g','e','n'); // genre
    00066 const AP4_Atom::Type AP4_ATOM_TYPE_cGRP = AP4_ATOM_TYPE(0xA9,'g','r','p'); // group
    00067 const AP4_Atom::Type AP4_ATOM_TYPE_cDAY = AP4_ATOM_TYPE(0xA9,'d','a','y'); // date
    00068 const AP4_Atom::Type AP4_ATOM_TYPE_cTOO = AP4_ATOM_TYPE(0xA9,'t','o','o'); // tool
    00069 const AP4_Atom::Type AP4_ATOM_TYPE_cCMT = AP4_ATOM_TYPE(0xA9,'c','m','t'); // comment
    00070 const AP4_Atom::Type AP4_ATOM_TYPE_cLYR = AP4_ATOM_TYPE(0xA9,'l','y','r'); // lyrics
    00071 const AP4_Atom::Type AP4_ATOM_TYPE_TRKN = AP4_ATOM_TYPE('t','r','k','n'); // track#
    00072 const AP4_Atom::Type AP4_ATOM_TYPE_DISK = AP4_ATOM_TYPE('d','i','s','k'); // disk#
    00073 const AP4_Atom::Type AP4_ATOM_TYPE_COVR = AP4_ATOM_TYPE('c','o','v','r'); // cover art
    00074 const AP4_Atom::Type AP4_ATOM_TYPE_DESC = AP4_ATOM_TYPE('d','e','s','c'); // description
    00075 const AP4_Atom::Type AP4_ATOM_TYPE_CPIL = AP4_ATOM_TYPE('c','p','i','l'); // compilation?
    00076 const AP4_Atom::Type AP4_ATOM_TYPE_TMPO = AP4_ATOM_TYPE('t','m','p','o'); // tempo
    00077 const AP4_Atom::Type AP4_ATOM_TYPE_apID = AP4_ATOM_TYPE('a','p','I','D');
    00078 const AP4_Atom::Type AP4_ATOM_TYPE_cnID = AP4_ATOM_TYPE('c','n','I','D');
    00079 const AP4_Atom::Type AP4_ATOM_TYPE_cmID = AP4_ATOM_TYPE('c','m','I','D');
    00080 const AP4_Atom::Type AP4_ATOM_TYPE_atID = AP4_ATOM_TYPE('a','t','I','D');
    00081 const AP4_Atom::Type AP4_ATOM_TYPE_plID = AP4_ATOM_TYPE('p','l','I','D');
    00082 const AP4_Atom::Type AP4_ATOM_TYPE_geID = AP4_ATOM_TYPE('g','e','I','D');
    00083 const AP4_Atom::Type AP4_ATOM_TYPE_sfID = AP4_ATOM_TYPE('s','f','I','D');
    00084 const AP4_Atom::Type AP4_ATOM_TYPE_akID = AP4_ATOM_TYPE('a','k','I','D');
    00085 const AP4_Atom::Type AP4_ATOM_TYPE_aART = AP4_ATOM_TYPE('a','A','R','T');
    00086 const AP4_Atom::Type AP4_ATOM_TYPE_TVNN = AP4_ATOM_TYPE('t','v','n','n'); // TV network
    00087 const AP4_Atom::Type AP4_ATOM_TYPE_TVSH = AP4_ATOM_TYPE('t','v','s','h'); // TV show
    00088 const AP4_Atom::Type AP4_ATOM_TYPE_TVEN = AP4_ATOM_TYPE('t','v','e','n'); // TV episode name
    00089 const AP4_Atom::Type AP4_ATOM_TYPE_TVSN = AP4_ATOM_TYPE('t','v','s','n'); // TV show season #
    00090 const AP4_Atom::Type AP4_ATOM_TYPE_TVES = AP4_ATOM_TYPE('t','v','e','s'); // TV show episode #
    00091 const AP4_Atom::Type AP4_ATOM_TYPE_STIK = AP4_ATOM_TYPE('s','t','i','k');
    00092 const AP4_Atom::Type AP4_ATOM_TYPE_PCST = AP4_ATOM_TYPE('p','c','s','t'); // Podcast?
    00093 const AP4_Atom::Type AP4_ATOM_TYPE_PURD = AP4_ATOM_TYPE('p','u','r','d'); //
    00094 const AP4_Atom::Type AP4_ATOM_TYPE_PURL = AP4_ATOM_TYPE('p','u','r','l'); // Podcast URL (binary)
    00095 const AP4_Atom::Type AP4_ATOM_TYPE_EGID = AP4_ATOM_TYPE('e','g','i','d'); //
    00096 const AP4_Atom::Type AP4_ATOM_TYPE_PGAP = AP4_ATOM_TYPE('p','g','a','p'); // Gapless Playback
    00097 const AP4_Atom::Type AP4_ATOM_TYPE_CATG = AP4_ATOM_TYPE('c','a','t','g'); // Category
    00098 const AP4_Atom::Type AP4_ATOM_TYPE_KEYW = AP4_ATOM_TYPE('k','e','y','w'); // Keywords
    00099 const AP4_Atom::Type AP4_ATOM_TYPE_SONM = AP4_ATOM_TYPE('s','o','n','m'); // Sort-Order: Name
    00100 const AP4_Atom::Type AP4_ATOM_TYPE_SOAL = AP4_ATOM_TYPE('s','o','a','l'); // Sort-Order: Album
    00101 const AP4_Atom::Type AP4_ATOM_TYPE_SOAR = AP4_ATOM_TYPE('s','o','a','r'); // Sort-Order: Artist
    00102 const AP4_Atom::Type AP4_ATOM_TYPE_SOAA = AP4_ATOM_TYPE('s','o','a','a'); // Sort-Order: Album Artist
    00103 const AP4_Atom::Type AP4_ATOM_TYPE_SOCO = AP4_ATOM_TYPE('s','o','c','o'); // Sort-Order: Composer
    00104 const AP4_Atom::Type AP4_ATOM_TYPE_SOSN = AP4_ATOM_TYPE('s','o','s','n'); // Sort-Order: Show
    00105
    00106 const AP4_Atom::Type AP4_ATOM_TYPE_TITL = AP4_ATOM_TYPE('t','i','t','l'); // 3GPP: title
    00107 const AP4_Atom::Type AP4_ATOM_TYPE_DSCP = AP4_ATOM_TYPE('d','s','c','p'); // 3GPP: description
    00108 const AP4_Atom::Type AP4_ATOM_TYPE_CPRT = AP4_ATOM_TYPE('c','p','r','t'); // 3GPP, ISO or ILST: copyright
    00109 const AP4_Atom::Type AP4_ATOM_TYPE_PERF = AP4_ATOM_TYPE('p','e','r','f'); // 3GPP: performer
    00110 const AP4_Atom::Type AP4_ATOM_TYPE_AUTH = AP4_ATOM_TYPE('a','u','t','h'); // 3GPP: author
    00111 const AP4_Atom::Type AP4_ATOM_TYPE_GNRE = AP4_ATOM_TYPE('g','n','r','e'); // 3GPP or ILST: genre (in 3GPP -> string, in ILST -> ID3v1 index + 1)
    00112 const AP4_Atom::Type AP4_ATOM_TYPE_RTNG = AP4_ATOM_TYPE('r','t','n','g'); // 3GPP or ILST: rating
    00113 const AP4_Atom::Type AP4_ATOM_TYPE_CLSF = AP4_ATOM_TYPE('c','l','s','f'); // 3GPP: classification
    00114 const AP4_Atom::Type AP4_ATOM_TYPE_KYWD = AP4_ATOM_TYPE('k','y','w','d'); // 3GPP: keywords
    00115 const AP4_Atom::Type AP4_ATOM_TYPE_LOCI = AP4_ATOM_TYPE('l','o','c','i'); // 3GPP: location information
    00116 const AP4_Atom::Type AP4_ATOM_TYPE_ALBM = AP4_ATOM_TYPE('a','l','b','m'); // 3GPP: album title and track number
    00117 const AP4_Atom::Type AP4_ATOM_TYPE_YRRC = AP4_ATOM_TYPE('y','r','r','c'); // 3GPP: recording year
    00118 const AP4_Atom::Type AP4_ATOM_TYPE_TSEL = AP4_ATOM_TYPE('t','s','e','l'); // 3GPP: track selection
    00119
    00120 const AP4_Atom::Type AP4_ATOM_TYPE_ICNU = AP4_ATOM_TYPE('i','c','n','u'); // DCF: icon URI      (OMA DCF 2.1)
    00121 const AP4_Atom::Type AP4_ATOM_TYPE_INFU = AP4_ATOM_TYPE('i','n','f','u'); // DCF: info URI      (OMA DCF 2.1)
    00122 const AP4_Atom::Type AP4_ATOM_TYPE_CVRU = AP4_ATOM_TYPE('c','v','r','u'); // DCF: cover art URI (OMA DCF 2.1)
    00123 const AP4_Atom::Type AP4_ATOM_TYPE_LRCU = AP4_ATOM_TYPE('l','r','c','u'); // DCF: lyrics URI    (OMA DCF 2.1)
    00124 const AP4_Atom::Type AP4_ATOM_TYPE_DCFD = AP4_ATOM_TYPE('d','c','f','D'); // DCF: duration      (OMarlin)
    00125
    00126 /*----------------------------------------------------------------------
    00127 |   AP4_MetaData
    00128 +---------------------------------------------------------------------*/
    00129 class AP4_MetaData {
    00130 public:
    00131     class Key {
    00132     public:
    00133         // constructors
    00134         Key(const char* name, const char* ns) :
    00135           m_Name(name), m_Namespace(ns) {}
    00136
    00137         // methods
    00138         const AP4_String& GetNamespace() const { return m_Namespace; }
    00139         const AP4_String& GetName()      const { return m_Name;      }
    00140
    00141     private:
    00142         // members
    00143         const AP4_String m_Name;
    00144         const AP4_String m_Namespace;
    00145     };
    00146
    00147     class Value {
    00148     public:
    00149         // types
    00150         typedef enum {
    00151             TYPE_BINARY,
    00152             TYPE_STRING_UTF_8,
    00153             TYPE_STRING_UTF_16,
    00154             TYPE_STRING_PASCAL,
    00155             TYPE_GIF,
    00156             TYPE_JPEG,
    00157             TYPE_INT_08_BE,
    00158             TYPE_INT_16_BE,
    00159             TYPE_INT_32_BE,
    00160             TYPE_FLOAT_32_BE,
    00161             TYPE_FLOAT_64_BE
    00162         } Type;
    00163
    00164         typedef enum {
    00165             TYPE_CATEGORY_STRING,
    00166             TYPE_CATEGORY_BINARY,
    00167             TYPE_CATEGORY_INTEGER,
    00168             TYPE_CATEGORY_FLOAT
    00169         } TypeCategory;
    00170
    00171         typedef enum {
    00172             MEANING_UNKNOWN,
    00173             MEANING_ID3_GENRE,
    00174             MEANING_BOOLEAN,
    00175             MEANING_FILE_KIND,
    00176             MEANING_BINARY_ENCODED_CHARS
    00177         } Meaning;
    00178
    00179         // destructor
    00180         virtual ~Value() {}
    00181
    00182         // methods
    00183         Type               GetType() const         { return m_Type;         }
    00184         TypeCategory       GetTypeCategory() const;
    00185         Meaning            GetMeaning() const      { return m_Meaning;      }
    00186         const AP4_String&  GetLanguage() const     { return m_Language;     }
    00187         virtual AP4_String ToString() const = 0;
    00188         virtual AP4_Result ToBytes(AP4_DataBuffer& bytes) const = 0;
    00189         virtual long       ToInteger() const = 0;
    00190
    00191     protected:
    00192         // class methods
    00193         static TypeCategory MapTypeToCategory(Type type);
    00194
    00195         // constructor
    00196         Value(Type        type,
    00197               Meaning     meaning  = MEANING_UNKNOWN,
    00198               const char* language = NULL) :
    00199             m_Type(type), m_Meaning(meaning), m_Language(language) {}
    00200
    00201         // members
    00202         Type       m_Type;
    00203         Meaning    m_Meaning;
    00204         AP4_String m_Language;
    00205     };
    00206
    00207     class KeyInfo {
    00208     public:
    00209         // members
    00210         const char* name;
    00211         const char* description;
    00212         AP4_UI32    four_cc;
    00213         Value::Type value_type;
    00214     };
    00215
    00216     class Entry {
    00217     public:
    00218         // constructor
    00219         Entry(const char* name, const char* ns, Value* value) :
    00220           m_Key(name, ns), m_Value(value) {}
    00221
    00222         // destructor
    00223         ~Entry() { delete m_Value; }
    00224
    00225         // methods
    00226         AP4_Result         AddToFile(AP4_File& file, AP4_Ordinal index = 0);
    00227         AP4_Result         AddToFileIlst(AP4_File& file, AP4_Ordinal index = 0);
    00228         AP4_Result         AddToFileDcf(AP4_File& file, AP4_Ordinal index = 0);
    00229         AP4_Result         RemoveFromFile(AP4_File& file, AP4_Ordinal index);
    00230         AP4_Result         RemoveFromFileIlst(AP4_File& file, AP4_Ordinal index);
    00231         AP4_Result         RemoveFromFileDcf(AP4_File& file, AP4_Ordinal index);
    00232         AP4_ContainerAtom* FindInIlst(AP4_ContainerAtom* ilst) const;
    00233         AP4_Atom*          ToAtom() const;
    00234
    00235         // members
    00236         Key    m_Key;
    00237         Value* m_Value;
    00238     };
    00239
    00240     // class members
    00241     static AP4_Array<KeyInfo> KeyInfos;
    00242
    00243     // constructor
    00244     AP4_MetaData(AP4_File* file);
    00245
    00246     // methods
    00247     AP4_Result ParseMoov(AP4_MoovAtom* moov);
    00248     AP4_Result ParseUdta(AP4_ContainerAtom* udta, const char* namespc);
    00249
    00250     // destructor
    00251     ~AP4_MetaData();
    00252
    00253     // accessors
    00254     const AP4_List<Entry>& GetEntries() const { return m_Entries; }
    00255
    00256     // methods
    00257     AP4_Result ResolveKeyName(AP4_Atom::Type atom_type, AP4_String& value);
    00258     AP4_Result AddIlstEntries(AP4_ContainerAtom* atom, const char* namespc);
    00259     AP4_Result Add3GppEntry(AP4_3GppLocalizedStringAtom* atom, const char* namespc);
    00260     AP4_Result AddDcfStringEntry(AP4_DcfStringAtom* atom, const char* namespc);
    00261     AP4_Result AddDcfdEntry(AP4_DcfdAtom* atom, const char* namespc);
    00262
    00263 private:
    00264     // members
    00265     AP4_List<Entry> m_Entries;
    00266 };
    00267
    00268 /*----------------------------------------------------------------------
    00269 |   AP4_MetaDataAtomTypeHandler
    00270 +---------------------------------------------------------------------*/
    00271 class AP4_MetaDataAtomTypeHandler : public AP4_AtomFactory::TypeHandler
    00272 {
    00273 public:
    00274     // constructor
    00275     AP4_MetaDataAtomTypeHandler(AP4_AtomFactory* atom_factory) :
    00276       m_AtomFactory(atom_factory) {}
    00277     virtual AP4_Result CreateAtom(AP4_Atom::Type  type,
    00278                                   AP4_UI32        size,
    00279                                   AP4_ByteStream& stream,
    00280                                   AP4_Atom::Type  context,
    00281                                   AP4_Atom*&      atom);
    00282
    00283     // types
    00284     struct TypeList {
    00285         const AP4_Atom::Type* m_Types;
    00286         AP4_Size              m_Size;
    00287     };
    00288
    00289     // class constants
    00290     static const AP4_Atom::Type IlstTypes[];
    00291     static const TypeList       IlstTypeList;
    00292     static const AP4_Atom::Type _3gppLocalizedStringTypes[];
    00293     static const TypeList       _3gppLocalizedStringTypeList;
    00294     static const AP4_Atom::Type _3gppOtherTypes[];
    00295     static const TypeList       _3gppOtherTypeList;
    00296     static const AP4_Atom::Type DcfStringTypes[];
    00297     static const TypeList       DcfStringTypeList;
    00298
    00299     // class methods
    00300     static bool IsTypeInList(AP4_Atom::Type type, const TypeList& list);
    00301
    00302 private:
    00303     // members
    00304     AP4_AtomFactory* m_AtomFactory;
    00305 };
    00306
    00307 /*----------------------------------------------------------------------
    00308 |   AP4_MetaDataTag
    00309 +---------------------------------------------------------------------*/
    00310 class AP4_MetaDataTag
    00311 {
    00312 public:
    00313
    00314     // destructor
    00315     virtual ~AP4_MetaDataTag() {}
    00316
    00317     // methods
    00318     virtual AP4_Result Write(AP4_ByteStream& stream);
    00319     virtual AP4_Result Inspect(AP4_AtomInspector& inspector);
    00320
    00321 protected:
    00322     // constructor
    00323     AP4_MetaDataTag(AP4_UI32        data_type,
    00324                     AP4_UI32        data_lang,
    00325                     AP4_Size        size,
    00326                     AP4_ByteStream& stream);
    00327
    00328 };
    00329
    00330 /*----------------------------------------------------------------------
    00331 |   AP4_3GppLocalizedStringAtom
    00332 +---------------------------------------------------------------------*/
    00333 class AP4_3GppLocalizedStringAtom : public AP4_Atom
    00334 {
    00335 public:
    00336     // factory method
    00337     static AP4_3GppLocalizedStringAtom* Create(Type type, AP4_UI32 size, AP4_ByteStream& stream);
    00338
    00339     // constructor
    00340     AP4_3GppLocalizedStringAtom(Type            type,
    00341                                 AP4_UI32        size,
    00342                                 AP4_UI32        version,
    00343                                 AP4_UI32        flags,
    00344                                 AP4_ByteStream& stream);
    00345
    00346     // AP4_Atom methods
    00347     virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
    00348     virtual AP4_Result WriteFields(AP4_ByteStream& stream);
    00349
    00350     // methods
    00351     const char*           GetLanguage() const { return m_Language; }
    00352     const AP4_DataBuffer& GetPayload()  const { return m_Payload;  }
    00353
    00354 private:
    00355     // members
    00356     char           m_Language[4];
    00357     AP4_DataBuffer m_Payload;
    00358 };
    00359
    00360 /*----------------------------------------------------------------------
    00361 |   AP4_DcfStringAtom
    00362 +---------------------------------------------------------------------*/
    00363 class AP4_DcfStringAtom : public AP4_Atom
    00364 {
    00365 public:
    00366     // factory method
    00367     static AP4_DcfStringAtom* Create(Type type, AP4_UI32 size, AP4_ByteStream& stream);
    00368
    00369     // constructor
    00370     AP4_DcfStringAtom(Type type, const char* value);
    00371     AP4_DcfStringAtom(Type            type,
    00372                       AP4_UI32        size,
    00373                       AP4_UI32        version,
    00374                       AP4_UI32        flags,
    00375                       AP4_ByteStream& stream);
    00376
    00377     // AP4_Atom methods
    00378     virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
    00379     virtual AP4_Result WriteFields(AP4_ByteStream& stream);
    00380
    00381     // methods
    00382     const AP4_String& GetValue() const { return m_Value;  }
    00383
    00384 private:
    00385     // members
    00386     AP4_String m_Value;
    00387 };
    00388
    00389 /*----------------------------------------------------------------------
    00390 |   AP4_DcfdAtom
    00391 +---------------------------------------------------------------------*/
    00392 class AP4_DcfdAtom : public AP4_Atom
    00393 {
    00394 public:
    00395     // factory method
    00396     static AP4_DcfdAtom* Create(AP4_UI32 size, AP4_ByteStream& stream);
    00397
    00398     // constructors
    00399     AP4_DcfdAtom(AP4_UI32        version,
    00400                  AP4_UI32        flags,
    00401                  AP4_ByteStream& stream);
    00402     AP4_DcfdAtom(AP4_UI32 duration);
    00403
    00404     // AP4_Atom methods
    00405     virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
    00406     virtual AP4_Result WriteFields(AP4_ByteStream& stream);
    00407
    00408     // methods
    00409     AP4_UI32 GetDuration() const { return m_Duration;  }
    00410
    00411 private:
    00412     // members
    00413     AP4_UI32 m_Duration;
    00414 };
    00415
    00416 /*----------------------------------------------------------------------
    00417 |   AP4_MetaDataStringAtom
    00418 +---------------------------------------------------------------------*/
    00419 class AP4_MetaDataStringAtom : public AP4_Atom
    00420 {
    00421 public:
    00422     // constructors
    00423     AP4_MetaDataStringAtom(Type type, const char* value);
    00424     AP4_MetaDataStringAtom(Type type, AP4_UI32 size, AP4_ByteStream& stream);
    00425
    00426     // AP4_Atom methods
    00427     virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
    00428     virtual AP4_Result WriteFields(AP4_ByteStream& stream);
    00429
    00430     // methods
    00431     const AP4_String& GetValue() { return m_Value; }
    00432
    00433 private:
    00434     // members
    00435     AP4_UI32   m_Reserved;
    00436     AP4_String m_Value;
    00437 };
    00438
    00439 /*----------------------------------------------------------------------
    00440 |   AP4_DataAtom
    00441 +---------------------------------------------------------------------*/
    00442 class AP4_DataAtom : public AP4_Atom
    00443 {
    00444 public:
    00445     typedef enum {
    00446         DATA_TYPE_BINARY        = 0,
    00447         DATA_TYPE_STRING_UTF_8  = 1,
    00448         DATA_TYPE_STRING_UTF_16 = 2,
    00449         DATA_TYPE_STRING_PASCAL = 3,
    00450         DATA_TYPE_GIF           = 13,
    00451         DATA_TYPE_JPEG          = 14,
    00452         DATA_TYPE_SIGNED_INT_BE = 21, /* the size of the integer is derived from the container size */
    00453         DATA_TYPE_FLOAT_32_BE   = 22,
    00454         DATA_TYPE_FLOAT_64_BE   = 23
    00455     } DataType;
    00456
    00457     typedef enum {
    00458         LANGUAGE_ENGLISH = 0
    00459     } DataLang;
    00460
    00461     // constructors
    00462     AP4_DataAtom(const AP4_MetaData::Value& value);
    00463     AP4_DataAtom(AP4_UI32 size, AP4_ByteStream& stream);
    00464
    00465     // destructor
    00466     ~AP4_DataAtom();
    00467
    00468     // AP4_Atom methods
    00469     virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
    00470     virtual AP4_Result WriteFields(AP4_ByteStream& stream);
    00471
    00472     // accessors
    00473     DataType GetDataType() { return m_DataType; }
    00474     DataLang GetDataLang() { return m_DataLang; }
    00475     AP4_MetaData::Value::Type GetValueType();
    00476
    00477     // methods
    00478     AP4_Result LoadString(AP4_String*& string);
    00479     AP4_Result LoadBytes(AP4_DataBuffer& bytes);
    00480     AP4_Result LoadInteger(long& value);
    00481
    00482 private:
    00483     // members
    00484     DataType        m_DataType;
    00485     DataLang        m_DataLang;
    00486     AP4_ByteStream* m_Source;
    00487 };
    00488
    00489 /*----------------------------------------------------------------------
    00490 |   AP4_StringMetaDataValue
    00491 +---------------------------------------------------------------------*/
    00492 class AP4_StringMetaDataValue : public AP4_MetaData::Value {
    00493 public:
    00494     // constructor
    00495     AP4_StringMetaDataValue(const char* value, const char* language=NULL) :
    00496         Value(TYPE_STRING_UTF_8, MEANING_UNKNOWN, language),
    00497         m_Value(value) {}
    00498
    00499     // AP4_MetaData::Value methods
    00500     virtual AP4_String ToString() const;
    00501     virtual AP4_Result ToBytes(AP4_DataBuffer& bytes) const;
    00502     virtual long       ToInteger() const;
    00503
    00504 private:
    00505     // members
    00506     AP4_String m_Value;
    00507 };
    00508
    00509 /*----------------------------------------------------------------------
    00510 |   AP4_IntegerMetaDataValue
    00511 +---------------------------------------------------------------------*/
    00512 class AP4_IntegerMetaDataValue : public AP4_MetaData::Value {
    00513 public:
    00514     // constructor
    00515     AP4_IntegerMetaDataValue(Type type, long value) :
    00516         Value(type), m_Value(value) {}
    00517
    00518     // AP4_MetaData::Value methods
    00519     virtual AP4_String ToString() const;
    00520     virtual AP4_Result ToBytes(AP4_DataBuffer& bytes) const;
    00521     virtual long       ToInteger() const;
    00522
    00523 private:
    00524     // members
    00525     long m_Value;
    00526 };
    00527
    00528 /*----------------------------------------------------------------------
    00529 |   AP4_BinaryMetaDataValue
    00530 +---------------------------------------------------------------------*/
    00531 class AP4_BinaryMetaDataValue : public AP4_MetaData::Value {
    00532 public:
    00533     // constructor
    00534     AP4_BinaryMetaDataValue(Type type, const AP4_UI08* data, AP4_Size size) :
    00535         Value(type), m_Value(data, size) {}
    00536
    00537     // AP4_MetaData::Value methods
    00538     virtual AP4_String ToString() const;
    00539     virtual AP4_Result ToBytes(AP4_DataBuffer& bytes) const;
    00540     virtual long       ToInteger() const;
    00541
    00542 private:
    00543     // members
    00544     AP4_DataBuffer m_Value;
    00545 };
    00546
    00547 /*----------------------------------------------------------------------
    00548 |   AP4_AtomMetaDataValue
    00549 +---------------------------------------------------------------------*/
    00550 class AP4_AtomMetaDataValue : public AP4_MetaData::Value
    00551 {
    00552 public:
    00553     // constructor
    00554     AP4_AtomMetaDataValue(AP4_DataAtom* data_atom, AP4_UI32 parent_type);
    00555
    00556     // AP4_MetaData::Value methods
    00557     virtual AP4_String ToString() const;
    00558     virtual AP4_Result ToBytes(AP4_DataBuffer& bytes) const;
    00559     virtual long       ToInteger() const;
    00560
    00561 private:
    00562     // members
    00563     AP4_DataAtom* m_DataAtom;
    00564 };
    00565
    00566 #endif // _AP4_META_DATA_H_