X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2FAS_DCP_TimedText.cpp;h=1f0930a53c2fdd231643dc0fcd4919edb19fd6e4;hb=f4061a21fffad4fdf8dbb2f193f0f0960b25421c;hp=6e34a5d8bcae2c884c0563cc9ea7966967b26f5b;hpb=38954bfe8dd72a817fb070c58327cd111b9bd282;p=asdcplib.git diff --git a/src/AS_DCP_TimedText.cpp b/src/AS_DCP_TimedText.cpp index 6e34a5d..1f0930a 100644 --- a/src/AS_DCP_TimedText.cpp +++ b/src/AS_DCP_TimedText.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2008-2016, John Hurst +Copyright (c) 2008-2018, John Hurst All rights reserved. Redistribution and use in source and binary forms, with or without @@ -244,7 +244,7 @@ ASDCP::TimedText::MXFReader::h__Reader::ReadTimedTextResource(FrameBuffer& Frame // ASDCP::Result_t -ASDCP::TimedText::MXFReader::h__Reader::ReadAncillaryResource(const byte_t* uuid, FrameBuffer& FrameBuf, +ASDCP::TimedText::MXFReader::h__Reader::ReadAncillaryResource(const byte_t* uuid, FrameBuffer& frame_buf, AESDecContext* Ctx, HMACContext* HMAC) { KM_TEST_NULL_L(uuid); @@ -258,68 +258,21 @@ ASDCP::TimedText::MXFReader::h__Reader::ReadAncillaryResource(const byte_t* uuid return RESULT_RANGE; } - TimedTextResourceSubDescriptor* DescObject = 0; // get the subdescriptor InterchangeObject* tmp_iobj = 0; Result_t result = m_HeaderPart.GetMDObjectByID((*ri).second, &tmp_iobj); - DescObject = static_cast(tmp_iobj); + TimedTextResourceSubDescriptor* desc_object = dynamic_cast(tmp_iobj); if ( KM_SUCCESS(result) ) { - RIP::const_pair_iterator pi; - RIP::PartitionPair TmpPair; - ui32_t sequence = 0; - - // Look up the partition start in the RIP using the SID. - // Count the sequence length in because this is the sequence - // value needed to complete the HMAC. - for ( pi = m_RIP.PairArray.begin(); pi != m_RIP.PairArray.end(); ++pi, ++sequence ) - { - if ( (*pi).BodySID == DescObject->EssenceStreamID ) - { - TmpPair = *pi; - break; - } - } - - if ( TmpPair.ByteOffset == 0 ) - { - DefaultLogSink().Error("Body SID not found in RIP set: %d\n", DescObject->EssenceStreamID); - return RESULT_FORMAT; - } + assert(desc_object); + result = ReadGenericStreamPartitionPayload(desc_object->EssenceStreamID, frame_buf); + } - if ( KM_SUCCESS(result) ) - { - FrameBuf.AssetID(uuid); - FrameBuf.MIMEType(DescObject->MIMEMediaType); - - // seek tp the start of the partition - if ( (Kumu::fpos_t)TmpPair.ByteOffset != m_LastPosition ) - { - m_LastPosition = TmpPair.ByteOffset; - result = m_File.Seek(TmpPair.ByteOffset); - } - - // read the partition header - MXF::Partition GSPart(m_Dict); - result = GSPart.InitFromFile(m_File); - - if( ASDCP_SUCCESS(result) ) - { - // check the SID - if ( DescObject->EssenceStreamID != GSPart.BodySID ) - { - char buf[64]; - DefaultLogSink().Error("Generic stream partition body differs: %s\n", RID.EncodeHex(buf, 64)); - return RESULT_FORMAT; - } - - // read the essence packet - assert(m_Dict); - if( ASDCP_SUCCESS(result) ) - result = ReadEKLVPacket(0, sequence, FrameBuf, m_Dict->ul(MDD_GenericStream_DataElement), Ctx, HMAC); - } - } + if ( KM_SUCCESS(result) ) + { + frame_buf.AssetID(uuid); + frame_buf.MIMEType(desc_object->MIMEMediaType); } return result;