summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-06-17 22:35:39 +0200
committerCarl Hetherington <cth@carlh.net>2025-07-03 22:46:34 +0200
commitd4019480147bd6b478f8b067982c53251e5d6f15 (patch)
tree9cf10f9655b7ef332d3362da32eba4000cd1fe4d /src
parentb4c7d661a2c7b072d18e82129ff0a31a99ba5081 (diff)
Add all DCP CPLs to the content list, and write CPL ID to SPLs instead of digest (#3040).
Diffstat (limited to 'src')
-rw-r--r--src/lib/content_store.h6
-rw-r--r--src/lib/spl.cc15
-rw-r--r--src/lib/spl_entry.cc8
-rw-r--r--src/lib/spl_entry.h2
-rw-r--r--src/tools/dcpomatic_playlist.cc11
-rw-r--r--src/wx/content_view.cc49
-rw-r--r--src/wx/content_view.h3
7 files changed, 73 insertions, 21 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;
diff --git a/src/tools/dcpomatic_playlist.cc b/src/tools/dcpomatic_playlist.cc
index 2e9bbb9f3..91375e489 100644
--- a/src/tools/dcpomatic_playlist.cc
+++ b/src/tools/dcpomatic_playlist.cc
@@ -102,9 +102,14 @@ public:
return _content_view->selected();
}
- shared_ptr<Content> get(string digest) const override
+ shared_ptr<Content> get_by_digest(string digest) const override
{
- return _content_view->get(digest);
+ return _content_view->get_by_digest(digest);
+ }
+
+ shared_ptr<Content> get_by_cpl_id(string cpl_id) const override
+ {
+ return _content_view->get_by_cpl_id(cpl_id);
}
private:
@@ -413,7 +418,7 @@ private:
void set_item(long N, SPLEntry e)
{
_list->SetItem(N, 0, std_to_wx(e.name));
- _list->SetItem(N, 1, std_to_wx(e.id));
+ _list->SetItem(N, 1, std_to_wx(e.id.get_value_or("")));
_list->SetItem(N, 2, std_to_wx(e.kind->name()));
_list->SetItem(N, 3, e.encrypted ? S_("Question|Y") : S_("Question|N"));
}
diff --git a/src/wx/content_view.cc b/src/wx/content_view.cc
index 6a5a3793d..fa6bd64dc 100644
--- a/src/wx/content_view.cc
+++ b/src/wx/content_view.cc
@@ -30,8 +30,10 @@
#include "lib/examine_content_job.h"
#include "lib/job_manager.h"
#include "lib/util.h"
+#include <dcp/cpl.h>
#include <dcp/exceptions.h>
#include <dcp/filesystem.h>
+#include <dcp/search.h>
#include <dcp/warnings.h>
#include <boost/filesystem.hpp>
#include <boost/optional.hpp>
@@ -134,8 +136,17 @@ ContentView::update ()
if (i->finished_in_error()) {
error_dialog(this, std_to_wx(i->error_summary()) + char_to_wx(".\n"), std_to_wx(i->error_details()));
} else {
- add (i->content());
- _content.push_back (i->content());
+ if (auto dcp = dynamic_pointer_cast<DCPContent>(i->content())) {
+ for (auto cpl: dcp::find_and_resolve_cpls(dcp->directories(), true)) {
+ auto copy = dynamic_pointer_cast<DCPContent>(dcp->clone());
+ copy->set_cpl(cpl->id());
+ add(copy);
+ _content.push_back(copy);
+ }
+ } else {
+ add(i->content());
+ _content.push_back(i->content());
+ }
}
}
}
@@ -170,13 +181,35 @@ ContentView::add (shared_ptr<Content> content)
shared_ptr<Content>
-ContentView::get (string digest) const
+ContentView::get_by_digest(string digest) const
{
- for (auto i: _content) {
- if (i->digest() == digest) {
- return i;
- }
+ auto iter = std::find_if(_content.begin(), _content.end(), [digest](shared_ptr<const Content> c) { return c->digest() == digest; });
+ if (iter == _content.end()) {
+ return {};
+ }
+
+ return *iter;
+}
+
+
+shared_ptr<Content>
+ContentView::get_by_cpl_id(string cpl_id) const
+{
+ auto iter = std::find_if(
+ _content.begin(),
+ _content.end(),
+ [cpl_id](shared_ptr<const Content> c) {
+ if (auto dcp = dynamic_pointer_cast<const DCPContent>(c)) {
+ if (dcp->cpl() && *dcp->cpl() == cpl_id) {
+ return true;
+ }
+ }
+ return false;
+ });
+
+ if (iter == _content.end()) {
+ return {};
}
- return {};
+ return *iter;
}
diff --git a/src/wx/content_view.h b/src/wx/content_view.h
index 16ff5c463..703878d46 100644
--- a/src/wx/content_view.h
+++ b/src/wx/content_view.h
@@ -39,7 +39,8 @@ public:
std::shared_ptr<Content> selected () const;
void update ();
- std::shared_ptr<Content> get (std::string digest) const override;
+ std::shared_ptr<Content> get_by_digest(std::string digest) const override;
+ std::shared_ptr<Content> get_by_cpl_id(std::string cpl_id) const override;
private:
void add (std::shared_ptr<Content> content);