41 #include "compose.hpp"
47 #include <libcxml/cxml.h>
48 LIBDCP_DISABLE_WARNINGS
49 #include <libxml++/libxml++.h>
50 LIBDCP_ENABLE_WARNINGS
55 using std::shared_ptr;
57 using boost::optional;
63 , _intrinsic_duration (intrinsic_duration)
64 , _edit_rate (edit_rate)
65 , _entry_point (entry_point)
68 _duration = intrinsic_duration - *_entry_point;
71 DCP_ASSERT (!_entry_point || *_entry_point <= _intrinsic_duration);
75 ReelAsset::ReelAsset (shared_ptr<const cxml::Node> node)
76 :
Object (remove_urn_uuid (node->string_child (
"Id")))
77 , _intrinsic_duration (node->number_child<int64_t> (
"IntrinsicDuration"))
78 , _duration (node->optional_number_child<int64_t>(
"Duration"))
79 , _annotation_text (node->optional_string_child(
"AnnotationText"))
80 , _edit_rate (
Fraction (node->string_child (
"EditRate")))
81 , _entry_point (node->optional_number_child<int64_t>(
"EntryPoint"))
88 ReelAsset::write_to_cpl(xmlpp::Element* node, Standard standard)
const
92 if (!attr.first.empty ()) {
93 a->set_attribute (attr.first, attr.second);
96 if (!ns.first.empty()) {
97 a->set_namespace_declaration (ns.first, ns.second);
99 cxml::add_text_child(a,
"Id",
"urn:uuid:" + _id);
104 cxml::add_text_child(a,
"EditRate",
_edit_rate.as_string());
107 cxml::add_text_child(a,
"EntryPoint", raw_convert<string>(*
_entry_point));
110 cxml::add_text_child(a,
"Duration", raw_convert<string>(*
_duration));
119 return make_pair (
"",
"");
126 return make_pair (
"",
"");
132 optional_to_string (optional<T> o)
134 return o ? raw_convert<string>(*o) :
"[none]";
139 ReelAsset::asset_equals(shared_ptr<const ReelAsset> other,
EqualityOptions const& opt, NoteHandler note)
const
144 string const s = String::compose(
"Reel %1: annotation texts differ (%2 vs %3)", node, optional_to_string(
_annotation_text), optional_to_string(other->_annotation_text));
146 note (NoteType::ERROR, s);
149 note (NoteType::NOTE, s);
156 String::compose(
"Reel %1: edit rates differ (%2 vs %3)", node,
_edit_rate.as_string(), other->_edit_rate.as_string())
164 String::compose(
"Reel %1: intrinsic durations differ (%2 vs %3)", node,
_intrinsic_duration, other->_intrinsic_duration)
172 String::compose(
"Reel %1: entry points differ (%2 vs %3)", node, optional_to_string(
_entry_point), optional_to_string(other->_entry_point))
180 String::compose(
"Reel %1: durations differ (%2 vs %3)", node, optional_to_string(
_duration), optional_to_string(other->_duration))
A class to describe what "equality" means for a particular test.
bool reel_annotation_texts_can_differ
A fraction (i.e. a thing with an integer numerator and an integer denominator).
Some part of a DCP that has a UUID.
virtual std::pair< std::string, std::string > cpl_node_attribute(Standard) const
boost::optional< int64_t > _entry_point
The <EntryPoint> from the reel's entry for this asset.
ReelAsset(std::string id, Fraction edit_rate, int64_t intrinsic_duration, boost::optional< int64_t > entry_point)
virtual std::pair< std::string, std::string > cpl_node_namespace() const
Fraction _edit_rate
The <EditRate> from the reel's entry for this asset.
boost::optional< std::string > _annotation_text
The <AnnotationText> from the reel's entry for this asset.
virtual std::string cpl_node_name() const =0
int64_t actual_duration() const
int64_t _intrinsic_duration
The <IntrinsicDuration> from the reel's entry for this asset.
boost::optional< int64_t > _duration
The <Duration> from the reel's entry for this asset, if present.
Class to describe what equality means when calling Asset::equals().
Namespace for everything in libdcp.
Methods for conversion to/from string.