X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2FMXF.h;h=d6e201a420a76f4bd52e300022747bd0ded226be;hb=fbdfd30bb77d37b354b19cf6cf3be72eec3bf725;hp=88fc0af69776bf83cb4eaa1f104ab7c4339d4161;hpb=dd03f3ae2c71df2c4eb89804293e621777a050cf;p=asdcplib.git diff --git a/src/MXF.h b/src/MXF.h index 88fc0af..d6e201a 100755 --- a/src/MXF.h +++ b/src/MXF.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2005-2013, John Hurst +Copyright (c) 2005-2018, John Hurst All rights reserved. Redistribution and use in source and binary forms, with or without @@ -64,15 +64,15 @@ namespace ASDCP public: // - class Pair : public Kumu::IArchive + class PartitionPair : public Kumu::IArchive { public: ui32_t BodySID; ui64_t ByteOffset; - Pair() : BodySID(0), ByteOffset(0) {} - Pair(ui32_t sid, ui64_t offset) : BodySID(sid), ByteOffset(offset) {} - virtual ~Pair() {} + PartitionPair() : BodySID(0), ByteOffset(0) {} + PartitionPair(ui32_t sid, ui64_t offset) : BodySID(sid), ByteOffset(offset) {} + virtual ~PartitionPair() {} ui32_t Size() { return sizeof(ui32_t) + sizeof(ui64_t); } @@ -99,13 +99,17 @@ namespace ASDCP }; const Dictionary*& m_Dict; - Array PairArray; + + typedef SimpleArray::iterator pair_iterator; + typedef SimpleArray::const_iterator const_pair_iterator; + + SimpleArray PairArray; RIP(const Dictionary*& d) : m_Dict(d) {} virtual ~RIP() {} virtual Result_t InitFromFile(const Kumu::FileReader& Reader); virtual Result_t WriteToFile(Kumu::FileWriter& Writer); - virtual Result_t GetPairBySID(ui32_t, Pair&) const; + virtual bool GetPairBySID(ui32_t, PartitionPair&) const; virtual void Dump(FILE* = 0); }; @@ -180,9 +184,23 @@ namespace ASDCP LocalTagEntry() { Tag.a = Tag.b = 0; } LocalTagEntry(const TagValue& tag, ASDCP::UL& ul) : Tag(tag), UL(ul) {} + bool operator<(const LocalTagEntry& rhs) const { + if ( Tag.a < rhs.Tag.a ) + { + return true; + } + + if ( Tag.a == rhs.Tag.a && Tag.b < rhs.Tag.b ) + { + return true; + } + + return false; + } + inline const char* EncodeString(char* str_buf, ui32_t buf_len) const { snprintf(str_buf, buf_len, "%02x %02x: ", Tag.a, Tag.b); - UL.EncodeString(str_buf + strlen(str_buf), buf_len - strlen(str_buf)); + UL.EncodeString(str_buf + strlen(str_buf), buf_len - (ui32_t)strlen(str_buf)); return str_buf; } @@ -227,8 +245,12 @@ namespace ASDCP public: optional_property() : m_has_value(false) {} - optional_property(const PropertyType& value) : m_property(value), m_has_value(false) {} - const optional_property& operator=(const PropertyType& rhs) { this->m_property = rhs; this->m_has_value = true; return *this; } + optional_property(const PropertyType& value) : m_property(value), m_has_value(true) {} + const optional_property& operator=(const PropertyType& rhs) { + this->m_property = rhs; + this->m_has_value = true; + return *this; + } bool operator==(const PropertyType& rhs) const { return this->m_property == rhs; } bool operator==(const optional_property& rhs) const { return this->m_property == rhs.m_property; } operator PropertyType&() { return this->m_property; } @@ -240,6 +262,30 @@ namespace ASDCP const PropertyType& const_get() const { return m_property; } }; + // wrapper object manages optional properties + template + class optional_container_property + { + PropertyType m_property; + + public: + optional_container_property() {} + optional_container_property(const PropertyType& value) : m_property(value) {} + const optional_container_property& operator=(const PropertyType& rhs) { + this->Copy(rhs.m_property); + return *this; + } + + bool operator==(const PropertyType& rhs) const { return this->m_property == rhs; } + bool operator==(const optional_property& rhs) const { return this->m_property == rhs.m_property; } + operator PropertyType&() { return this->m_property; } + void set(const PropertyType& rhs) { this->m_property = rhs; } + void reset(const PropertyType& rhs) { this->clear(); } + bool empty() const { return ! this->m_property.HasValue(); } + PropertyType& get() { return m_property; } + const PropertyType& const_get() const { return m_property; } + }; + // base class of all metadata objects // class InterchangeObject : public ASDCP::KLVPacket @@ -280,12 +326,13 @@ namespace ASDCP ui16_t Version; optional_property ObjectModelVersion; optional_property PrimaryPackage; - Batch Identifications; + Array Identifications; UUID ContentStorage; UL OperationalPattern; Batch
    EssenceContainers; Batch
      DMSchemes; optional_property > ApplicationSchemes; + optional_property > ConformsToSpecifications; Preface(const Dictionary*& d); virtual ~Preface() {} @@ -338,7 +385,7 @@ namespace ASDCP // std::list SliceOffset; // Array PosTable; - IndexEntry() : TemporalOffset(0), KeyFrameOffset(0), Flags(0), StreamOffset(0) {} + IndexEntry() : TemporalOffset(0), KeyFrameOffset(0), Flags(0x80), StreamOffset(0) {} IndexEntry(i8_t t_ofst, i8_t k_ofst, ui8_t flags, ui64_t s_ofst) : TemporalOffset(t_ofst), KeyFrameOffset(k_ofst), Flags(flags), StreamOffset(s_ofst) {} inline bool HasValue() const { return true; } @@ -360,8 +407,8 @@ namespace ASDCP ui32_t BodySID; ui8_t SliceCount; ui8_t PosTableCount; - Batch DeltaEntryArray; - Batch IndexEntryArray; + Array DeltaEntryArray; + Array IndexEntryArray; IndexTableSegment(const Dictionary*&); virtual ~IndexTableSegment(); @@ -405,6 +452,10 @@ namespace ASDCP SourcePackage* GetSourcePackage(); }; + // Searches the header object and returns the edit rate based on the contents of the + // File Package items. Logs an error message and returns false if anthing goes wrong. + bool GetEditRateFromFP(ASDCP::MXF::OP1aHeader& header, ASDCP::Rational& edit_rate); + // class OPAtomIndexFooter : public Partition {