X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Freel_picture_asset.cc;h=ccb4bd5672b1397b5760322b05c87eb544e5fa9d;hb=81312913ad26aaee12eeabd3f27a537806c97049;hp=1a3d47b99e40240c2d79947e3ad703679c1c011e;hpb=2f0e6ee9d883abbbc31aca0d1cc80e89eb9b0af2;p=libdcp.git diff --git a/src/reel_picture_asset.cc b/src/reel_picture_asset.cc index 1a3d47b9..ccb4bd56 100644 --- a/src/reel_picture_asset.cc +++ b/src/reel_picture_asset.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Carl Hetherington + Copyright (C) 2014-2015 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,17 +21,19 @@ * @brief ReelPictureAsset class. */ -#include "content.h" #include "reel_picture_asset.h" -#include "picture_mxf.h" +#include "picture_asset.h" +#include "dcp_assert.h" #include "compose.hpp" #include +#include #include using std::bad_cast; using std::string; using std::stringstream; using boost::shared_ptr; +using boost::dynamic_pointer_cast; using namespace dcp; ReelPictureAsset::ReelPictureAsset () @@ -41,16 +43,18 @@ ReelPictureAsset::ReelPictureAsset () } -ReelPictureAsset::ReelPictureAsset (boost::shared_ptr content, int64_t entry_point) - : ReelAsset (content, entry_point) - , _frame_rate (content->frame_rate ()) - , _screen_aspect_ratio (content->screen_aspect_ratio ()) +ReelPictureAsset::ReelPictureAsset (shared_ptr asset, int64_t entry_point) + : ReelAsset (asset, asset->edit_rate(), asset->intrinsic_duration(), entry_point) + , ReelMXF (asset->key_id()) + , _frame_rate (asset->frame_rate ()) + , _screen_aspect_ratio (asset->screen_aspect_ratio ()) { - + } -ReelPictureAsset::ReelPictureAsset (boost::shared_ptr node) +ReelPictureAsset::ReelPictureAsset (shared_ptr node) : ReelAsset (node) + , ReelMXF (node) { _frame_rate = Fraction (node->string_child ("FrameRate")); try { @@ -71,22 +75,54 @@ ReelPictureAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const { ReelAsset::write_to_cpl (node, standard); - xmlpp::Node::NodeList c = node->get_children (); - xmlpp::Node::NodeList::iterator i = c.begin(); - while (i != c.end() && (*i)->get_name() != cpl_node_name ()) { - ++i; - } + /* Find */ + xmlpp::Node* mp = find_child (node, cpl_node_name ()); - assert (i != c.end ()); - - (*i)->add_child ("FrameRate")->add_child_text (String::compose ("%1 %2", _frame_rate.numerator, _frame_rate.denominator)); + mp->add_child ("FrameRate")->add_child_text (String::compose ("%1 %2", _frame_rate.numerator, _frame_rate.denominator)); if (standard == INTEROP) { stringstream s; s << std::fixed << std::setprecision (2) << (float (_screen_aspect_ratio.numerator) / _screen_aspect_ratio.denominator); - (*i)->add_child ("ScreenAspectRatio")->add_child_text (s.str ()); + mp->add_child ("ScreenAspectRatio")->add_child_text (s.str ()); } else { - (*i)->add_child ("ScreenAspectRatio")->add_child_text ( + mp->add_child ("ScreenAspectRatio")->add_child_text ( String::compose ("%1 %2", _screen_aspect_ratio.numerator, _screen_aspect_ratio.denominator) ); } + + if (key_id ()) { + /* Find */ + xmlpp::Node* hash = find_child (mp, "Hash"); + mp->add_child_before (hash, "KeyId")->add_child_text ("urn:uuid:" + key_id().get ()); + } +} + +string +ReelPictureAsset::key_type () const +{ + return "MDIK"; +} + +bool +ReelPictureAsset::equals (shared_ptr other, EqualityOptions opt, NoteHandler note) const +{ + if (!ReelAsset::equals (other, opt, note)) { + return false; + } + + shared_ptr rpa = dynamic_pointer_cast (other); + if (!rpa) { + return false; + } + + if (_frame_rate != rpa->_frame_rate) { + note (DCP_ERROR, "frame rates differ in reel"); + return false; + } + + if (_screen_aspect_ratio != rpa->_screen_aspect_ratio) { + note (DCP_ERROR, "screen aspect ratios differ in reel"); + return false; + } + + return true; }