From bdae32bb84672026c1a373e809804109e95accf4 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 2 Mar 2016 23:10:55 +0000 Subject: [PATCH] Take notice of cinema time zones when making KDMs (#788). --- ChangeLog | 5 +++++ src/lib/film.cc | 24 ++++++++++++++++++++---- src/lib/film.h | 6 +++--- src/tools/dcpomatic_kdm.cc | 7 ++++++- src/tools/dcpomatic_kdm_cli.cc | 6 +++--- src/wx/kdm_dialog.h | 4 ++-- 6 files changed, 39 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index f35e0adbc..897e1f0f7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2016-03-08 Carl Hetherington + + * Store time zone with cinemas and use them to + mark KDM start and end times correctly (#788). + 2016-03-08 Carl Hetherington * Version 2.7.0 released. diff --git a/src/lib/film.cc b/src/lib/film.cc index 1b0f14095..e669ea4ae 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2015 Carl Hetherington + Copyright (C) 2012-2016 Carl Hetherington 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 @@ -50,6 +50,7 @@ #include "ffmpeg_content.h" #include "dcp_content.h" #include "screen_kdm.h" +#include "cinema.h" #include #include #include @@ -1163,6 +1164,9 @@ Film::frame_size () const return fit_ratio_within (container()->ratio(), full_frame ()); } +/** @param from KDM from time expressed as a local time with an offset from UTC + * @param to KDM to time expressed as a local time with an offset from UTC + */ dcp::EncryptedKDM Film::make_kdm ( dcp::Certificate recipient, @@ -1184,12 +1188,15 @@ Film::make_kdm ( ).encrypt (signer, recipient, trusted_devices, formulation); } +/** @param from KDM from time expressed as a local time in the time zone of the Screen's Cinema. + * @param to KDM to time expressed as a local time in the time zone of the Screen's Cinema. + */ list Film::make_kdms ( list > screens, boost::filesystem::path dcp, - dcp::LocalTime from, - dcp::LocalTime until, + boost::posix_time::ptime from, + boost::posix_time::ptime until, dcp::Formulation formulation ) const { @@ -1197,7 +1204,16 @@ Film::make_kdms ( BOOST_FOREACH (shared_ptr i, screens) { if (i->recipient) { - kdms.push_back (ScreenKDM (i, make_kdm (i->recipient.get(), i->trusted_devices, dcp, from, until, formulation))); + dcp::EncryptedKDM const kdm = make_kdm ( + i->recipient.get(), + i->trusted_devices, + dcp, + dcp::LocalTime (from, i->cinema->utc_offset(), 0), + dcp::LocalTime (until, i->cinema->utc_offset(), 0), + formulation + ); + + kdms.push_back (ScreenKDM (i, kdm)); } } diff --git a/src/lib/film.h b/src/lib/film.h index b34e4bcfa..b8e31a420 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2015 Carl Hetherington + Copyright (C) 2012-2016 Carl Hetherington 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 @@ -132,8 +132,8 @@ public: std::list make_kdms ( std::list >, boost::filesystem::path cpl_file, - dcp::LocalTime from, - dcp::LocalTime until, + boost::posix_time::ptime from, + boost::posix_time::ptime until, dcp::Formulation formulation ) const; diff --git a/src/tools/dcpomatic_kdm.cc b/src/tools/dcpomatic_kdm.cc index 643aaeb77..b98ec84a9 100644 --- a/src/tools/dcpomatic_kdm.cc +++ b/src/tools/dcpomatic_kdm.cc @@ -38,6 +38,7 @@ #include "lib/cinema_kdms.h" #include "lib/send_kdm_email_job.h" #include "lib/compose.hpp" +#include "lib/cinema.h" #include #include #include @@ -270,7 +271,11 @@ private: /* Make an empty KDM */ dcp::DecryptedKDM kdm ( - _timing->from(), _timing->until(), decrypted.annotation_text(), decrypted.content_title_text(), dcp::LocalTime().as_string() + dcp::LocalTime (_timing->from(), i->cinema->utc_offset(), 0), + dcp::LocalTime (_timing->until(), i->cinema->utc_offset(), 0), + decrypted.annotation_text(), + decrypted.content_title_text(), + dcp::LocalTime().as_string() ); /* Add keys from the DKDM */ diff --git a/src/tools/dcpomatic_kdm_cli.cc b/src/tools/dcpomatic_kdm_cli.cc index 2f8212a61..2a6ce9e12 100644 --- a/src/tools/dcpomatic_kdm_cli.cc +++ b/src/tools/dcpomatic_kdm_cli.cc @@ -46,8 +46,8 @@ help () cerr << "Syntax: " << program_name << " [OPTION] []\n" " -h, --help show this help\n" " -o, --output output file or directory\n" - " -f, --valid-from valid from time (in local time zone) (e.g. \"2013-09-28 01:41:51\") or \"now\"\n" - " -t, --valid-to valid to time (in local time zone) (e.g. \"2014-09-28 01:41:51\")\n" + " -f, --valid-from valid from time (in local time zone of the cinema) (e.g. \"2013-09-28 01:41:51\") or \"now\"\n" + " -t, --valid-to valid to time (in local time zone of the cinema) (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" @@ -283,7 +283,7 @@ int main (int argc, char* argv[]) try { list screen_kdms = film->make_kdms ( - (*i)->screens(), cpl, dcp::LocalTime (valid_from.get()), dcp::LocalTime (valid_to.get()), formulation + (*i)->screens(), cpl, valid_from.get(), valid_to.get(), formulation ); if (zip) { diff --git a/src/wx/kdm_dialog.h b/src/wx/kdm_dialog.h index 3ec21b41d..0f7840045 100644 --- a/src/wx/kdm_dialog.h +++ b/src/wx/kdm_dialog.h @@ -39,9 +39,9 @@ public: KDMDialog (wxWindow *, boost::shared_ptr); std::list > screens () const; - /** @return KDM from time in local time */ + /** @return KDM from time in local time; note that ptime has no time zone information */ boost::posix_time::ptime from () const; - /** @return KDM until time in local time */ + /** @return KDM until time in local time; note that ptime has no time zone information */ boost::posix_time::ptime until () const; boost::filesystem::path cpl () const; -- 2.30.2