Merge branch 'master' into 1.0
[libdcp.git] / asdcplib / src / h__Writer.cpp
index 5d3a1d5ab6a8a393ea0a1fbc55c14d55269fcafc..d743e300c0f7e6298e7db6f0239c2a35b8987dc1 100755 (executable)
@@ -32,6 +32,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include "AS_DCP_internal.h"
 #include "KLV.h"
 
+using std::cout;
 using namespace ASDCP;
 using namespace ASDCP::MXF;
 
@@ -499,11 +500,13 @@ ASDCP::h__Writer::WriteMXFHeader(const std::string& PackageLabel, const UL& Wrap
 // standard method of writing a plaintext or encrypted frame
 Result_t
 ASDCP::h__Writer::WriteEKLVPacket(const ASDCP::FrameBuffer& FrameBuf, const byte_t* EssenceUL,
-                                 AESEncContext* Ctx, HMACContext* HMAC)
+                                 AESEncContext* Ctx, HMACContext* HMAC, std::string* hash)
 {
   Result_t result = RESULT_OK;
   IntegrityPack IntPack;
 
+  m_File.StartHashing();
+
   byte_t overhead[128];
   Kumu::MemIOWriter Overhead(overhead, 128);
   assert(m_Dict);
@@ -635,6 +638,21 @@ ASDCP::h__Writer::WriteEKLVPacket(const ASDCP::FrameBuffer& FrameBuf, const byte
   if ( ASDCP_SUCCESS(result) )
     result = m_File.Writev();
 
+  if (hash) {
+         *hash = m_File.StopHashing();
+  }
+
+  return result;
+}
+
+Result_t
+ASDCP::h__Writer::FakeWriteEKLVPacket(int size)
+{
+  Result_t result = RESULT_OK;
+
+  m_StreamOffset += size;
+  m_File.Seek(size, Kumu::SP_POS);
+
   return result;
 }