X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Freel_asset.cc;h=cd54ccba753f43fc93a11fcfb2ecfb2efc185063;hb=2fa5b7bfeb3826c20f2fe80f272b556d61935063;hp=8cac7403f5d5608bfe761eaa729f6b7924eff9ae;hpb=5665c52ad16aaba050c34b8b391a3212e8cf85a8;p=libdcp.git diff --git a/src/reel_asset.cc b/src/reel_asset.cc index 8cac7403..cd54ccba 100644 --- a/src/reel_asset.cc +++ b/src/reel_asset.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2015 Carl Hetherington + Copyright (C) 2014-2021 Carl Hetherington This file is part of libdcp. @@ -31,30 +31,29 @@ files in the program, then also delete it here. */ + /** @file src/reel_asset.cc - * @brief ReelAsset class. + * @brief ReelAsset class */ + #include "raw_convert.h" #include "reel_asset.h" #include "asset.h" #include "compose.hpp" +#include "dcp_assert.h" #include #include + using std::pair; using std::string; using std::make_pair; -using boost::shared_ptr; +using std::shared_ptr; using boost::optional; using namespace dcp; -/** Construct a ReelAsset. - * @param id ID of this ReelAsset (which is that of the MXF, if there is one) - * @param edit_rate Edit rate for the asset. - * @param intrinsic_duration Intrinsic duration of this asset. - * @param entry_point Entry point to use in that asset. - */ + ReelAsset::ReelAsset (string id, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point) : Object (id) , _intrinsic_duration (intrinsic_duration) @@ -62,9 +61,10 @@ ReelAsset::ReelAsset (string id, Fraction edit_rate, int64_t intrinsic_duration, , _edit_rate (edit_rate) , _entry_point (entry_point) { - + DCP_ASSERT (_entry_point <= _intrinsic_duration); } + ReelAsset::ReelAsset (shared_ptr node) : Object (remove_urn_uuid (node->string_child ("Id"))) , _intrinsic_duration (node->number_child ("IntrinsicDuration")) @@ -76,21 +76,22 @@ ReelAsset::ReelAsset (shared_ptr node) } + xmlpp::Node* ReelAsset::write_to_cpl_asset (xmlpp::Node* node, Standard standard, optional hash) const { - xmlpp::Element* a = node->add_child (cpl_node_name (standard)); - pair const attr = cpl_node_attribute (standard); + auto a = node->add_child (cpl_node_name (standard)); + auto const attr = cpl_node_attribute (standard); if (!attr.first.empty ()) { a->set_attribute (attr.first, attr.second); } - pair const ns = cpl_node_namespace (standard); - if (!ns.first.empty ()) { + auto const ns = cpl_node_namespace (); + if (!ns.first.empty()) { a->set_namespace_declaration (ns.first, ns.second); } a->add_child("Id")->add_child_text ("urn:uuid:" + _id); a->add_child("AnnotationText")->add_child_text (_annotation_text); - a->add_child("EditRate")->add_child_text (String::compose ("%1 %2", _edit_rate.numerator, _edit_rate.denominator)); + a->add_child("EditRate")->add_child_text (_edit_rate.as_string()); a->add_child("IntrinsicDuration")->add_child_text (raw_convert (_intrinsic_duration)); if (_entry_point) { a->add_child("EntryPoint")->add_child_text(raw_convert(*_entry_point)); @@ -104,55 +105,58 @@ ReelAsset::write_to_cpl_asset (xmlpp::Node* node, Standard standard, optional ReelAsset::cpl_node_attribute (Standard) const { return make_pair ("", ""); } + pair -ReelAsset::cpl_node_namespace (Standard) const +ReelAsset::cpl_node_namespace () const { return make_pair ("", ""); } + bool ReelAsset::asset_equals (shared_ptr other, EqualityOptions opt, NoteHandler note) const { if (_annotation_text != other->_annotation_text) { string const s = "Reel: annotation texts differ (" + _annotation_text + " vs " + other->_annotation_text + ")\n"; if (!opt.reel_annotation_texts_can_differ) { - note (DCP_ERROR, s); + note (NoteType::ERROR, s); return false; } else { - note (DCP_NOTE, s); + note (NoteType::NOTE, s); } } if (_edit_rate != other->_edit_rate) { - note (DCP_ERROR, "Reel: edit rates differ"); + note (NoteType::ERROR, "Reel: edit rates differ"); return false; } if (_intrinsic_duration != other->_intrinsic_duration) { - note (DCP_ERROR, String::compose ("Reel: intrinsic durations differ (%1 vs %2)", _intrinsic_duration, other->_intrinsic_duration)); + note (NoteType::ERROR, String::compose ("Reel: intrinsic durations differ (%1 vs %2)", _intrinsic_duration, other->_intrinsic_duration)); return false; } if (_entry_point != other->_entry_point) { - note (DCP_ERROR, "Reel: entry points differ"); + note (NoteType::ERROR, "Reel: entry points differ"); return false; } if (_duration != other->_duration) { - note (DCP_ERROR, "Reel: durations differ"); + note (NoteType::ERROR, "Reel: durations differ"); return false; } return true; } -/** @return , or - if is not present */ + int64_t ReelAsset::actual_duration () const {