Remove unnecessary Film variable in ContentPart.
[dcpomatic.git] / src / lib / dcp_content.cc
index 2cd7e576f2f63d4f7fa27e1b85e45fd192bcae0b..b28e91dd5cb30d74bf964ae827efa771bb378124 100644 (file)
@@ -62,8 +62,8 @@ DCPContent::DCPContent (shared_ptr<const Film> film, boost::filesystem::path p)
        , _reference_audio (false)
        , _reference_subtitle (false)
 {
-       video.reset (new VideoContent (this, film));
-       audio.reset (new AudioContent (this, film));
+       video.reset (new VideoContent (this));
+       audio.reset (new AudioContent (this));
 
        read_directory (p);
        set_default_colour_conversion ();
@@ -72,13 +72,17 @@ DCPContent::DCPContent (shared_ptr<const Film> film, boost::filesystem::path p)
 DCPContent::DCPContent (shared_ptr<const Film> film, cxml::ConstNodePtr node, int version)
        : Content (film, node)
 {
-       video = VideoContent::from_xml (this, film, node, version);
-       audio = AudioContent::from_xml (this, film, node);
-       subtitle = SubtitleContent::from_xml (this, film, node, version);
+       video = VideoContent::from_xml (this, node, version);
+       audio = AudioContent::from_xml (this, node);
+       subtitle = SubtitleContent::from_xml (this, node, version);
 
        audio->set_stream (
                AudioStreamPtr (
-                       new AudioStream (node->number_child<int> ("AudioFrameRate"), AudioMapping (node->node_child ("AudioMapping"), version))
+                       new AudioStream (
+                               node->number_child<int> ("AudioFrameRate"),
+                               node->number_child<Frame> ("AudioLength"),
+                               AudioMapping (node->node_child ("AudioMapping"), version)
+                               )
                        )
                );
 
@@ -121,7 +125,7 @@ DCPContent::examine (shared_ptr<Job> job)
        {
                boost::mutex::scoped_lock lm (_mutex);
 
-               AudioStreamPtr as (new AudioStream (examiner->audio_frame_rate(), examiner->audio_channels ()));
+               AudioStreamPtr as (new AudioStream (examiner->audio_frame_rate(), examiner->audio_length(), examiner->audio_channels()));
                audio->set_stream (as);
                AudioMapping m = as->mapping ();
                film()->make_audio_mapping_default (m);
@@ -134,7 +138,7 @@ DCPContent::examine (shared_ptr<Job> job)
                boost::mutex::scoped_lock lm (_mutex);
                _name = examiner->name ();
                if (examiner->has_subtitles ()) {
-                       subtitle.reset (new SubtitleContent (this, film()));
+                       subtitle.reset (new SubtitleContent (this));
                }
                _encrypted = examiner->encrypted ();
                _kdm_valid = examiner->kdm_valid ();
@@ -166,10 +170,18 @@ DCPContent::as_xml (xmlpp::Node* node) const
        node->add_child("Type")->add_child_text ("DCP");
 
        Content::as_xml (node);
-       video->as_xml (node);
-       audio->as_xml (node);
-       node->add_child("AudioFrameRate")->add_child_text (raw_convert<string> (audio->stream()->frame_rate()));
-       audio->stream()->mapping().as_xml (node->add_child("AudioMapping"));
+
+       if (video) {
+               video->as_xml (node);
+       }
+
+       if (audio) {
+               audio->as_xml (node);
+               node->add_child("AudioFrameRate")->add_child_text (raw_convert<string> (audio->stream()->frame_rate()));
+               node->add_child("AudioLength")->add_child_text (raw_convert<string> (audio->stream()->length()));
+               audio->stream()->mapping().as_xml (node->add_child("AudioMapping"));
+       }
+
        if (subtitle) {
                subtitle->as_xml (node);
        }