- for (auto i: _screens->screens()) {
-
- if (!i->recipient) {
- continue;
- }
-
- dcp::LocalTime begin(_timing->from(), i->cinema->utc_offset_hour(), i->cinema->utc_offset_minute());
- dcp::LocalTime end(_timing->until(), i->cinema->utc_offset_hour(), i->cinema->utc_offset_minute());
-
- /* Make an empty KDM */
- dcp::DecryptedKDM kdm (
- begin,
- end,
- decrypted.annotation_text().get_value_or (""),
- decrypted.content_title_text(),
- dcp::LocalTime().as_string()
- );
-
- /* Add keys from the DKDM */
- for (auto const& j: decrypted.keys()) {
- 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 KDMWithMetadata(name_values, i->cinema.get(), i->cinema->emails, encrypted)
- )
- );
+ return kdm;
+ };
+
+ for (auto i: _screens->screens()) {
+
+ auto kdm = kdm_for_screen(
+ make_kdm,
+ i,
+ _timing->from(),
+ _timing->until(),
+ _output->formulation(),
+ !_output->forensic_mark_video(),
+ _output->forensic_mark_audio() ? boost::optional<int>() : 0,
+ period_checks
+ );
+
+ if (kdm) {
+ kdms.push_back(kdm);