Result_t ASDCP::TimedText::DCSubtitleParser::h__SubtitleParser::ReadAncillaryResource(const byte_t* uuid, FrameBuffer& FrameBuf, const IResourceResolver& Resolver) const { FrameBuf.AssetID(uuid); UUID TmpID(uuid); char buf[64]; ResourceTypeMap_t::const_iterator rmi = m_ResourceTypes.find(TmpID); if ( rmi == m_ResourceTypes.end() ) { DefaultLogSink().Error("Unknown ancillary resource id: %s\n", TmpID.EncodeHex(buf, 64)); return RESULT_RANGE; } Result_t result = Resolver.ResolveRID(uuid, FrameBuf); if ( KM_SUCCESS(result) ) { if ( (*rmi).second == MT_PNG ) FrameBuf.MIMEType("image/png"); else if ( (*rmi).second == MT_OPENTYPE ) FrameBuf.MIMEType("application/x-font-opentype"); else FrameBuf.MIMEType("application/octet-stream"); } return result; }
ASDCP::Result_t ASDCP::TimedText::MXFReader::h__Reader::ReadAncillaryResource(const byte_t* uuid, FrameBuffer& frame_buf, AESDecContext* Ctx, HMACContext* HMAC) { KM_TEST_NULL_L(uuid); UUID RID(uuid); ResourceMap_t::const_iterator ri = m_ResourceMap.find(RID); if ( ri == m_ResourceMap.end() ) { char buf[64]; DefaultLogSink().Error("No such resource: %s\n", RID.EncodeHex(buf, 64)); return RESULT_RANGE; } // get the subdescriptor InterchangeObject* tmp_iobj = 0; Result_t result = m_HeaderPart.GetMDObjectByID((*ri).second, &tmp_iobj); TimedTextResourceSubDescriptor* desc_object = dynamic_cast<TimedTextResourceSubDescriptor*>(tmp_iobj); if ( KM_SUCCESS(result) ) { assert(desc_object); result = ReadGenericStreamPartitionPayload(desc_object->EssenceStreamID, frame_buf, Ctx, HMAC); } if ( KM_SUCCESS(result) ) { frame_buf.AssetID(uuid); frame_buf.MIMEType(desc_object->MIMEMediaType); } return result; }
ASDCP::Result_t ASDCP::TimedText::MXFReader::h__Reader::ReadTimedTextResource(FrameBuffer& FrameBuf, AESDecContext* Ctx, HMACContext* HMAC) { if ( ! m_File.IsOpen() ) return RESULT_INIT; assert(m_Dict); Result_t result = ReadEKLVFrame(0, FrameBuf, m_Dict->ul(MDD_TimedTextEssence), Ctx, HMAC); if( ASDCP_SUCCESS(result) ) { FrameBuf.AssetID(m_TDesc.AssetID); FrameBuf.MIMEType("text/xml"); } return result; }
ASDCP::Result_t ASDCP::TimedText::MXFReader::h__Reader::ReadAncillaryResource(const byte_t* uuid, FrameBuffer& FrameBuf, AESDecContext* Ctx, HMACContext* HMAC) { KM_TEST_NULL_L(uuid); UUID RID(uuid); ResourceMap_t::const_iterator ri = m_ResourceMap.find(RID); if ( ri == m_ResourceMap.end() ) { char buf[64]; DefaultLogSink().Error("No such resource: %s\n", RID.EncodeHex(buf, 64)); 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<TimedTextResourceSubDescriptor*>(tmp_iobj); if ( KM_SUCCESS(result) ) { Array<RIP::Pair>::const_iterator pi; RIP::Pair 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_HeaderPart.m_RIP.PairArray.begin(); pi != m_HeaderPart.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; } 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); } } } return result; }