Extract common code out into kdm_for_screen()
[dcpomatic.git] / src / wx / kdm_dialog.cc
index 0686450fbf7fbf814efcb2ba6e20939217192cb9..d3bbf02c998e164ec4f317a00db7c80a04d9718c 100644 (file)
@@ -162,28 +162,11 @@ KDMDialog::make_clicked ()
                }
 
                BOOST_FOREACH (shared_ptr<dcpomatic::Screen> i, _screens->screens()) {
-                       if (i->recipient) {
-                               dcp::EncryptedKDM const kdm = film->make_kdm (
-                                               i->recipient.get(),
-                                               i->trusted_device_thumbprints(),
-                                               _cpl->cpl(),
-                                               dcp::LocalTime(_timing->from(),  i->cinema ? i->cinema->utc_offset_hour() : 0, i->cinema ? i->cinema->utc_offset_minute() : 0),
-                                               dcp::LocalTime(_timing->until(), i->cinema ? i->cinema->utc_offset_hour() : 0, i->cinema ? i->cinema->utc_offset_minute() : 0),
-                                               _output->formulation(),
-                                               !_output->forensic_mark_video(),
-                                               for_audio
-                                               );
-
-                               dcp::NameFormat::Map name_values;
-                               if (i->cinema) {
-                                       name_values['c'] = i->cinema->name;
-                               }
-                               name_values['s'] = i->name;
-
-                               kdms.push_back (KDMWithMetadataPtr(new DCPKDMWithMetadata(name_values, i->cinema, kdm)));
+                       KDMWithMetadataPtr p = kdm_for_screen (film, _cpl->cpl(), i, _timing->from(), _timing->until(), _output->formulation(), !_output->forensic_mark_video(), for_audio);
+                       if (p) {
+                               kdms.push_back (p);
                        }
                }
-
        } catch (dcp::BadKDMDateError& e) {
                if (e.starts_too_early()) {
                        error_dialog (this, _("The KDM start period is before (or close to) the start of the signing certificate's validity period.  Use a later start time for this KDM."));
@@ -196,7 +179,7 @@ KDMDialog::make_clicked ()
                return;
        }
 
-       pair<shared_ptr<Job>, int> result = _output->make (kdms, film->name(), _timing, bind (&KDMDialog::confirm_overwrite, this, _1));
+       pair<shared_ptr<Job>, int> result = _output->make (kdms, film->name(), bind (&KDMDialog::confirm_overwrite, this, _1));
        if (result.first) {
                JobManager::instance()->add (result.first);
        }