diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-06-17 22:35:39 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-07-03 22:46:34 +0200 |
| commit | d4019480147bd6b478f8b067982c53251e5d6f15 (patch) | |
| tree | 9cf10f9655b7ef332d3362da32eba4000cd1fe4d /src/lib | |
| parent | b4c7d661a2c7b072d18e82129ff0a31a99ba5081 (diff) | |
Add all DCP CPLs to the content list, and write CPL ID to SPLs instead of digest (#3040).
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/content_store.h | 6 | ||||
| -rw-r--r-- | src/lib/spl.cc | 15 | ||||
| -rw-r--r-- | src/lib/spl_entry.cc | 8 | ||||
| -rw-r--r-- | src/lib/spl_entry.h | 2 |
4 files changed, 22 insertions, 9 deletions
diff --git a/src/lib/content_store.h b/src/lib/content_store.h index d5a6336a5..c615a856e 100644 --- a/src/lib/content_store.h +++ b/src/lib/content_store.h @@ -24,11 +24,13 @@ class Content; + /** @class ContentStore - * @brief Parent for classes which store content and can return content with a given digest. + * @brief Parent for classes which store content and can return content with a given digest or CPL ID. */ class ContentStore { public: - virtual std::shared_ptr<Content> get (std::string digest) const = 0; + virtual std::shared_ptr<Content> get_by_digest(std::string digest) const = 0; + virtual std::shared_ptr<Content> get_by_cpl_id(std::string id) const = 0; }; diff --git a/src/lib/spl.cc b/src/lib/spl.cc index 615dd916a..ff37e5cbf 100644 --- a/src/lib/spl.cc +++ b/src/lib/spl.cc @@ -45,11 +45,18 @@ SPL::read (boost::filesystem::path path, ContentStore* store) _id = doc.string_child("Id"); _name = doc.string_child("Name"); for (auto i: doc.node_children("Entry")) { - auto c = store->get(i->string_child("Digest")); - if (c) { - add (SPLEntry(c)); + if (auto cpl = i->optional_string_child("CPL")) { + if (auto c = store->get_by_cpl_id(*cpl)) { + add(SPLEntry(c)); + } else { + _missing = true; + } } else { - _missing = true; + if (auto c = store->get_by_digest(i->string_child("Digest"))) { + add(SPLEntry(c)); + } else { + _missing = true; + } } } } diff --git a/src/lib/spl_entry.cc b/src/lib/spl_entry.cc index a77b0b7d5..f5e7c9644 100644 --- a/src/lib/spl_entry.cc +++ b/src/lib/spl_entry.cc @@ -40,7 +40,7 @@ SPLEntry::SPLEntry (shared_ptr<Content> c) if (dcp) { name = dcp->name (); DCPOMATIC_ASSERT (dcp->cpl()); - id = *dcp->cpl(); + id = dcp->cpl(); kind = dcp->content_kind().get_value_or(dcp::ContentKind::FEATURE); encrypted = dcp->encrypted (); } else { @@ -53,5 +53,9 @@ SPLEntry::SPLEntry (shared_ptr<Content> c) void SPLEntry::as_xml (xmlpp::Element* e) { - cxml::add_text_child(e, "Digest", digest); + if (id) { + cxml::add_text_child(e, "CPL", *id); + } else { + cxml::add_text_child(e, "Digest", digest); + } } diff --git a/src/lib/spl_entry.h b/src/lib/spl_entry.h index 6fa3dd32c..cbb597d20 100644 --- a/src/lib/spl_entry.h +++ b/src/lib/spl_entry.h @@ -46,7 +46,7 @@ public: /** Digest of this content */ std::string digest; /** CPL ID */ - std::string id; + boost::optional<std::string> id; boost::optional<dcp::ContentKind> kind; bool encrypted; |
