Update for newer libdcp; add start of manual.
[dcpomatic.git] / src / lib / make_dcp_job.cc
index b0b8a2a1af0d5a959d1c74f26a53dbc79a273605..4f42e13f13f2881939de89ea3d5097338b174423 100644 (file)
@@ -31,6 +31,7 @@ extern "C" {
 #include "dcp_content_type.h"
 #include "exceptions.h"
 #include "options.h"
+#include "imagemagick_decoder.h"
 
 using namespace std;
 using namespace boost;
@@ -53,6 +54,18 @@ MakeDCPJob::name () const
        return s.str ();
 }
 
+string
+MakeDCPJob::j2c_path (int f) const
+{
+       return _opt->frame_out_path (f, false);
+}
+
+string
+MakeDCPJob::wav_path (libdcp::Channel c) const
+{
+       return _opt->multichannel_audio_out_path (int (c), false);
+}
+
 void
 MakeDCPJob::run ()
 {
@@ -61,27 +74,26 @@ MakeDCPJob::run ()
        /* Remove any old DCP */
        filesystem::remove_all (dcp_path);
 
-       libdcp::DCP dcp (_fs->dir (_fs->name), _fs->name, _fs->dcp_content_type->libdcp_type (), rint (_fs->frames_per_second), _fs->length);
-       dcp.Progress.connect (sigc::mem_fun (*this, &MakeDCPJob::dcp_progress));
-
-       list<string> j2cs;
-       int f = _fs->dcp_frames ? _fs->dcp_frames : _fs->length;
-       for (int i = 0; i < f; ++i) {
-               j2cs.push_back (_opt->frame_out_path (i, false));
+       int frames = 0;
+       switch (_fs->content_type ()) {
+       case VIDEO:
+               frames = _fs->dcp_frames ? _fs->dcp_frames : _fs->length;
+               break;
+       case STILL:
+               frames = _fs->still_duration * ImageMagickDecoder::static_frames_per_second ();
+               break;
        }
+       
+       libdcp::DCP dcp (_fs->dir (_fs->name), _fs->name, _fs->dcp_content_type->libdcp_kind (), rint (_fs->frames_per_second), frames);
+       dcp.Progress.connect (sigc::mem_fun (*this, &MakeDCPJob::dcp_progress));
 
        descend (0.9);
-       dcp.add_picture_asset (j2cs, _opt->out_size.width, _opt->out_size.height);
+       dcp.add_picture_asset (sigc::mem_fun (*this, &MakeDCPJob::j2c_path), _opt->out_size.width, _opt->out_size.height);
        ascend ();
 
-       list<string> wavs;
-       for (int i = 0; i < _fs->audio_channels; ++i) {
-               wavs.push_back (_opt->multichannel_audio_out_path (i, false));
-       }
-
-       if (!wavs.empty ()) {
+       if (_fs->audio_channels > 0) {
                descend (0.1);
-               dcp.add_sound_asset (wavs);
+               dcp.add_sound_asset (sigc::mem_fun (*this, &MakeDCPJob::wav_path), _fs->audio_channels);
                ascend ();
        }