Use make_shared<>.
[dcpomatic.git] / src / lib / dcp_content.cc
index d41a59b7161addfa4ff2ffd6e2c3d99b9b5c9445..dbbd65077b85c871457f994164274b5bb2603dcf 100644 (file)
@@ -1,19 +1,20 @@
 /*
     Copyright (C) 2014-2016 Carl Hetherington <cth@carlh.net>
 
-    This program is free software; you can redistribute it and/or modify
+    This file is part of DCP-o-matic.
+
+    DCP-o-matic is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     the Free Software Foundation; either version 2 of the License, or
     (at your option) any later version.
 
-    This program is distributed in the hope that it will be useful,
+    DCP-o-matic is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.
 
     You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
 
 */
 
@@ -34,6 +35,7 @@
 #include <dcp/reel.h>
 #include <libxml++/libxml++.h>
 #include <boost/foreach.hpp>
+#include <boost/make_shared.hpp>
 #include <iterator>
 #include <iostream>
 
@@ -46,6 +48,7 @@ using std::pair;
 using std::vector;
 using std::list;
 using boost::shared_ptr;
+using boost::make_shared;
 using boost::scoped_ptr;
 using boost::optional;
 using boost::function;
@@ -62,6 +65,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));
@@ -74,7 +78,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 (
@@ -107,6 +111,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
@@ -129,7 +134,7 @@ DCPContent::examine (shared_ptr<Job> job)
        job->set_progress_unknown ();
        Content::examine (job);
 
-       shared_ptr<DCPExaminer> examiner (new DCPExaminer (shared_from_this ()));
+       shared_ptr<DCPExaminer> examiner = make_shared<DCPExaminer> (shared_from_this ());
        video->take_from_examiner (examiner);
        set_default_colour_conversion ();
 
@@ -154,11 +159,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
@@ -220,6 +228,7 @@ DCPContent::as_xml (xmlpp::Node* node) const
                        DCPOMATIC_ASSERT (false);
                }
        }
+       node->add_child("ThreeD")->add_child_text (_three_d ? "1" : "0");
 }
 
 DCPTime
@@ -274,6 +283,8 @@ DCPContent::directory () const
 void
 DCPContent::add_properties (list<UserProperty>& p) const
 {
+       Content::add_properties (p);
+       video->add_properties (p);
        audio->add_properties (p);
 }