if ( ASDCP_SUCCESS(result) )
result = m_HeaderPart.InitFromFile(m_File);
- // if this is a three partition file, go to the body
- // partition and read off the partition pack
- if ( m_HeaderPart.m_RIP.PairArray.size() == 3 )
+ if ( ASDCP_SUCCESS(result) )
{
- DefaultLogSink().Error("RIP count is 3: must write code...\n");
- return RESULT_FORMAT;
- }
- // TODO: check the partition pack to make sure it is
- // really a body with a single essence container
+ // if this is a three partition file, go to the body
+ // partition and read the partition pack
+ if ( m_HeaderPart.m_RIP.PairArray.size() == 3 )
+ {
+ Array<RIP::Pair>::iterator r_i = m_HeaderPart.m_RIP.PairArray.begin();
+ r_i++;
+ m_File.Seek((*r_i).ByteOffset);
- m_EssenceStart = m_File.Tell();
+ result = m_BodyPart.InitFromFile(m_File);
+ }
+
+ m_EssenceStart = m_File.Tell();
+ }
- return RESULT_OK;
+ return result;
}
inline const ui64_t Length() { return m_ValueLength; }
inline const ui64_t KLLength() { return m_KLLength; }
- Result_t ReadKLFromFile(ASDCP::FileReader& Reader)
+ Result_t ReadKLFromFile(Kumu::FileReader& Reader)
{
ui32_t read_count;
ui32_t header_length = SMPTE_UL_LENGTH + MXF_BER_LENGTH;
if ( ASDCP_FAILURE(m_FooterPart.Lookup(FrameNum, TmpEntry)) )
{
- DefaultLogSink().Error("Frame value out of range: %lu\n", FrameNum);
+ DefaultLogSink().Error("Frame value out of range: %u\n", FrameNum);
return RESULT_RANGE;
}
// get frame position and go read the frame's key and length
Result_t result = RESULT_OK;
KLReader Reader;
- ASDCP::fpos_t FilePosition = m_EssenceStart + TmpEntry.StreamOffset;
+ Kumu::fpos_t FilePosition = m_EssenceStart + TmpEntry.StreamOffset;
if ( FilePosition != m_LastPosition )
{
return result;
UL Key(Reader.Key());
- UL CryptEssenceUL(Dict::ul(MDD_CryptEssence));
- UL InteropCryptEssenceUL(Dict::ul(MDD_MXFInterop_CryptEssence));
ui64_t PacketLength = Reader.Length();
m_LastPosition = m_LastPosition + Reader.KLLength() + PacketLength;
- if ( Key == InteropCryptEssenceUL || Key == CryptEssenceUL )
+ if ( memcmp(Key.Value(), Dict::ul(MDD_CryptEssence), Key.Size() - 1) == 0 // ignore the stream numbers
+ || memcmp(Key.Value(), Dict::ul(MDD_MXFInterop_CryptEssence), Key.Size() - 1) == 0 )
{
if ( ! m_Info.EncryptedEssence )
{
byte_t* ess_p = m_CtFrameBuf.Data();
// read context ID length
- if ( ! read_test_BER(&ess_p, UUIDlen) )
+ if ( ! Kumu::read_test_BER(&ess_p, UUIDlen) )
return RESULT_FORMAT;
// test the context ID
ess_p += UUIDlen;
// read PlaintextOffset length
- if ( ! read_test_BER(&ess_p, sizeof(ui64_t)) )
+ if ( ! Kumu::read_test_BER(&ess_p, sizeof(ui64_t)) )
return RESULT_FORMAT;
- ui32_t PlaintextOffset = (ui32_t)ASDCP_i64_BE(cp2i<ui64_t>(ess_p));
+ ui32_t PlaintextOffset = (ui32_t)KM_i64_BE(Kumu::cp2i<ui64_t>(ess_p));
ess_p += sizeof(ui64_t);
// read essence UL length
- if ( ! read_test_BER(&ess_p, SMPTE_UL_LENGTH) )
+ if ( ! Kumu::read_test_BER(&ess_p, SMPTE_UL_LENGTH) )
return RESULT_FORMAT;
- // TODO: test essence UL
+ // test essence UL
+ if ( memcmp(ess_p, EssenceUL, SMPTE_UL_LENGTH - 1) != 0 ) // ignore the stream number
+ {
+ char strbuf[IntBufferLen];
+ const MDDEntry* Entry = Dict::FindUL(Key.Value());
+ if ( Entry == 0 )
+ DefaultLogSink().Warn("Unexpected Essence UL found: %s.\n", Key.EncodeString(strbuf, IntBufferLen));
+ else
+ DefaultLogSink().Warn("Unexpected Essence UL found: %s.\n", Entry->name);
+ return RESULT_FORMAT;
+ }
ess_p += SMPTE_UL_LENGTH;
// read SourceLength length
- if ( ! read_test_BER(&ess_p, sizeof(ui64_t)) )
+ if ( ! Kumu::read_test_BER(&ess_p, sizeof(ui64_t)) )
return RESULT_FORMAT;
- ui32_t SourceLength = (ui32_t)ASDCP_i64_BE(cp2i<ui64_t>(ess_p));
+ ui32_t SourceLength = (ui32_t)KM_i64_BE(Kumu::cp2i<ui64_t>(ess_p));
ess_p += sizeof(ui64_t);
assert(SourceLength);
if ( FrameBuf.Capacity() < SourceLength )
{
- DefaultLogSink().Error("FrameBuf.Capacity: %lu SourceLength: %lu\n", FrameBuf.Capacity(), SourceLength);
+ DefaultLogSink().Error("FrameBuf.Capacity: %u SourceLength: %u\n", FrameBuf.Capacity(), SourceLength);
return RESULT_SMALLBUF;
}
ui32_t esv_length = calc_esv_length(SourceLength, PlaintextOffset);
// read ESV length
- if ( ! read_test_BER(&ess_p, esv_length) )
+ if ( ! Kumu::read_test_BER(&ess_p, esv_length) )
{
- DefaultLogSink().Error("read_test_BER did not return %lu\n", esv_length);
+ DefaultLogSink().Error("read_test_BER did not return %u\n", esv_length);
return RESULT_FORMAT;
}
else // return ciphertext to caller
{
if ( FrameBuf.Capacity() < tmp_len )
- return RESULT_SMALLBUF;
+ {
+ char intbuf[IntBufferLen];
+ DefaultLogSink().Error("FrameBuf.Capacity: %u FrameLength: %s\n",
+ FrameBuf.Capacity(), ui64sz(PacketLength, intbuf));
+ return RESULT_SMALLBUF;
+ }
memcpy(FrameBuf.Data(), ess_p, tmp_len);
FrameBuf.Size(tmp_len);
FrameBuf.PlaintextOffset(PlaintextOffset);
}
}
- else if ( Key == EssenceUL )
+ else if ( memcmp(Key.Value(), EssenceUL, Key.Size() - 1) == 0 ) // ignore the stream number
{ // read plaintext frame
if ( FrameBuf.Capacity() < PacketLength )
{
char intbuf[IntBufferLen];
- DefaultLogSink().Error("FrameBuf.Capacity: %lu FrameLength: %s\n",
+ DefaultLogSink().Error("FrameBuf.Capacity: %u FrameLength: %s\n",
FrameBuf.Capacity(), ui64sz(PacketLength, intbuf));
return RESULT_SMALLBUF;
}
char strbuf[IntBufferLen];
const MDDEntry* Entry = Dict::FindUL(Key.Value());
if ( Entry == 0 )
- DefaultLogSink().Warn("Unexpected Essence UL found: %s.\n", Key.ToString(strbuf));
+ DefaultLogSink().Warn("Unexpected Essence UL found: %s.\n", Key.EncodeString(strbuf, IntBufferLen));
else
DefaultLogSink().Warn("Unexpected Essence UL found: %s.\n", Entry->name);
return RESULT_FORMAT;