Supporter.
[dcpomatic.git] / src / lib / dcp_content.cc
index a01f0effd4c530e177789992f47599d9062f8213..431492c7ac29b8b50091d75e1cdbfead4d5e3dac 100644 (file)
@@ -63,6 +63,7 @@ DCPContent::DCPContent (shared_ptr<const Film> film, boost::filesystem::path p)
        , _reference_video (false)
        , _reference_audio (false)
        , _reference_subtitle (false)
+       , _three_d (false)
 {
        video.reset (new VideoContent (this));
        audio.reset (new AudioContent (this));
@@ -75,7 +76,7 @@ DCPContent::DCPContent (shared_ptr<const Film> film, cxml::ConstNodePtr node, in
        : Content (film, node)
 {
        video = VideoContent::from_xml (this, node, version);
-       audio = AudioContent::from_xml (this, node);
+       audio = AudioContent::from_xml (this, node, version);
        subtitle = SubtitleContent::from_xml (this, node, version);
 
        audio->set_stream (
@@ -108,6 +109,7 @@ DCPContent::DCPContent (shared_ptr<const Film> film, cxml::ConstNodePtr node, in
                        DCPOMATIC_ASSERT (false);
                }
        }
+       _three_d = node->optional_bool_child("ThreeD").get_value_or (false);
 }
 
 void
@@ -155,11 +157,14 @@ DCPContent::examine (shared_ptr<Job> job)
                _encrypted = examiner->encrypted ();
                _kdm_valid = examiner->kdm_valid ();
                _standard = examiner->standard ();
+               _three_d = examiner->three_d ();
        }
 
        if (could_be_played != can_be_played ()) {
                signal_changed (DCPContentProperty::CAN_BE_PLAYED);
        }
+
+       video->set_frame_type (_three_d ? VIDEO_FRAME_TYPE_3D : VIDEO_FRAME_TYPE_2D);
 }
 
 string
@@ -221,6 +226,7 @@ DCPContent::as_xml (xmlpp::Node* node) const
                        DCPOMATIC_ASSERT (false);
                }
        }
+       node->add_child("ThreeD")->add_child_text (_three_d ? "1" : "0");
 }
 
 DCPTime
@@ -233,7 +239,7 @@ DCPContent::full_length () const
 string
 DCPContent::identifier () const
 {
-       SafeStringStream s;
+       locked_stringstream s;
        s << Content::identifier() << "_" << video->identifier() << "_";
        if (subtitle) {
                s << subtitle->identifier () << " ";
@@ -275,6 +281,8 @@ DCPContent::directory () const
 void
 DCPContent::add_properties (list<UserProperty>& p) const
 {
+       Content::add_properties (p);
+       video->add_properties (p);
        audio->add_properties (p);
 }
 
@@ -324,7 +332,7 @@ DCPContent::reels () const
        list<DCPTimePeriod> p;
        scoped_ptr<DCPDecoder> decoder;
        try {
-               decoder.reset (new DCPDecoder (shared_from_this(), film()->log(), false));
+               decoder.reset (new DCPDecoder (shared_from_this(), film()->log()));
        } catch (...) {
                /* Could not load the DCP; guess reels */
                list<DCPTimePeriod> p;
@@ -395,7 +403,7 @@ DCPContent::can_reference_video (list<string>& why_not) const
 bool
 DCPContent::can_reference_audio (list<string>& why_not) const
 {
-        DCPDecoder decoder (shared_from_this(), film()->log(), false);
+        DCPDecoder decoder (shared_from_this(), film()->log());
         BOOST_FOREACH (shared_ptr<dcp::Reel> i, decoder.reels()) {
                 if (!i->main_sound()) {
                         why_not.push_back (_("The DCP does not have sound in all reels."));
@@ -409,7 +417,7 @@ DCPContent::can_reference_audio (list<string>& why_not) const
 bool
 DCPContent::can_reference_subtitle (list<string>& why_not) const
 {
-        DCPDecoder decoder (shared_from_this(), film()->log(), false);
+        DCPDecoder decoder (shared_from_this(), film()->log());
         BOOST_FOREACH (shared_ptr<dcp::Reel> i, decoder.reels()) {
                 if (!i->main_subtitle()) {
                         why_not.push_back (_("The DCP does not have subtitles in all reels."));