1 #ifndef __QuickTime_Support_hpp__ 2 #define __QuickTime_Support_hpp__ 1 3 4 // ================================================================================================= 5 // ADOBE SYSTEMS INCORPORATED 6 // Copyright 2009 Adobe Systems Incorporated 7 // All Rights Reserved 8 // 9 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms 10 // of the Adobe license agreement accompanying it. 11 // ================================================================================================= 12 13 #include "public/include/XMP_Environment.h" // ! This must be the first include. 14 15 #include "public/include/XMP_Const.h" 16 #include "public/include/XMP_IO.hpp" 17 18 #include <string> 19 #include <vector> 20 #include <map> 21 22 #include "XMPFiles/source/XMPFiles_Impl.hpp" 23 #include "XMPFiles/source/FormatSupport/ISOBaseMedia_Support.hpp" 24 #include "XMPFiles/source/FormatSupport/MOOV_Support.hpp" 25 26 // ================================================================================================= 27 // ================================================================================================= 28 29 // ================================================================================================= 30 // TradQT_Manager 31 // ============== 32 33 // Support for selected traditional QuickTime metadata items. The supported items are the children 34 // of the 'moov'/'udta' box whose type begins with 0xA9, a MacRoman copyright symbol. Each of these 35 // is a box whose contents are a sequence of "mini boxes" analogous to XMP AltText arrays. Each mini 36 // box has a 16-bit size, 16-bit language code, and text. The language code values are the old 37 // Macintosh Script Manager langXyz codes, the text encoding is implicit, see Mac Script.h. 38 39 enum { // List of recognized items from the QuickTime 'moov'/'udta' box. 40 // These items are defined by Adobe. 41 kQTilst_Reel = 0xA952454CUL, // '�REL' 42 kQTilst_Timecode = 0xA954494DUL, // '�TIM' 43 kQTilst_TimeScale = 0xA9545343UL, // '�TSC' 44 kQTilst_TimeSize = 0xA954535AUL // '�TSZ' 45 }; 46 47 enum { 48 kNoMacLang = 0xFFFF, 49 kNoMacScript = 0xFFFF 50 }; 51 52 extern bool ConvertToMacLang ( const std::string & utf8Value, XMP_Uns16 macLang, std::string * macValue ); 53 extern bool ConvertFromMacLang ( const std::string & macValue, XMP_Uns16 macLang, std::string * utf8Value ); 54 55 class TradQT_Manager { 56 public: 57 TradQT_Manager()58 TradQT_Manager() : changed(false) {}; 59 60 bool ParseCachedBoxes ( const MOOV_Manager & moovMgr ); 61 62 bool ImportSimpleXMP ( XMP_Uns32 id, SXMPMeta * xmp, XMP_StringPtr ns, XMP_StringPtr prop ) const; 63 bool ImportLangAltXMP ( XMP_Uns32 id, SXMPMeta * xmp, XMP_StringPtr ns, XMP_StringPtr langArray ) const; 64 65 void ExportSimpleXMP ( XMP_Uns32 id, const SXMPMeta & xmp, XMP_StringPtr ns, XMP_StringPtr prop, 66 bool createWithZeroLang = false ); 67 void ExportLangAltXMP ( XMP_Uns32 id, const SXMPMeta & xmp, XMP_StringPtr ns, XMP_StringPtr langArray ); 68 IsChanged() const69 bool IsChanged() const { return this->changed; }; 70 71 void UpdateChangedBoxes ( MOOV_Manager * moovMgr ); 72 73 private: 74 75 struct ValueInfo { 76 bool marked; 77 XMP_Uns16 macLang; 78 XMP_StringPtr xmpLang; // ! Only set if macLang is known, i.e. the value can be converted. 79 std::string macValue; ValueInfoTradQT_Manager::ValueInfo80 ValueInfo() : marked(false), macLang(kNoMacLang), xmpLang("") {}; 81 }; 82 typedef std::vector<ValueInfo> ValueVector; 83 typedef ValueVector::iterator ValueInfoPos; 84 typedef ValueVector::const_iterator ValueInfoCPos; 85 86 struct ParsedBoxInfo { 87 XMP_Uns32 id; 88 ValueVector values; 89 bool changed; ParsedBoxInfoTradQT_Manager::ParsedBoxInfo90 ParsedBoxInfo() : id(0), changed(false) {}; ParsedBoxInfoTradQT_Manager::ParsedBoxInfo91 ParsedBoxInfo ( XMP_Uns32 _id ) : id(_id), changed(false) {}; 92 }; 93 94 typedef std::map < XMP_Uns32, ParsedBoxInfo > InfoMap; // Metadata item kind and content info. 95 typedef InfoMap::iterator InfoMapPos; 96 typedef InfoMap::const_iterator InfoMapCPos; 97 98 InfoMap parsedBoxes; 99 bool changed; 100 101 bool ImportLangItem ( const ValueInfo & qtItem, SXMPMeta * xmp, XMP_StringPtr ns, XMP_StringPtr langArray ) const; 102 103 }; // TradQT_Manager 104 105 #endif // __QuickTime_Support_hpp__ 106