Rename split-by-video content slightly; fix referencing to multi-reel DCPs.
[dcpomatic.git] / src / lib / dcp_content.cc
index 15bcd0b56096c03795c86b915416e37743e255fc..f39b2fb4a221c8070199d01aa3629972fc07a352 100644 (file)
 #include "film.h"
 #include "config.h"
 #include "compose.hpp"
+#include "dcp_decoder.h"
 #include <dcp/dcp.h>
 #include <dcp/exceptions.h>
+#include <dcp/reel_picture_asset.h>
+#include <dcp/reel.h>
 #include <libxml++/libxml++.h>
+#include <boost/foreach.hpp>
 #include <iterator>
 #include <iostream>
 
@@ -39,7 +43,10 @@ using std::list;
 using boost::shared_ptr;
 using boost::optional;
 
-int const DCPContentProperty::CAN_BE_PLAYED = 600;
+int const DCPContentProperty::CAN_BE_PLAYED      = 600;
+int const DCPContentProperty::REFERENCE_VIDEO    = 601;
+int const DCPContentProperty::REFERENCE_AUDIO    = 602;
+int const DCPContentProperty::REFERENCE_SUBTITLE = 603;
 
 DCPContent::DCPContent (shared_ptr<const Film> film, boost::filesystem::path p)
        : Content (film)
@@ -209,3 +216,53 @@ DCPContent::set_default_colour_conversion ()
        /* Default to no colour conversion for DCPs */
        unset_colour_conversion ();
 }
+
+void
+DCPContent::set_reference_video (bool r)
+{
+       {
+               boost::mutex::scoped_lock lm (_mutex);
+               _reference_video = r;
+       }
+
+       signal_changed (DCPContentProperty::REFERENCE_VIDEO);
+}
+
+void
+DCPContent::set_reference_audio (bool r)
+{
+       {
+               boost::mutex::scoped_lock lm (_mutex);
+               _reference_audio = r;
+       }
+
+       signal_changed (DCPContentProperty::REFERENCE_AUDIO);
+}
+
+void
+DCPContent::set_reference_subtitle (bool r)
+{
+       {
+               boost::mutex::scoped_lock lm (_mutex);
+               _reference_subtitle = r;
+       }
+
+       signal_changed (DCPContentProperty::REFERENCE_SUBTITLE);
+}
+
+list<DCPTime>
+DCPContent::reel_split_points () const
+{
+       list<DCPTime> s;
+       DCPDecoder decoder (shared_from_this(), false);
+       DCPTime t = position();
+
+       shared_ptr<const Film> film = _film.lock ();
+       DCPOMATIC_ASSERT (film);
+       BOOST_FOREACH (shared_ptr<dcp::Reel> k, decoder.reels()) {
+               s.push_back (t);
+               t += DCPTime::from_frames (k->main_picture()->duration(), film->video_frame_rate());
+       }
+
+       return s;
+}