oi
authorjhurst <jhurst@cinecert.com>
Mon, 18 May 2009 16:24:44 +0000 (16:24 +0000)
committerjhurst <>
Mon, 18 May 2009 16:24:44 +0000 (16:24 +0000)
src/AS_DCP_MXF.cpp
src/Dict.cpp
src/KLV.h
src/MDD.cpp
src/MDD.h
src/MXF.cpp
src/asdcp-test.cpp

index 1e0e2f8288a123d99e34c259fc1f98e88a320d1f..f8a415b67483b6102edb681eb28f7e4d982657c8 100755 (executable)
@@ -163,8 +163,7 @@ ASDCP::MD_to_CryptoInfo(CryptographicContext* InfoObj, WriterInfo& Info, const D
 ASDCP::Result_t
 ASDCP::EssenceType(const char* filename, EssenceType_t& type)
 {
-  // TODO
-  Dictionary m_Dict;
+  const Dictionary& m_Dict = DefaultCompositeDict();
 
   ASDCP_TEST_NULL_STR(filename);
   Kumu::FileReader   Reader;
index b6b31f815f12e81be909fe154299b14740414ed5..deb05d89895bf384292b2c271d9ad4f183cc9e6b 100755 (executable)
@@ -33,41 +33,33 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include "KM_mutex.h"
 #include "KLV.h"
 #include "MDD.cpp"
-#include <map>
-static Kumu::Mutex s_Lock;
-static bool    s_md_init = false;
-static std::map<ASDCP::UL, ui32_t> s_md_lookup;
 
 //------------------------------------------------------------------------------------------
 
-static ASDCP::Dictionary s_SMPTEDict;
-static ASDCP::Dictionary s_InteropDict;
-static ASDCP::Dictionary s_CompositeDict;
-
-const ASDCP::Dictionary&
-ASDCP::DefaultSMPTEDict() { return s_SMPTEDict; }
+//static ASDCP::Dictionary s_SMPTEDict;
+//static ASDCP::Dictionary s_InteropDict;
 
 const ASDCP::Dictionary&
-ASDCP::DefaultInteropDict() { return s_InteropDict; }
+ASDCP::DefaultSMPTEDict() {
+  // return s_SMPTEDict;
+  return DefaultCompositeDict();
+}
 
 const ASDCP::Dictionary&
-ASDCP::DefaultCompositeDict() { return s_CompositeDict; }
-
-
-// singleton wrapper
-#if 0
-//
-const ASDCP::MDDEntry&
-ASDCP::Dict::Type(MDD_t type_id)
-{
-  return s_MDD_Table[type_id];
+ASDCP::DefaultInteropDict() {
+  // return s_InteropDict;
+  return DefaultCompositeDict();
 }
 
+//
+//
+static ASDCP::Dictionary s_CompositeDict;
+static Kumu::Mutex s_Lock;
+static bool s_md_init = false;
 
 //
-const ASDCP::MDDEntry*
-ASDCP::Dict::FindUL(const byte_t* ul_buf)
+const ASDCP::Dictionary&
+ASDCP::DefaultCompositeDict()
 {
   if ( ! s_md_init )
     {
@@ -75,31 +67,80 @@ ASDCP::Dict::FindUL(const byte_t* ul_buf)
 
       if ( ! s_md_init )
        {
-         for ( ui32_t x = 0; x < s_MDD_Table_size; x++ )
-           s_md_lookup.insert(std::map<UL, ui32_t>::value_type(UL(s_MDD_Table[x].ul), x));
+         for ( ui32_t x = 0; x < ASDCP::MDD_Table_size; x++ )
+           s_CompositeDict.AddEntry(s_MDD_Table[x], x);
+         //        s_md_lookup.insert(std::map<UL, ui32_t>::value_type(UL(s_MDD_Table[x].ul), x));
 
          s_md_init = true;
        }
     }
 
-  std::map<UL, ui32_t>::iterator i = s_md_lookup.find(UL(ul_buf));
+  return s_CompositeDict;
+}
+
+//------------------------------------------------------------------------------------------
+//
+
+ASDCP::Dictionary::Dictionary() {}
+ASDCP::Dictionary::~Dictionary() {}
+
+
+//
+bool
+ASDCP::Dictionary::AddEntry(const MDDEntry& Entry, ui32_t index)
+{
+  m_MDD_Table[index] = Entry;
+  m_md_lookup.insert(std::map<UL, ui32_t>::value_type(UL(Entry.ul), index));
+  return true;
+}
+
+//
+const ASDCP::MDDEntry&
+ASDCP::Dictionary::Type(MDD_t type_id) const
+{
+  return m_MDD_Table[type_id];
+}
+
+//
+const ASDCP::MDDEntry*
+ASDCP::Dictionary::FindUL(const byte_t* ul_buf) const
+{
+  std::map<UL, ui32_t>::const_iterator i = m_md_lookup.find(UL(ul_buf));
   
-  if ( i == s_md_lookup.end() )
+  if ( i == m_md_lookup.end() )
     {
       byte_t tmp_ul[SMPTE_UL_LENGTH];
       memcpy(tmp_ul, ul_buf, SMPTE_UL_LENGTH);
       tmp_ul[SMPTE_UL_LENGTH-1] = 0;
 
-      i = s_md_lookup.find(UL(tmp_ul));
+      i = m_md_lookup.find(UL(tmp_ul));
 
-      if ( i == s_md_lookup.end() )
+      if ( i == m_md_lookup.end() )
        return 0;
     }
 
-  return &s_MDD_Table[(*i).second];
+  return &m_MDD_Table[(*i).second];
+}
+
+//
+void
+ASDCP::Dictionary::Dump(FILE* stream) const
+{
+  if ( stream == 0 )
+    stream = stderr;
+
+  MDD_t di = (MDD_t)0;
+  char     str_buf[64];
+
+  while ( di < MDD_Max )
+    {
+      MDDEntry TmpType = m_MDD_Table[di];
+      UL TmpUL(TmpType.ul);
+      fprintf(stream, "%s: %s\n", TmpUL.EncodeString(str_buf, 64), TmpType.name);
+      di = (MDD_t)(di + 1);
+    }
 }
 
-#endif
 //
 // end Dict.cpp
 //
index e9d0374c430f1582a4ec4cd2c216b032103c8aaa..1a5c298bdbc9baa33ad820390bb9fdb214832349 100755 (executable)
--- a/src/KLV.h
+++ b/src/KLV.h
@@ -36,6 +36,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include <KM_memio.h>
 #include "AS_DCP.h"
 #include "MDD.h"
+#include <map>
 
 
 namespace ASDCP
@@ -138,20 +139,17 @@ inline const char* ui64sz(ui64_t i, char* buf)
     {
     public:
 #if 0
-      static const MDDEntry* FindUL(const byte_t*);
       static const MDDEntry* FindName(const char*);
       static const MDDEntry& Type(MDD_t type_id);
       static bool            Replace(const MDDEntry& Entry);
       static void            Restore(const byte_t* ul);
       static void            RestoreAll();
-
-      inline static const byte_t* ul(MDD_t type_id) {
-       return Type(type_id).ul;
-      }
 #endif
 
     private:
-      //      Dictionary* m_Dict;
+      std::map<ASDCP::UL, ui32_t> m_md_lookup;
+      MDDEntry m_MDD_Table[ASDCP::MDD_Table_size];
+
       ASDCP_NO_COPY_CONSTRUCT(Dictionary);
 
 
@@ -159,13 +157,16 @@ inline const char* ui64sz(ui64_t i, char* buf)
       Dictionary();
       ~Dictionary();
 
+      bool AddEntry(const MDDEntry& Entry, ui32_t index);
+
       const MDDEntry* FindUL(const byte_t*) const;
+      const MDDEntry& Type(MDD_t type_id) const;
 
       inline const byte_t* ul(MDD_t type_id) const {
        return Type(type_id).ul;
       }
 
-      const MDDEntry& Type(MDD_t type_id) const;
+      void Dump(FILE* = 0) const;
     };
 
 
index 4c7fa275b1e8a361f9eaf63c784190840b429a39..9ddca068171c0074e89e7368a81ed05fd4f0bd85 100644 (file)
@@ -858,8 +858,6 @@ static const ASDCP::MDDEntry s_MDD_Table[] = {
   { {0}, {0}, false, 0 }
 };
 
-const ui32_t s_MDD_Table_size = 273;
-
 //
 // end MDD.cpp
 //
index b0bac3cad0713a5c6a7a4a0babc0a34d5beea2a4..758096f883c3bf3f6d3c976bfc4e4bb3c37a873c 100755 (executable)
--- a/src/MDD.h
+++ b/src/MDD.h
@@ -310,6 +310,9 @@ namespace ASDCP {
         MDD_GenericDescriptor_MXFInterop_SubDescriptors,  // 272
        MDD_Max
     }; // enum MDD_t
+
+    const ui32_t MDD_Table_size = 273;
 } // namespaceASDCP
 
 
index bf8b0491774947cb0dade00854e72462a4d924ac..9d20dcdab3e7c08e3aa3b2df4a4576e8e25fc9b4 100755 (executable)
@@ -1382,9 +1382,6 @@ ASDCP::MXF::SetObjectFactory(ASDCP::UL label, ASDCP::MXF::MXFObjectFactory_t fac
 ASDCP::MXF::InterchangeObject*
 ASDCP::MXF::CreateObject(const Dictionary& Dict, const UL& label)
 {
-  if ( label == 0 )
-    return 0;
-
   if ( ! s_TypesInit )
     {
       Kumu::AutoMutex BlockLock(s_InitLock);
@@ -1396,7 +1393,7 @@ ASDCP::MXF::CreateObject(const Dictionary& Dict, const UL& label)
        }
     }
 
-  FLi_t i = s_FactoryList.find(label);
+  FLi_t i = s_FactoryList.find(label.Value());
 
   if ( i == s_FactoryList.end() )
     return new InterchangeObject(Dict);
index 5b1167c6fa63ab33eaf6be774db13721cbb5083e..9397c50e64ceda5ee2a14364025c8a9b2519c91c 100755 (executable)
@@ -1737,15 +1737,15 @@ show_file_info(CommandOptions& Options)
 
       if ( ASDCP_SUCCESS(result) )
        {
-         TestHeader.Partition::Dump();
+         TestHeader.Partition::Dump(stdout);
 
          if ( MXF::Identification* ID = TestHeader.GetIdentification() )
-           ID->Dump();
+           ID->Dump(stdout);
          else
            fputs("File contains no Identification object.\n", stdout);
 
          if ( MXF::SourcePackage* SP = TestHeader.GetSourcePackage() )
-           SP->Dump();
+           SP->Dump(stdout);
          else
            fputs("File contains no SourcePackage object.\n", stdout);
        }
@@ -1851,20 +1851,13 @@ main(int argc, const char** argv)
       for ( ui32_t i = 0; i < Options.file_count && ASDCP_SUCCESS(result); i++ )
        result = digest_file(Options.filenames[i]);
     }
-#if 0
   else if ( Options.mode == MMT_UL_LIST )
     {
-      MDD_t di = (MDD_t)0;
-
-      while ( di < MDD_Max )
-       {
-         MDDEntry TmpType = Dict::Type(di);
-         UL TmpUL(TmpType.ul);
-         fprintf(stdout, "%s: %s\n", TmpUL.EncodeString(str_buf, 64), TmpType.name);
-         di = (MDD_t)(di + 1);
-       }
+      if ( Options.use_smpte_labels )
+       DefaultSMPTEDict().Dump(stdout);
+      else
+       DefaultInteropDict().Dump(stdout);
     }
-#endif
   else if ( Options.mode == MMT_EXTRACT )
     {
       EssenceType_t EssenceType;