/*
-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
static Kumu::Mutex sg_DefaultMDInitLock;
static bool sg_DefaultMDTypesInit = false;
-static const ASDCP::Dictionary *sg_dict;
+static const ASDCP::Dictionary *sg_dict = 0;
//
void
// AS-DCP method of opening an MXF file for read
Result_t
-ASDCP::h__ASDCPReader::OpenMXFRead(const char* filename)
+ASDCP::h__ASDCPReader::OpenMXFRead(const std::string& filename)
{
Result_t result = ASDCP::MXF::TrackFileReader<OP1aHeader, OPAtomIndexFooter>::OpenMXFRead(filename);
m_Info.LabelSetType = LS_MXF_UNKNOWN;
- if ( m_HeaderPart.OperationalPattern.ExactMatch(MXFInterop_OPAtom_Entry().ul) )
+ if ( m_HeaderPart.OperationalPattern.MatchExact(MXFInterop_OPAtom_Entry().ul) )
{
m_Info.LabelSetType = LS_MXF_INTEROP;
}
- else if ( m_HeaderPart.OperationalPattern.ExactMatch(SMPTE_390_OPAtom_Entry().ul) )
+ else if ( m_HeaderPart.OperationalPattern.MatchExact(SMPTE_390_OPAtom_Entry().ul) )
{
m_Info.LabelSetType = LS_MXF_SMPTE;
}
else
{
char strbuf[IdentBufferLen];
- const MDDEntry* Entry = m_Dict->FindUL(m_HeaderPart.OperationalPattern.Value());
+ const MDDEntry* Entry = m_Dict->FindULExact(m_HeaderPart.OperationalPattern.Value());
if ( Entry == 0 )
{
}
}
+ if ( m_RIP.PairArray.front().ByteOffset != 0 )
+ {
+ DefaultLogSink().Error("First Partition in RIP is not at offset 0.\n");
+ result = RESULT_FORMAT;
+ }
+
//
if ( m_RIP.PairArray.size() < 2 )
{
{
// if this is a three partition file, go to the body
// partition and read the partition pack
- Array<RIP::Pair>::iterator r_i = m_RIP.PairArray.begin();
+ RIP::const_pair_iterator r_i = m_RIP.PairArray.begin();
r_i++;
m_File.Seek((*r_i).ByteOffset);
result = m_BodyPart.InitFromFile(m_File);
DefaultLogSink().Error("ASDCP::h__ASDCPReader::OpenMXFRead, m_BodyPart.InitFromFile failed\n");
}
}
- else if ( m_RIP.PairArray.front().ByteOffset != 0 )
- {
- DefaultLogSink().Error("First Partition in RIP is not at offset 0.\n");
- result = RESULT_FORMAT;
- }
}
if ( KM_SUCCESS(result) )
{
+ // this position will be at either
+ // a) the spot in the header partition where essence units appear, or
+ // b) right after the body partition header (where essence units appear)
m_HeaderPart.BodyOffset = m_File.Tell();
result = m_File.Seek(m_HeaderPart.FooterPartition);
ASDCP::h__ASDCPReader::ReadEKLVFrame(ui32_t FrameNum, ASDCP::FrameBuffer& FrameBuf,
const byte_t* EssenceUL, AESDecContext* Ctx, HMACContext* HMAC)
{
- return ASDCP::MXF::TrackFileReader<OP1aHeader, OPAtomIndexFooter>::ReadEKLVFrame(m_HeaderPart, FrameNum, FrameBuf,
+ return ASDCP::MXF::TrackFileReader<OP1aHeader, OPAtomIndexFooter>::ReadEKLVFrame(m_HeaderPart.BodyOffset, FrameNum, FrameBuf,
EssenceUL, Ctx, HMAC);
}
ASDCP::h__ASDCPReader::LocateFrame(ui32_t FrameNum, Kumu::fpos_t& streamOffset,
i8_t& temporalOffset, i8_t& keyFrameOffset)
{
- return ASDCP::MXF::TrackFileReader<OP1aHeader, OPAtomIndexFooter>::LocateFrame(m_HeaderPart, FrameNum,
+ return ASDCP::MXF::TrackFileReader<OP1aHeader, OPAtomIndexFooter>::LocateFrame(m_HeaderPart.BodyOffset, FrameNum,
streamOffset, temporalOffset, keyFrameOffset);
}
if ( ber_size < MXF_BER_LENGTH )
{
- DefaultLogSink().Error("BER size %d shorter than AS-DCP minimum %d.\n",
+ DefaultLogSink().Error("BER size %d shorter than AS-DCP/AS-02 minimum %d.\n",
ber_size, MXF_BER_LENGTH);
return RESULT_FORMAT;
}
return InitFromBuffer(m_KeyBuf, header_length);
}
+
+//------------------------------------------------------------------------------------------
+//
+
+
// base subroutine for reading a KLV packet, assumes file position is at the first byte of the packet
Result_t
-ASDCP::Read_EKLV_Packet(Kumu::FileReader& File, const ASDCP::Dictionary& Dict, const MXF::OP1aHeader& HeaderPart,
+ASDCP::Read_EKLV_Packet(Kumu::FileReader& File, const ASDCP::Dictionary& Dict,
const ASDCP::WriterInfo& Info, Kumu::fpos_t& LastPosition, ASDCP::FrameBuffer& CtFrameBuf,
ui32_t FrameNum, ui32_t SequenceNum, ASDCP::FrameBuffer& FrameBuf,
const byte_t* EssenceUL, AESDecContext* Ctx, HMACContext* HMAC)
if ( ! UL(ess_p).MatchIgnoreStream(EssenceUL) ) // ignore the stream number
{
char strbuf[IntBufferLen];
- const MDDEntry* Entry = Dict.FindUL(Key.Value());
+ const MDDEntry* Entry = Dict.FindULAnyVersion(Key.Value());
if ( Entry == 0 )
{
else
{
char strbuf[IntBufferLen];
- const MDDEntry* Entry = Dict.FindUL(Key.Value());
+ const MDDEntry* Entry = Dict.FindULAnyVersion(Key.Value());
if ( Entry == 0 )
{