diff options
| author | Carl Hetherington <cth@carlh.net> | 2012-07-30 23:47:57 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2012-07-30 23:47:57 +0100 |
| commit | 9a9d4e014c16be88d72914a9480343445bc785a5 (patch) | |
| tree | 1857fcdd8963d51ac50f1467d9ae81d4d9be5f8e /src/dcp.cc | |
| parent | 34a25d89b16a33b5f619ae0eaaa03c17f93980af (diff) | |
Various.
Diffstat (limited to 'src/dcp.cc')
| -rw-r--r-- | src/dcp.cc | 147 |
1 files changed, 18 insertions, 129 deletions
@@ -32,15 +32,18 @@ #include "picture_asset.h" #include "util.h" #include "metadata.h" +#include "exceptions.h" +#include "cpl.h" +#include "pkl.h" using namespace std; using namespace boost; using namespace libdcp; -DCP::DCP (string directory, string name, ContentType content_type, int fps, int length) +DCP::DCP (string directory, string name, ContentKind content_kind, int fps, int length) : _directory (directory) , _name (name) - , _content_type (content_type) + , _content_kind (content_kind) , _fps (fps) , _length (length) { @@ -115,7 +118,7 @@ DCP::write_cpl (string cpl_uuid) const << " <IssueDate>" << Metadata::instance()->issue_date << "</IssueDate>\n" << " <Creator>" << Metadata::instance()->creator << "</Creator>\n" << " <ContentTitleText>" << _name << "</ContentTitleText>\n" - << " <ContentKind>" << content_type_string (_content_type) << "</ContentKind>\n" + << " <ContentKind>" << content_kind_to_string (_content_kind) << "</ContentKind>\n" << " <ContentVersion>\n" << " <Id>urn:uri:" << cpl_uuid << "_" << Metadata::instance()->issue_date << "</Id>\n" << " <LabelText>" << cpl_uuid << "_" << Metadata::instance()->issue_date << "</LabelText>\n" @@ -243,148 +246,34 @@ DCP::write_assetmap (string cpl_uuid, int cpl_length, string pkl_uuid, int pkl_l DCP::DCP (string directory) : _directory (directory) { - string cpl; - string pkl; - string asset_map; + string cpl_file; + string pkl_file; + string asset_map_file; for (filesystem::directory_iterator i = filesystem::directory_iterator(directory); i != filesystem::directory_iterator(); ++i) { - string const t = i->path()->string (); + string const t = i->path().string (); if (ends_with (t, "_cpl.xml")) { - if (cpl.empty ()) { - cpl = t; + if (cpl_file.empty ()) { + cpl_file = t; } else { throw DCPReadError ("duplicate CPLs found"); } } else if (ends_with (t, "_pkl.xml")) { - if (pkl.empty ()) { - pkl = t; + if (pkl_file.empty ()) { + pkl_file = t; } else { throw DCPReadError ("duplicate PKLs found"); } } else if (ends_with (t, "ASSETMAP.xml")) { - if (asset_map.empty ()) { - asset_map = t; + if (asset_map_file.empty ()) { + asset_map_file = t; } else { throw DCPReadError ("duplicate AssetMaps found"); } } } - load_cpl (cpl); - load_pkl (pkl); - load_asset_map (asset_map); + CPL cpl (cpl_file); + PKL pkl (pkl_file); } -void -DCP::load_cpl (string file) -{ - xmlpp::DOMParser parser; - parser.parser_file (file); - if (!parser) { - throw DCPReadError ("could not create parser for CPL"); - } - - xmlpp::Element* root = parser.get_document()->get_root_node (); - dcp_read_assert (root->get_name() == "CompositionPlaylist", "unrecognised CPL format"); - - xmlpp::Node::NodeList children = root->get_children (); - for (xmlpp::Node::NodeList::iterator i = children.begin(); i != children.end(); ++i) { - bool taken = false; - xml_maybe (*i, taken, _cpl_id, "Id"); - xml_maybe (*i, taken, _annotation_text, "AnnotationText"); - xml_maybe (*i, taken, _issue_date, "IssueDate"); - xml_maybe (*i, taken, _creator, "Creator"); - xml_maybe (*i, taken, _content_title_text, "ContentTitleText"); - xml_maybe (*i, taken, _content_kind, "ContentKind"); - - if ((*i)->get_name() == "ContentVersion") { - taken = true; - load_cpl_content_version (*i); - } - - if ((*i)->get_name() == "RatingList") { - taken = true; - } - - if ((*i)->get_name() == "ReelList") { - taken = true; - load_cpl_reel_list (*i); - } - - xml_assert_taken (*i, taken); - } -} - -void -DCP::load_cpl_content_version (xmlpp::Node const * node) -{ - xmlpp::Node::NodeList children = node->get_children (); - for (xmlpp::Node::NodeList::iterator i = children.begin(); i != children.end(); ++i) { - bool taken = false; - xml_maybe (*i, taken, _content_version_id, "Id"); - xml_maybe (*i, taken, _content_version_label_text, "LabelText"); - xml_assert_taken (*i, taken); - } -} - -void -DCP::load_cpl_reel_list (xmlpp::Node const * node) -{ - xmlpp::Node::NodeList children = node->get_children (); - bool had_reel = false; - for (xmlpp::Node::NodeList::iterator i = children.begin(); i != children.end(); ++i) { - bool taken = false; - if ((*i)->get_name() == "Reel") { - if (!had_reel) { - load_cpl_reel (*i); - had_reel = true; - } else { - throw DCPReadError ("multiple reels not supported"); - } - } - xml_assert_taken (*i, taken); - } -} - -void -DCP::load_cpl_reel (xmlpp::Node const * node) -{ - xmlpp::Node::NodeList children = node->get_children (); - for (xmlpp::Node::NodeList::iterator i = children.begin(); i != children.end(); ++i) { - bool taken = false; - xml_taken (*i, taken, _reel_id, "Id"); - if ((*i)->name() == "AssetList") { - taken = true; - load_cpl_asset_list (*i); - } - xml_assert_taken (*i, taken); - } -} - -void -DCP::load_cpl_asset_list (xmlpp::Node const * node) -{ - xmlpp::Node::NodeList children = node->get_children (); - for (xmlpp::Node::NodeList::iterator i = children.begin(); i != children.end(); ++i) { - bool taken = false; - if ((*i)->name() == "MainPicture") { - taken = true; - load_cpl_main_picture (*i); - } else if ((*i)->name() == "MainSound") { - taken = true; - load_cpl_main_sound (*i); - } - xml_assert_taken (*i, taken); - } -} - -void -DCP::load_cpl_main_picture (xmlpp::Node const * node) -{ - xmlpp::Node::NodeList children = node->get_children (); - for (xmlpp::Node::NodeList::iterator i = children.begin(); i != children.end(); ++i) { - bool taken = false; - xml_maybe (*i, taken, _video_id, "Id"); - - } -} |
