Some boost::filesystem::path cleanups; tweak for changes to libdcp.
[dcpomatic.git] / src / lib / writer.cc
index 4c8a36597e56667bbbd0ff55c84211b4cf000e57..4f93373f7d6094659a75a0600c395a7154e9c689 100644 (file)
@@ -73,13 +73,14 @@ Writer::Writer (shared_ptr<const Film> f, shared_ptr<Job> j)
           it into the DCP later.
        */
 
-       if (f->three_d ()) {
+       if (_film->three_d ()) {
                _picture_asset.reset (
                        new libdcp::StereoPictureAsset (
                                _film->internal_video_mxf_dir (),
                                _film->internal_video_mxf_filename (),
                                _film->video_frame_rate (),
-                               _film->container()->size (_film->full_frame ())
+                               _film->container()->size (_film->full_frame ()),
+                               _film->encrypted ()
                                )
                        );
                
@@ -89,13 +90,14 @@ Writer::Writer (shared_ptr<const Film> f, shared_ptr<Job> j)
                                _film->internal_video_mxf_dir (),
                                _film->internal_video_mxf_filename (),
                                _film->video_frame_rate (),
-                               _film->container()->size (_film->full_frame ())
+                               _film->container()->size (_film->full_frame ()),
+                               _film->encrypted ()
                                )
                        );
 
        }
 
-       _picture_asset_writer = _picture_asset->start_write (_first_nonexistant_frame > 0);
+       _picture_asset_writer = _picture_asset->start_write (_first_nonexistant_frame > 0, _film->interop ());
        
        _sound_asset.reset (
                new libdcp::SoundAsset (
@@ -103,13 +105,16 @@ Writer::Writer (shared_ptr<const Film> f, shared_ptr<Job> j)
                        _film->audio_mxf_filename (),
                        _film->video_frame_rate (),
                        _film->audio_channels (),
-                       _film->audio_frame_rate ()
+                       _film->audio_frame_rate (),
+                       _film->encrypted ()
                        )
                );
        
-       _sound_asset_writer = _sound_asset->start_write ();
+       _sound_asset_writer = _sound_asset->start_write (_film->interop ());
 
        _thread = new boost::thread (boost::bind (&Writer::thread, this));
+
+       _job->descend (0.9);
 }
 
 void
@@ -151,8 +156,15 @@ Writer::fake_write (int frame, Eyes eyes)
        qi.type = QueueItem::FAKE;
        qi.size = info.size;
        qi.frame = frame;
-       qi.eyes = eyes;
-       _queue.push_back (qi);
+       if (_film->three_d() && eyes == EYES_BOTH) {
+               qi.eyes = EYES_LEFT;
+               _queue.push_back (qi);
+               qi.eyes = EYES_RIGHT;
+               _queue.push_back (qi);
+       } else {
+               qi.eyes = eyes;
+               _queue.push_back (qi);
+       }
 
        _condition.notify_all ();
 }
@@ -382,9 +394,21 @@ Writer::finish ()
                                                         )
                               ));
 
+       /* Compute the digests for the assets now so that we can keep track of progress.
+          We did _job->descend (0.9) in our constructor */
+       _job->ascend ();
+
+       _job->descend (0.1);
+       _picture_asset->compute_digest (boost::bind (&Job::set_progress, _job.get(), _1));
+       _job->ascend ();
+
+       _job->descend (0.1);
+       _sound_asset->compute_digest (boost::bind (&Job::set_progress, _job.get(), _1));
+       _job->ascend ();
+
        libdcp::XMLMetadata meta = Config::instance()->dcp_metadata ();
        meta.set_issue_date_now ();
-       dcp.write_xml (meta);
+       dcp.write_xml (_film->interop (), meta);
 
        _film->log()->log (String::compose (N_("Wrote %1 FULL, %2 FAKE, %3 REPEAT; %4 pushed to disk"), _full_written, _fake_written, _repeat_written, _pushed_to_disk));
 }
@@ -398,9 +422,15 @@ Writer::repeat (int f, Eyes e)
        QueueItem qi;
        qi.type = QueueItem::REPEAT;
        qi.frame = f;
-       qi.eyes = e;
-       
-       _queue.push_back (qi);
+       if (_film->three_d() && e == EYES_BOTH) {
+               qi.eyes = EYES_LEFT;
+               _queue.push_back (qi);
+               qi.eyes = EYES_RIGHT;
+               _queue.push_back (qi);
+       } else {
+               qi.eyes = e;
+               _queue.push_back (qi);
+       }
 
        _condition.notify_all ();
 }
@@ -487,8 +517,8 @@ operator< (QueueItem const & a, QueueItem const & b)
        if (a.frame != b.frame) {
                return a.frame < b.frame;
        }
-       
-       return a.eyes == EYES_LEFT && b.eyes == EYES_RIGHT;
+
+       return static_cast<int> (a.eyes) < static_cast<int> (b.eyes);
 }
 
 bool