diff options
| author | John Hurst <jhurst@cinecert.com> | 2021-08-26 20:30:08 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-08-26 20:30:08 -0700 |
| commit | 68c1e325043dafc3c57b5cb849ee8c99bc607e66 (patch) | |
| tree | 7c1f1e914277dc97101d2e37ef9504508d56399c /src | |
| parent | 8bf9afd450ff50f0fdcdd7d8d9d78cb8b81f001b (diff) | |
| parent | 81619e49fa8df104f5a9baeb36aada42c4d247eb (diff) | |
Merge pull request #3 from DolbyLaboratories/dolby/atmos_storage/asdcplib_integration/add_api_AddDmsGenericPartUtf8Text_ReadGenericStreamPartitionPayload
Merge dolby/atmos_storage/asdcplib_integration/add_api_AddDmsGenericPartUtf8Text_ReadGenericStreamPartitionPayload (contains also write seq and segment duration)) to master
Diffstat (limited to 'src')
| -rw-r--r-- | src/AS_02_IAB.cpp | 22 | ||||
| -rw-r--r-- | src/AS_02_IAB.h | 19 | ||||
| -rwxr-xr-x | src/AS_DCP_internal.h | 13 | ||||
| -rwxr-xr-x | src/h__Writer.cpp | 14 |
4 files changed, 61 insertions, 7 deletions
diff --git a/src/AS_02_IAB.cpp b/src/AS_02_IAB.cpp index c25f7bf..9278381 100644 --- a/src/AS_02_IAB.cpp +++ b/src/AS_02_IAB.cpp @@ -265,6 +265,17 @@ AS_02::IAB::MXFWriter::WriteFrame(const ui8_t* frame, ui32_t sz) { } Result_t +AS_02::IAB::MXFWriter::AddDmsGenericPartUtf8Text(const ASDCP::FrameBuffer& FrameBuf, ASDCP::AESEncContext* Ctx, + ASDCP::HMACContext* HMAC, const std::string& trackDescription, const std::string& dataDescription) +{ + if ( m_Writer.empty() ) + return RESULT_INIT; + + m_Writer->FlushIndexPartition(); + return m_Writer->AddDmsGenericPartUtf8Text(FrameBuf, Ctx, HMAC, trackDescription, dataDescription); +} + +Result_t AS_02::IAB::MXFWriter::Finalize() { /* are we running */ @@ -598,6 +609,17 @@ AS_02::IAB::MXFReader::ReadFrame(ui32_t frame_number, AS_02::IAB::MXFReader::Fra } Result_t +AS_02::IAB::MXFReader::ReadGenericStreamPartitionPayload(const ui32_t SID, ASDCP::FrameBuffer& frame_buf) +{ + if ( m_Reader && m_Reader->m_File->IsOpen() ) + { + return m_Reader->ReadGenericStreamPartitionPayload(SID, frame_buf, 0, 0 /*no encryption*/); + } + + return RESULT_INIT; +} + +Result_t AS_02::IAB::MXFReader::FillWriterInfo(WriterInfo& Info) const { /* are we already running */ diff --git a/src/AS_02_IAB.h b/src/AS_02_IAB.h index 57fb77e..42c9ce3 100644 --- a/src/AS_02_IAB.h +++ b/src/AS_02_IAB.h @@ -125,6 +125,15 @@ namespace AS_02 { Result_t WriteFrame(const ui8_t* frame, ui32_t sz); /** + * Writes an XML text document to the MXF file as per RP 2057. If the + * optional AESEncContext argument is present, the document is encrypted + * prior to writing. Fails if the file is not open, is finalized, or an + * operating system error occurs. + */ + Result_t AddDmsGenericPartUtf8Text(const ASDCP::FrameBuffer& frame_buffer, ASDCP::AESEncContext* enc = 0, ASDCP::HMACContext* hmac = 0, + const std::string& trackDescription = "Descriptive Track", const std::string& dataDescription = ""); + + /** * Writes the Track File footer and closes the file. * * Must be preceded by a succesful OpenWrite() call followed by zero or more WriteFrame() calls @@ -211,7 +220,7 @@ namespace AS_02 { /** * Reads an IA Frame. - * + * * @param frame_number Index of the frame to be read. Must be in the range [0, GetFrameCount()). * @param frame Frame data. Must not be modified. Remains valid until the next call to ReadFrame(). * @return RESULT_OK indicates that more frames are ready to be read, @@ -219,6 +228,14 @@ namespace AS_02 { */ Result_t ReadFrame(ui32_t frame_number, Frame& frame); + + /** Reads a Generic Stream Partition payload. Returns RESULT_INIT if the file is + * not open, or RESULT_FORMAT if the SID is not present in the RIP, or if the + * actual partition at ByteOffset does not have a matching BodySID value. + * Encryption is not currently supported. + */ + Result_t ReadGenericStreamPartitionPayload(ui32_t SID, ASDCP::FrameBuffer& FrameBuf); + /** * Returns the number of IA Frame in the Track File. * diff --git a/src/AS_DCP_internal.h b/src/AS_DCP_internal.h index 5626058..7f3201f 100755 --- a/src/AS_DCP_internal.h +++ b/src/AS_DCP_internal.h @@ -170,7 +170,8 @@ namespace ASDCP WriterInfo& Descr, const UL& WrappingUL, const Dictionary *Dict); Result_t AddDmsTrackGenericPartUtf8Text(Kumu::FileWriter&, ASDCP::MXF::OP1aHeader&, SourcePackage&, - ASDCP::MXF::RIP&, const Dictionary*); + ASDCP::MXF::RIP&, const Dictionary*, const std::string&, const std::string&, std::list<ui64_t*>&); + // Result_t WriteGenericStreamPartition(Kumu::FileWriter&, ASDCP::MXF::OP1aHeader&, ASDCP::MXF::RIP&, const Dictionary*, const ASDCP::FrameBuffer&, ASDCP::AESEncContext* = 0, ASDCP::HMACContext* = 0); @@ -854,10 +855,13 @@ namespace ASDCP } Result_t AddDmsGenericPartUtf8Text(const ASDCP::FrameBuffer& frame_buffer, - ASDCP::AESEncContext* enc = 0, ASDCP::HMACContext* hmac = 0) + ASDCP::AESEncContext* enc = 0, ASDCP::HMACContext* hmac = 0, + const std::string& trackDescription = "Descriptive Track", + const std::string& dataDescription = "") { Kumu::fpos_t previous_partition_offset = m_RIP.PairArray.back().ByteOffset; - Result_t result = AddDmsTrackGenericPartUtf8Text(m_File, m_HeaderPart, *m_FilePackage, m_RIP, m_Dict); + + Result_t result = AddDmsTrackGenericPartUtf8Text(m_File, m_HeaderPart, *m_FilePackage, m_RIP, m_Dict, trackDescription, dataDescription, m_DurationUpdateList); if ( KM_SUCCESS(result) ) { @@ -886,8 +890,9 @@ namespace ASDCP if ( KM_SUCCESS(result) ) { + ui64_t streamOffset = m_StreamOffset; result = Write_EKLV_Packet(m_File, *m_Dict, m_HeaderPart, m_Info, m_CtFrameBuf, m_FramesWritten, - m_StreamOffset, frame_buffer, GenericStream_DataElement.Value(), + streamOffset, frame_buffer, GenericStream_DataElement.Value(), MXF_BER_LENGTH, enc, hmac); } } diff --git a/src/h__Writer.cpp b/src/h__Writer.cpp index 5f836fe..b05749d 100755 --- a/src/h__Writer.cpp +++ b/src/h__Writer.cpp @@ -102,7 +102,9 @@ id_batch_contains(const Array<Kumu::UUID>& batch, const Kumu::UUID& value) // Result_t ASDCP::AddDmsTrackGenericPartUtf8Text(Kumu::FileWriter& file_writer, MXF::OP1aHeader& header_part, - SourcePackage& source_package, MXF::RIP& rip, const Dictionary* Dict) + SourcePackage& source_package, MXF::RIP& rip, const Dictionary* Dict, + const std::string& trackDescription, const std::string& dataDescription, + std::list<ui64_t*>& durationUpdateList) { Sequence* Sequence_obj = 0; InterchangeObject* tmp_iobj = 0; @@ -157,13 +159,15 @@ ASDCP::AddDmsTrackGenericPartUtf8Text(Kumu::FileWriter& file_writer, MXF::OP1aHe StaticTrack* static_track = new StaticTrack(Dict); header_part.AddChildObject(static_track); source_package.Tracks.push_back(static_track->InstanceUID); - static_track->TrackName = "Descriptive Track"; + static_track->TrackName = trackDescription; static_track->TrackID = 4; Sequence_obj = new Sequence(Dict); header_part.AddChildObject(Sequence_obj); static_track->Sequence = Sequence_obj->InstanceUID; Sequence_obj->DataDefinition = UL(Dict->ul(MDD_DescriptiveMetaDataDef)); + Sequence_obj->Duration.set_has_value(); + durationUpdateList.push_back(&Sequence_obj->Duration.get()); header_part.m_Preface->DMSchemes.push_back(UL(Dict->ul(MDD_MXFTextBasedFramework))); } @@ -174,6 +178,11 @@ ASDCP::AddDmsTrackGenericPartUtf8Text(Kumu::FileWriter& file_writer, MXF::OP1aHe Sequence_obj->StructuralComponents.push_back(Segment->InstanceUID); Segment->EventComment = rp2057_static_track_label; Segment->DataDefinition = UL(Dict->ul(MDD_DescriptiveMetaDataDef)); + if (!Segment->Duration.empty()) + { + durationUpdateList.push_back(&Segment->Duration.get()); + } + // TextBasedDMFramework *dmf_obj = new TextBasedDMFramework(Dict); @@ -208,6 +217,7 @@ ASDCP::AddDmsTrackGenericPartUtf8Text(Kumu::FileWriter& file_writer, MXF::OP1aHe gst_obj->InstanceUID = dmf_obj->ObjectRef; gst_obj->GenericStreamSID = max_sid + 1; gst_obj->PayloadSchemeID = UL(Dict->ul(MDD_MXFTextBasedFramework)); + gst_obj->TextDataDescription = dataDescription; return RESULT_OK; } |
