Denis' bug fixes
[asdcplib.git] / src / AS_DCP_internal.h
index 15890a77917f6f82adb79a906976d7a8d2727e99..177a74da00f6d0291e088923beefa8c8a0e09a4f 100755 (executable)
@@ -29,14 +29,16 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     \brief   AS-DCP library, non-public common elements
 */
 
-#ifndef _AS_DCP_INTERNAL_H__
-#define _AS_DCP_INTERNAL_H__
+#ifndef _AS_DCP_INTERNAL_H_
+#define _AS_DCP_INTERNAL_H_
 
-#include "AS_DCP_system.h"
+#include <KM_platform.h>
+#include <KM_util.h>
+#include <KM_log.h>
 #include "Metadata.h"
-#include "hex_utils.h"
 
-using namespace std;
+using Kumu::DefaultLogSink;
+// using namespace std;
 using namespace ASDCP;
 using namespace ASDCP::MXF;
 
@@ -45,7 +47,6 @@ using namespace ASDCP::MXF;
 namespace ASDCP
 {
   // constant values used to calculate KLV and EKLV packet sizes
-
   static const ui32_t klv_cryptinfo_size =
     MXF_BER_LENGTH
     + UUIDlen /* ContextID */
@@ -75,17 +76,6 @@ namespace ASDCP
       return plaintext_offset + block_size + (CBC_BLOCK_SIZE * 3);
     }
 
-  // Interop labels
-
-  static byte_t OPAtom_Data[SMPTE_UL_LENGTH] =
-  { 0x06, 0x0e, 0x2b, 0x34, 0x04, 0x01, 0x01, 0x01,
-    0x0d, 0x01, 0x02, 0x01, 0x10, 0x00, 0x00, 0x00 };
-  static UL OPAtomUL(OPAtom_Data);
-
-  static const byte_t CryptEssenceUL_Data[SMPTE_UL_LENGTH] =
-  { 0x06, 0x0e, 0x2b, 0x34, 0x02, 0x04, 0x01, 0x07,
-    0x0d, 0x01, 0x03, 0x01, 0x02, 0x7e, 0x01, 0x00 };
-
   // the check value for EKLV packets
   // CHUKCHUKCHUKCHUK
   static const byte_t ESV_CheckValue[CBC_BLOCK_SIZE] =
@@ -106,19 +96,19 @@ namespace ASDCP
       ASDCP_NO_COPY_CONSTRUCT(h__Reader);
 
     public:
-      FileReader         m_File;
+      Kumu::FileReader   m_File;
       OPAtomHeader       m_HeaderPart;
       Partition          m_BodyPart;
       OPAtomIndexFooter  m_FooterPart;
       ui64_t             m_EssenceStart;
       WriterInfo         m_Info;
       ASDCP::FrameBuffer m_CtFrameBuf;
-      fpos_t             m_LastPosition;
+      Kumu::fpos_t       m_LastPosition;
 
       h__Reader();
       virtual ~h__Reader();
 
-      Result_t InitInfo(WriterInfo& Info);
+      Result_t InitInfo();
       Result_t OpenMXFRead(const char* filename);
       Result_t InitMXFIndex();
       Result_t ReadEKLVPacket(ui32_t FrameNum, ASDCP::FrameBuffer& FrameBuf,
@@ -168,7 +158,7 @@ namespace ASDCP
       ASDCP_NO_COPY_CONSTRUCT(h__Writer);
 
     public:
-      FileWriter         m_File;
+      Kumu::FileWriter   m_File;
       ui32_t             m_HeaderSize;
       OPAtomHeader       m_HeaderPart;
       Partition          m_BodyPart;
@@ -188,6 +178,7 @@ namespace ASDCP
       SourceClip*        m_FPClip;                     //! File Package SourceClip for each essence stream 
 
       FileDescriptor*    m_EssenceDescriptor;
+      std::list<FileDescriptor*> m_EssenceSubDescriptorList;
 
       ui32_t             m_FramesWritten;
       ui64_t             m_StreamOffset;
@@ -228,29 +219,10 @@ namespace ASDCP
       Result_t TestValues(const ASDCP::FrameBuffer&, byte_t* AssetID, ui32_t sequence, HMACContext* HMAC);
     };
 
-  //
-  class KLVReader
-    {
-      byte_t m_Key[32];
-      ui64_t m_Length;
-      ui32_t m_BERLength;
-      ui32_t m_HeaderLength;
-
-      ASDCP_NO_COPY_CONSTRUCT(KLVReader);
-
-    public:
-      KLVReader() : m_Length(0), m_BERLength(0), m_HeaderLength(0) {}
-      ~KLVReader() {}
-
-      inline const byte_t* Key() { return m_Key; }
-      inline const ui64_t  Length() { return m_Length; }
-      inline const ui64_t  KLLength() { return m_BERLength + SMPTE_UL_LENGTH; }
-      Result_t ReadKLFromFile(ASDCP::FileReader& Reader);
-    };
 
 } // namespace ASDCP
 
-#endif // _AS_DCP_INTERNAL_H__
+#endif // _AS_DCP_INTERNAL_H_
 
 
 //