diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-08-30 17:27:22 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-08-30 17:27:22 +0100 |
| commit | ff38c8737a36e5aced5f2dede5bccd2832fc446a (patch) | |
| tree | 652a0548b76cfff2f4e7438c477cd4ac18f7a089 /src/asset_instance.cc | |
| parent | d0e025d26cab0eecfea1528343638dac69f363cd (diff) | |
Partial.rework-again
Diffstat (limited to 'src/asset_instance.cc')
| -rw-r--r-- | src/asset_instance.cc | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/src/asset_instance.cc b/src/asset_instance.cc new file mode 100644 index 00000000..6892ea8f --- /dev/null +++ b/src/asset_instance.cc @@ -0,0 +1,114 @@ +/* + Copyright (C) 2012-2013 Carl Hetherington <cth@carlh.net> + + 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 <libcxml/cxml.h> +#include "asset_instance.h" + +using std::string; +using boost::shared_ptr; +using namespace libdcp; + +AssetInstance::AssetInstance (shared_ptr<cxml::Node> 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<int64_t> ("IntrinsicDuration"); + entry_point = node->number_child<int64_t> ("EntryPoint"); + duration = node->number_child<int64_t> ("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<string, string> 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<string> (_edit_rate) + " 1"); + a->add_child ("IntrinsicDuration")->add_child_text (lexical_cast<string> (_intrinsic_duration)); + a->add_child ("EntryPoint")->add_child_text (lexical_cast<string> (_entry_point)); + a->add_child ("Duration")->add_child_text (lexical_cast<string> (_duration)); + if (_encrypted) { + a->add_child("KeyId")->add_child_text ("urn:uuid:" + _key_id); + } +} + +bool +AssetInstance::equals (shared_ptr<const AssetInstance> other, EqualityOptions opt, boost::function<void (NoteType, string)> 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<const MXFAsset> other_mxf = dynamic_pointer_cast<const MXFAsset> (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; + +} |
