From 4898f9d60bc621cb464faa00fb50146495d76928 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 16 Mar 2024 21:50:24 +0100 Subject: Support hashing while writing MXFs. --- src/h__Writer.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/h__Writer.cpp') diff --git a/src/h__Writer.cpp b/src/h__Writer.cpp index c7aa8ab..4eaf72f 100755 --- a/src/h__Writer.cpp +++ b/src/h__Writer.cpp @@ -319,12 +319,12 @@ ASDCP::h__ASDCPWriter::WriteASDCPHeader(const std::string& PackageLabel, const U // Result_t ASDCP::h__ASDCPWriter::WriteEKLVPacket(const ASDCP::FrameBuffer& FrameBuf,const byte_t* EssenceUL, - const ui32_t& MinEssenceElementBerLength, - AESEncContext* Ctx, HMACContext* HMAC) + const ui32_t& MinEssenceElementBerLength, + AESEncContext* Ctx, HMACContext* HMAC, std::string* hash) { return Write_EKLV_Packet(m_File, *m_Dict, m_HeaderPart, m_Info, m_CtFrameBuf, m_FramesWritten, m_StreamOffset, FrameBuf, EssenceUL, MinEssenceElementBerLength, - Ctx, HMAC); + Ctx, HMAC, hash); } Result_t @@ -393,11 +393,16 @@ ASDCP::Write_EKLV_Packet(Kumu::FileWriter& File, const ASDCP::Dictionary& Dict, const ASDCP::WriterInfo& Info, ASDCP::FrameBuffer& CtFrameBuf, ui32_t& FramesWritten, ui64_t & StreamOffset, const ASDCP::FrameBuffer& FrameBuf, const byte_t* EssenceUL, const ui32_t& MinEssenceElementBerLength, - AESEncContext* Ctx, HMACContext* HMAC) + AESEncContext* Ctx, HMACContext* HMAC, std::string* hash) { Result_t result = RESULT_OK; IntegrityPack IntPack; + if (hash) + { + File.StartHashing(); + } + byte_t overhead[128]; Kumu::MemIOWriter Overhead(overhead, 128); // We declare HMACOverhead and its buffer in the outer scope, even though it is not used on @@ -538,6 +543,11 @@ ASDCP::Write_EKLV_Packet(Kumu::FileWriter& File, const ASDCP::Dictionary& Dict, if ( ASDCP_SUCCESS(result) ) result = File.Writev(); + if (hash) + { + *hash = File.StopHashing(); + } + return result; } -- cgit v1.2.3