Write 'f', 'b' and 'e' tags into all KDMWithMetadata when they are made.
[dcpomatic.git] / src / tools / dcpomatic_kdm.cc
index 1ff69d13562cd3dfcdd2f194be6c70796283506a..7920f7e5756b9994c7147fd5c45bccc1fb87cd9d 100644 (file)
@@ -40,7 +40,6 @@
 #include "lib/job_manager.h"
 #include "lib/kdm_with_metadata.h"
 #include "lib/exceptions.h"
-#include "lib/cinema_kdms.h"
 #include "lib/send_kdm_email_job.h"
 #include "lib/compose.hpp"
 #include "lib/cinema.h"
@@ -303,7 +302,7 @@ private:
                                return;
                        }
 
-                       list<shared_ptr<KDMWithMetadata> > screen_kdms;
+                       list<KDMWithMetadataPtr> kdms;
                        string title;
 
 #ifdef DCPOMATIC_VARIANT_SWAROOP
@@ -318,18 +317,28 @@ private:
                                                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());
+
                                        DecryptedECinemaKDM kdm (
                                                decrypted.id(),
                                                decrypted.name(),
                                                decrypted.key(),
-                                               dcp::LocalTime (_timing->from(), i->cinema->utc_offset_hour(), i->cinema->utc_offset_minute()),
-                                               dcp::LocalTime (_timing->until(), i->cinema->utc_offset_hour(), i->cinema->utc_offset_minute())
+                                               begin,
+                                               end
                                                );
 
+                                       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);
+
                                        /* Encrypt */
-                                       screen_kdms.push_back (
-                                               shared_ptr<KDMWithMetadata>(
-                                                       new ECinemaKDMWithMetadata(i, kdm.encrypt(i->recipient.get()))
+                                       kdms.push_back (
+                                               KDMWithMetadataPtr(
+                                                       new ECinemaKDMWithMetadata(name_values, i->cinema, kdm.encrypt(i->recipient.get()))
                                                        )
                                                );
                                }
@@ -355,10 +364,13 @@ private:
                                                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 (
-                                               dcp::LocalTime (_timing->from(), i->cinema->utc_offset_hour(), i->cinema->utc_offset_minute()),
-                                               dcp::LocalTime (_timing->until(), i->cinema->utc_offset_hour(), i->cinema->utc_offset_minute()),
+                                               begin,
+                                               end,
                                                decrypted.annotation_text().get_value_or (""),
                                                decrypted.content_title_text(),
                                                dcp::LocalTime().as_string()
@@ -369,11 +381,19 @@ private:
                                                kdm.add_key (j);
                                        }
 
+                                       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);
+
                                        /* Encrypt */
-                                       screen_kdms.push_back (
-                                               shared_ptr<KDMWithMetadata>(
+                                       kdms.push_back (
+                                               KDMWithMetadataPtr(
                                                        new DCPKDMWithMetadata(
-                                                               i,
+                                                               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
@@ -384,12 +404,12 @@ private:
                                }
                        }
 
-                       if (screen_kdms.empty()) {
+                       if (kdms.empty()) {
                                return;
                        }
 
                        pair<shared_ptr<Job>, int> result = _output->make (
-                               screen_kdms, title, _timing, bind (&DOMFrame::confirm_overwrite, this, _1)
+                               kdms, title, bind (&DOMFrame::confirm_overwrite, this, _1)
                                );
 
                        if (result.first) {