diff options
| author | jhurst <jhurst@cinecert.com> | 2014-09-21 13:27:43 +0000 |
|---|---|---|
| committer | jhurst <> | 2014-09-21 13:27:43 +0000 |
| commit | ab3e3df49a9d4a44a3bf11211e31bdeac3ef7bcf (patch) | |
| tree | 52023c92807dde6cb56835e957349327f1b9df0b /src/MXF.cpp | |
| parent | 8d24b6effb0377fc3041c2e024e7c5593caecc52 (diff) | |
imf bugs
date parse bug
timed-text transform removed
Diffstat (limited to 'src/MXF.cpp')
| -rwxr-xr-x | src/MXF.cpp | 123 |
1 files changed, 122 insertions, 1 deletions
diff --git a/src/MXF.cpp b/src/MXF.cpp index f113444..c3a3a5d 100755 --- a/src/MXF.cpp +++ b/src/MXF.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2005-2013, John Hurst +Copyright (c) 2005-2014, John Hurst All rights reserved. Redistribution and use in source and binary forms, with or without @@ -1716,6 +1716,127 @@ ASDCP::MXF::AS02_MCAConfigParser::AS02_MCAConfigParser(const Dictionary*& d) : A m_LabelMap.insert(pair("VIN", label_traits("VIN", true, m_Dict->ul(MDD_IMFAudioSoundfield_VIN)))); } + + +// +bool +ASDCP::MXF::GetEditRateFromFP(ASDCP::MXF::OP1aHeader& header, ASDCP::Rational& edit_rate) +{ + bool has_first_item = false; + + MXF::InterchangeObject* temp_item; + std::list<MXF::InterchangeObject*> temp_items; + + Result_t result = header.GetMDObjectsByType(DefaultCompositeDict().ul(MDD_SourcePackage), temp_items); + + if ( KM_FAILURE(result) ) + { + DefaultLogSink().Error("The MXF header does not contain a FilePackage item.\n"); + return false; + } + + if ( temp_items.size() != 1 ) + { + DefaultLogSink().Error("The MXF header must contain one FilePackage item, found %d.\n", temp_items.size()); + return false; + } + + char buf[64]; + MXF::Batch<UUID>::const_iterator i; + MXF::SourcePackage *source_package = dynamic_cast<MXF::SourcePackage*>(temp_items.front()); + assert(source_package); + + for ( i = source_package->Tracks.begin(); i != source_package->Tracks.end(); ++i ) + { + // Track + result = header.GetMDObjectByID(*i, &temp_item); + + if ( KM_FAILURE(result) ) + { + DefaultLogSink().Error("The MXF header is incomplete: strong reference %s leads nowhere.\n", + i->EncodeHex(buf, 64)); + return false; + } + + MXF::Track *track = dynamic_cast<MXF::Track*>(temp_item); + + if ( track == 0 ) + { + DefaultLogSink().Error("The MXF header is incomplete: %s is not a Track item.\n", + i->EncodeHex(buf, 64)); + return false; + } + + // Sequence + result = header.GetMDObjectByID(track->Sequence, &temp_item); + + if ( KM_FAILURE(result) ) + { + DefaultLogSink().Error("The MXF header is incomplete: strong reference %s leads nowhere.\n", + i->EncodeHex(buf, 64)); + return false; + } + + MXF::Sequence *sequence = dynamic_cast<MXF::Sequence*>(temp_item); + + if ( sequence == 0 ) + { + DefaultLogSink().Error("The MXF header is incomplete: %s is not a Sequence item.\n", + track->Sequence.get().EncodeHex(buf, 64)); + return false; + } + + if ( sequence->StructuralComponents.size() != 1 ) + { + DefaultLogSink().Error("The Sequence item must contain one reference to an esence item, found %d.\n", + sequence->StructuralComponents.size()); + return false; + } + + // SourceClip + result = header.GetMDObjectByID(sequence->StructuralComponents.front(), &temp_item); + + if ( KM_FAILURE(result) ) + { + DefaultLogSink().Error("The MXF header is incomplete: strong reference %s leads nowhere.\n", + sequence->StructuralComponents.front().EncodeHex(buf, 64)); + return false; + } + + if ( temp_item->IsA(DefaultCompositeDict().ul(MDD_SourceClip)) ) + { + MXF::SourceClip *source_clip = dynamic_cast<MXF::SourceClip*>(temp_item); + + if ( source_clip == 0 ) + { + DefaultLogSink().Error("The MXF header is incomplete: %s is not a SourceClip item.\n", + sequence->StructuralComponents.front().EncodeHex(buf, 64)); + return false; + } + + if ( ! has_first_item ) + { + edit_rate = track->EditRate; + has_first_item = true; + } + else if ( edit_rate != track->EditRate ) + { + DefaultLogSink().Error("The MXF header is incomplete: %s EditRate value does not match others in the file.\n", + sequence->StructuralComponents.front().EncodeHex(buf, 64)); + return false; + } + } + else if ( ! temp_item->IsA(DefaultCompositeDict().ul(MDD_TimecodeComponent)) ) + { + DefaultLogSink().Error("Reference from Sequence to an unexpected type: %s.\n", temp_item->ObjectName()); + return false; + } + } + + return true; +} + + // // end MXF.cpp // |
