From 2cd9086c95686117ffbce92188d50d525ed488bb Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 11 Aug 2012 22:06:47 +0100 Subject: Various tweaks for a real-life DCP. --- src/dcp.cc | 46 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) (limited to 'src/dcp.cc') diff --git a/src/dcp.cc b/src/dcp.cc index b6014941..99cc517a 100644 --- a/src/dcp.cc +++ b/src/dcp.cc @@ -25,7 +25,9 @@ #include #include #include +#include #include +#include #include "dcp.h" #include "asset.h" #include "sound_asset.h" @@ -240,25 +242,49 @@ DCP::DCP (string directory) string asset_map_file; for (filesystem::directory_iterator i = filesystem::directory_iterator(directory); i != filesystem::directory_iterator(); ++i) { + string const t = i->path().string (); - if (ends_with (t, "_cpl.xml")) { + + if (ends_with (t, ".mxf")) { + continue; + } + + xmlpp::DomParser* p = new xmlpp::DomParser; + + try { + p->parse_file (t); + } catch (std::exception& e) { + delete p; + continue; + } + + if (!p) { + delete p; + continue; + } + + string const root = p->get_document()->get_root_node()->get_name (); + delete p; + + if (root == "CompositionPlaylist") { if (cpl_file.empty ()) { cpl_file = t; } else { throw DCPReadError ("duplicate CPLs found"); } - } else if (ends_with (t, "_pkl.xml")) { + } else if (root == "PackingList") { if (pkl_file.empty ()) { pkl_file = t; } else { throw DCPReadError ("duplicate PKLs found"); } - } else if (ends_with (t, "ASSETMAP.xml")) { + } else if (root == "AssetMap") { if (asset_map_file.empty ()) { asset_map_file = t; } else { throw DCPReadError ("duplicate AssetMaps found"); } + asset_map_file = t; } } @@ -310,10 +336,15 @@ DCP::DCP (string directory) _fps = cpl_assets->main_picture->frame_rate.numerator; _length = cpl_assets->main_picture->duration; + string n = cpl_assets->main_picture->annotation_text; + if (n.empty ()) { + n = pkl->asset_from_id(cpl_assets->main_picture->id)->original_file_name; + } + _assets.push_back (shared_ptr ( new PictureAsset ( _directory, - cpl_assets->main_picture->annotation_text, + n, _fps, _length, cpl_assets->main_picture->screen_aspect_ratio.numerator, @@ -321,11 +352,16 @@ DCP::DCP (string directory) ) )); + n = cpl_assets->main_sound->annotation_text; + if (n.empty ()) { + n = pkl->asset_from_id(cpl_assets->main_sound->id)->original_file_name; + } + if (cpl_assets->main_sound) { _assets.push_back (shared_ptr ( new SoundAsset ( _directory, - cpl_assets->main_sound->annotation_text, + n, _fps, _length ) -- cgit v1.2.3