+
+
+/** @return a list of properties that might be interesting to the user */
+list<UserProperty>
+Content::user_properties (shared_ptr<const Film> film) const
+{
+ list<UserProperty> p;
+ add_properties (film, p);
+ return p;
+}
+
+
+/** @return DCP times of points within this content where a reel split could occur */
+list<DCPTime>
+Content::reel_split_points (shared_ptr<const Film>) const
+{
+ list<DCPTime> t;
+ /* This is only called for video content and such content has its position forced
+ to start on a frame boundary.
+ */
+ t.push_back (position());
+ return t;
+}
+
+
+void
+Content::set_video_frame_rate (double r)
+{
+ ContentChangeSignaller cc (this, ContentProperty::VIDEO_FRAME_RATE);
+
+ {
+ boost::mutex::scoped_lock lm (_mutex);
+ if (_video_frame_rate && fabs(r - *_video_frame_rate) < VIDEO_FRAME_RATE_EPSILON) {
+ cc.abort();
+ }
+ _video_frame_rate = r;
+ }
+
+ /* Make sure trim is still on a frame boundary */
+ if (video) {
+ set_trim_start (trim_start());
+ }
+}
+
+
+void
+Content::unset_video_frame_rate ()
+{
+ ContentChangeSignaller cc (this, ContentProperty::VIDEO_FRAME_RATE);
+
+ {
+ boost::mutex::scoped_lock lm (_mutex);
+ _video_frame_rate = optional<double>();
+ }
+}
+
+
+double
+Content::active_video_frame_rate (shared_ptr<const Film> film) const
+{
+ {
+ boost::mutex::scoped_lock lm (_mutex);
+ if (_video_frame_rate) {
+ return _video_frame_rate.get ();
+ }
+ }
+
+ /* No frame rate specified, so assume this content has been
+ prepared for any concurrent video content or perhaps
+ just the DCP rate.
+ */
+ return film->active_frame_rate_change(position()).source;
+}
+
+
+void
+Content::add_properties (shared_ptr<const Film>, list<UserProperty>& p) const
+{
+ p.push_back (UserProperty (UserProperty::GENERAL, _("Filename"), path(0).string ()));
+
+ if (_video_frame_rate) {
+ if (video) {
+ p.push_back (
+ UserProperty (
+ UserProperty::VIDEO,
+ _("Frame rate"),
+ locale_convert<string> (_video_frame_rate.get(), 5),
+ _("frames per second")
+ )
+ );
+ } else {
+ p.push_back (
+ UserProperty (
+ UserProperty::GENERAL,
+ _("Prepared for video frame rate"),
+ locale_convert<string> (_video_frame_rate.get(), 5),
+ _("frames per second")
+ )
+ );
+ }
+ }
+}
+
+
+/** Take settings from the given content if it is of the correct type */
+void
+Content::take_settings_from (shared_ptr<const Content> c)
+{
+ if (video && c->video) {
+ video->take_settings_from (c->video);
+ }
+ if (audio && c->audio) {
+ audio->take_settings_from (c->audio);
+ }
+
+ auto i = text.begin ();
+ auto j = c->text.begin ();
+ while (i != text.end() && j != c->text.end()) {
+ (*i)->take_settings_from (*j);
+ ++i;
+ ++j;
+ }
+}
+
+
+shared_ptr<TextContent>
+Content::only_text () const
+{
+ DCPOMATIC_ASSERT (text.size() < 2);
+ if (text.empty()) {
+ return {};
+ }
+ return text.front ();
+}
+
+
+shared_ptr<TextContent>
+Content::text_of_original_type (TextType type) const
+{
+ for (auto i: text) {
+ if (i->original_type() == type) {
+ return i;
+ }
+ }
+
+ return {};
+}
+
+
+void
+Content::add_path (boost::filesystem::path p)
+{
+ boost::mutex::scoped_lock lm (_mutex);
+ _paths.push_back (p);
+ boost::system::error_code ec;
+ auto last_write = boost::filesystem::last_write_time(p, ec);
+ _last_write_times.push_back (ec ? 0 : last_write);
+}
+
+
+bool
+Content::changed () const
+{
+ bool write_time_changed = false;
+ for (auto i = 0U; i < _paths.size(); ++i) {
+ if (boost::filesystem::last_write_time(_paths[i]) != last_write_time(i)) {
+ write_time_changed = true;
+ break;
+ }
+ }
+
+ return (write_time_changed || calculate_digest() != digest());
+}