summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-09-03 01:52:14 +0200
committerCarl Hetherington <cth@carlh.net>2022-09-03 14:46:38 +0200
commit1d13ce8be4df51e85b7222a7c9d357366c841a89 (patch)
tree1be0a392051a1f520eef79778379497db800c22e /src
parent6740903432bca2ab447a47ac773a735d4f1f2e50 (diff)
Properly support ContentKind scope attribute.v1.8.26
Diffstat (limited to 'src')
-rw-r--r--src/content_kind.cc14
-rw-r--r--src/content_kind.h16
-rw-r--r--src/cpl.cc9
-rw-r--r--src/verify.cc15
-rw-r--r--src/verify.h4
5 files changed, 51 insertions, 7 deletions
diff --git a/src/content_kind.cc b/src/content_kind.cc
index 4b0da53c..10439452 100644
--- a/src/content_kind.cc
+++ b/src/content_kind.cc
@@ -43,6 +43,10 @@ using std::vector;
using namespace dcp;
+static std::string const smpte_429_16_scope = "http://www.smpte-ra.org/schemas/429-16/2014/CPL-Metadata#scope/content-kind";
+static std::string const smpte_2067_3_scope = "http://www.smpte-ra.org/schemas/2067-3/2013#content-kind";
+
+
ContentKind const ContentKind::FEATURE = ContentKind{"feature"};
ContentKind const ContentKind::SHORT = ContentKind{"short"};
ContentKind const ContentKind::TRAILER = ContentKind{"trailer"};
@@ -53,8 +57,12 @@ ContentKind const ContentKind::TEASER = ContentKind{"teaser
ContentKind const ContentKind::POLICY = ContentKind{"policy"};
ContentKind const ContentKind::PUBLIC_SERVICE_ANNOUNCEMENT = ContentKind{"psa"};
ContentKind const ContentKind::ADVERTISEMENT = ContentKind{"advertisement"};
-ContentKind const ContentKind::EPISODE = ContentKind{"episode"};
-ContentKind const ContentKind::PROMO = ContentKind{"promo"};
+ContentKind const ContentKind::CLIP = ContentKind{"clip", smpte_429_16_scope};
+ContentKind const ContentKind::PROMO = ContentKind{"promo", smpte_429_16_scope};
+ContentKind const ContentKind::STEREOCARD = ContentKind{"stereocard", smpte_429_16_scope};
+ContentKind const ContentKind::EPISODE = ContentKind{"episode", smpte_2067_3_scope};
+ContentKind const ContentKind::HIGHLIGHTS = ContentKind{"highlights", smpte_2067_3_scope};
+ContentKind const ContentKind::EVENT = ContentKind{"event", smpte_2067_3_scope};
vector<ContentKind>
@@ -93,7 +101,7 @@ ContentKind::from_name(string name)
bool
dcp::operator==(ContentKind const& a, ContentKind const& b)
{
- return a.name() == b.name();
+ return a.name() == b.name() && a.scope() == b.scope();
}
diff --git a/src/content_kind.h b/src/content_kind.h
index 08aa17b4..39872fea 100644
--- a/src/content_kind.h
+++ b/src/content_kind.h
@@ -47,10 +47,19 @@ namespace dcp {
class ContentKind
{
public:
+ ContentKind(std::string name, boost::optional<std::string> scope)
+ : _name(name)
+ , _scope(scope)
+ {}
+
std::string name() const {
return _name;
}
+ boost::optional<std::string> scope() const {
+ return _scope;
+ }
+
static const ContentKind FEATURE;
static const ContentKind SHORT;
static const ContentKind TRAILER;
@@ -61,8 +70,12 @@ public:
static const ContentKind POLICY;
static const ContentKind PUBLIC_SERVICE_ANNOUNCEMENT;
static const ContentKind ADVERTISEMENT;
- static const ContentKind EPISODE;
+ static const ContentKind CLIP;
static const ContentKind PROMO;
+ static const ContentKind STEREOCARD;
+ static const ContentKind EPISODE;
+ static const ContentKind HIGHLIGHTS;
+ static const ContentKind EVENT;
static ContentKind from_name(std::string name);
static std::vector<ContentKind> all();
@@ -73,6 +86,7 @@ private:
{}
std::string _name;
+ boost::optional<std::string> _scope;
};
diff --git a/src/cpl.cc b/src/cpl.cc
index 5e0ca2cc..ee1817fc 100644
--- a/src/cpl.cc
+++ b/src/cpl.cc
@@ -122,7 +122,8 @@ CPL::CPL (boost::filesystem::path file)
_creator = f.optional_string_child("Creator").get_value_or("");
_issue_date = f.string_child ("IssueDate");
_content_title_text = f.string_child ("ContentTitleText");
- _content_kind = ContentKind::from_name(f.string_child("ContentKind"));
+ auto content_kind = f.node_child("ContentKind");
+ _content_kind = ContentKind(content_kind->content(), content_kind->optional_string_attribute("scope"));
shared_ptr<cxml::Node> content_version = f.optional_node_child ("ContentVersion");
if (content_version) {
/* XXX: SMPTE should insist that Id is present */
@@ -198,7 +199,11 @@ CPL::write_xml (boost::filesystem::path file, shared_ptr<const CertificateChain>
root->add_child("Issuer")->add_child_text (_issuer);
root->add_child("Creator")->add_child_text (_creator);
root->add_child("ContentTitleText")->add_child_text (_content_title_text);
- root->add_child("ContentKind")->add_child_text(_content_kind.name());
+ auto content_kind = root->add_child("ContentKind");
+ content_kind->add_child_text(_content_kind.name());
+ if (_content_kind.scope()) {
+ content_kind->set_attribute("scope", *_content_kind.scope());
+ }
if (_content_versions.empty()) {
ContentVersion cv;
cv.as_xml (root);
diff --git a/src/verify.cc b/src/verify.cc
index e14a81b1..a3f7d5a7 100644
--- a/src/verify.cc
+++ b/src/verify.cc
@@ -1315,6 +1315,19 @@ dcp::verify (
verify_language_tag (i, notes);
}
+ if (!cpl->content_kind().scope() || *cpl->content_kind().scope() == "http://www.smpte-ra.org/schemas/429-7/2006/CPL#standard-content") {
+ /* This is a content kind from http://www.smpte-ra.org/schemas/429-7/2006/CPL#standard-content; make sure it's one
+ * of the approved ones.
+ */
+ auto all = ContentKind::all();
+ auto name = cpl->content_kind().name();
+ transform(name.begin(), name.end(), name.begin(), ::tolower);
+ auto iter = std::find_if(all.begin(), all.end(), [name](ContentKind const& k) { return !k.scope() && k.name() == name; });
+ if (iter == all.end()) {
+ notes.push_back({VerificationNote::Type::ERROR, VerificationNote::Code::INVALID_CONTENT_KIND, cpl->content_kind().name()});
+ }
+ }
+
if (cpl->release_territory()) {
if (!cpl->release_territory_scope() || cpl->release_territory_scope().get() != "http://www.smpte-ra.org/schemas/429-16/2014/CPL-Metadata#scope/release-territory/UNM49") {
auto terr = cpl->release_territory().get();
@@ -1770,6 +1783,8 @@ dcp::note_to_string (VerificationNote note)
return "There is an <EntryPoint> node inside a <MainMarkers>.";
case VerificationNote::Code::UNEXPECTED_DURATION:
return "There is an <Duration> node inside a <MainMarkers>.";
+ case VerificationNote::Code::INVALID_CONTENT_KIND:
+ return String::compose("<ContentKind> has an invalid value %1.", note.note().get());
}
return "";
diff --git a/src/verify.h b/src/verify.h
index 3dd7d125..baa36138 100644
--- a/src/verify.h
+++ b/src/verify.h
@@ -396,7 +396,9 @@ public:
/** Some <MainMarkers> asset has an <EntryPoint> that should not be there */
UNEXPECTED_ENTRY_POINT,
/** Some <MainMarkers> asset has an <Duration> that should not be there */
- UNEXPECTED_DURATION
+ UNEXPECTED_DURATION,
+ /** A <ContentKind> has been specified with either no scope or the SMPTE 429-7 scope, but which is not one of those allowed */
+ INVALID_CONTENT_KIND
};
VerificationNote (Type type, Code code)