Support different KDM formulations.
authorCarl Hetherington <cth@carlh.net>
Thu, 26 Jun 2014 18:15:56 +0000 (19:15 +0100)
committerCarl Hetherington <cth@carlh.net>
Thu, 26 Jun 2014 18:15:56 +0000 (19:15 +0100)
12 files changed:
ChangeLog
cscript
src/lib/film.cc
src/lib/film.h
src/lib/kdm.cc
src/lib/kdm.h
src/lib/send_kdm_email_job.cc
src/lib/send_kdm_email_job.h
src/tools/dcpomatic.cc
src/tools/dcpomatic_kdm.cc
src/wx/kdm_dialog.cc
src/wx/kdm_dialog.h

index 39acb863e6fa664d833c1709e4c3403fb7d686bb..bcf3cdb79a42bf964c663b6ea308aee417375669 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2014-06-26  Carl Hetherington  <cth@carlh.net>
 
+       * Support different KDM formulations.
+
        * Allow override of detected video frame rates.
 
        * Optimisation of uncertain effect to encoder and server
diff --git a/cscript b/cscript
index 9080a1e09e9416c2bf197b4ceab60796604cb429..af3921e2f742535f192b12e805649de1c51e27a2 100644 (file)
--- a/cscript
+++ b/cscript
@@ -157,7 +157,7 @@ def make_control(debian_version, bits, filename, debug):
 
 def dependencies(target):
     return (('ffmpeg-cdist', '67dc770'),
-            ('libdcp', '2224998'))
+            ('libdcp', '7103135'))
 
 def build(target, options):
     cmd = './waf configure --prefix=%s' % target.work_dir_cscript()
index 940eba1eb10e1a0fe34f6aa68f4a0e80c002225d..0a77caf502cc4405695a84c6db8aec6fa9f23387 100644 (file)
@@ -1086,7 +1086,8 @@ Film::make_kdm (
        shared_ptr<libdcp::Certificate> target,
        boost::filesystem::path cpl_file,
        boost::posix_time::ptime from,
-       boost::posix_time::ptime until
+       boost::posix_time::ptime until,
+       libdcp::KDM::Formulation formulation
        ) const
 {
        shared_ptr<const Signer> signer = make_signer ();
@@ -1095,7 +1096,7 @@ Film::make_kdm (
        struct tm* tm = localtime (&now);
        string const issue_date = libdcp::tm_to_string (tm);
        
-       return libdcp::KDM (cpl_file, signer, target, key (), from, until, "DCP-o-matic", issue_date);
+       return libdcp::KDM (cpl_file, signer, target, key (), from, until, "DCP-o-matic", issue_date, formulation);
 }
 
 list<libdcp::KDM>
@@ -1103,13 +1104,14 @@ Film::make_kdms (
        list<shared_ptr<Screen> > screens,
        boost::filesystem::path dcp,
        boost::posix_time::ptime from,
-       boost::posix_time::ptime until
+       boost::posix_time::ptime until,
+       libdcp::KDM::Formulation formulation
        ) const
 {
        list<libdcp::KDM> kdms;
 
        for (list<shared_ptr<Screen> >::iterator i = screens.begin(); i != screens.end(); ++i) {
-               kdms.push_back (make_kdm ((*i)->certificate, dcp, from, until));
+               kdms.push_back (make_kdm ((*i)->certificate, dcp, from, until, formulation));
        }
 
        return kdms;
index cbe6d7b6b397646765fdafb8cf9fa601d93f0549..b7d105688d06c2a1bf644544fb43aff9e9fd9c37 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -128,14 +128,16 @@ public:
                boost::shared_ptr<libdcp::Certificate> target,
                boost::filesystem::path cpl_file,
                boost::posix_time::ptime from,
-               boost::posix_time::ptime until
+               boost::posix_time::ptime until,
+               libdcp::KDM::Formulation formulation
                ) const;
        
        std::list<libdcp::KDM> make_kdms (
                std::list<boost::shared_ptr<Screen> >,
                boost::filesystem::path cpl_file,
                boost::posix_time::ptime from,
-               boost::posix_time::ptime until
+               boost::posix_time::ptime until,
+               libdcp::KDM::Formulation formulation
                ) const;
 
        libdcp::Key key () const {
index 5efea089c1053661d8ad86b6724889886bc58d30..49bfae20ad727c36d62d057582c943c2edc9ac8c 100644 (file)
@@ -105,10 +105,11 @@ make_screen_kdms (
        list<shared_ptr<Screen> > screens,
        boost::filesystem::path cpl,
        boost::posix_time::ptime from,
-       boost::posix_time::ptime to
+       boost::posix_time::ptime to,
+       libdcp::KDM::Formulation formulation
        )
 {
-       list<libdcp::KDM> kdms = film->make_kdms (screens, cpl, from, to);
+       list<libdcp::KDM> kdms = film->make_kdms (screens, cpl, from, to, formulation);
           
        list<ScreenKDM> screen_kdms;
        
@@ -129,10 +130,11 @@ make_cinema_kdms (
        list<shared_ptr<Screen> > screens,
        boost::filesystem::path cpl,
        boost::posix_time::ptime from,
-       boost::posix_time::ptime to
+       boost::posix_time::ptime to,
+       libdcp::KDM::Formulation formulation
        )
 {
-       list<ScreenKDM> screen_kdms = make_screen_kdms (film, screens, cpl, from, to);
+       list<ScreenKDM> screen_kdms = make_screen_kdms (film, screens, cpl, from, to, formulation);
        list<CinemaKDMs> cinema_kdms;
 
        while (!screen_kdms.empty ()) {
@@ -175,10 +177,11 @@ write_kdm_files (
        boost::filesystem::path cpl,
        boost::posix_time::ptime from,
        boost::posix_time::ptime to,
+       libdcp::KDM::Formulation formulation,
        boost::filesystem::path directory
        )
 {
-       list<ScreenKDM> screen_kdms = make_screen_kdms (film, screens, cpl, from, to);
+       list<ScreenKDM> screen_kdms = make_screen_kdms (film, screens, cpl, from, to, formulation);
 
        /* Write KDMs to the specified directory */
        for (list<ScreenKDM>::iterator i = screen_kdms.begin(); i != screen_kdms.end(); ++i) {
@@ -195,10 +198,11 @@ write_kdm_zip_files (
        boost::filesystem::path cpl,
        boost::posix_time::ptime from,
        boost::posix_time::ptime to,
+       libdcp::KDM::Formulation formulation,
        boost::filesystem::path directory
        )
 {
-       list<CinemaKDMs> cinema_kdms = make_cinema_kdms (film, screens, cpl, from, to);
+       list<CinemaKDMs> cinema_kdms = make_cinema_kdms (film, screens, cpl, from, to, formulation);
 
        for (list<CinemaKDMs>::const_iterator i = cinema_kdms.begin(); i != cinema_kdms.end(); ++i) {
                boost::filesystem::path path = directory;
@@ -213,10 +217,11 @@ email_kdms (
        list<shared_ptr<Screen> > screens,
        boost::filesystem::path cpl,
        boost::posix_time::ptime from,
-       boost::posix_time::ptime to
+       boost::posix_time::ptime to,
+       libdcp::KDM::Formulation formulation
        )
 {
-       list<CinemaKDMs> cinema_kdms = make_cinema_kdms (film, screens, cpl, from, to);
+       list<CinemaKDMs> cinema_kdms = make_cinema_kdms (film, screens, cpl, from, to, formulation);
 
        for (list<CinemaKDMs>::const_iterator i = cinema_kdms.begin(); i != cinema_kdms.end(); ++i) {
                
index 8aacd7b720fe8bfce57c7f75b493d8fb28f17a39..8fb4ec494d2e2a52866e8fe68d1cc5a2ff92766a 100644 (file)
@@ -29,6 +29,7 @@ extern void write_kdm_files (
        boost::filesystem::path cpl,
        boost::posix_time::ptime from,
        boost::posix_time::ptime to,
+       libdcp::KDM::Formulation formulation,
        boost::filesystem::path directory
        );
 
@@ -38,6 +39,7 @@ extern void write_kdm_zip_files (
        boost::filesystem::path cpl,
        boost::posix_time::ptime from,
        boost::posix_time::ptime to,
+       libdcp::KDM::Formulation formulation,
        boost::filesystem::path directory
        );
 
@@ -46,6 +48,7 @@ extern void email_kdms (
        std::list<boost::shared_ptr<Screen> > screens,
        boost::filesystem::path cpl,
        boost::posix_time::ptime from,
-       boost::posix_time::ptime to
+       boost::posix_time::ptime to,
+       libdcp::KDM::Formulation formulation
        );
 
index 8af0b556a13e7f1a5ceffcc066e9c02d0038c04d..1dec2ffb001dc7ce77fdfd4d1c595e8646bb90c9 100644 (file)
@@ -33,13 +33,15 @@ SendKDMEmailJob::SendKDMEmailJob (
        list<shared_ptr<Screen> > screens,
        boost::filesystem::path dcp,
        boost::posix_time::ptime from,
-       boost::posix_time::ptime to
+       boost::posix_time::ptime to,
+       libdcp::KDM::Formulation formulation
        )
        : Job (f)
        , _screens (screens)
        , _dcp (dcp)
        , _from (from)
        , _to (to)
+       , _formulation (formulation)
 {
 
 }
@@ -62,7 +64,7 @@ SendKDMEmailJob::run ()
        try {
                
                set_progress_unknown ();
-               email_kdms (_film, _screens, _dcp, _from, _to);
+               email_kdms (_film, _screens, _dcp, _from, _to, _formulation);
                set_progress (1);
                set_state (FINISHED_OK);
                
index f4d154a9183b227dc897c97c5660f9f04aef3114..8a8903040c06b573815fe2d3be9b999fa90c47b1 100644 (file)
@@ -18,6 +18,7 @@
 */
 
 #include <boost/filesystem.hpp>
+#include <libdcp/kdm.h>
 #include "job.h"
 
 class Screen;
@@ -30,7 +31,8 @@ public:
                std::list<boost::shared_ptr<Screen> >,
                boost::filesystem::path,
                boost::posix_time::ptime,
-               boost::posix_time::ptime
+               boost::posix_time::ptime,
+               libdcp::KDM::Formulation
                );
 
        std::string name () const;
@@ -42,4 +44,5 @@ private:
        boost::filesystem::path _dcp;
        boost::posix_time::ptime _from;
        boost::posix_time::ptime _to;
+       libdcp::KDM::Formulation _formulation;
 };
index c9d17eb9b7ee4ce92939fe51bdc1db599bd058d7..588fd5c486da54bd037cf2228bcaa05ceac4c448 100644 (file)
@@ -470,10 +470,10 @@ private:
 
                try {
                        if (d->write_to ()) {
-                               write_kdm_files (film, d->screens (), d->cpl (), d->from (), d->until (), d->directory ());
+                               write_kdm_files (film, d->screens (), d->cpl (), d->from (), d->until (), d->formulation (), d->directory ());
                        } else {
                                JobManager::instance()->add (
-                                       shared_ptr<Job> (new SendKDMEmailJob (film, d->screens (), d->cpl (), d->from (), d->until ()))
+                                       shared_ptr<Job> (new SendKDMEmailJob (film, d->screens (), d->cpl (), d->from (), d->until (), d->formulation ()))
                                        );
                        }
                } catch (libdcp::NotEncryptedError& e) {
index 041f6c7ef295d1a9100454fa7d25cfb0a6e87991..8c26ba4ccc5cba33eb8eadd0b06cfae9e9bf461a 100644 (file)
@@ -44,6 +44,7 @@ help ()
                "  -f, --valid-from       valid from time (e.g. \"2013-09-28 01:41:51\") or \"now\"\n"
                "  -t, --valid-to         valid to time (e.g. \"2014-09-28 01:41:51\")\n"
                "  -d, --valid-duration   valid duration (e.g. \"1 day\", \"4 hours\", \"2 weeks\")\n"
+               "      --formulation      modified-transitional-1, dci-any or dci-specific [default modified-transitional-1]\n"
                "  -z, --zip              ZIP each cinema's KDMs into its own file\n"
                "  -v, --verbose          be verbose\n"
                "  -c, --cinema           specify a cinema, either by name or email address\n"
@@ -110,6 +111,7 @@ int main (int argc, char* argv[])
        bool cinemas = false;
        string duration_string;
        bool verbose = false;
+       libdcp::KDM::Formulation formulation = libdcp::KDM::MODIFIED_TRANSITIONAL_1;
 
        program_name = argv[0];
        
@@ -126,10 +128,11 @@ int main (int argc, char* argv[])
                        { "zip", no_argument, 0, 'z' },
                        { "duration", required_argument, 0, 'd' },
                        { "verbose", no_argument, 0, 'v' },
+                       { "formulation", required_argument, 0, 'C' },
                        { 0, 0, 0, 0 }
                };
 
-               int c = getopt_long (argc, argv, "ho:f:t:c:A:Bzd:v", long_options, &option_index);
+               int c = getopt_long (argc, argv, "ho:f:t:c:A:Bzd:vC:", long_options, &option_index);
 
                if (c == -1) {
                        break;
@@ -166,6 +169,16 @@ int main (int argc, char* argv[])
                case 'v':
                        verbose = true;
                        break;
+               case 'C':
+                       if (string (optarg) == "modified-transitional-1") {
+                               formulation = libdcp::KDM::MODIFIED_TRANSITIONAL_1;
+                       } else if (string (optarg) == "dci-any") {
+                               formulation = libdcp::KDM::DCI_ANY;
+                       } else if (string (optarg) == "dci-specific") {
+                               formulation = libdcp::KDM::DCI_SPECIFIC;
+                       } else {
+                               error ("unrecognised KDM formulation " + formulation);
+                       }
                }
        }
 
@@ -236,7 +249,7 @@ int main (int argc, char* argv[])
                }
                
                shared_ptr<libdcp::Certificate> certificate (new libdcp::Certificate (boost::filesystem::path (certificate_file)));
-               libdcp::KDM kdm = film->make_kdm (certificate, cpl, valid_from.get(), valid_to.get());
+               libdcp::KDM kdm = film->make_kdm (certificate, cpl, valid_from.get(), valid_to.get(), formulation);
                kdm.as_xml (output);
                if (verbose) {
                        cout << "Generated KDM " << output << " for certificate.\n";
@@ -260,12 +273,12 @@ int main (int argc, char* argv[])
 
                try {
                        if (zip) {
-                               write_kdm_zip_files (film, (*i)->screens(), cpl, valid_from.get(), valid_to.get(), output);
+                               write_kdm_zip_files (film, (*i)->screens(), cpl, valid_from.get(), valid_to.get(), formulation, output);
                                if (verbose) {
                                        cout << "Wrote ZIP files to " << output << "\n";
                                }
                        } else {
-                               write_kdm_files (film, (*i)->screens(), cpl, valid_from.get(), valid_to.get(), output);
+                               write_kdm_files (film, (*i)->screens(), cpl, valid_from.get(), valid_to.get(), formulation, output);
                                if (verbose) {
                                        cout << "Wrote KDM files to " << output << "\n";
                                }
index 6750e0e98cb5606fa154c15e7f1cbc0a861759b1..8df94de9c5f06a986213d479d56e5463d83df51d 100644 (file)
@@ -159,6 +159,14 @@ KDMDialog::KDMDialog (wxWindow* parent, boost::shared_ptr<const Film> film)
        
        table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, 0);
 
+       add_label_to_sizer (table, this, _("KDM type"), true);
+       _type = new wxChoice (this, wxID_ANY);
+       _type->Append ("Modified Transitional 1");
+       _type->Append ("DCI Any");
+       _type->Append ("DCI Specific");
+       table->Add (_type, 1, wxEXPAND);
+       _type->SetSelection (0);
+
        _write_to = new wxRadioButton (this, wxID_ANY, _("Write to"));
        table->Add (_write_to, 1, wxEXPAND);
 
@@ -480,6 +488,21 @@ KDMDialog::write_to () const
        return _write_to->GetValue ();
 }
 
+libdcp::KDM::Formulation
+KDMDialog::formulation () const
+{
+       switch (_type->GetSelection()) {
+       case 0:
+               return libdcp::KDM::MODIFIED_TRANSITIONAL_1;
+       case 1:
+               return libdcp::KDM::DCI_ANY;
+       case 2:
+               return libdcp::KDM::DCI_SPECIFIC;
+       default:
+               assert (false);
+       }
+}
+
 void
 KDMDialog::update_cpl_choice ()
 {
index 6327b29e8d1b84db982a3529b499da97150b31b3..13e9196ea055180a4ee29e6b664338b2d94b1a33 100644 (file)
@@ -48,6 +48,7 @@ public:
        boost::filesystem::path cpl () const;
        boost::filesystem::path directory () const;
        bool write_to () const;
+       libdcp::KDM::Formulation formulation () const;
 
 private:
        void add_cinema (boost::shared_ptr<Cinema>);
@@ -83,6 +84,7 @@ private:
        wxStaticText* _dcp_directory;
        wxStaticText* _cpl_id;
        wxStaticText* _cpl_annotation_text;
+       wxChoice* _type;
        wxRadioButton* _write_to;
 #ifdef DCPOMATIC_USE_OWN_DIR_PICKER
        DirPickerCtrl* _folder;