ASDCP::Result_t ASDCP::TimedText::MXFWriter::h__Writer::WriteAncillaryResource(const ASDCP::TimedText::FrameBuffer& FrameBuf, ASDCP::AESEncContext* Ctx, ASDCP::HMACContext* HMAC) { if ( ! m_State.Test_RUNNING() ) return RESULT_STATE; Kumu::fpos_t here = m_File.Tell(); assert(m_Dict); // create generic stream partition header static UL GenericStream_DataElement(m_Dict->ul(MDD_GenericStream_DataElement)); MXF::Partition GSPart(m_Dict); GSPart.ThisPartition = here; GSPart.PreviousPartition = m_HeaderPart.m_RIP.PairArray.back().ByteOffset; GSPart.BodySID = m_EssenceStreamID; GSPart.OperationalPattern = m_HeaderPart.OperationalPattern; m_HeaderPart.m_RIP.PairArray.push_back(RIP::Pair(m_EssenceStreamID++, here)); GSPart.EssenceContainers.push_back(UL(m_Dict->ul(MDD_TimedTextEssence))); UL TmpUL(m_Dict->ul(MDD_GenericStreamPartition)); Result_t result = GSPart.WriteToFile(m_File, TmpUL); if ( ASDCP_SUCCESS(result) ) result = WriteEKLVPacket(FrameBuf, GenericStream_DataElement.Value(), Ctx, HMAC); m_FramesWritten++; return result; }
// Closes the MXF file, writing the index and other closing information. // Result_t AS_02::PHDR::MXFWriter::h__Writer::Finalize(const std::string& PHDR_master_metadata) { if ( ! m_State.Test_RUNNING() ) return RESULT_STATE; Result_t result = m_State.Goto_FINAL(); if ( KM_SUCCESS(result) ) { if ( m_IndexWriter.GetDuration() > 0 ) { m_IndexWriter.ThisPartition = this->m_File.Tell(); m_IndexWriter.WriteToFile(this->m_File); m_RIP.PairArray.push_back(RIP::Pair(0, this->m_IndexWriter.ThisPartition)); } if ( ! PHDR_master_metadata.empty() ) { // write PHDRSimplePayload Kumu::fpos_t here = m_File.Tell(); // create generic stream partition header static UL GenericStream_DataElement(m_Dict->ul(MDD_GenericStream_DataElement)); ASDCP::MXF::Partition GSPart(m_Dict); GSPart.ThisPartition = here; GSPart.PreviousPartition = m_RIP.PairArray.back().ByteOffset; GSPart.OperationalPattern = m_HeaderPart.OperationalPattern; GSPart.BodySID = 2; m_MetadataTrackSubDescriptor->SimplePayloadSID = 2; m_RIP.PairArray.push_back(RIP::Pair(2, here)); GSPart.EssenceContainers = m_HeaderPart.EssenceContainers; static UL gs_part_ul(m_Dict->ul(MDD_GenericStreamPartition)); Result_t result = GSPart.WriteToFile(m_File, gs_part_ul); if ( KM_SUCCESS(result) ) { ASDCP::FrameBuffer tmp_buf; tmp_buf.SetData((byte_t*)PHDR_master_metadata.c_str(), PHDR_master_metadata.size()); tmp_buf.Size(PHDR_master_metadata.size()); result = Write_EKLV_Packet(m_File, *m_Dict, m_HeaderPart, m_Info, m_CtFrameBuf, m_FramesWritten, m_StreamOffset, tmp_buf, GenericStream_DataElement.Value(), 0, 0); } } result = WriteAS02Footer(); } return result; }
ASDCP::Result_t ASDCP::KLVFilePacket::WriteKLToFile(Kumu::FileWriter& Writer, const UL& label, ui32_t length) { byte_t buffer[kl_length]; memcpy(buffer, label.Value(), label.Size()); if ( ! Kumu::write_BER(buffer+SMPTE_UL_LENGTH, length, MXF_BER_LENGTH) ) return RESULT_FAIL; ui32_t write_count; Writer.Write(buffer, kl_length, &write_count); assert(write_count == kl_length); return RESULT_OK; }
ASDCP::Result_t ASDCP::KLVPacket::WriteKLToBuffer(ASDCP::FrameBuffer& Buffer, const UL& label, ui32_t length) { assert(label.HasValue()); if ( Buffer.Size() + kl_length > Buffer.Capacity() ) { DefaultLogSink().Error("Small write buffer\n"); return RESULT_FAIL; } memcpy(Buffer.Data() + Buffer.Size(), label.Value(), label.Size()); if ( ! Kumu::write_BER(Buffer.Data() + Buffer.Size() + SMPTE_UL_LENGTH, length, MXF_BER_LENGTH) ) return RESULT_FAIL; Buffer.Size(Buffer.Size() + kl_length); return RESULT_OK; }