Take ISDCF metadata from templates.
[dcpomatic.git] / src / lib / content.cc
index 21b04c6493aea2f3d2ee0410a788b39a8dc85d04..f2380653f661d54131e50194f42522742f07a562 100644 (file)
@@ -48,6 +48,7 @@ using std::vector;
 using std::max;
 using std::pair;
 using boost::shared_ptr;
+using boost::optional;
 using dcp::raw_convert;
 using dcp::locale_convert;
 
@@ -190,6 +191,11 @@ Content::signal_changed (int p)
 void
 Content::set_position (DCPTime p)
 {
+       /* video content can modify its position */
+       if (video) {
+               video->modify_position (p);
+       }
+
        {
                boost::mutex::scoped_lock lm (_mutex);
                if (p == _position) {
@@ -205,6 +211,11 @@ Content::set_position (DCPTime p)
 void
 Content::set_trim_start (ContentTime t)
 {
+       /* video content can modify its start trim */
+       if (video) {
+               video->modify_trim_start (t);
+       }
+
        {
                boost::mutex::scoped_lock lm (_mutex);
                _trim_start = t;
@@ -333,8 +344,10 @@ list<DCPTime>
 Content::reel_split_points () const
 {
        list<DCPTime> t;
-       /* XXX: this is questionable; perhaps the position itself should be forced to be on a frame boundary */
-       t.push_back (position().ceil (film()->video_frame_rate()));
+       /* 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;
 }
 
@@ -349,6 +362,17 @@ Content::set_video_frame_rate (double r)
        signal_changed (ContentProperty::VIDEO_FRAME_RATE);
 }
 
+void
+Content::unset_video_frame_rate ()
+{
+       {
+               boost::mutex::scoped_lock lm (_mutex);
+               _video_frame_rate = optional<double>();
+       }
+
+       signal_changed (ContentProperty::VIDEO_FRAME_RATE);
+}
+
 double
 Content::active_video_frame_rate () const
 {
@@ -396,16 +420,17 @@ Content::add_properties (list<UserProperty>& p) const
        }
 }
 
+/** Take settings from the given content if it is of the correct type */
 void
-Content::use_template (shared_ptr<const Content> c)
+Content::take_settings_from (shared_ptr<const Content> c)
 {
        if (video && c->video) {
-               video->use_template (c->video);
+               video->take_settings_from (c->video);
        }
        if (audio && c->audio) {
-               audio->use_template (c->audio);
+               audio->take_settings_from (c->audio);
        }
        if (subtitle && c->subtitle) {
-               subtitle->use_template (c->subtitle);
+               subtitle->take_settings_from (c->subtitle);
        }
 }