/*
-Copyright (c) 2005-2013, John Hurst
+Copyright (c) 2005-2014, John Hurst
All rights reserved.
Redistribution and use in source and binary forms, with or without
typedef ASDCP::MXF::InterchangeObject* (*MXFObjectFactory_t)(const Dictionary*&);
//
- void SetObjectFactory(UL label, MXFObjectFactory_t factory);
+ void SetObjectFactory(const UL& label, MXFObjectFactory_t factory);
//
InterchangeObject* CreateObject(const Dictionary*& Dict, const UL& label);
virtual void Dump(FILE* = 0);
};
+ // wrapper object manages optional properties
+ template <class PropertyType>
+ class optional_property
+ {
+ PropertyType m_property;
+ bool m_has_value;
+ public:
+ optional_property() : m_has_value(false) {}
+ optional_property(const PropertyType& value) : m_property(value), m_has_value(false) {}
+ const optional_property<PropertyType>& 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<PropertyType>& rhs) const { return this->m_property == rhs.m_property; }
+ operator PropertyType&() { return this->m_property; }
+ void set(const PropertyType& rhs) { this->m_property = rhs; this->m_has_value = true; }
+ void set_has_value(bool has_value = true) { this->m_has_value = has_value; }
+ void reset(const PropertyType& rhs) { this->m_has_value = false; }
+ bool empty() const { return ! m_has_value; }
+ PropertyType& get() { return m_property; }
+ const PropertyType& const_get() const { return m_property; }
+ };
+
+ // base class of all metadata objects
//
class InterchangeObject : public ASDCP::KLVPacket
{
const Dictionary*& m_Dict;
IPrimerLookup* m_Lookup;
UUID InstanceUID;
- UUID GenerationUID;
+ optional_property<UUID> GenerationUID;
InterchangeObject(const Dictionary*& d) : m_Dict(d), m_Lookup(0) {}
virtual ~InterchangeObject() {}
const Dictionary*& m_Dict;
Kumu::Timestamp LastModifiedDate;
ui16_t Version;
- ui32_t ObjectModelVersion;
- UUID PrimaryPackage;
+ optional_property<ui32_t> ObjectModelVersion;
+ optional_property<UUID> PrimaryPackage;
Batch<UUID> Identifications;
UUID ContentStorage;
UL OperationalPattern;
Batch<UL> EssenceContainers;
Batch<UL> DMSchemes;
+ optional_property<Batch<UL> > ApplicationSchemes;
Preface(const Dictionary*& d);
virtual ~Preface() {}
//
class IndexTableSegment : public InterchangeObject
{
+ IndexTableSegment();
ASDCP_NO_COPY_CONSTRUCT(IndexTableSegment);
public:
ui8_t Slice;
ui32_t ElementData;
- DeltaEntry() : PosTableIndex(-1), Slice(0), ElementData(0) {}
+ DeltaEntry() : PosTableIndex(0), Slice(0), ElementData(0) {}
DeltaEntry(i8_t pos, ui8_t slice, ui32_t data) : PosTableIndex(pos), Slice(slice), ElementData(data) {}
inline bool HasValue() const { return true; }
ui32_t ArchiveLength() const { return sizeof(ui32_t) + 2; }
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
{
ui32_t m_BytesPerEditUnit;
Rational m_EditRate;
ui32_t m_BodySID;
+ IndexTableSegment::DeltaEntry m_DefaultDeltaEntry;
ASDCP_NO_COPY_CONSTRUCT(OPAtomIndexFooter);
OPAtomIndexFooter();
virtual Result_t Lookup(ui32_t frame_num, IndexTableSegment::IndexEntry&) const;
virtual void PushIndexEntry(const IndexTableSegment::IndexEntry&);
+ virtual void SetDeltaParams(const IndexTableSegment::DeltaEntry&);
virtual void SetIndexParamsCBR(IPrimerLookup* lookup, ui32_t size, const Rational& Rate);
virtual void SetIndexParamsVBR(IPrimerLookup* lookup, const Rational& Rate, Kumu::fpos_t offset);
};
}
};
- typedef std::map<const std::string, const UL, ci_comp> mca_label_map_t;
- bool decode_mca_string(const std::string& s, const mca_label_map_t& labels, const Dictionary& dict, const std::string& language, InterchangeObject_list_t&, ui32_t&);
+ struct label_traits
+ {
+ const std::string tag_name;
+ const bool requires_prefix;
+ const UL ul;
+
+ label_traits(const std::string& tag_name, const bool requires_prefix, const UL ul) :
+ tag_name(tag_name), requires_prefix(requires_prefix), ul(ul) { }
+ };
+
+ typedef std::map<const std::string, const label_traits, ci_comp> mca_label_map_t;
+
+ bool decode_mca_string(const std::string& s, const mca_label_map_t& labels,
+ const Dictionary*& dict, const std::string& language, InterchangeObject_list_t&, ui32_t&);
//
class ASDCP_MCAConfigParser : public InterchangeObject_list_t
public:
ASDCP_MCAConfigParser(const Dictionary*&);
- bool DecodeString(const std::string& s, const std::string& language = "en");
+ bool DecodeString(const std::string& s, const std::string& language = "en-US");
// Valid only after a successful call to DecodeString
ui32_t ChannelCount() const;