/*
-Copyright (c) 2005-2006, John Hurst
+Copyright (c) 2005-2009, John Hurst
All rights reserved.
Redistribution and use in source and binary forms, with or without
//
ASDCP::Result_t
-ASDCP::KLVPacket::InitFromBuffer(const byte_t* buf, ui32_t buf_len, const byte_t* label)
+ASDCP::KLVPacket::InitFromBuffer(const byte_t* buf, ui32_t buf_len, const UL& label)
{
Result_t result = KLVPacket::InitFromBuffer(buf, buf_len);
if ( ASDCP_SUCCESS(result) )
- result = ( memcmp(m_KeyStart, label, SMPTE_UL_LENGTH) == 0 ) ?
- RESULT_OK : RESULT_FAIL;
+ result = ( UL(m_KeyStart) == label ) ? RESULT_OK : RESULT_FAIL;
return result;
}
//
ASDCP::Result_t
-ASDCP::KLVPacket::WriteKLToBuffer(ASDCP::FrameBuffer& Buffer, const byte_t* label, ui32_t length)
+ASDCP::KLVPacket::WriteKLToBuffer(ASDCP::FrameBuffer& Buffer, const UL& label, ui32_t length)
{
if ( Buffer.Size() + kl_length > Buffer.Capacity() )
{
return RESULT_FAIL;
}
- memcpy(Buffer.Data() + Buffer.Size(), label, SMPTE_UL_LENGTH);
+ memcpy(Buffer.Data() + Buffer.Size(), label.Value(), label.Size());
if ( ! Kumu::write_BER(Buffer.Data() + Buffer.Size() + SMPTE_UL_LENGTH, length, MXF_BER_LENGTH) )
return RESULT_FAIL;
//
void
-ASDCP::KLVPacket::Dump(FILE* stream, bool show_hex)
+ASDCP::KLVPacket::Dump(FILE* stream, const Dictionary& Dict, bool show_value)
{
if ( stream == 0 )
stream = stderr;
char buf[64];
fprintf(stream, "%s", TmpUL.EncodeString(buf, 64));
- const MDDEntry* Entry = Dict::FindUL(m_KeyStart);
+ const MDDEntry* Entry = Dict.FindUL(m_KeyStart);
fprintf(stream, " len: %7u (%s)\n", m_ValueLength, (Entry ? Entry->name : "Unknown"));
- if ( show_hex && m_ValueLength < 1000 )
- Kumu::hexdump(m_ValueStart, Kumu::xmin(m_ValueLength, (ui32_t)64), stream);
+ if ( show_value && m_ValueLength < 1000 )
+ Kumu::hexdump(m_ValueStart, Kumu::xmin(m_ValueLength, (ui32_t)128), stream);
}
else
{
//
ASDCP::Result_t
-ASDCP::KLVFilePacket::InitFromFile(const Kumu::FileReader& Reader, const byte_t* label)
+ASDCP::KLVFilePacket::InitFromFile(const Kumu::FileReader& Reader, const UL& label)
{
Result_t result = KLVFilePacket::InitFromFile(Reader);
if ( ASDCP_SUCCESS(result) )
- result = ( memcmp(m_KeyStart, label, SMPTE_UL_LENGTH) == 0 ) ?
- RESULT_OK : RESULT_FAIL;
+ result = ( UL(m_KeyStart) == label ) ? RESULT_OK : RESULT_FAIL;
return result;
}
//
ASDCP::Result_t
-ASDCP::KLVFilePacket::WriteKLToFile(Kumu::FileWriter& Writer, const byte_t* label, ui32_t length)
+ASDCP::KLVFilePacket::WriteKLToFile(Kumu::FileWriter& Writer, const UL& label, ui32_t length)
{
byte_t buffer[kl_length];
- memcpy(buffer, label, SMPTE_UL_LENGTH);
+ memcpy(buffer, label.Value(), label.Size());
if ( ! Kumu::write_BER(buffer+SMPTE_UL_LENGTH, length, MXF_BER_LENGTH) )
return RESULT_FAIL;