Set 'i' earlier in name_values.
authorCarl Hetherington <cth@carlh.net>
Tue, 5 May 2020 13:24:36 +0000 (15:24 +0200)
committerCarl Hetherington <cth@carlh.net>
Wed, 6 May 2020 18:15:49 +0000 (20:15 +0200)
src/lib/kdm_with_metadata.cc
src/lib/kdm_with_metadata.h
src/tools/dcpomatic_kdm.cc
src/tools/dcpomatic_kdm_cli.cc
src/wx/kdm_dialog.cc

index 62d544e..bf24f70 100644 (file)
@@ -66,7 +66,6 @@ write_files (
 
        /* Write KDMs to the specified directory */
        BOOST_FOREACH (KDMWithMetadataPtr i, kdms) {
-               name_values['i'] = i->kdm_id ();
                boost::filesystem::path out = directory / careful_string_filter(name_format.get(name_values, ".xml"));
                if (!boost::filesystem::exists (out) || confirm_overwrite (out)) {
                        i->kdm_as_xml (out);
@@ -96,7 +95,6 @@ make_zip_file (list<KDMWithMetadataPtr> kdms, boost::filesystem::path zip_file,
        Zipper zipper (zip_file);
 
        BOOST_FOREACH (KDMWithMetadataPtr i, kdms) {
-               name_values['i'] = i->kdm_id ();
                string const name = careful_string_filter(name_format.get(name_values, ".xml"));
                zipper.add (name, i->kdm_as_xml());
        }
index c2a13fc..e7b3c23 100644 (file)
@@ -42,7 +42,6 @@ public:
 
        virtual std::string kdm_as_xml () const = 0;
        virtual void kdm_as_xml (boost::filesystem::path out) const = 0;
-       virtual std::string kdm_id () const = 0;
 
        dcp::NameFormat::Map const& name_values () const {
                return _name_values;
@@ -121,10 +120,6 @@ public:
                return kdm.as_xml (out);
        }
 
-       std::string kdm_id () const {
-               return kdm.cpl_id ();
-       }
-
        dcp::EncryptedKDM kdm;
 };
 
@@ -145,10 +140,6 @@ public:
                return kdm.as_xml (out);
        }
 
-       std::string kdm_id () const {
-               return kdm.id ();
-       }
-
        EncryptedECinemaKDM kdm;
 };
 #endif
index 7920f7e..da856d3 100644 (file)
@@ -334,6 +334,7 @@ private:
                                        name_values['f'] = title;
                                        name_values['b'] = begin.date() + " " + begin.time_of_day(true, false);
                                        name_values['e'] = end.date() + " " + end.time_of_day(true, false);
+                                       name_values['i'] = kdm.id();
 
                                        /* Encrypt */
                                        kdms.push_back (
@@ -381,24 +382,23 @@ private:
                                                kdm.add_key (j);
                                        }
 
+                                       dcp::EncryptedKDM const encrypted = kdm.encrypt(
+                                                       signer, i->recipient.get(), i->trusted_device_thumbprints(), _output->formulation(),
+                                                       !_output->forensic_mark_video(), _output->forensic_mark_audio() ? boost::optional<int>() : 0
+                                                       );
+
                                        dcp::NameFormat::Map name_values;
                                        name_values['c'] = i->cinema->name;
                                        name_values['s'] = i->name;
                                        name_values['f'] = title;
                                        name_values['b'] = begin.date() + " " + begin.time_of_day(true, false);
                                        name_values['e'] = end.date() + " " + end.time_of_day(true, false);
+                                       name_values['i'] = encrypted.cpl_id ();
 
                                        /* Encrypt */
                                        kdms.push_back (
                                                KDMWithMetadataPtr(
-                                                       new DCPKDMWithMetadata(
-                                                               name_values,
-                                                               i->cinema,
-                                                               kdm.encrypt(
-                                                                       signer, i->recipient.get(), i->trusted_device_thumbprints(), _output->formulation(),
-                                                                       !_output->forensic_mark_video(), _output->forensic_mark_audio() ? boost::optional<int>() : 0
-                                                                       )
-                                                               )
+                                                       new DCPKDMWithMetadata(name_values, i->cinema, encrypted)
                                                        )
                                                );
                                }
index a85624c..6bcad22 100644 (file)
@@ -250,6 +250,7 @@ from_film (
                                name_values['f'] = film->name();
                                name_values['b'] = dcp::LocalTime(begin).date() + " " + dcp::LocalTime(begin).time_of_day(true, false);
                                name_values['e'] = dcp::LocalTime(end).date() + " " + dcp::LocalTime(end).time_of_day(true, false);
+                               name_values['i'] = kdm.cpl_id();
 
                                kdms.push_back (KDMWithMetadataPtr(new DCPKDMWithMetadata(name_values, i->cinema, kdm)));
                        }
@@ -358,19 +359,7 @@ from_dkdm (
                        dcp::LocalTime begin(valid_from, i->cinema->utc_offset_hour(), i->cinema->utc_offset_minute());
                        dcp::LocalTime end(valid_to, i->cinema->utc_offset_hour(), i->cinema->utc_offset_minute());
 
-                       dcp::NameFormat::Map name_values;
-                       name_values['c'] = i->cinema->name;
-                       name_values['s'] = i->name;
-                       name_values['f'] = dkdm.annotation_text().get_value_or("");
-                       name_values['b'] = begin.date() + " " + begin.time_of_day(true, false);
-                       name_values['e'] = end.date() + " " + end.time_of_day(true, false);
-
-                       kdms.push_back (
-                               KDMWithMetadataPtr(
-                                       new DCPKDMWithMetadata(
-                                               name_values,
-                                               i->cinema,
-                                               kdm_from_dkdm(
+                       dcp::EncryptedKDM const kdm = kdm_from_dkdm(
                                                        dkdm,
                                                        i->recipient.get(),
                                                        i->trusted_device_thumbprints(),
@@ -379,10 +368,17 @@ from_dkdm (
                                                        formulation,
                                                        disable_forensic_marking_picture,
                                                        disable_forensic_marking_audio
-                                                       )
-                                               )
-                                       )
-                               );
+                                                       );
+
+                       dcp::NameFormat::Map name_values;
+                       name_values['c'] = i->cinema->name;
+                       name_values['s'] = i->name;
+                       name_values['f'] = dkdm.annotation_text().get_value_or("");
+                       name_values['b'] = begin.date() + " " + begin.time_of_day(true, false);
+                       name_values['e'] = end.date() + " " + end.time_of_day(true, false);
+                       name_values['i'] = kdm.cpl_id();
+
+                       kdms.push_back (KDMWithMetadataPtr(new DCPKDMWithMetadata(name_values, i->cinema, kdm)));
                }
                write_files (kdms, zip, output, container_name_format, filename_format, values, verbose);
        } catch (FileError& e) {
index d946e1d..d747418 100644 (file)
@@ -185,6 +185,7 @@ KDMDialog::make_clicked ()
                                name_values['f'] = film->name();
                                name_values['b'] = dcp::LocalTime(begin).date() + " " + dcp::LocalTime(begin).time_of_day(false, false);
                                name_values['e'] = dcp::LocalTime(end).date() + " " + dcp::LocalTime(end).time_of_day(false, false);
+                               name_values['i'] = kdm.cpl_id();
 
                                kdms.push_back (KDMWithMetadataPtr(new DCPKDMWithMetadata(name_values, i->cinema, kdm)));
                        }