summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2024-06-09 19:55:58 +0200
committerCarl Hetherington <cth@carlh.net>2024-06-09 19:56:23 +0200
commite85519d4085b6af00f0c407b65f3cccd5c7ddcf1 (patch)
tree3462b8ff978bcce7d7f9993308e2b0e596153fb0 /src
parent76c2bbd1893037879ce78114fdbecad428849248 (diff)
Collect MainCaption and ClosedSubtitle assets and use the correct tags for them.
Diffstat (limited to 'src')
-rw-r--r--src/reel.cc32
-rw-r--r--src/reel.h11
-rw-r--r--src/reel_interop_subtitle_asset.cc8
-rw-r--r--src/reel_interop_subtitle_asset.h3
-rw-r--r--src/reel_smpte_caption_asset.cc27
-rw-r--r--src/reel_smpte_subtitle_asset.cc27
-rw-r--r--src/reel_smpte_subtitle_asset.h2
-rw-r--r--src/reel_subtitle_asset.cc7
-rw-r--r--src/reel_subtitle_asset.h2
9 files changed, 108 insertions, 11 deletions
diff --git a/src/reel.cc b/src/reel.cc
index 0bd1d73b..4e560157 100644
--- a/src/reel.cc
+++ b/src/reel.cc
@@ -106,11 +106,35 @@ Reel::Reel (std::shared_ptr<const cxml::Node> node, dcp::Standard standard)
}
}
+ auto main_caption = asset_list->optional_node_child("MainCaption");
+ if (main_caption) {
+ switch (standard) {
+ case Standard::INTEROP:
+ DCP_ASSERT(false);
+ break;
+ case Standard::SMPTE:
+ _main_caption = make_shared<ReelSMPTECaptionAsset>(main_caption);
+ break;
+ }
+ }
+
auto main_markers = asset_list->optional_node_child ("MainMarkers");
if (main_markers) {
_main_markers = make_shared<ReelMarkersAsset>(main_markers);
}
+ auto closed_subtitles = asset_list->node_children("ClosedSubtitle");
+ for (auto i: closed_subtitles) {
+ switch (standard) {
+ case Standard::INTEROP:
+ DCP_ASSERT(false);
+ break;
+ case Standard::SMPTE:
+ _closed_subtitles.push_back(make_shared<ReelSMPTESubtitleAsset>(i));
+ break;
+ }
+ }
+
/* XXX: it's not ideal that we silently tolerate Interop or SMPTE nodes here */
/* XXX: not sure if Interop supports multiple closed captions */
auto closed_captions = asset_list->node_children ("MainClosedCaption");
@@ -162,6 +186,14 @@ Reel::write_to_cpl (xmlpp::Element* node, Standard standard) const
_main_subtitle->write_to_cpl (asset_list, standard);
}
+ if (_main_caption) {
+ _main_caption->write_to_cpl(asset_list, standard);
+ }
+
+ for (auto i: _closed_subtitles) {
+ i->write_to_cpl(asset_list, standard);
+ }
+
for (auto i: _closed_captions) {
i->write_to_cpl (asset_list, standard);
}
diff --git a/src/reel.h b/src/reel.h
index 1eccc6c1..77e781bf 100644
--- a/src/reel.h
+++ b/src/reel.h
@@ -66,6 +66,7 @@ namespace dcp {
class DecryptedKDM;
class ReelAsset;
+class ReelCaptionAsset;
class ReelPictureAsset;
class ReelSoundAsset;
class ReelSubtitleAsset;
@@ -109,10 +110,18 @@ public:
return _main_subtitle;
}
+ std::shared_ptr<ReelCaptionAsset> main_caption() const {
+ return _main_caption;
+ }
+
std::shared_ptr<ReelMarkersAsset> main_markers () const {
return _main_markers;
}
+ std::vector<std::shared_ptr<ReelSubtitleAsset>> closed_subtitles() const {
+ return _closed_subtitles;
+ }
+
std::vector<std::shared_ptr<ReelCaptionAsset>> closed_captions () const {
return _closed_captions;
}
@@ -146,7 +155,9 @@ private:
std::shared_ptr<ReelPictureAsset> _main_picture;
std::shared_ptr<ReelSoundAsset> _main_sound;
std::shared_ptr<ReelSubtitleAsset> _main_subtitle;
+ std::shared_ptr<ReelCaptionAsset> _main_caption;
std::shared_ptr<ReelMarkersAsset> _main_markers;
+ std::vector<std::shared_ptr<ReelSubtitleAsset>> _closed_subtitles;
std::vector<std::shared_ptr<ReelCaptionAsset>> _closed_captions;
std::shared_ptr<ReelAtmosAsset> _atmos;
diff --git a/src/reel_interop_subtitle_asset.cc b/src/reel_interop_subtitle_asset.cc
index 5f295d53..ef903ba1 100644
--- a/src/reel_interop_subtitle_asset.cc
+++ b/src/reel_interop_subtitle_asset.cc
@@ -63,3 +63,11 @@ ReelInteropSubtitleAsset::ReelInteropSubtitleAsset (std::shared_ptr<const cxml::
node->done ();
}
+
+string
+ReelInteropSubtitleAsset::cpl_node_name(Standard) const
+{
+ return "MainSubtitle";
+}
+
+
diff --git a/src/reel_interop_subtitle_asset.h b/src/reel_interop_subtitle_asset.h
index 7e90e9e0..6c2ab06f 100644
--- a/src/reel_interop_subtitle_asset.h
+++ b/src/reel_interop_subtitle_asset.h
@@ -61,6 +61,9 @@ public:
std::shared_ptr<InteropSubtitleAsset> interop_asset () {
return asset_of_type<InteropSubtitleAsset>();
}
+
+private:
+ std::string cpl_node_name (Standard standard) const override;
};
diff --git a/src/reel_smpte_caption_asset.cc b/src/reel_smpte_caption_asset.cc
index eeebf844..5a9f04ec 100644
--- a/src/reel_smpte_caption_asset.cc
+++ b/src/reel_smpte_caption_asset.cc
@@ -37,6 +37,7 @@
*/
+#include "compose.hpp"
#include "reel_smpte_caption_asset.h"
#include "warnings.h"
LIBDCP_DISABLE_WARNINGS
@@ -51,6 +52,9 @@ using std::string;
using namespace dcp;
+char constexpr ns_prefix[] = "tt";
+
+
ReelSMPTECaptionAsset::ReelSMPTECaptionAsset(shared_ptr<SMPTESubtitleAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point, TextType type)
: ReelCaptionAsset(asset, edit_rate, intrinsic_duration, entry_point, type)
{
@@ -58,9 +62,28 @@ ReelSMPTECaptionAsset::ReelSMPTECaptionAsset(shared_ptr<SMPTESubtitleAsset> asse
}
+static
+string
+cpl_node_name_without_prefix(TextType type)
+{
+ switch (type) {
+ case TextType::OPEN:
+ return "MainCaption";
+ case TextType::CLOSED:
+ return "ClosedCaption";
+ }
+}
+
+
ReelSMPTECaptionAsset::ReelSMPTECaptionAsset(shared_ptr<const cxml::Node> node)
: ReelCaptionAsset(node)
{
+ for (auto const& type: { TextType::OPEN, TextType::CLOSED }) {
+ if (node->name() == cpl_node_name_without_prefix(type)) {
+ _type = type;
+ }
+ }
+
node->done ();
}
@@ -79,13 +102,13 @@ ReelSMPTECaptionAsset::write_to_cpl(xmlpp::Element* node, Standard standard) con
string
ReelSMPTECaptionAsset::cpl_node_name(Standard) const
{
- return "tt:ClosedCaption";
+ return String::compose("%1:%2", ns_prefix, cpl_node_name_without_prefix(_type));
}
pair<string, string>
ReelSMPTECaptionAsset::cpl_node_namespace() const
{
- return make_pair("http://www.smpte-ra.org/schemas/429-12/2008/TT", "tt");
+ return make_pair("http://www.smpte-ra.org/schemas/429-12/2008/TT", ns_prefix);
}
diff --git a/src/reel_smpte_subtitle_asset.cc b/src/reel_smpte_subtitle_asset.cc
index 025ab25c..4e2b842a 100644
--- a/src/reel_smpte_subtitle_asset.cc
+++ b/src/reel_smpte_subtitle_asset.cc
@@ -58,9 +58,36 @@ ReelSMPTESubtitleAsset::ReelSMPTESubtitleAsset (shared_ptr<SMPTESubtitleAsset> a
}
+static
+string
+cpl_node_name_by_type(TextType type)
+{
+ switch (type) {
+ case TextType::OPEN:
+ return "MainSubtitle";
+ case TextType::CLOSED:
+ return "ClosedSubtitle";
+ }
+}
+
+
ReelSMPTESubtitleAsset::ReelSMPTESubtitleAsset (shared_ptr<const cxml::Node> node)
: ReelSubtitleAsset (node)
{
+ for (auto const& type: { TextType::OPEN, TextType::CLOSED }) {
+ if (node->name() == cpl_node_name_by_type(type)) {
+ _type = type;
+ }
+ }
+
node->done ();
}
+
+string
+ReelSMPTESubtitleAsset::cpl_node_name(Standard) const
+{
+ return cpl_node_name_by_type(_type);
+}
+
+
diff --git a/src/reel_smpte_subtitle_asset.h b/src/reel_smpte_subtitle_asset.h
index aee63c74..b34e3eb3 100644
--- a/src/reel_smpte_subtitle_asset.h
+++ b/src/reel_smpte_subtitle_asset.h
@@ -68,6 +68,8 @@ private:
boost::optional<std::string> key_type () const override {
return std::string("MDSK");
}
+
+ std::string cpl_node_name (Standard standard) const override;
};
diff --git a/src/reel_subtitle_asset.cc b/src/reel_subtitle_asset.cc
index b4bddfac..a90ed74c 100644
--- a/src/reel_subtitle_asset.cc
+++ b/src/reel_subtitle_asset.cc
@@ -76,13 +76,6 @@ ReelSubtitleAsset::ReelSubtitleAsset (std::shared_ptr<const cxml::Node> node)
}
-string
-ReelSubtitleAsset::cpl_node_name (Standard) const
-{
- return "MainSubtitle";
-}
-
-
void
ReelSubtitleAsset::set_language (dcp::LanguageTag language)
{
diff --git a/src/reel_subtitle_asset.h b/src/reel_subtitle_asset.h
index e56e8581..a072f0e9 100644
--- a/src/reel_subtitle_asset.h
+++ b/src/reel_subtitle_asset.h
@@ -98,8 +98,6 @@ protected:
private:
friend struct ::verify_invalid_language1;
-
- std::string cpl_node_name (Standard standard) const override;
};