checky
[asdcplib.git] / src / AS_DCP_TimedText.cpp
index f7d64bda3a004c2207a7200ea5983b737575874d..11995549dbb418a958e48587915c8885454abee0 100644 (file)
@@ -1,5 +1,5 @@
 /*
-Copyright (c) 2008-2011, John Hurst
+Copyright (c) 2008-2012, John Hurst
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
@@ -271,12 +271,12 @@ ASDCP::TimedText::MXFReader::h__Reader::ReadAncillaryResource(const byte_t* uuid
     {
       Array<RIP::Pair>::const_iterator pi;
       RIP::Pair TmpPair;
-      ui32_t sequence = 1;
+      ui32_t sequence = 0;
 
       // Look up the partition start in the RIP using the SID.
       // Count the sequence length in because this is the sequence
       // value needed to  complete the HMAC.
-      for ( pi = m_HeaderPart.m_RIP.PairArray.begin(); pi != m_HeaderPart.m_RIP.PairArray.end(); pi++, sequence++ )
+      for ( pi = m_HeaderPart.m_RIP.PairArray.begin(); pi != m_HeaderPart.m_RIP.PairArray.end(); ++pi, ++sequence )
        {
          if ( (*pi).BodySID == DescObject->EssenceStreamID )
            {
@@ -320,7 +320,7 @@ ASDCP::TimedText::MXFReader::h__Reader::ReadAncillaryResource(const byte_t* uuid
              // read the essence packet
              assert(m_Dict);
              if( ASDCP_SUCCESS(result) )
-               result = ReadEKLVPacket(0, 1, FrameBuf, m_Dict->ul(MDD_GenericStream_DataElement), Ctx, HMAC);
+               result = ReadEKLVPacket(0, sequence, FrameBuf, m_Dict->ul(MDD_GenericStream_DataElement), Ctx, HMAC);
            }
        }
     }
@@ -341,6 +341,36 @@ ASDCP::TimedText::MXFReader::~MXFReader()
 {
 }
 
+// Warning: direct manipulation of MXF structures can interfere
+// with the normal operation of the wrapper.  Caveat emptor!
+//
+ASDCP::MXF::OPAtomHeader&
+ASDCP::TimedText::MXFReader::OPAtomHeader()
+{
+  if ( m_Reader.empty() )
+    {
+      assert(g_OPAtomHeader);
+      return *g_OPAtomHeader;
+    }
+
+  return m_Reader->m_HeaderPart;
+}
+
+// Warning: direct manipulation of MXF structures can interfere
+// with the normal operation of the wrapper.  Caveat emptor!
+//
+ASDCP::MXF::OPAtomIndexFooter&
+ASDCP::TimedText::MXFReader::OPAtomIndexFooter()
+{
+  if ( m_Reader.empty() )
+    {
+      assert(g_OPAtomIndexFooter);
+      return *g_OPAtomIndexFooter;
+    }
+
+  return m_Reader->m_FooterPart;
+}
+
 // Open the file for reading. The file must exist. Returns error if the
 // operation cannot be completed.
 ASDCP::Result_t
@@ -647,6 +677,35 @@ ASDCP::TimedText::MXFWriter::~MXFWriter()
 {
 }
 
+// Warning: direct manipulation of MXF structures can interfere
+// with the normal operation of the wrapper.  Caveat emptor!
+//
+ASDCP::MXF::OPAtomHeader&
+ASDCP::TimedText::MXFWriter::OPAtomHeader()
+{
+  if ( m_Writer.empty() )
+    {
+      assert(g_OPAtomHeader);
+      return *g_OPAtomHeader;
+    }
+
+  return m_Writer->m_HeaderPart;
+}
+
+// Warning: direct manipulation of MXF structures can interfere
+// with the normal operation of the wrapper.  Caveat emptor!
+//
+ASDCP::MXF::OPAtomIndexFooter&
+ASDCP::TimedText::MXFWriter::OPAtomIndexFooter()
+{
+  if ( m_Writer.empty() )
+    {
+      assert(g_OPAtomIndexFooter);
+      return *g_OPAtomIndexFooter;
+    }
+
+  return m_Writer->m_FooterPart;
+}
 
 // Open the file for writing. The file must not exist. Returns error if
 // the operation cannot be completed.