update makefile for version roll
[asdcplib.git] / src / h__Writer.cpp
index 4290974d675bf13c23a4cbe24c0b664fc1dbea84..07d418f7035087bfc5c705c9be09bec1e898a560 100755 (executable)
@@ -1,5 +1,5 @@
 /*
-Copyright (c) 2004-2013, John Hurst
+Copyright (c) 2004-2015, John Hurst
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
@@ -35,6 +35,13 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 using namespace ASDCP;
 using namespace ASDCP::MXF;
 
+//
+ui32_t
+ASDCP::derive_timecode_rate_from_edit_rate(const ASDCP::Rational& edit_rate)
+{
+  return floor(0.5 + edit_rate.Quotient());
+}
+
 //
 // add DMS CryptographicFramework entry to source package
 void
@@ -58,7 +65,7 @@ ASDCP::AddDMScrypt(Partition& HeaderPart, SourcePackage& Package,
   HeaderPart.AddChildObject(Segment);
   Seq->StructuralComponents.push_back(Segment->InstanceUID);
   Segment->EventComment = "AS-DCP KLV Encryption";
-  
+
   CryptographicFramework* CFW = new CryptographicFramework(Dict);
   HeaderPart.AddChildObject(CFW);
   Segment->DMFramework = CFW->InstanceUID;
@@ -99,7 +106,7 @@ ASDCP::h__ASDCPWriter::CreateBodyPart(const MXF::Rational& EditRate, ui32_t Byte
       m_BodyPart.BodySID = 1;
       UL OPAtomUL(m_Dict->ul(MDD_OPAtom));
       m_BodyPart.OperationalPattern = OPAtomUL;
-      m_RIP.PairArray.push_back(RIP::Pair(1, m_BodyPart.ThisPartition)); // Second RIP Entry
+      m_RIP.PairArray.push_back(RIP::PartitionPair(1, m_BodyPart.ThisPartition)); // Second RIP Entry
       
       UL BodyUL(m_Dict->ul(MDD_ClosedCompleteBodyPartition));
       result = m_BodyPart.WriteToFile(m_File, BodyUL);
@@ -139,14 +146,15 @@ ASDCP::h__ASDCPWriter::WriteASDCPHeader(const std::string& PackageLabel, const U
   // First RIP Entry
   if ( m_Info.LabelSetType == LS_MXF_SMPTE )  // ERK
     {
-      m_RIP.PairArray.push_back(RIP::Pair(0, 0)); // 3-part, no essence in header
+      m_RIP.PairArray.push_back(RIP::PartitionPair(0, 0)); // 3-part, no essence in header
     }
   else
     {
-      m_RIP.PairArray.push_back(RIP::Pair(1, 0)); // 2-part, essence in header
+      m_RIP.PairArray.push_back(RIP::PartitionPair(1, 0)); // 2-part, essence in header
     }
 
-  AddSourceClip(EditRate, TCFrameRate, TrackName, EssenceUL, DataDefinition, PackageLabel);
+  // timecode rate and essence rate are the same
+  AddSourceClip(EditRate, EditRate, TCFrameRate, TrackName, EssenceUL, DataDefinition, PackageLabel);
   AddEssenceDescriptor(WrappingUL);
 
   Result_t result = m_HeaderPart.WriteToFile(m_File, m_HeaderSize);
@@ -157,7 +165,14 @@ ASDCP::h__ASDCPWriter::WriteASDCPHeader(const std::string& PackageLabel, const U
   return result;
 }
 
-
+//
+Result_t
+ASDCP::h__ASDCPWriter::WriteEKLVPacket(const ASDCP::FrameBuffer& FrameBuf,const byte_t* EssenceUL,
+                                      AESEncContext* Ctx, HMACContext* HMAC)
+{
+  return Write_EKLV_Packet(m_File, *m_Dict, m_HeaderPart, m_Info, m_CtFrameBuf, m_FramesWritten,
+                          m_StreamOffset, FrameBuf, EssenceUL, Ctx, HMAC);
+}
 
 // standard method of writing the header and footer of a completed MXF file
 //
@@ -176,7 +191,7 @@ ASDCP::h__ASDCPWriter::WriteASDCPFooter()
   m_FooterPart.PreviousPartition = m_RIP.PairArray.back().ByteOffset;
 
   Kumu::fpos_t here = m_File.Tell();
-  m_RIP.PairArray.push_back(RIP::Pair(0, here)); // Last RIP Entry
+  m_RIP.PairArray.push_back(RIP::PartitionPair(0, here)); // Last RIP Entry
   m_HeaderPart.FooterPartition = here;
 
   assert(m_Dict);