working multi-dict
[asdcplib.git] / src / h__Reader.cpp
index d329e603bc474bed6023f9a4da15c4060b39fe4c..7a1dd12ea43e1dde757d8a99124785866bb73b19 100755 (executable)
@@ -1,5 +1,5 @@
 /*
-Copyright (c) 2004-2006, John Hurst
+Copyright (c) 2004-2009, John Hurst
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
@@ -36,7 +36,8 @@ using namespace ASDCP;
 using namespace ASDCP::MXF;
 
 //
-ASDCP::h__Reader::h__Reader() : m_EssenceStart(0)
+ASDCP::h__Reader::h__Reader(const Dictionary& d) :
+  m_HeaderPart(m_Dict), m_BodyPart(m_Dict), m_FooterPart(m_Dict), m_Dict(&d), m_EssenceStart(0)
 {
 }
 
@@ -61,8 +62,8 @@ ASDCP::h__Reader::InitInfo()
   InterchangeObject* Object;
 
   m_Info.LabelSetType = LS_MXF_UNKNOWN;
-  UL OPAtomUL(Dict::ul(MDD_OPAtom));
-  UL Interop_OPAtomUL(Dict::ul(MDD_MXFInterop_OPAtom));
+  UL OPAtomUL(m_Dict->ul(MDD_OPAtom));
+  UL Interop_OPAtomUL(m_Dict->ul(MDD_MXFInterop_OPAtom));
 
   if ( m_HeaderPart.OperationalPattern == Interop_OPAtomUL )
     m_Info.LabelSetType = LS_MXF_INTEROP;
@@ -91,7 +92,7 @@ ASDCP::h__Reader::InitInfo()
       Result_t cr_result = m_HeaderPart.GetMDObjectByType(OBJ_TYPE_ARGS(CryptographicContext), &Object);
 
       if( ASDCP_SUCCESS(cr_result) )
-       MD_to_CryptoInfo((CryptographicContext*)Object, m_Info);
+       MD_to_CryptoInfo((CryptographicContext*)Object, m_Info, *m_Dict);
     }
 
   return result;
@@ -214,8 +215,8 @@ ASDCP::h__Reader::ReadEKLVPacket(ui32_t FrameNum, ui32_t SequenceNum, ASDCP::Fra
   ui64_t PacketLength = Reader.Length();
   m_LastPosition = m_LastPosition + Reader.KLLength() + PacketLength;
 
-  if ( memcmp(Key.Value(), Dict::ul(MDD_CryptEssence), Key.Size() - 1) == 0  // ignore the stream numbers
-       || memcmp(Key.Value(), Dict::ul(MDD_MXFInterop_CryptEssence), Key.Size() - 1) == 0 )
+  if ( memcmp(Key.Value(), m_Dict->ul(MDD_CryptEssence), Key.Size() - 1) == 0  // ignore the stream numbers
+       || memcmp(Key.Value(), m_Dict->ul(MDD_MXFInterop_CryptEssence), Key.Size() - 1) == 0 )
     {
       if ( ! m_Info.EncryptedEssence )
        {
@@ -271,7 +272,7 @@ ASDCP::h__Reader::ReadEKLVPacket(ui32_t FrameNum, ui32_t SequenceNum, ASDCP::Fra
       if ( memcmp(ess_p, EssenceUL, SMPTE_UL_LENGTH - 1) != 0 ) // ignore the stream number
        {
          char strbuf[IntBufferLen];
-         const MDDEntry* Entry = Dict::FindUL(Key.Value());
+         const MDDEntry* Entry = m_Dict->FindUL(Key.Value());
          if ( Entry == 0 )
            DefaultLogSink().Warn("Unexpected Essence UL found: %s.\n", Key.EncodeString(strbuf, IntBufferLen));
          else
@@ -382,7 +383,7 @@ ASDCP::h__Reader::ReadEKLVPacket(ui32_t FrameNum, ui32_t SequenceNum, ASDCP::Fra
   else
     {
       char strbuf[IntBufferLen];
-      const MDDEntry* Entry = Dict::FindUL(Key.Value());
+      const MDDEntry* Entry = m_Dict->FindUL(Key.Value());
       if ( Entry == 0 )
         DefaultLogSink().Warn("Unexpected Essence UL found: %s.\n", Key.EncodeString(strbuf, IntBufferLen));
       else