diff options
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/cinema.cc | 15 | ||||
| -rw-r--r-- | src/lib/cinema.h | 16 | ||||
| -rw-r--r-- | src/lib/film.cc | 24 | ||||
| -rw-r--r-- | src/lib/film.h | 6 |
4 files changed, 50 insertions, 11 deletions
diff --git a/src/lib/cinema.cc b/src/lib/cinema.cc index ebd716009..5e2b1b533 100644 --- a/src/lib/cinema.cc +++ b/src/lib/cinema.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net> + Copyright (C) 2013-2016 Carl Hetherington <cth@carlh.net> 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 @@ -19,9 +19,12 @@ #include "cinema.h" #include "screen.h" +#include "dcpomatic_assert.h" #include <libcxml/cxml.h> +#include <dcp/raw_convert.h> #include <libxml++/libxml++.h> #include <boost/foreach.hpp> +#include <iostream> using std::list; using std::string; @@ -29,6 +32,7 @@ using boost::shared_ptr; Cinema::Cinema (cxml::ConstNodePtr node) : name (node->string_child ("Name")) + , _utc_offset (node->optional_number_child<int>("UTCOffset").get_value_or (0)) { BOOST_FOREACH (cxml::ConstNodePtr i, node->node_children("Email")) { emails.push_back (i->content ()); @@ -56,6 +60,8 @@ Cinema::as_xml (xmlpp::Element* parent) const parent->add_child("Email")->add_child_text (i); } + parent->add_child("UTCOffset")->add_child_text (dcp::raw_convert<string> (_utc_offset)); + BOOST_FOREACH (shared_ptr<Screen> i, _screens) { i->as_xml (parent->add_child ("Screen")); } @@ -73,3 +79,10 @@ Cinema::remove_screen (shared_ptr<Screen> s) { _screens.remove (s); } + +void +Cinema::set_utc_offset (int o) +{ + DCPOMATIC_ASSERT (o >= -11 && o <= 12); + _utc_offset = o; +} diff --git a/src/lib/cinema.h b/src/lib/cinema.h index aec4c83ec..7df83c767 100644 --- a/src/lib/cinema.h +++ b/src/lib/cinema.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net> + Copyright (C) 2013-2016 Carl Hetherington <cth@carlh.net> 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 @@ -33,15 +33,16 @@ class Screen; /** @class Cinema * @brief A description of a Cinema for KDM generation. * - * This is a cinema name, contact email addresses and a list of + * This is a cinema name, some metadata and a list of * Screen objects. */ class Cinema : public boost::enable_shared_from_this<Cinema> { public: - Cinema (std::string const & n, std::list<std::string> const & e) + Cinema (std::string const & n, std::list<std::string> const & e, int utc_offset) : name (n) , emails (e) + , _utc_offset (utc_offset) {} Cinema (cxml::ConstNodePtr); @@ -53,12 +54,21 @@ public: void add_screen (boost::shared_ptr<Screen>); void remove_screen (boost::shared_ptr<Screen>); + void set_utc_offset (int o); + std::string name; std::list<std::string> emails; + int utc_offset () const { + return _utc_offset; + } std::list<boost::shared_ptr<Screen> > screens () const { return _screens; } private: std::list<boost::shared_ptr<Screen> > _screens; + /** Offset such that the equivalent time in UTC can be determined + by subtracting the offset from the local time. + */ + int _utc_offset; }; 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 <cth@carlh.net> + Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net> 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 <libcxml/cxml.h> #include <dcp/cpl.h> #include <dcp/certificate_chain.h> @@ -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<ScreenKDM> Film::make_kdms ( list<shared_ptr<Screen> > 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<Screen> 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 <cth@carlh.net> + Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net> 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<ScreenKDM> make_kdms ( std::list<boost::shared_ptr<Screen> >, 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; |
