metadata.h

Go to the documentation of this file.
00001 
00014 /*
00015  *  Copyright (c) 2003, Matt Beard
00016  *  Portions Copyright (c) 2003, Metaglue Corporation
00017  *
00018  *  This software is provided 'as-is', without any express or implied warranty.
00019  *  In no event will the authors be held liable for any damages arising from
00020  *  the use of this software.
00021  *
00022  *  Permission is granted to anyone to use this software for any purpose,
00023  *  including commercial applications, and to alter it and redistribute it
00024  *  freely, subject to the following restrictions:
00025  *
00026  *    1. The origin of this software must not be misrepresented; you must
00027  *       not claim that you wrote the original software. If you use this
00028  *       software in a product, an acknowledgment in the product
00029  *       documentation would be appreciated but is not required.
00030  *  
00031  *    2. Altered source versions must be plainly marked as such, and must
00032  *       not be misrepresented as being the original software.
00033  *  
00034  *    3. This notice may not be removed or altered from any source
00035  *       distribution.
00036  */
00037 #ifndef MXFLIB__METADATA_H
00038 #define MXFLIB__METADATA_H
00039 
00040 namespace mxflib
00041 {
00042     // Forward declare so the class can include pointers to itself
00043     class Metadata;
00044     class MetadataPtr;
00045 
00047     class MetadataPtr : public SmartPtr<Metadata>
00048     {
00049     public:
00050         MetadataPtr() : SmartPtr<Metadata>() {}
00051         MetadataPtr(IRefCount<Metadata> * ptr) : SmartPtr<Metadata>(ptr) {};
00052         
00054         MDObjectPtr operator[](const char *ChildName);
00055         MDObjectPtr operator[](MDOTypePtr ChildType);
00056         MDObjectPtr operator[](const UL &ChildType);
00057         MDObjectPtr operator[](ULPtr &ChildType);
00058     };
00059 }
00060 
00061 
00062 // Forward definitions
00063 namespace mxflib
00064 {
00065     class Package;
00067     class PackagePtr : public SmartPtr<Package>
00068     {
00069     public:
00070         PackagePtr() : SmartPtr<Package>() {}
00071         PackagePtr(IRefCount<Package> * ptr) : SmartPtr<Package>(ptr) {}
00072         
00074         MDObjectPtr operator[](const char *ChildName);
00075         MDObjectPtr operator[](MDOTypePtr ChildType);
00076         MDObjectPtr operator[](const UL &ChildType);
00077         MDObjectPtr operator[](ULPtr &ChildType);
00078     };
00079 
00081     class PackageParent : public ParentPtr<Package>
00082     {
00083     public:
00084         PackageParent() : ParentPtr<Package>() {}
00085         PackageParent(IRefCount<Package> * ptr) : ParentPtr<Package>(ptr) {}
00086 
00088         MDObjectPtr operator[](const char *ChildName);
00089         MDObjectPtr operator[](MDOTypePtr ChildType);
00090         MDObjectPtr operator[](const UL &ChildType);
00091         MDObjectPtr operator[](ULPtr &ChildType);
00092     };
00093 
00095     typedef std::list<PackagePtr> PackageList;
00096 
00097 
00098     class Track;
00100     class TrackPtr : public SmartPtr<Track>
00101     {
00102     public:
00103         TrackPtr() : SmartPtr<Track>() {}
00104         TrackPtr(IRefCount<Track> * ptr) : SmartPtr<Track>(ptr) {}
00105 
00107         MDObjectPtr operator[](const char *ChildName);
00108         MDObjectPtr operator[](MDOTypePtr ChildType);
00109         MDObjectPtr operator[](const UL &ChildType);
00110         MDObjectPtr operator[](ULPtr &ChildType);
00111     };
00112 
00114     typedef std::list<TrackPtr> TrackList;
00115 
00116 
00118     class TrackParent : public ParentPtr<Track>
00119     {
00120     public:
00121         TrackParent() : ParentPtr<Track>() {}
00122         TrackParent(IRefCount<Track> * ptr) : ParentPtr<Track>(ptr) {}
00123 
00125         TrackParent & operator=(const TrackPtr &sp) { __Assign(sp.GetRef()); return *this;}
00126 
00128         TrackParent & operator=(IRefCount<Track> *ptr) { __Assign(ptr); return *this;}
00129 
00131         MDObjectPtr operator[](const char *ChildName);
00132         MDObjectPtr operator[](MDOTypePtr ChildType);
00133         MDObjectPtr operator[](const UL &ChildType);
00134         MDObjectPtr operator[](ULPtr &ChildType);
00135     };
00136 
00137 
00139 
00140     class Component : public ObjectInterface, public RefCount<Component>
00141     {
00142     protected:
00143         TrackParent Parent;                 
00144 
00146         Component(MDObjectPtr BaseObject) : ObjectInterface(BaseObject) {}
00147 
00148     public:
00149         Component(std::string BaseType) { Object = new MDObject(BaseType); if(Object) Object->SetOuter(this); }
00150         Component(MDOTypePtr BaseType) { Object = new MDObject(BaseType); if(Object) Object->SetOuter(this); }
00151         Component(const UL &BaseUL) { Object = new MDObject(BaseUL); if(Object) Object->SetOuter(this); }
00152         Component(ULPtr &BaseUL) { Object = new MDObject(BaseUL); if(Object) Object->SetOuter(this); }
00153 
00155         TrackParent GetParent(void) { return Parent; };
00156 
00158         void SetParent(TrackPtr &NewParent) { Parent = NewParent; }
00159 
00161         void SetParent(IRefCount<Track> *NewParent) { Parent = TrackParent(NewParent); }
00162 
00164 
00165         virtual bool MakeLink(TrackPtr SourceTrack, Int64 StartPosition = 0) { return false; }
00166 
00168 
00169         virtual bool MakeLink(UMIDPtr LinkUMID, UInt32 LinkTrackID, Int64 StartPosition = 0) { return false; }
00170 
00172 
00173         virtual void SetDuration(Length Duration = -1);
00174 
00176         virtual ~Component() {};
00177     };
00178 
00180     typedef SmartPtr<Component> ComponentPtr;
00181 
00183     typedef std::list<ComponentPtr> ComponentList;
00184 
00185 
00186     class SourceClip;
00188     class SourceClipPtr : public SmartPtr<SourceClip>
00189     {
00190     public:
00192         SourceClipPtr() : SmartPtr<SourceClip>() {}
00193 
00195 
00196         SourceClipPtr(IRefCount<Component> * ptr) : SmartPtr<SourceClip>((IRefCount<SourceClip> *)ptr) {}
00197 
00199         MDObjectPtr operator[](const char *ChildName);
00200         MDObjectPtr operator[](MDOTypePtr ChildType);
00201         MDObjectPtr operator[](const UL &ChildType);
00202         MDObjectPtr operator[](ULPtr &ChildType);
00203     };
00204 
00205     class DMSourceClip;
00207     class DMSourceClipPtr : public SmartPtr<DMSourceClip>
00208     {
00209     public:
00211         DMSourceClipPtr() : SmartPtr<DMSourceClip>() {}
00212 
00214 
00215         DMSourceClipPtr(IRefCount<Component> * ptr) : SmartPtr<DMSourceClip>((IRefCount<DMSourceClip> *)ptr) {}
00216 
00218         MDObjectPtr operator[](const char *ChildName);
00219         MDObjectPtr operator[](MDOTypePtr ChildType);
00220         MDObjectPtr operator[](const UL &ChildType);
00221         MDObjectPtr operator[](ULPtr &ChildType);
00222     };
00223 
00224     class TimecodeComponent;
00226     class TimecodeComponentPtr : public SmartPtr<TimecodeComponent>
00227     {
00228     public:
00230         TimecodeComponentPtr() : SmartPtr<TimecodeComponent>() {}
00231 
00233 
00234         TimecodeComponentPtr(IRefCount<Component> * ptr) : SmartPtr<TimecodeComponent>((IRefCount<TimecodeComponent> *)ptr) {}
00235 
00237         MDObjectPtr operator[](const char *ChildName);
00238         MDObjectPtr operator[](MDOTypePtr ChildType);
00239         MDObjectPtr operator[](const UL &ChildType);
00240         MDObjectPtr operator[](ULPtr &ChildType);
00241     };
00242 
00243     class DMSegment;
00245     class DMSegmentPtr : public SmartPtr<DMSegment>
00246     {
00247     public:
00249         DMSegmentPtr() : SmartPtr<DMSegment>() {}
00250 
00252 
00253         DMSegmentPtr(IRefCount<Component> * ptr) : SmartPtr<DMSegment>((IRefCount<DMSegment> *)ptr) {};
00254 
00256         MDObjectPtr operator[](const char *ChildName);
00257         MDObjectPtr operator[](MDOTypePtr ChildType);
00258         MDObjectPtr operator[](const UL &ChildType);
00259         MDObjectPtr operator[](ULPtr &ChildType);
00260     };
00261 }
00262 
00263 
00264 
00265 namespace mxflib
00266 {
00268     class SourceClip : public Component
00269     {
00270     protected:
00272         SourceClip(MDObjectPtr BaseObject) : Component(BaseObject) {}
00273 
00274     public:
00275         SourceClip(std::string BaseType) : Component(BaseType) {};
00276         SourceClip(MDOTypePtr BaseType) : Component(BaseType) {};
00277         SourceClip(const UL &BaseUL) : Component(BaseUL) {};
00278         SourceClip(ULPtr &BaseUL) : Component(BaseUL) {};
00279 
00281         virtual bool MakeLink(TrackPtr SourceTrack, Int64 StartPosition = 0);
00282 
00284         virtual bool MakeLink(UMIDPtr LinkUMID, UInt32 LinkTrackID, Int64 StartPosition = 0);
00285 
00287 
00289         static SourceClipPtr GetSourceClip(MDObjectPtr Object);
00290 
00292         static SourceClipPtr Parse(MDObjectPtr BaseObject);
00293     };
00294 }
00295 
00296 
00297 namespace mxflib
00298 {
00300     class DMSourceClip : public SourceClip
00301     {
00302     protected:
00304         DMSourceClip(MDObjectPtr BaseObject) : SourceClip(BaseObject) {}
00305 
00306     public:
00307         DMSourceClip(std::string BaseType) : SourceClip(BaseType) {};
00308         DMSourceClip(MDOTypePtr BaseType) : SourceClip(BaseType) {};
00309         DMSourceClip(const UL &BaseUL) : SourceClip(BaseUL) {};
00310         DMSourceClip(ULPtr &BaseUL) : SourceClip(BaseUL) {};
00311 
00313 
00315         static DMSourceClipPtr GetDMSourceClip(MDObjectPtr Object);
00316 
00318         static DMSourceClipPtr Parse(MDObjectPtr BaseObject);
00319     };
00320 }
00321 
00322 
00323 namespace mxflib
00324 {
00326     class TimecodeComponent : public Component
00327     {
00328     protected:
00330         TimecodeComponent(MDObjectPtr BaseObject) : Component(BaseObject) {}
00331 
00332     public:
00333         TimecodeComponent(std::string BaseType) : Component(BaseType) {};
00334         TimecodeComponent(MDOTypePtr BaseType) : Component(BaseType) {};
00335         TimecodeComponent(const UL &BaseUL) : Component(BaseUL) {};
00336         TimecodeComponent(ULPtr &BaseUL) : Component(BaseUL) {};
00337 
00339 
00341         static TimecodeComponentPtr GetTimecodeComponent(MDObjectPtr Object);
00342 
00344         static TimecodeComponentPtr Parse(MDObjectPtr BaseObject);
00345     };
00346 }
00347 
00348 namespace mxflib
00349 {
00351     class DMSegment : public Component
00352     {
00353     protected:
00355         DMSegment(MDObjectPtr BaseObject) : Component(BaseObject) {}
00356 
00357     public:
00358         DMSegment(std::string BaseType) : Component(BaseType) {};
00359         DMSegment(MDOTypePtr BaseType) : Component(BaseType) {};
00360         DMSegment(const UL &BaseUL) : Component(BaseUL) {};
00361         DMSegment(ULPtr &BaseUL) : Component(BaseUL) {};
00362 
00363 //      //! Make a link to a specified track (in the same Package)
00364 //      bool MakeLink(TrackPtr SourceTrack);
00365 
00367         bool MakeLink(MDObjectPtr DMFramework);
00368 
00370 
00372         static DMSegmentPtr GetDMSegment(MDObjectPtr Object);
00373 
00375         static DMSegmentPtr Parse(MDObjectPtr BaseObject);
00376     };
00377 }
00378 
00379 namespace mxflib
00380 {
00382     class Track : public ObjectInterface, public RefCount<Track>
00383     {
00384     public:
00386         enum TrackType
00387         {
00388             TypeUndetermined = -1,              
00389             TypeUnknown = 0,                    
00390             TypeTimecode,                       
00391             TypeDM,                             
00392             TypePicture,                        
00393             TypeSound,                          
00394             TypeData,                           
00395             TypeAux,                            
00396             TypePText                           
00397         };
00398 
00399     public:
00400         ComponentList Components;               
00401 
00402     protected:
00403         PackageParent Parent;                   
00404 
00405         TrackType ThisTrackType;                
00406 
00408         Track(MDObjectPtr BaseObject) : ObjectInterface(BaseObject) 
00409         {
00410             ThisTrackType = TypeUndetermined;
00411         }
00412 
00414         struct TrackTypeListItem
00415         {
00416             TrackType Type;                     
00417             UInt8 Label[16];                    
00418             int CompareLength;                  
00419         };
00420 
00422         typedef std::list<TrackTypeListItem> TrackTypeList;
00423 
00424         static TrackTypeList TrackTypes;        
00425         static bool TrackTypesInited;           
00426 
00427     public:
00428         Track(std::string BaseType) { Object = new MDObject(BaseType); ThisTrackType = TypeUndetermined; }
00429         Track(MDOTypePtr BaseType) { Object = new MDObject(BaseType); ThisTrackType = TypeUndetermined; }
00430         Track(const UL &BaseUL) { Object = new MDObject(BaseUL); ThisTrackType = TypeUndetermined; }
00431         Track(ULPtr &BaseUL) { Object = new MDObject(BaseUL); ThisTrackType = TypeUndetermined; }
00432 
00434         SourceClipPtr AddSourceClip(Int64 Duration = -1);
00435 
00437         TimecodeComponentPtr AddTimecodeComponent(Int64 Start = 0, Int64 Duration = -1)
00438         {
00439             MDObjectPtr EditRate = Child("EditRate");
00440             if(EditRate)
00441             {
00442                 double FPS = ((double)GetInt("Numerator", 1)) / ((double)GetInt("Denominator", 1));
00443                 return AddTimecodeComponent((UInt16)FPS, (GetInt("Denominator") == 1001), Start, Duration);
00444             }
00445 
00446             // Default to an edit rate of 1 if no known edit rate
00447             return AddTimecodeComponent(1, false, Start, Duration);
00448         }
00449 
00451         TimecodeComponentPtr AddTimecodeComponent(UInt16 FPS, bool DropFrame, Int64 Start = 0, Int64 Duration = -1);
00452 
00454         DMSegmentPtr AddDMSegment(Int64 EventStart = -1, Int64 Duration = -1);
00455 
00457         DMSourceClipPtr AddDMSourceClip(Int64 Duration = -1);
00458 
00460         Int64 UpdateDuration(void);
00461 
00463         PackageParent GetParent(void) { return Parent; };
00464 
00466         void SetParent(PackagePtr &NewParent) { Parent = PackageParent(NewParent.GetRef()); }
00467 
00469         void SetParent(IRefCount<Package> *NewParent) { Parent = PackageParent(NewParent); }
00470 
00472         TrackType GetType(void);
00473 
00475         bool IsEssenceTrack(void)
00476         {
00477             TrackType ThisType = GetType();
00478 
00479             switch(ThisType)
00480             {
00481                 case TypePicture:               
00482                 case TypeSound:                 
00483                 case TypeData:                  
00484 
00485                 // DRAGONS: We currently don't treat the following as essence
00486 //              case TypeAux:                   //!< Auxiliary track
00487 //              case TypePText:                 //!< Parsed Text track
00488                     return true;
00489 
00490                 default:
00491                     return false;
00492             }
00493         }
00494 
00496         bool IsTimecodeTrack(void)
00497         {
00498             if(GetType() == TypeTimecode) return true;
00499             return false;
00500         }
00501 
00503         bool IsDMTrack(void)
00504         {
00505             if(GetType() == TypeDM) return true;
00506             return false;
00507         }
00508 
00510 
00512         static TrackPtr GetTrack(MDObjectPtr Object);
00513 
00515         static TrackPtr Parse(MDObjectPtr BaseObject);
00516 
00518 
00522         static void AddTrackType(TrackType Type, const UInt8 *Label, int CompareLength = 16);
00523 
00524     protected:
00526         static void InitTrackTypes(void);
00527     };
00528 }
00529 
00530 
00531 namespace mxflib
00532 {
00534     enum
00535     {
00536         DurationUnspecified = -1,      
00537         DurationInstantaneous = 0,     
00538     };
00539 
00541 
00542     class Package : public ObjectInterface, public RefCount<Package>
00543     {
00544     public:
00545         TrackList Tracks;                       
00546 
00547     protected:
00548         UInt32 LastTrackID;                     
00549 
00551         Package(MDObjectPtr BaseObject) : ObjectInterface(BaseObject) {}
00552 
00553     private:
00554         // Can't create from nothing
00555         Package();
00556 
00557     public:
00558         Package(std::string BaseType) : LastTrackID(0) { Object = new MDObject(BaseType); if(Object) Object->SetOuter(this); }
00559         Package(MDOTypePtr BaseType) : LastTrackID(0) { Object = new MDObject(BaseType); if(Object) Object->SetOuter(this); }
00560         Package(const UL &BaseUL) : LastTrackID(0) { Object = new MDObject(BaseUL); if(Object) Object->SetOuter(this); }
00561         Package(ULPtr &BaseUL) : LastTrackID(0) { Object = new MDObject(BaseUL); if(Object) Object->SetOuter(this); }
00562 
00564         TrackPtr AddTrack(ULPtr DataDef, UInt32 TrackNumber, Rational EditRate, std::string TrackName = "", UInt32 TrackID = 0);
00565 
00567         TrackPtr AddTrack(ULPtr DataDef, UInt32 TrackNumber, Rational EditRate, Length DefaultDuration, std::string TrackName = "", UInt32 TrackID = 0);
00568 
00570         TrackPtr AddTrack(ULPtr DataDef, UInt32 TrackNumber, std::string TrackName = "", UInt32 TrackID = 0);
00571 
00572         TrackPtr AddPictureTrack(Rational EditRate, std::string TrackName = "Picture Track", UInt32 TrackID = 0) { return AddPictureTrack(0, EditRate, TrackName, TrackID); }
00573         TrackPtr AddPictureTrack(UInt32 TrackNumber, Rational EditRate, std::string TrackName = "Picture Track", UInt32 TrackID = 0)
00574         {
00575             static const ULPtr PictureDD = new UL(TrackTypeDataDefPicture);
00576             return AddTrack(PictureDD, TrackNumber, EditRate, TrackName, TrackID);
00577         }
00578 
00579         TrackPtr AddSoundTrack(Rational EditRate, std::string TrackName = "Sound Track", UInt32 TrackID = 0) { return AddSoundTrack(0, EditRate, TrackName, TrackID); }
00580         TrackPtr AddSoundTrack(UInt32 TrackNumber, Rational EditRate, std::string TrackName = "Sound Track", UInt32 TrackID = 0)
00581         {
00582             static const ULPtr SoundDD = new UL(TrackTypeDataDefSound);
00583             return AddTrack(SoundDD, TrackNumber, EditRate, TrackName, TrackID);
00584         }
00585 
00586         TrackPtr AddDataTrack(Rational EditRate, std::string TrackName = "Data Track", UInt32 TrackID = 0) { return AddDataTrack(0, EditRate, TrackName, TrackID); }
00587         TrackPtr AddDataTrack(UInt32 TrackNumber, Rational EditRate, std::string TrackName = "Data Track", UInt32 TrackID = 0)
00588         {
00589             static const ULPtr DataDD = new UL(TrackTypeDataDefData);
00590             return AddTrack(DataDD, TrackNumber, EditRate, TrackName, TrackID);
00591         }
00592 
00593         TrackPtr AddTimecodeTrack(Rational EditRate, std::string TrackName = "Timecode Track", UInt32 TrackID = 0) { return AddTimecodeTrack(0, EditRate, TrackName, TrackID); }
00594         TrackPtr AddTimecodeTrack(UInt32 TrackNumber, Rational EditRate, std::string TrackName = "Timecode Track", UInt32 TrackID = 0)
00595         {
00596             static const ULPtr TCDD = new UL(TrackTypeDataDefTimecode12M);
00597             return AddTrack(TCDD, TrackNumber, EditRate, TrackName, TrackID);
00598         }
00599 
00601         TrackPtr AddDMTrack(Rational EditRate, Length DefaultDuration, std::string TrackName = "Descriptive Track", UInt32 TrackID = 0) { return AddDMTrack(0, EditRate, DefaultDuration, TrackName, TrackID); }
00602         TrackPtr AddDMTrack(UInt32 TrackNumber, Rational EditRate, Length DefaultDuration, std::string TrackName = "Descriptive Track", UInt32 TrackID = 0)
00603         {
00604             static const ULPtr TCDM = new UL(TrackTypeDataDefDM);
00605             return AddTrack(TCDM, TrackNumber, EditRate, DefaultDuration, TrackName, TrackID);
00606         }
00607 
00609         TrackPtr AddDMTrack(Rational EditRate, std::string TrackName = "Descriptive Track", UInt32 TrackID = 0) { return AddDMTrack(0, EditRate, TrackName, TrackID); }
00610         TrackPtr AddDMTrack(UInt32 TrackNumber, Rational EditRate, std::string TrackName = "Descriptive Track", UInt32 TrackID = 0)
00611         {
00612             static const ULPtr TCDM = new UL(TrackTypeDataDefDM);
00613             return AddTrack(TCDM, TrackNumber, EditRate, TrackName, TrackID);
00614         }
00615 
00617         TrackPtr AddDMTrack(std::string TrackName = "Descriptive Track", UInt32 TrackID = 0) { return AddDMTrack(0, TrackName, TrackID); }
00618         TrackPtr AddDMTrack(UInt32 TrackNumber, std::string TrackName = "Descriptive Track", UInt32 TrackID = 0)
00619         {
00620             static const ULPtr TCDM = new UL(TrackTypeDataDefDM);
00621             return AddTrack(TCDM, TrackNumber, TrackName, TrackID);
00622         }
00623 
00625         void RemoveTrack(TrackPtr &Track);
00626 
00628         void UpdateDurations(void);
00629 
00631 
00633         static PackagePtr GetPackage(MDObjectPtr Object);
00634 
00636         static PackagePtr Parse(MDObjectPtr BaseObject);
00637     };
00638 }
00639 
00640 
00641 namespace mxflib
00642 {
00644     class Metadata : public ObjectInterface, public RefCount<Metadata>
00645     {
00646     public:
00647         PackageList Packages;                       
00648 
00649     protected:
00650         std::string ModificationTime;               
00651 
00653         Metadata(MDObjectPtr BaseObject) : ObjectInterface(BaseObject) {}
00654 
00655     public:
00656         Metadata();
00657         Metadata(std::string TimeStamp);
00658         void Init(void);
00659 
00660         // Update the modification time for this file and any new packages
00661         void SetTime(void) { ModificationTime = Now2String(); }
00662         void SetTime(std::string TimeStamp) { ModificationTime = TimeStamp; }
00663 
00665         void AddDMScheme(ULPtr Scheme)
00666         {
00667             DataChunk SchemeValue;
00668             SchemeValue.Set(16, Scheme->GetValue());
00669 
00670             // Get a list of current schemes
00671             MDObjectPtr SchemeList = Object->Child(DMSchemes_UL);
00672 
00673             // Scan the list to see if we already have this one
00674             MDObjectULList::iterator it = SchemeList->begin();
00675             while(it != SchemeList->end())
00676             {
00677                 if(SchemeValue == *((*it).second->PutData())) return;
00678                 it++;
00679             }
00680 
00681             // New scheme, so add it
00682             Object->Child(DMSchemes_UL)->AddChild()->SetValue(SchemeValue);
00683         }
00684 
00686 
00687         void AddEssenceType(ULPtr ECType) { AddEssenceType(*ECType); };
00688 
00690 
00691         void AddEssenceType(const UL &ECType)
00692         {
00693             DataChunk ECTypeValue;
00694             ECTypeValue.Set(16, ECType.GetValue());
00695 
00696             // Get a list of known containers
00697             MDObjectPtr ECTypeList = Object->Child(EssenceContainers_UL);
00698 
00699             // Scan the list to see if we already have this type
00700             MDObjectULList::iterator it = ECTypeList->begin();
00701             while(it != ECTypeList->end())
00702             {
00703                 if(ECTypeValue == *((*it).second->PutData())) return;
00704                 it++;
00705             }
00706 
00707             // New type, so add it
00708             Object->Child(EssenceContainers_UL)->AddChild()->SetValue(ECTypeValue);
00709         }
00710 
00712         void SetOP(const UL &OP)
00713         {
00714             MDObjectPtr Ptr = Object->AddChild(OperationalPattern_UL);
00715             Ptr->ReadValue(OP.GetValue(), 16);
00716         }
00717 
00719         void SetOP(ULPtr OP) { SetOP(*OP); }
00720 
00721         // Add a material package to the metadata
00722         PackagePtr AddMaterialPackage(UMIDPtr PackageUMID) { return AddPackage(MaterialPackage_UL, "", PackageUMID); }
00723         PackagePtr AddMaterialPackage(std::string PackageName = "", UMIDPtr PackageUMID = NULL) { return AddPackage(MaterialPackage_UL, PackageName, PackageUMID); }
00724 
00725         // Add a top-level file package to the metadata
00726         PackagePtr AddFilePackage(UInt32 BodySID, UMIDPtr PackageUMID) { return AddPackage(SourcePackage_UL, "", PackageUMID, BodySID); }
00727         PackagePtr AddFilePackage(UInt32 BodySID, std::string PackageName = "", UMIDPtr PackageUMID = NULL) { return AddPackage(SourcePackage_UL, PackageName, PackageUMID, BodySID); }
00728 
00729         // Add a lower-level source package to the metadata
00730         PackagePtr AddSourcePackage(UInt32 BodySID, UMIDPtr PackageUMID) { return AddPackage(SourcePackage_UL, "", PackageUMID, BodySID); }
00731         PackagePtr AddSourcePackage(UInt32 BodySID, std::string PackageName = "", UMIDPtr PackageUMID = NULL) { return AddPackage(SourcePackage_UL, PackageName, PackageUMID, BodySID); }
00732 
00734         bool AddEssenceContainerData(UMIDPtr TheUMID, UInt32 BodySID, UInt32 IndexSID = 0);
00735 
00737         void SetPrimaryPackage(PackagePtr Package) { SetPrimaryPackage(Package->Object); }
00738 
00740         void SetPrimaryPackage(MDObjectPtr Package)
00741         {
00742             MDObjectPtr Ptr = Object->Child(PrimaryPackage_UL);
00743             if(!Ptr) Ptr = Object->AddChild(PrimaryPackage_UL);
00744             Ptr->MakeRef(Package);
00745         }
00746 
00748         PackagePtr GetPrimaryPackage(void);
00749 
00751         bool UpdateGenerations(MDObjectPtr Ident, std::string UpdateTime = "");
00752 
00754 
00756         static MetadataPtr GetMetadata(MDObjectPtr Object);
00757 
00759         static MetadataPtr Parse(MDObjectPtr BaseObject);
00760 
00761     private:
00763         PackagePtr AddPackage(const UL &PackageType, std::string PackageName, UMIDPtr PackageUMID, UInt32 BidySID = 0);
00764 
00766         bool UpdateGenerations_Internal(MDObjectPtr Obj, UUIDPtr ThisGeneration);
00767 
00769         void ClearModified_Internal(MDObjectPtr Obj);
00770     };
00771 }
00772 
00773 
00774 
00775 
00776 // These simple inlines need to be defined after the classes
00777 namespace mxflib
00778 {
00779 inline MDObjectPtr PackagePtr::operator[](const char *ChildName) { return GetPtr()->Object[ChildName]; }
00780 inline MDObjectPtr PackagePtr::operator[](MDOTypePtr ChildType) { return GetPtr()->Object[ChildType]; }
00781 inline MDObjectPtr PackagePtr::operator[](const UL &ChildType) { return GetPtr()->Object[ChildType]; }
00782 inline MDObjectPtr PackagePtr::operator[](ULPtr &ChildType) { return GetPtr()->Object[*ChildType]; }
00783 inline MDObjectPtr PackageParent::operator[](const char *ChildName) { return GetPtr()->Object[ChildName]; }
00784 inline MDObjectPtr PackageParent::operator[](MDOTypePtr ChildType) { return GetPtr()->Object[ChildType]; }
00785 inline MDObjectPtr PackageParent::operator[](const UL &ChildType) { return GetPtr()->Object[ChildType]; }
00786 inline MDObjectPtr PackageParent::operator[](ULPtr &ChildType) { return GetPtr()->Object[*ChildType]; }
00787 inline MDObjectPtr TrackPtr::operator[](const char *ChildName) { return GetPtr()->Object[ChildName]; }
00788 inline MDObjectPtr TrackPtr::operator[](MDOTypePtr ChildType) { return GetPtr()->Object[ChildType]; }
00789 inline MDObjectPtr TrackPtr::operator[](const UL &ChildType) { return GetPtr()->Object[ChildType]; }
00790 inline MDObjectPtr TrackPtr::operator[](ULPtr &ChildType) { return GetPtr()->Object[*ChildType]; }
00791 inline MDObjectPtr TrackParent::operator[](const char *ChildName) { return GetPtr()->Object[ChildName]; }
00792 inline MDObjectPtr TrackParent::operator[](MDOTypePtr ChildType) { return GetPtr()->Object[ChildType]; }
00793 inline MDObjectPtr TrackParent::operator[](const UL &ChildType) { return GetPtr()->Object[ChildType]; }
00794 inline MDObjectPtr TrackParent::operator[](ULPtr &ChildType) { return GetPtr()->Object[*ChildType]; }
00795 inline MDObjectPtr SourceClipPtr::operator[](const char *ChildName) { return GetPtr()->Object[ChildName]; }
00796 inline MDObjectPtr SourceClipPtr::operator[](MDOTypePtr ChildType) { return GetPtr()->Object[ChildType]; }
00797 inline MDObjectPtr SourceClipPtr::operator[](const UL &ChildType) { return GetPtr()->Object[ChildType]; }
00798 inline MDObjectPtr SourceClipPtr::operator[](ULPtr &ChildType) { return GetPtr()->Object[*ChildType]; }
00799 inline MDObjectPtr DMSourceClipPtr::operator[](const char *ChildName) { return GetPtr()->Object[ChildName]; }
00800 inline MDObjectPtr DMSourceClipPtr::operator[](MDOTypePtr ChildType) { return GetPtr()->Object[ChildType]; }
00801 inline MDObjectPtr DMSourceClipPtr::operator[](const UL &ChildType) { return GetPtr()->Object[ChildType]; }
00802 inline MDObjectPtr DMSourceClipPtr::operator[](ULPtr &ChildType) { return GetPtr()->Object[*ChildType]; }
00803 inline MDObjectPtr MetadataPtr::operator[](const char *ChildName) { return GetPtr()->Object[ChildName]; }
00804 inline MDObjectPtr MetadataPtr::operator[](MDOTypePtr ChildType) { return GetPtr()->Object[ChildType]; }
00805 inline MDObjectPtr MetadataPtr::operator[](const UL &ChildType) { return GetPtr()->Object[ChildType]; }
00806 inline MDObjectPtr MetadataPtr::operator[](ULPtr &ChildType) { return GetPtr()->Object[*ChildType]; }
00807 inline MDObjectPtr DMSegmentPtr::operator[](const char *ChildName) { return GetPtr()->Object[ChildName]; }
00808 inline MDObjectPtr DMSegmentPtr::operator[](MDOTypePtr ChildType) { return GetPtr()->Object[ChildType]; }
00809 inline MDObjectPtr DMSegmentPtr::operator[](const UL &ChildType) { return GetPtr()->Object[ChildType]; }
00810 inline MDObjectPtr DMSegmentPtr::operator[](ULPtr &ChildType) { return GetPtr()->Object[*ChildType]; }
00811 }
00812 
00813 #endif // MXFLIB__METADATA_H

Generated on Mon Apr 2 15:20:53 2007 for MXFLib by  doxygen 1.5.1-p1