Clean up after previous commit.
[dcpomatic.git] / src / lib / playlist.cc
index a8b5a26ebbc0c4e91a9385d2aa67b5a724cf9bb2..a5451bafa418e21fedacb48eb319f8dfb8d33bcc 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2013-2016 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-2018 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
 
 #include "playlist.h"
 #include "video_content.h"
-#include "subtitle_content.h"
+#include "caption_content.h"
 #include "ffmpeg_decoder.h"
 #include "ffmpeg_content.h"
 #include "image_decoder.h"
+#include "audio_content.h"
 #include "content_factory.h"
 #include "dcp_content.h"
 #include "job.h"
@@ -66,7 +67,12 @@ Playlist::~Playlist ()
 void
 Playlist::content_changed (weak_ptr<Content> content, int property, bool frequent)
 {
-       if (property == ContentProperty::LENGTH || property == VideoContentProperty::FRAME_TYPE) {
+       if (
+               property == ContentProperty::TRIM_START ||
+               property == ContentProperty::TRIM_END ||
+               property == ContentProperty::LENGTH ||
+               property == VideoContentProperty::FRAME_TYPE
+               ) {
                /* Don't respond to position changes here, as:
                   - sequencing after earlier/later changes is handled by move_earlier/move_later
                   - any other position changes will be timeline drags which should not result in content
@@ -129,7 +135,7 @@ Playlist::maybe_sequence ()
 
        DCPTime next;
        BOOST_FOREACH (shared_ptr<Content> i, _content) {
-               if (!i->subtitle || find (placed.begin(), placed.end(), i) != placed.end()) {
+               if (!i->caption || find (placed.begin(), placed.end(), i) != placed.end()) {
                        continue;
                }
 
@@ -149,7 +155,7 @@ Playlist::video_identifier () const
        string t;
 
        BOOST_FOREACH (shared_ptr<const Content> i, _content) {
-               if (i->video || (i->subtitle && i->subtitle->burn())) {
+               if (i->video || (i->caption && i->caption->burn())) {
                        t += i->identifier ();
                }
        }
@@ -159,7 +165,11 @@ Playlist::video_identifier () const
        return digester.get ();
 }
 
-/** @param node <Playlist> node */
+/** @param film Film that this Playlist is for.
+ *  @param node &lt;Playlist&gt; node.
+ *  @param version Metadata version number.
+ *  @param notes Output notes about that happened.
+ */
 void
 Playlist::set_from_xml (shared_ptr<const Film> film, cxml::ConstNodePtr node, int version, list<string>& notes)
 {
@@ -173,12 +183,14 @@ Playlist::set_from_xml (shared_ptr<const Film> film, cxml::ConstNodePtr node, in
        reconnect ();
 }
 
-/** @param node <Playlist> node */
+/** @param node &lt;Playlist&gt; node.
+ *  @param with_content_paths true to include &lt;Path&gt; nodes in &lt;Content&gt; nodes, false to omit them.
+ */
 void
-Playlist::as_xml (xmlpp::Node* node)
+Playlist::as_xml (xmlpp::Node* node, bool with_content_paths)
 {
        BOOST_FOREACH (shared_ptr<Content> i, _content) {
-               i->as_xml (node->add_child ("Content"));
+               i->as_xml (node->add_child ("Content"), with_content_paths);
        }
 }
 
@@ -354,7 +366,7 @@ Playlist::subtitle_end () const
 {
        DCPTime end;
        BOOST_FOREACH (shared_ptr<Content> i, _content) {
-               if (i->subtitle) {
+               if (i->caption) {
                        end = max (end, i->end ());
                }
        }
@@ -536,3 +548,26 @@ Playlist::content_summary (DCPTimePeriod period) const
 
        return best_summary;
 }
+
+pair<double, double>
+Playlist::speed_up_range (int dcp_video_frame_rate) const
+{
+       pair<double, double> range (DBL_MAX, -DBL_MAX);
+
+       BOOST_FOREACH (shared_ptr<Content> i, _content) {
+               if (!i->video) {
+                       continue;
+               }
+               if (i->video_frame_rate()) {
+                       FrameRateChange const frc (i->video_frame_rate().get(), dcp_video_frame_rate);
+                       range.first = min (range.first, frc.speed_up);
+                       range.second = max (range.second, frc.speed_up);
+               } else {
+                       FrameRateChange const frc (dcp_video_frame_rate, dcp_video_frame_rate);
+                       range.first = min (range.first, frc.speed_up);
+                       range.second = max (range.second, frc.speed_up);
+               }
+       }
+
+       return range;
+}