diff options
| author | Carl Hetherington <cth@carlh.net> | 2012-08-13 00:10:19 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2012-08-13 00:10:19 +0100 |
| commit | 830d8e01713add5856f44a5246eb65781458d0b8 (patch) | |
| tree | 736702d96029223cd3403f58bbbd9286dc5680c8 /src | |
| parent | a1a33941351365cc371f468c6c9c8f0cf8ca32d2 (diff) | |
Tweaks for more real-life DCPs; beginning of subtitle support.
Diffstat (limited to 'src')
| -rw-r--r-- | src/asset_map.cc | 2 | ||||
| -rw-r--r-- | src/cpl.cc | 18 | ||||
| -rw-r--r-- | src/cpl.h | 15 | ||||
| -rw-r--r-- | src/dcp.cc | 12 | ||||
| -rw-r--r-- | src/dcp.h | 1 | ||||
| -rw-r--r-- | src/xml.cc | 7 |
6 files changed, 47 insertions, 8 deletions
diff --git a/src/asset_map.cc b/src/asset_map.cc index b77c4ac1..3e0a0545 100644 --- a/src/asset_map.cc +++ b/src/asset_map.cc @@ -26,7 +26,7 @@ Chunk::Chunk (xmlpp::Node const * node) : XMLNode (node) { path = string_node ("Path"); - volume_index = int64_node ("VolumeIndex"); + volume_index = optional_int64_node ("VolumeIndex"); offset = optional_int64_node ("Offset"); length = optional_int64_node ("Length"); } @@ -8,7 +8,7 @@ CPL::CPL (string file) : XMLFile (file, "CompositionPlaylist") { id = string_node ("Id"); - annotation_text = string_node ("AnnotationText"); + annotation_text = optional_string_node ("AnnotationText"); issue_date = string_node ("IssueDate"); creator = string_node ("Creator"); content_title_text = string_node ("ContentTitleText"); @@ -46,6 +46,7 @@ CPLAssetList::CPLAssetList (xmlpp::Node const * node) { main_picture = sub_node<MainPicture> ("MainPicture"); main_sound = optional_sub_node<MainSound> ("MainSound"); + main_subtitle = optional_sub_node<MainSubtitle> ("MainSubtitle"); done (); } @@ -91,3 +92,18 @@ MainSound::MainSound (xmlpp::Node const * node) done (); } + +MainSubtitle::MainSubtitle (xmlpp::Node const * node) + : XMLNode (node) +{ + id = string_node ("Id"); + annotation_text = optional_string_node ("AnnotationText"); + edit_rate = fraction_node ("EditRate"); + intrinsic_duration = int64_node ("IntrinsicDuration"); + entry_point = int64_node ("EntryPoint"); + duration = int64_node ("Duration"); + + ignore_node ("Hash"); + + done (); +} @@ -34,6 +34,20 @@ public: int64_t duration; }; +class MainSubtitle : public XMLNode +{ +public: + MainSubtitle () {} + MainSubtitle (xmlpp::Node const * node); + + std::string id; + std::string annotation_text; + Fraction edit_rate; + int64_t intrinsic_duration; + int64_t entry_point; + int64_t duration; +}; + class CPLAssetList : public XMLNode { public: @@ -42,6 +56,7 @@ public: boost::shared_ptr<MainPicture> main_picture; boost::shared_ptr<MainSound> main_sound; + boost::shared_ptr<MainSubtitle> main_subtitle; }; class Reel : public XMLNode @@ -288,9 +288,9 @@ 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; + string n = pkl->asset_from_id(cpl_assets->main_picture->id)->original_file_name; if (n.empty ()) { - n = pkl->asset_from_id(cpl_assets->main_picture->id)->original_file_name; + n = cpl_assets->main_picture->annotation_text; } _assets.push_back (shared_ptr<PictureAsset> ( @@ -304,9 +304,9 @@ DCP::DCP (string directory) if (cpl_assets->main_sound) { - n = cpl_assets->main_sound->annotation_text; + n = pkl->asset_from_id(cpl_assets->main_sound->id)->original_file_name; if (n.empty ()) { - n = pkl->asset_from_id(cpl_assets->main_sound->id)->original_file_name; + n = cpl_assets->main_sound->annotation_text; } _assets.push_back (shared_ptr<SoundAsset> ( @@ -333,7 +333,7 @@ DCP::scan (Files& files, string directory) const continue; } - if (ends_with (t, ".mxf")) { + if (ends_with (t, ".mxf") || ends_with (t, ".ttf")) { continue; } @@ -373,6 +373,8 @@ DCP::scan (Files& files, string directory) const throw DCPReadError ("duplicate AssetMaps found"); } files.asset_map = t; + } else if (root == "DCSubtitle") { + files.subtitles.push_back (t); } } } @@ -149,6 +149,7 @@ private: std::string cpl; std::string pkl; std::string asset_map; + std::list<std::string> subtitles; }; void scan (Files& files, std::string directory) const; @@ -62,9 +62,14 @@ XMLNode::string_node (string name) xmlpp::Node* node = xml_node (name); xmlpp::Node::NodeList c = node->get_children (); - if (c.size() != 1) { + + if (c.size() > 1) { throw XMLError ("unexpected content in XML node"); } + + if (c.empty ()) { + return ""; + } xmlpp::ContentNode const * v = dynamic_cast<xmlpp::ContentNode const *> (c.front()); if (!v) { |
