summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2023-11-19 21:34:56 +0100
committerCarl Hetherington <cth@carlh.net>2023-11-20 07:31:44 +0100
commit16557827b252bd653b15eead479ec5699eda7360 (patch)
treef94f6822143802f2676c44e711984029eb3fb6cc /src/lib
parent9d1d75e474bc92d8b0f823141073ad9dd639c8e0 (diff)
Add a dialog to show which screens have potentially-problematic
certificate validity periods when making KDMs (#2645).
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/kdm_cli.cc12
-rw-r--r--src/lib/kdm_util.cc24
-rw-r--r--src/lib/kdm_util.h28
-rw-r--r--src/lib/screen.cc2
4 files changed, 56 insertions, 10 deletions
diff --git a/src/lib/kdm_cli.cc b/src/lib/kdm_cli.cc
index 5ea808967..ddc77e771 100644
--- a/src/lib/kdm_cli.cc
+++ b/src/lib/kdm_cli.cc
@@ -257,13 +257,21 @@ from_film (
}
- if (find(period_checks.begin(), period_checks.end(), KDMCertificatePeriod::KDM_OUTSIDE_CERTIFICATE) != period_checks.end()) {
+ if (find_if(
+ period_checks.begin(),
+ period_checks.end(),
+ [](KDMCertificatePeriod const& p) { return p.overlap == KDMCertificateOverlap::KDM_OUTSIDE_CERTIFICATE; }
+ ) != period_checks.end()) {
throw KDMCLIError(
"Some KDMs would have validity periods which are completely outside the recipient certificate periods. Such KDMs are very unlikely to work, so will not be created."
);
}
- if (find(period_checks.begin(), period_checks.end(), KDMCertificatePeriod::KDM_OVERLAPS_CERTIFICATE) != period_checks.end()) {
+ if (find_if(
+ period_checks.begin(),
+ period_checks.end(),
+ [](KDMCertificatePeriod const& p) { return p.overlap == KDMCertificateOverlap::KDM_OVERLAPS_CERTIFICATE; }
+ ) != period_checks.end()) {
out("For some of these KDMs the recipient certificate's validity period will not cover the whole of the KDM validity period. This might cause problems with the KDMs.");
}
diff --git a/src/lib/kdm_util.cc b/src/lib/kdm_util.cc
index bf112ce11..dcfd1fe67 100644
--- a/src/lib/kdm_util.cc
+++ b/src/lib/kdm_util.cc
@@ -35,7 +35,13 @@ using boost::optional;
KDMCertificatePeriod
-check_kdm_and_certificate_validity_periods(dcp::Certificate const& recipient, dcp::LocalTime kdm_from, dcp::LocalTime kdm_to)
+check_kdm_and_certificate_validity_periods(
+ string const& cinema_name,
+ string const& screen_name,
+ dcp::Certificate const& recipient,
+ dcp::LocalTime kdm_from,
+ dcp::LocalTime kdm_to
+ )
{
auto overlaps = [](dcp::LocalTime from_a, dcp::LocalTime to_a, dcp::LocalTime from_b, dcp::LocalTime to_b) {
return std::max(from_a, from_b) < std::min(to_a, to_b);
@@ -45,16 +51,26 @@ check_kdm_and_certificate_validity_periods(dcp::Certificate const& recipient, dc
return bigger_from <= smaller_from && bigger_to >= smaller_to;
};
+ KDMCertificatePeriod period(
+ cinema_name,
+ screen_name,
+ recipient.not_before(),
+ recipient.not_after()
+ );
+
if (contains(recipient.not_before(), recipient.not_after(), kdm_from, kdm_to)) {
- return KDMCertificatePeriod::KDM_WITHIN_CERTIFICATE;
+ period.overlap = KDMCertificateOverlap::KDM_WITHIN_CERTIFICATE;
+ return period;
}
if (overlaps(recipient.not_before(), recipient.not_after(), kdm_from, kdm_to)) {
/* The KDM overlaps the certificate validity: maybe not the end of the world */
- return KDMCertificatePeriod::KDM_OVERLAPS_CERTIFICATE;
+ period.overlap = KDMCertificateOverlap::KDM_OVERLAPS_CERTIFICATE;
+ return period;
} else {
/* The KDM validity is totally outside the certificate validity: bad news */
- return KDMCertificatePeriod::KDM_OUTSIDE_CERTIFICATE;
+ period.overlap = KDMCertificateOverlap::KDM_OUTSIDE_CERTIFICATE;
+ return period;
}
}
diff --git a/src/lib/kdm_util.h b/src/lib/kdm_util.h
index 398819ae0..8dba1ff98 100644
--- a/src/lib/kdm_util.h
+++ b/src/lib/kdm_util.h
@@ -32,21 +32,43 @@ namespace dcp {
}
-enum class KDMCertificatePeriod {
+enum class KDMCertificateOverlap {
KDM_WITHIN_CERTIFICATE,
KDM_OVERLAPS_CERTIFICATE,
KDM_OUTSIDE_CERTIFICATE
};
+struct KDMCertificatePeriod
+{
+ KDMCertificatePeriod(std::string cinema_name_, std::string screen_name_, dcp::LocalTime from_, dcp::LocalTime to_)
+ : cinema_name(std::move(cinema_name_))
+ , screen_name(std::move(screen_name_))
+ , from(std::move(from_))
+ , to(std::move(to_))
+ {}
+
+ std::string cinema_name;
+ std::string screen_name;
+ KDMCertificateOverlap overlap = KDMCertificateOverlap::KDM_WITHIN_CERTIFICATE;
+ dcp::LocalTime from;
+ dcp::LocalTime to;
+};
+
+
/** @param recipient Some KDM recipient certificate.
* @param kdm_from Proposed KDM start time.
* @param kdm_to Proposed KDM end time.
* @return Relationship between certificate and KDM validity periods.
*/
-KDMCertificatePeriod
-check_kdm_and_certificate_validity_periods(dcp::Certificate const& recipient, dcp::LocalTime kdm_from, dcp::LocalTime kdm_to);
+KDMCertificatePeriod check_kdm_and_certificate_validity_periods(
+ std::string const& cinema_name,
+ std::string const& screen_name,
+ dcp::Certificate const& recipient,
+ dcp::LocalTime kdm_from,
+ dcp::LocalTime kdm_to
+ );
#endif
diff --git a/src/lib/screen.cc b/src/lib/screen.cc
index 097ff80b8..7e2918018 100644
--- a/src/lib/screen.cc
+++ b/src/lib/screen.cc
@@ -93,7 +93,7 @@ kdm_for_screen (
dcp::LocalTime const begin(valid_from, dcp::UTCOffset(cinema ? cinema->utc_offset_hour() : 0, cinema ? cinema->utc_offset_minute() : 0));
dcp::LocalTime const end (valid_to, dcp::UTCOffset(cinema ? cinema->utc_offset_hour() : 0, cinema ? cinema->utc_offset_minute() : 0));
- period_checks.push_back(check_kdm_and_certificate_validity_periods(screen->recipient.get(), begin, end));
+ period_checks.push_back(check_kdm_and_certificate_validity_periods(cinema->name, screen->name, screen->recipient.get(), begin, end));
auto signer = Config::instance()->signer_chain();
if (!signer->valid()) {