Basic email of KDMs works.
[dcpomatic.git] / src / lib / make_dcp_job.cc
index fb24fedb386ab386f55b5b92c4ab6644e9b56831..37c9ca6206429d2a864e1f21e11c0c1f48805905 100644 (file)
@@ -36,7 +36,6 @@ extern "C" {
 #include "options.h"
 #include "imagemagick_decoder.h"
 #include "film.h"
-#include "format.h"
 
 using std::string;
 using std::cout;
@@ -45,8 +44,9 @@ using boost::shared_ptr;
 /** @param f Film we are making the DCP for.
  *  @param o Options.
  */
-MakeDCPJob::MakeDCPJob (shared_ptr<Film> f, shared_ptr<Job> req)
+MakeDCPJob::MakeDCPJob (shared_ptr<Film> f, shared_ptr<const EncodeOptions> o, shared_ptr<Job> req)
        : Job (f, req)
+       , _opt (o)
 {
        
 }
@@ -61,20 +61,21 @@ MakeDCPJob::name () const
 string
 MakeDCPJob::j2c_path (int f, int offset) const
 {
-       return _film->frame_out_path (f + offset, false);
+       SourceFrame const s = ((f + offset) * dcp_frame_rate(_film->frames_per_second()).skip) + _film->dcp_trim_start();
+       return _opt->frame_out_path (s, false);
 }
 
 string
 MakeDCPJob::wav_path (libdcp::Channel c) const
 {
-       return _film->multichannel_audio_out_path (int (c), false);
+       return _opt->multichannel_audio_out_path (int (c), false);
 }
 
 void
 MakeDCPJob::run ()
 {
-       if (!_film->dcp_intrinsic_duration()) {
-               throw EncodeError ("cannot make a DCP when its intrinsic duration is not known");
+       if (!_film->dcp_length()) {
+               throw EncodeError ("cannot make a DCP when the source length is not known");
        }
 
        descend (0.9);
@@ -84,9 +85,18 @@ MakeDCPJob::run ()
        /* Remove any old DCP */
        boost::filesystem::remove_all (dcp_path);
 
-       int const frames = _film->dcp_intrinsic_duration().get();
-       int const duration = frames - _film->trim_start() - _film->trim_end();
-       DCPFrameRate const dfr (_film->frames_per_second ());
+       DCPFrameRate const dfr = dcp_frame_rate (_film->frames_per_second ());
+
+       int frames = 0;
+       switch (_film->content_type ()) {
+       case VIDEO:
+               /* Source frames -> DCP frames */
+               frames = _film->dcp_length().get() / dfr.skip;
+               break;
+       case STILL:
+               frames = _film->still_duration() * 24;
+               break;
+       }
 
        libdcp::DCP dcp (_film->dir (_film->dcp_name()));
        dcp.Progress.connect (boost::bind (&MakeDCPJob::dcp_progress, this, _1));
@@ -123,12 +133,11 @@ MakeDCPJob::run ()
                                &dcp.Progress,
                                dfr.frames_per_second,
                                this_time,
-                               _film->format()->dcp_size()
+                               _opt->out_size.width,
+                               _opt->out_size.height,
+                               _film->encrypted()
                                )
                        );
-
-               pa->set_entry_point (_film->trim_start ());
-               pa->set_duration (duration);
        
                ascend ();
                
@@ -145,13 +154,10 @@ MakeDCPJob::run ()
                                        dfr.frames_per_second,
                                        this_time,
                                        frames_done,
-                                       dcp_audio_channels (_film->audio_channels())
+                                       dcp_audio_channels (_film->audio_channels()),
+                                       _film->encrypted()
                                        )
                                );
-
-                       sa->set_entry_point (_film->trim_start ());
-                       sa->set_duration (duration);
-                       
                        ascend ();
                }