ASDCP::Result_t
ASDCP::MXF::RIP::InitFromFile(const Kumu::FileReader& Reader)
{
- Result_t result = KLVFilePacket::InitFromFile(Reader, m_Dict.ul(MDD_RandomIndexMetadata));
+ assert(m_Dict);
+ Result_t result = KLVFilePacket::InitFromFile(Reader, m_Dict->ul(MDD_RandomIndexMetadata));
if ( ASDCP_SUCCESS(result) )
{
ASDCP::Result_t
ASDCP::MXF::RIP::WriteToFile(Kumu::FileWriter& Writer)
{
+ assert(m_Dict);
ASDCP::FrameBuffer Buffer;
ui32_t RIPSize = ( PairArray.size() * (sizeof(ui32_t) + sizeof(ui64_t)) ) + 4;
Result_t result = Buffer.Capacity(RIPSize);
if ( ASDCP_SUCCESS(result) )
- result = WriteKLToFile(Writer, m_Dict.ul(MDD_RandomIndexMetadata), RIPSize);
+ result = WriteKLToFile(Writer, m_Dict->ul(MDD_RandomIndexMetadata), RIPSize);
if ( ASDCP_SUCCESS(result) )
{
if ( stream == 0 )
stream = stderr;
- KLVFilePacket::Dump(stream, m_Dict, false);
+ KLVFilePacket::Dump(stream, *m_Dict, false);
PairArray.Dump(stream, false);
}
//
-ASDCP::MXF::Partition::Partition(const Dictionary& d) :
+ASDCP::MXF::Partition::Partition(const Dictionary*& d) :
m_Dict(d),
MajorVersion(1), MinorVersion(2),
KAGSize(1), ThisPartition(0), PreviousPartition(0),
if ( stream == 0 )
stream = stderr;
- KLVFilePacket::Dump(stream, m_Dict, false);
+ KLVFilePacket::Dump(stream, *m_Dict, false);
fprintf(stream, " MajorVersion = %hu\n", MajorVersion);
fprintf(stream, " MinorVersion = %hu\n", MinorVersion);
fprintf(stream, " KAGSize = %u\n", KAGSize);
//
-ASDCP::MXF::Primer::Primer(const Dictionary& d) : m_LocalTag(0xff), m_Dict(d) {}
+ASDCP::MXF::Primer::Primer(const Dictionary*& d) : m_LocalTag(0xff), m_Dict(d) {}
//
ASDCP::MXF::Primer::~Primer() {}
ASDCP::Result_t
ASDCP::MXF::Primer::InitFromBuffer(const byte_t* p, ui32_t l)
{
- Result_t result = KLVPacket::InitFromBuffer(p, l, m_Dict.ul(MDD_Primer));
+ assert(m_Dict);
+ Result_t result = KLVPacket::InitFromBuffer(p, l, m_Dict->ul(MDD_Primer));
if ( ASDCP_SUCCESS(result) )
{
ASDCP::Result_t
ASDCP::MXF::Primer::WriteToBuffer(ASDCP::FrameBuffer& Buffer)
{
+ assert(m_Dict);
ASDCP::FrameBuffer LocalTagBuffer;
Kumu::MemIOWriter MemWRT(Buffer.Data() + kl_length, Buffer.Capacity() - kl_length);
Result_t result = LocalTagEntryBatch.Archive(&MemWRT) ? RESULT_OK : RESULT_KLV_CODING;
if ( ASDCP_SUCCESS(result) )
{
ui32_t packet_length = MemWRT.Length();
- result = WriteKLToBuffer(Buffer, m_Dict.ul(MDD_Primer), packet_length);
+ result = WriteKLToBuffer(Buffer, m_Dict->ul(MDD_Primer), packet_length);
if ( ASDCP_SUCCESS(result) )
Buffer.Size(Buffer.Size() + packet_length);
void
ASDCP::MXF::Primer::Dump(FILE* stream)
{
+ assert(m_Dict);
char identbuf[IdentBufferLen];
if ( stream == 0 )
stream = stderr;
- KLVPacket::Dump(stream, m_Dict, false);
+ KLVPacket::Dump(stream, *m_Dict, false);
fprintf(stream, "Primer: %u %s\n",
(ui32_t)LocalTagEntryBatch.size(),
( LocalTagEntryBatch.size() == 1 ? "entry" : "entries" ));
Batch<LocalTagEntry>::iterator i = LocalTagEntryBatch.begin();
for ( ; i != LocalTagEntryBatch.end(); i++ )
{
- const MDDEntry* Entry = m_Dict.FindUL((*i).UL.Value());
+ const MDDEntry* Entry = m_Dict->FindUL((*i).UL.Value());
fprintf(stream, " %s %s\n", (*i).EncodeString(identbuf, IdentBufferLen), (Entry ? Entry->name : "Unknown"));
}
}
ASDCP::Result_t
ASDCP::MXF::Preface::InitFromBuffer(const byte_t* p, ui32_t l)
{
- m_Typeinfo = &m_Dict.Type(MDD_Preface);
+ assert(m_Dict);
+ m_Typeinfo = &(m_Dict->Type(MDD_Preface));
return InterchangeObject::InitFromBuffer(p, l);
}
ASDCP::Result_t
ASDCP::MXF::Preface::WriteToBuffer(ASDCP::FrameBuffer& Buffer)
{
- m_Typeinfo = &m_Dict.Type(MDD_Preface);
+ assert(m_Dict);
+ m_Typeinfo = &(m_Dict->Type(MDD_Preface));
return InterchangeObject::WriteToBuffer(Buffer);
}
//------------------------------------------------------------------------------------------
//
-ASDCP::MXF::OPAtomHeader::OPAtomHeader(const Dictionary& d) : Partition(d), m_Dict(d), m_RIP(d), m_Primer(d), m_Preface(0), m_HasRIP(false) {}
+ASDCP::MXF::OPAtomHeader::OPAtomHeader(const Dictionary*& d) : Partition(d), m_Dict(d), m_RIP(d), m_Primer(d), m_Preface(0), m_HasRIP(false) {}
ASDCP::MXF::OPAtomHeader::~OPAtomHeader() {}
//
return result;
// is it really OP-Atom?
- UL OPAtomUL(m_Dict.ul(MDD_OPAtom));
- UL InteropOPAtomUL(m_Dict.ul(MDD_MXFInterop_OPAtom));
+ assert(m_Dict);
+ UL OPAtomUL(SMPTE_390_OPAtom_Entry().ul);
+ UL InteropOPAtomUL(MXFInterop_OPAtom_Entry().ul);
- if ( ! ( OperationalPattern == OPAtomUL || OperationalPattern == InteropOPAtomUL ) )
+ if ( OperationalPattern == OPAtomUL ) // SMPTE
+ {
+ if ( m_Dict == &DefaultCompositeDict() )
+ m_Dict = &DefaultSMPTEDict();
+ }
+ else if ( OperationalPattern == InteropOPAtomUL ) // Interop
+ {
+ if ( m_Dict == &DefaultCompositeDict() )
+ m_Dict = &DefaultInteropDict();
+ }
+ else
{
char strbuf[IdentBufferLen];
- const MDDEntry* Entry = m_Dict.FindUL(OperationalPattern.Value());
+ const MDDEntry* Entry = m_Dict->FindUL(OperationalPattern.Value());
if ( Entry == 0 )
- DefaultLogSink().Warn("Operational pattern is not OP-Atom: %s\n", OperationalPattern.EncodeString(strbuf, IdentBufferLen));
+ DefaultLogSink().Warn("Operational pattern is not OP-Atom: %s\n",
+ OperationalPattern.EncodeString(strbuf, IdentBufferLen));
else
DefaultLogSink().Warn("Operational pattern is not OP-Atom: %s\n", Entry->name);
}
ASDCP::Result_t
ASDCP::MXF::OPAtomHeader::InitFromBuffer(const byte_t* p, ui32_t l)
{
+ assert(m_Dict);
Result_t result = RESULT_OK;
const byte_t* end_p = p + l;
if ( ASDCP_SUCCESS(result) )
{
- if ( object->IsA(m_Dict.ul(MDD_KLVFill)) )
+ if ( object->IsA(m_Dict->ul(MDD_KLVFill)) )
{
delete object;
}
- else if ( object->IsA(m_Dict.ul(MDD_Primer)) )
+ else if ( object->IsA(m_Dict->ul(MDD_Primer)) ) // TODO: only one primer should be found
{
delete object;
result = m_Primer.InitFromBuffer(redo_p, end_p - redo_p);
{
m_PacketList->AddPacket(object);
- if ( object->IsA(m_Dict.ul(MDD_Preface)) && m_Preface == 0 )
+ if ( object->IsA(m_Dict->ul(MDD_Preface)) && m_Preface == 0 )
m_Preface = (Preface*)object;
}
}
ASDCP::Result_t
ASDCP::MXF::OPAtomHeader::WriteToFile(Kumu::FileWriter& Writer, ui32_t HeaderSize)
{
+ assert(m_Dict);
if ( m_Preface == 0 )
return RESULT_STATE;
if ( ASDCP_SUCCESS(result) )
{
- UL TmpUL(m_Dict.ul(MDD_ClosedCompleteHeader));
+ UL TmpUL(m_Dict->ul(MDD_ClosedCompleteHeader));
result = Partition::WriteToFile(Writer, TmpUL);
}
}
klv_fill_length -= kl_length;
- result = WriteKLToFile(Writer, m_Dict.ul(MDD_KLVFill), klv_fill_length);
+ result = WriteKLToFile(Writer, m_Dict->ul(MDD_KLVFill), klv_fill_length);
if ( ASDCP_SUCCESS(result) )
result = NilBuf.Capacity(klv_fill_length);
//------------------------------------------------------------------------------------------
//
-ASDCP::MXF::OPAtomIndexFooter::OPAtomIndexFooter(const Dictionary& d) :
+ASDCP::MXF::OPAtomIndexFooter::OPAtomIndexFooter(const Dictionary*& d) :
Partition(d), m_Dict(d),
m_CurrentSegment(0), m_BytesPerEditUnit(0), m_BodySID(0),
m_ECOffset(0), m_Lookup(0)
ASDCP::Result_t
ASDCP::MXF::OPAtomIndexFooter::WriteToFile(Kumu::FileWriter& Writer, ui64_t duration)
{
+ assert(m_Dict);
ASDCP::FrameBuffer FooterBuffer;
ui32_t footer_size = m_PacketList->m_List.size() * MaxIndexSegmentSize; // segment-count * max-segment-size
Result_t result = FooterBuffer.Capacity(footer_size);
if ( ASDCP_SUCCESS(result) )
{
IndexByteCount = FooterBuffer.Size();
- UL FooterUL(m_Dict.ul(MDD_CompleteFooter));
+ UL FooterUL(m_Dict->ul(MDD_CompleteFooter));
result = Partition::WriteToFile(Writer, FooterUL);
}
char identbuf[IdentBufferLen];
fputc('\n', stream);
- KLVPacket::Dump(stream, m_Dict, false);
+ KLVPacket::Dump(stream, *m_Dict, false);
fprintf(stream, " InstanceUID = %s\n", InstanceUID.EncodeHex(identbuf, IdentBufferLen));
fprintf(stream, " GenerationUID = %s\n", GenerationUID.EncodeHex(identbuf, IdentBufferLen));
}
//
ASDCP::MXF::InterchangeObject*
-ASDCP::MXF::CreateObject(const Dictionary& Dict, const UL& label)
+ASDCP::MXF::CreateObject(const Dictionary*& Dict, const UL& label)
{
- if ( label == 0 )
- return 0;
-
if ( ! s_TypesInit )
{
Kumu::AutoMutex BlockLock(s_InitLock);
}
}
- FLi_t i = s_FactoryList.find(label);
+ FLi_t i = s_FactoryList.find(label.Value());
if ( i == s_FactoryList.end() )
return new InterchangeObject(Dict);