/* Copyright (C) 2012-2013 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 the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include "asset_instance.h" using std::string; using boost::shared_ptr; using namespace libdcp; AssetInstance::AssetInstance (shared_ptr node) { id = node->string_child ("Id"); annotation_text = node->optional_string_child ("AnnotationText").get_value_or (""); edit_rate = Fraction (node->string_child ("EditRate")); intrinsic_duration = node->number_child ("IntrinsicDuration"); entry_point = node->number_child ("EntryPoint"); duration = node->number_child ("Duration"); frame_rate = Fraction (node->string_child ("FrameRate")); key_id = node->optional_string_child ("KeyId").get_value_or (""); node->ignore_child ("Hash"); node->ignore_child ("ScreenAspectRatio"); node->ignore_child ("Language"); node->done (); } void AssetInstance::write_to_cpl (xmlpp::Element* node, bool interop) const { pair const attr = cpl_node_attribute (interop); xmlpp::Element* a = node->add_child (cpl_node_name ()); if (!attr.first.empty ()) { a->set_attribute (attr.first, attr.second); } a->add_child ("Id")->add_child_text ("urn:uuid:" + _uuid); a->add_child ("AnnotationText")->add_child_text (_file_name); a->add_child ("EditRate")->add_child_text (lexical_cast (_edit_rate) + " 1"); a->add_child ("IntrinsicDuration")->add_child_text (lexical_cast (_intrinsic_duration)); a->add_child ("EntryPoint")->add_child_text (lexical_cast (_entry_point)); a->add_child ("Duration")->add_child_text (lexical_cast (_duration)); if (_encrypted) { a->add_child("KeyId")->add_child_text ("urn:uuid:" + _key_id); } } bool AssetInstance::equals (shared_ptr other, EqualityOptions opt, boost::function note) const { if (id != other->id) { note (ERROR, "ids differ"); return false; } /* XXX: to do */ std::string annotation_text; if (edit_rate != other->edit_rate) { note (ERROR, "asset edit rates differ"); return false; } if (intrinsic_duration != other->intrinsic_duration) { note (ERROR, "asset intrinsic durations differ"); } if (duration != other->duration) { note (ERROR, "asset durations differ"); } Fraction edit_rate; /** Duration of the whole thing */ int64_t intrinsic_duration; /** Start point in frames */ int64_t entry_point; /** Duration that will actually play */ int64_t duration; Fraction frame_rate; std::string key_id; shared_ptr other_mxf = dynamic_pointer_cast (other); if (!other_mxf) { note (ERROR, "comparing an MXF asset with a non-MXF asset"); return false; } if (_file_name != other_mxf->_file_name) { note (ERROR, "MXF names differ"); if (!opt.mxf_names_can_differ) { return false; } } return true; }