summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cpl.cc1
-rw-r--r--src/reel.cc17
-rw-r--r--src/reel.h4
-rw-r--r--src/reel_closed_caption_asset.cc90
-rw-r--r--src/reel_closed_caption_asset.h97
-rw-r--r--src/reel_interop_closed_caption_asset.cc86
-rw-r--r--src/reel_interop_text_asset.cc49
-rw-r--r--src/reel_interop_text_asset.h8
-rw-r--r--src/reel_smpte_closed_caption_asset.cc91
-rw-r--r--src/reel_smpte_closed_caption_asset.h83
-rw-r--r--src/reel_smpte_text_asset.cc50
-rw-r--r--src/reel_smpte_text_asset.h8
-rw-r--r--src/reel_text_asset.cc30
-rw-r--r--src/reel_text_asset.h19
-rw-r--r--src/text_type.h (renamed from src/reel_interop_closed_caption_asset.h)42
-rw-r--r--src/verify.cc3
-rw-r--r--src/wscript7
17 files changed, 147 insertions, 538 deletions
diff --git a/src/cpl.cc b/src/cpl.cc
index c41a86eb..79aedc4c 100644
--- a/src/cpl.cc
+++ b/src/cpl.cc
@@ -48,7 +48,6 @@
#include "raw_convert.h"
#include "reel.h"
#include "reel_atmos_asset.h"
-#include "reel_closed_caption_asset.h"
#include "reel_picture_asset.h"
#include "reel_sound_asset.h"
#include "reel_text_asset.h"
diff --git a/src/reel.cc b/src/reel.cc
index 6a7043f0..3eb81e1d 100644
--- a/src/reel.cc
+++ b/src/reel.cc
@@ -45,12 +45,9 @@
#include "j2k_picture_asset.h"
#include "reel.h"
#include "reel_atmos_asset.h"
-#include "reel_closed_caption_asset.h"
-#include "reel_interop_closed_caption_asset.h"
#include "reel_interop_text_asset.h"
#include "reel_markers_asset.h"
#include "reel_mono_picture_asset.h"
-#include "reel_smpte_closed_caption_asset.h"
#include "reel_smpte_text_asset.h"
#include "reel_sound_asset.h"
#include "reel_stereo_picture_asset.h"
@@ -120,10 +117,10 @@ Reel::Reel (std::shared_ptr<const cxml::Node> node, dcp::Standard standard)
for (auto i: closed_captions) {
switch (standard) {
case Standard::INTEROP:
- _closed_captions.push_back (make_shared<ReelInteropClosedCaptionAsset>(i));
+ _closed_captions.push_back (make_shared<ReelInteropTextAsset>(i));
break;
case Standard::SMPTE:
- _closed_captions.push_back (make_shared<ReelSMPTEClosedCaptionAsset>(i));
+ _closed_captions.push_back (make_shared<ReelSMPTETextAsset>(i));
break;
}
}
@@ -358,12 +355,14 @@ Reel::add (shared_ptr<ReelAsset> asset)
_main_picture = p;
} else if (auto so = dynamic_pointer_cast<ReelSoundAsset>(asset)) {
_main_sound = so;
- } else if (auto su = dynamic_pointer_cast<ReelTextAsset>(asset)) {
- _main_subtitle = su;
+ } else if (auto te = dynamic_pointer_cast<ReelTextAsset>(asset)) {
+ if (te->type() == TextType::SUBTITLE) {
+ _main_subtitle = te;
+ } else {
+ _closed_captions.push_back(te);
+ }
} else if (auto m = dynamic_pointer_cast<ReelMarkersAsset>(asset)) {
_main_markers = m;
- } else if (auto c = dynamic_pointer_cast<ReelClosedCaptionAsset>(asset)) {
- _closed_captions.push_back (c);
} else if (auto a = dynamic_pointer_cast<ReelAtmosAsset>(asset)) {
_atmos = a;
} else {
diff --git a/src/reel.h b/src/reel.h
index 7c9ba0d4..28e574ea 100644
--- a/src/reel.h
+++ b/src/reel.h
@@ -113,7 +113,7 @@ public:
return _main_markers;
}
- std::vector<std::shared_ptr<ReelClosedCaptionAsset>> closed_captions () const {
+ std::vector<std::shared_ptr<ReelTextAsset>> closed_captions () const {
return _closed_captions;
}
@@ -147,7 +147,7 @@ private:
std::shared_ptr<ReelSoundAsset> _main_sound;
std::shared_ptr<ReelTextAsset> _main_subtitle;
std::shared_ptr<ReelMarkersAsset> _main_markers;
- std::vector<std::shared_ptr<ReelClosedCaptionAsset>> _closed_captions;
+ std::vector<std::shared_ptr<ReelTextAsset>> _closed_captions;
std::shared_ptr<ReelAtmosAsset> _atmos;
std::vector<dcp::DecryptedKDM> _kdms;
diff --git a/src/reel_closed_caption_asset.cc b/src/reel_closed_caption_asset.cc
deleted file mode 100644
index e5649d6a..00000000
--- a/src/reel_closed_caption_asset.cc
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
-
- This file is part of libdcp.
-
- libdcp is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- libdcp is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with libdcp. If not, see <http://www.gnu.org/licenses/>.
-
- In addition, as a special exception, the copyright holders give
- permission to link the code of portions of this program with the
- OpenSSL library under certain conditions as described in each
- individual source file, and distribute linked combinations
- including the two.
-
- You must obey the GNU General Public License in all respects
- for all of the code used other than OpenSSL. If you modify
- file(s) with this exception, you may extend this exception to your
- version of the file(s), but you are not obligated to do so. If you
- do not wish to do so, delete this exception statement from your
- version. If you delete this exception statement from all source
- files in the program, then also delete it here.
-*/
-
-
-/** @file src/reel_closed_caption_asset.cc
- * @brief ReelClosedCaptionAsset class
- */
-
-
-#include "dcp_assert.h"
-#include "reel_closed_caption_asset.h"
-#include "smpte_subtitle_asset.h"
-#include "subtitle_asset.h"
-#include "warnings.h"
-LIBDCP_DISABLE_WARNINGS
-#include <libxml++/libxml++.h>
-LIBDCP_ENABLE_WARNINGS
-
-
-using std::string;
-using std::shared_ptr;
-using std::dynamic_pointer_cast;
-using namespace dcp;
-
-
-ReelClosedCaptionAsset::ReelClosedCaptionAsset (std::shared_ptr<SubtitleAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point)
- : ReelFileAsset (
- asset,
- dynamic_pointer_cast<SMPTESubtitleAsset>(asset) ? dynamic_pointer_cast<SMPTESubtitleAsset>(asset)->key_id() : boost::none,
- asset->id(),
- edit_rate,
- intrinsic_duration,
- entry_point
- )
-{
-
-}
-
-
-ReelClosedCaptionAsset::ReelClosedCaptionAsset (std::shared_ptr<const cxml::Node> node)
- : ReelFileAsset (node)
-{
- _language = node->optional_string_child ("Language");
-}
-
-
-bool
-ReelClosedCaptionAsset::equals(shared_ptr<const ReelClosedCaptionAsset> other, EqualityOptions const& opt, NoteHandler note) const
-{
- if (!asset_equals (other, opt, note)) {
- return false;
- }
- if (!file_asset_equals (other, opt, note)) {
- return false;
- }
-
- return true;
-}
-
-
diff --git a/src/reel_closed_caption_asset.h b/src/reel_closed_caption_asset.h
deleted file mode 100644
index 405de34b..00000000
--- a/src/reel_closed_caption_asset.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
-
- This file is part of libdcp.
-
- libdcp is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- libdcp is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with libdcp. If not, see <http://www.gnu.org/licenses/>.
-
- In addition, as a special exception, the copyright holders give
- permission to link the code of portions of this program with the
- OpenSSL library under certain conditions as described in each
- individual source file, and distribute linked combinations
- including the two.
-
- You must obey the GNU General Public License in all respects
- for all of the code used other than OpenSSL. If you modify
- file(s) with this exception, you may extend this exception to your
- version of the file(s), but you are not obligated to do so. If you
- do not wish to do so, delete this exception statement from your
- version. If you delete this exception statement from all source
- files in the program, then also delete it here.
-*/
-
-
-/** @file src/reel_closed_caption_asset.h
- * @brief ReelClosedCaptionAsset class
- */
-
-
-#ifndef LIBDCP_REEL_CLOSED_CAPTION_ASSET_H
-#define LIBDCP_REEL_CLOSED_CAPTION_ASSET_H
-
-
-#include "language_tag.h"
-#include "reel_asset.h"
-#include "reel_file_asset.h"
-#include "subtitle_asset.h"
-
-
-struct verify_invalid_language2;
-
-
-namespace dcp {
-
-
-/** @class ReelClosedCaptionAsset
- * @brief Part of a Reel's description which refers to a closed caption XML/MXF file
- */
-class ReelClosedCaptionAsset : public ReelFileAsset
-{
-public:
- ReelClosedCaptionAsset (std::shared_ptr<SubtitleAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point);
- explicit ReelClosedCaptionAsset (std::shared_ptr<const cxml::Node>);
-
- std::shared_ptr<const SubtitleAsset> asset () const {
- return asset_of_type<const SubtitleAsset>();
- }
-
- std::shared_ptr<SubtitleAsset> asset () {
- return asset_of_type<SubtitleAsset>();
- }
-
- bool equals(std::shared_ptr<const ReelClosedCaptionAsset>, EqualityOptions const&, NoteHandler) const;
-
- void set_language (dcp::LanguageTag l) {
- _language = l.to_string();
- }
-
- void unset_language () {
- _language = boost::optional<std::string> ();
- }
-
- boost::optional<std::string> language () const {
- return _language;
- }
-
-protected:
- friend struct ::verify_invalid_language2;
-
- boost::optional<std::string> _language;
-};
-
-
-}
-
-
-#endif
diff --git a/src/reel_interop_closed_caption_asset.cc b/src/reel_interop_closed_caption_asset.cc
deleted file mode 100644
index c4539fd7..00000000
--- a/src/reel_interop_closed_caption_asset.cc
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- Copyright (C) 2021 Carl Hetherington <cth@carlh.net>
-
- This file is part of libdcp.
-
- libdcp is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- libdcp is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with libdcp. If not, see <http://www.gnu.org/licenses/>.
-
- In addition, as a special exception, the copyright holders give
- permission to link the code of portions of this program with the
- OpenSSL library under certain conditions as described in each
- individual source file, and distribute linked combinations
- including the two.
-
- You must obey the GNU General Public License in all respects
- for all of the code used other than OpenSSL. If you modify
- file(s) with this exception, you may extend this exception to your
- version of the file(s), but you are not obligated to do so. If you
- do not wish to do so, delete this exception statement from your
- version. If you delete this exception statement from all source
- files in the program, then also delete it here.
-*/
-
-
-#include "reel_interop_closed_caption_asset.h"
-#include "warnings.h"
-LIBDCP_DISABLE_WARNINGS
-#include <libxml++/libxml++.h>
-LIBDCP_ENABLE_WARNINGS
-
-
-using std::make_pair;
-using std::pair;
-using std::shared_ptr;
-using std::string;
-using namespace dcp;
-
-
-ReelInteropClosedCaptionAsset::ReelInteropClosedCaptionAsset (shared_ptr<InteropSubtitleAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point)
- : ReelClosedCaptionAsset (asset, edit_rate, intrinsic_duration, entry_point)
-{
-
-}
-
-
-
-ReelInteropClosedCaptionAsset::ReelInteropClosedCaptionAsset (shared_ptr<const cxml::Node> node)
- : ReelClosedCaptionAsset (node)
-{
- node->done ();
-}
-
-
-string
-ReelInteropClosedCaptionAsset::cpl_node_name (Standard) const
-{
- return "cc-cpl:MainClosedCaption";
-}
-
-
-pair<string, string>
-ReelInteropClosedCaptionAsset::cpl_node_namespace () const
-{
- return make_pair("http://www.digicine.com/PROTO-ASDCP-CC-CPL-20070926#", "cc-cpl");
-}
-
-
-xmlpp::Element*
-ReelInteropClosedCaptionAsset::write_to_cpl(xmlpp::Element* node, Standard standard) const
-{
- auto asset = ReelClosedCaptionAsset::write_to_cpl (node, standard);
- if (_language) {
- cxml::add_text_child(asset, "Language", *_language);
- }
- return asset;
-}
diff --git a/src/reel_interop_text_asset.cc b/src/reel_interop_text_asset.cc
index 4bd030aa..b5e20f78 100644
--- a/src/reel_interop_text_asset.cc
+++ b/src/reel_interop_text_asset.cc
@@ -37,6 +37,7 @@
*/
+#include "dcp_assert.h"
#include "reel_interop_text_asset.h"
#include "warnings.h"
LIBDCP_DISABLE_WARNINGS
@@ -44,13 +45,15 @@ LIBDCP_DISABLE_WARNINGS
LIBDCP_ENABLE_WARNINGS
+using std::make_pair;
+using std::pair;
using std::string;
using boost::optional;
using namespace dcp;
-ReelInteropTextAsset::ReelInteropTextAsset(std::shared_ptr<SubtitleAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point)
- : ReelTextAsset(asset, edit_rate, intrinsic_duration, entry_point)
+ReelInteropTextAsset::ReelInteropTextAsset(TextType type, std::shared_ptr<SubtitleAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point)
+ : ReelTextAsset(type, asset, edit_rate, intrinsic_duration, entry_point)
{
}
@@ -62,3 +65,45 @@ ReelInteropTextAsset::ReelInteropTextAsset(std::shared_ptr<const cxml::Node> nod
node->done ();
}
+
+string
+ReelInteropTextAsset::cpl_node_name(Standard) const
+{
+ switch (_type) {
+ case TextType::SUBTITLE:
+ return "MainSubtitle";
+ case TextType::CAPTION:
+ return "cc-cpl:MainClosedCaption";
+ }
+
+ DCP_ASSERT(false);
+ return "";
+}
+
+
+pair<string, string>
+ReelInteropTextAsset::cpl_node_namespace() const
+{
+ switch (_type) {
+ case TextType::SUBTITLE:
+ return {};
+ case TextType::CAPTION:
+ return make_pair("http://www.digicine.com/PROTO-ASDCP-CC-CPL-20070926#", "cc-cpl");
+ }
+
+ DCP_ASSERT(false);
+ return {};
+}
+
+
+xmlpp::Element *
+ReelInteropTextAsset::write_to_cpl(xmlpp::Element* node, Standard standard) const
+{
+ auto asset = ReelFileAsset::write_to_cpl (node, standard);
+ if (_language) {
+ cxml::add_text_child(asset, "Language", *_language);
+ }
+ return asset;
+}
+
+
diff --git a/src/reel_interop_text_asset.h b/src/reel_interop_text_asset.h
index cedc2ae5..88cdeaae 100644
--- a/src/reel_interop_text_asset.h
+++ b/src/reel_interop_text_asset.h
@@ -50,7 +50,7 @@ namespace dcp {
class ReelInteropTextAsset : public ReelTextAsset
{
public:
- ReelInteropTextAsset(std::shared_ptr<SubtitleAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point);
+ ReelInteropTextAsset(TextType type, std::shared_ptr<SubtitleAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point);
explicit ReelInteropTextAsset (std::shared_ptr<const cxml::Node>);
std::shared_ptr<const InteropSubtitleAsset> interop_asset () const {
@@ -60,6 +60,12 @@ public:
std::shared_ptr<InteropSubtitleAsset> interop_asset () {
return asset_of_type<InteropSubtitleAsset>();
}
+
+ xmlpp::Element* write_to_cpl(xmlpp::Element* node, Standard standard) const override;
+
+protected:
+ std::string cpl_node_name (Standard standard) const override;
+ std::pair<std::string, std::string> cpl_node_namespace() const override;
};
diff --git a/src/reel_smpte_closed_caption_asset.cc b/src/reel_smpte_closed_caption_asset.cc
deleted file mode 100644
index 70e5eb36..00000000
--- a/src/reel_smpte_closed_caption_asset.cc
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- Copyright (C) 2021 Carl Hetherington <cth@carlh.net>
-
- This file is part of libdcp.
-
- libdcp is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- libdcp is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with libdcp. If not, see <http://www.gnu.org/licenses/>.
-
- In addition, as a special exception, the copyright holders give
- permission to link the code of portions of this program with the
- OpenSSL library under certain conditions as described in each
- individual source file, and distribute linked combinations
- including the two.
-
- You must obey the GNU General Public License in all respects
- for all of the code used other than OpenSSL. If you modify
- file(s) with this exception, you may extend this exception to your
- version of the file(s), but you are not obligated to do so. If you
- do not wish to do so, delete this exception statement from your
- version. If you delete this exception statement from all source
- files in the program, then also delete it here.
-*/
-
-
-/** @file src/reel_smpte_closed_caption_asset.cc
- * @brief ReelSMPTEClosedCaptionAsset class
- */
-
-
-#include "reel_smpte_closed_caption_asset.h"
-#include "warnings.h"
-LIBDCP_DISABLE_WARNINGS
-#include <libxml++/libxml++.h>
-LIBDCP_ENABLE_WARNINGS
-
-
-using std::make_pair;
-using std::pair;
-using std::shared_ptr;
-using std::string;
-using namespace dcp;
-
-
-ReelSMPTEClosedCaptionAsset::ReelSMPTEClosedCaptionAsset (shared_ptr<SMPTESubtitleAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point)
- : ReelClosedCaptionAsset (asset, edit_rate, intrinsic_duration, entry_point)
-{
-
-}
-
-
-ReelSMPTEClosedCaptionAsset::ReelSMPTEClosedCaptionAsset (shared_ptr<const cxml::Node> node)
- : ReelClosedCaptionAsset (node)
-{
- node->done ();
-}
-
-
-xmlpp::Element*
-ReelSMPTEClosedCaptionAsset::write_to_cpl(xmlpp::Element* node, Standard standard) const
-{
- auto asset = ReelClosedCaptionAsset::write_to_cpl (node, standard);
- if (_language) {
- cxml::add_child(asset, "Language", string("tt"))->add_child_text(*_language);
- }
- return asset;
-}
-
-
-string
-ReelSMPTEClosedCaptionAsset::cpl_node_name (Standard) const
-{
- return "tt:ClosedCaption";
-}
-
-
-pair<string, string>
-ReelSMPTEClosedCaptionAsset::cpl_node_namespace () const
-{
- return make_pair("http://www.smpte-ra.org/schemas/429-12/2008/TT", "tt");
-}
-
diff --git a/src/reel_smpte_closed_caption_asset.h b/src/reel_smpte_closed_caption_asset.h
deleted file mode 100644
index e7a26f65..00000000
--- a/src/reel_smpte_closed_caption_asset.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- Copyright (C) 2021 Carl Hetherington <cth@carlh.net>
-
- This file is part of libdcp.
-
- libdcp is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- libdcp is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with libdcp. If not, see <http://www.gnu.org/licenses/>.
-
- In addition, as a special exception, the copyright holders give
- permission to link the code of portions of this program with the
- OpenSSL library under certain conditions as described in each
- individual source file, and distribute linked combinations
- including the two.
-
- You must obey the GNU General Public License in all respects
- for all of the code used other than OpenSSL. If you modify
- file(s) with this exception, you may extend this exception to your
- version of the file(s), but you are not obligated to do so. If you
- do not wish to do so, delete this exception statement from your
- version. If you delete this exception statement from all source
- files in the program, then also delete it here.
-*/
-
-
-/** @file src/reel_smpte_closed_caption_asset.h
- * @brief ReelSMPTEClosedCaptionAsset class
- */
-
-
-#ifndef LIBDCP_REEL_SMPTE_CLOSED_CAPTION_ASSET_H
-#define LIBDCP_REEL_SMPTE_CLOSED_CAPTION_ASSET_H
-
-
-#include "reel_file_asset.h"
-#include "reel_closed_caption_asset.h"
-#include "smpte_subtitle_asset.h"
-
-
-namespace dcp {
-
-
-class ReelSMPTEClosedCaptionAsset : public ReelClosedCaptionAsset
-{
-public:
- ReelSMPTEClosedCaptionAsset (std::shared_ptr<SMPTESubtitleAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point);
- explicit ReelSMPTEClosedCaptionAsset (std::shared_ptr<const cxml::Node>);
-
- std::shared_ptr<SMPTESubtitleAsset> smpte_asset () {
- return asset_of_type<SMPTESubtitleAsset>();
- }
-
- std::shared_ptr<const SMPTESubtitleAsset> smpte_asset () const {
- return asset_of_type<const SMPTESubtitleAsset>();
- }
-
- xmlpp::Element* write_to_cpl(xmlpp::Element* node, Standard standard) const override;
-
-
-private:
- boost::optional<std::string> key_type () const override {
- return std::string("MDSK");
- }
-
- std::string cpl_node_name (Standard) const override;
- std::pair<std::string, std::string> cpl_node_namespace () const override;
-};
-
-
-};
-
-
-#endif
-
diff --git a/src/reel_smpte_text_asset.cc b/src/reel_smpte_text_asset.cc
index bbfa1b39..68f85586 100644
--- a/src/reel_smpte_text_asset.cc
+++ b/src/reel_smpte_text_asset.cc
@@ -45,14 +45,16 @@ LIBDCP_DISABLE_WARNINGS
LIBDCP_ENABLE_WARNINGS
+using std::make_pair;
+using std::pair;
using std::shared_ptr;
using std::string;
using boost::optional;
using namespace dcp;
-ReelSMPTETextAsset::ReelSMPTETextAsset(shared_ptr<SMPTESubtitleAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point)
- : ReelTextAsset(asset, edit_rate, intrinsic_duration, entry_point)
+ReelSMPTETextAsset::ReelSMPTETextAsset(TextType type, shared_ptr<SMPTESubtitleAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point)
+ : ReelTextAsset(type, asset, edit_rate, intrinsic_duration, entry_point)
{
}
@@ -64,3 +66,47 @@ ReelSMPTETextAsset::ReelSMPTETextAsset(shared_ptr<const cxml::Node> node)
node->done ();
}
+
+
+string
+ReelSMPTETextAsset::cpl_node_name(Standard) const
+{
+ switch (_type) {
+ case TextType::SUBTITLE:
+ return "MainSubtitle";
+ case TextType::CAPTION:
+ return "tt:ClosedCaption";
+ }
+
+ DCP_ASSERT(false);
+ return "";
+}
+
+
+pair<string, string>
+ReelSMPTETextAsset::cpl_node_namespace() const
+{
+ switch (_type) {
+ case TextType::SUBTITLE:
+ return {};
+ case TextType::CAPTION:
+ return make_pair("http://www.smpte-ra.org/schemas/429-12/2008/TT", "tt");
+ }
+
+ DCP_ASSERT(false);
+ return {};
+}
+
+
+xmlpp::Element *
+ReelSMPTETextAsset::write_to_cpl(xmlpp::Element* node, Standard standard) const
+{
+ auto asset = ReelFileAsset::write_to_cpl (node, standard);
+ string const ns = _type == TextType::CAPTION ? "tt" : "";
+ if (_language) {
+ cxml::add_child(asset, "Language", ns)->add_child_text(*_language);
+ }
+ return asset;
+}
+
+
diff --git a/src/reel_smpte_text_asset.h b/src/reel_smpte_text_asset.h
index 6eb3260d..24344a3a 100644
--- a/src/reel_smpte_text_asset.h
+++ b/src/reel_smpte_text_asset.h
@@ -53,7 +53,7 @@ class SMPTESubtitleAsset;
class ReelSMPTETextAsset : public ReelTextAsset
{
public:
- ReelSMPTETextAsset(std::shared_ptr<SMPTESubtitleAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point);
+ ReelSMPTETextAsset(TextType type, std::shared_ptr<SMPTESubtitleAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point);
explicit ReelSMPTETextAsset(std::shared_ptr<const cxml::Node>);
std::shared_ptr<const SMPTESubtitleAsset> smpte_asset () const {
@@ -64,6 +64,12 @@ public:
return asset_of_type<SMPTESubtitleAsset>();
}
+ xmlpp::Element* write_to_cpl(xmlpp::Element* node, Standard standard) const override;
+
+protected:
+ std::string cpl_node_name (Standard standard) const override;
+ std::pair<std::string, std::string> cpl_node_namespace() const override;
+
private:
boost::optional<std::string> key_type () const override {
return std::string("MDSK");
diff --git a/src/reel_text_asset.cc b/src/reel_text_asset.cc
index 1802ad51..87a8ae58 100644
--- a/src/reel_text_asset.cc
+++ b/src/reel_text_asset.cc
@@ -54,7 +54,7 @@ using boost::optional;
using namespace dcp;
-ReelTextAsset::ReelTextAsset(std::shared_ptr<SubtitleAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point)
+ReelTextAsset::ReelTextAsset(TextType type, std::shared_ptr<SubtitleAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point)
: ReelFileAsset (
asset,
dynamic_pointer_cast<SMPTESubtitleAsset>(asset) ? dynamic_pointer_cast<SMPTESubtitleAsset>(asset)->key_id() : boost::none,
@@ -63,6 +63,7 @@ ReelTextAsset::ReelTextAsset(std::shared_ptr<SubtitleAsset> asset, Fraction edit
intrinsic_duration,
entry_point
)
+ , _type(type)
{
}
@@ -71,14 +72,15 @@ ReelTextAsset::ReelTextAsset(std::shared_ptr<SubtitleAsset> asset, Fraction edit
ReelTextAsset::ReelTextAsset(std::shared_ptr<const cxml::Node> node)
: ReelFileAsset (node)
{
- _language = node->optional_string_child("Language");
-}
-
+ if (node->name() == "MainSubtitle") {
+ _type = TextType::SUBTITLE;
+ } else if (node->name() == "MainClosedCaption" || node->name() == "ClosedCaption") {
+ _type = TextType::CAPTION;
+ } else {
+ DCP_ASSERT(false);
+ }
-string
-ReelTextAsset::cpl_node_name(Standard) const
-{
- return "MainSubtitle";
+ _language = node->optional_string_child("Language");
}
@@ -102,15 +104,3 @@ ReelTextAsset::equals(shared_ptr<const ReelTextAsset> other, EqualityOptions con
return true;
}
-
-xmlpp::Element *
-ReelTextAsset::write_to_cpl(xmlpp::Element* node, Standard standard) const
-{
- auto asset = ReelFileAsset::write_to_cpl (node, standard);
- if (_language) {
- cxml::add_text_child(asset, "Language", *_language);
- }
- return asset;
-}
-
-
diff --git a/src/reel_text_asset.h b/src/reel_text_asset.h
index 63962155..cf904921 100644
--- a/src/reel_text_asset.h
+++ b/src/reel_text_asset.h
@@ -45,9 +45,11 @@
#include "reel_asset.h"
#include "reel_file_asset.h"
#include "subtitle_asset.h"
+#include "text_type.h"
struct verify_invalid_language1;
+struct verify_invalid_language2;
namespace dcp {
@@ -62,7 +64,7 @@ class SubtitleAsset;
class ReelTextAsset : public ReelFileAsset
{
public:
- ReelTextAsset(std::shared_ptr<SubtitleAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point);
+ ReelTextAsset(TextType type, std::shared_ptr<SubtitleAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point);
explicit ReelTextAsset(std::shared_ptr<const cxml::Node>);
std::shared_ptr<const SubtitleAsset> asset () const {
@@ -73,8 +75,6 @@ public:
return asset_of_type<SubtitleAsset>();
}
- xmlpp::Element* write_to_cpl(xmlpp::Element* node, Standard standard) const override;
-
bool equals(std::shared_ptr<const ReelTextAsset>, EqualityOptions const&, NoteHandler) const;
void set_language (dcp::LanguageTag language);
@@ -83,17 +83,20 @@ public:
return _language;
}
+ TextType type() const {
+ return _type;
+ }
+
protected:
+ friend struct ::verify_invalid_language1;
+ friend struct ::verify_invalid_language2;
+
/** As in other places, this is stored and returned as a string so that
* we can tolerate non-RFC-5646 strings, but must be set as a dcp::LanguageTag
* to try to ensure that we create compliant output.
*/
boost::optional<std::string> _language;
-
-private:
- friend struct ::verify_invalid_language1;
-
- std::string cpl_node_name (Standard standard) const override;
+ TextType _type;
};
diff --git a/src/reel_interop_closed_caption_asset.h b/src/text_type.h
index 5a074357..daac36c8 100644
--- a/src/reel_interop_closed_caption_asset.h
+++ b/src/text_type.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2021 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2024 Carl Hetherington <cth@carlh.net>
This file is part of libdcp.
@@ -32,46 +32,14 @@
*/
-/** @file src/reel_interop_closed_caption_asset.h
- * @brief ReelInteropClosedCaptionAsset class
- */
-
-
-#ifndef LIBDCP_REEL_INTEROP_CLOSED_CAPTION_ASSET_H
-#define LIBDCP_REEL_INTEROP_CLOSED_CAPTION_ASSET_H
-
-
-#include "interop_subtitle_asset.h"
-#include "reel_closed_caption_asset.h"
-
-
namespace dcp {
-class ReelInteropClosedCaptionAsset : public ReelClosedCaptionAsset
+enum class TextType
{
-public:
- ReelInteropClosedCaptionAsset (std::shared_ptr<InteropSubtitleAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point);
- explicit ReelInteropClosedCaptionAsset (std::shared_ptr<const cxml::Node>);
-
- std::shared_ptr<const InteropSubtitleAsset> interop_asset () const {
- return asset_of_type<const InteropSubtitleAsset>();
- }
-
- std::shared_ptr<InteropSubtitleAsset> interop_asset () {
- return asset_of_type<InteropSubtitleAsset>();
- }
-
- xmlpp::Element* write_to_cpl(xmlpp::Element* node, Standard standard) const override;
-
-private:
- std::string cpl_node_name (Standard) const override;
- std::pair<std::string, std::string> cpl_node_namespace () const override;
+ SUBTITLE,
+ CAPTION
};
-};
-
-
-#endif
-
+}
diff --git a/src/verify.cc b/src/verify.cc
index 067ebfd2..b921375c 100644
--- a/src/verify.cc
+++ b/src/verify.cc
@@ -47,7 +47,6 @@
#include "mono_j2k_picture_frame.h"
#include "raw_convert.h"
#include "reel.h"
-#include "reel_closed_caption_asset.h"
#include "reel_interop_text_asset.h"
#include "reel_markers_asset.h"
#include "reel_picture_asset.h"
@@ -738,7 +737,7 @@ verify_main_subtitle_reel(Context& context, shared_ptr<const ReelTextAsset> reel
static void
-verify_closed_caption_reel(Context& context, shared_ptr<const ReelClosedCaptionAsset> reel_asset)
+verify_closed_caption_reel(Context& context, shared_ptr<const ReelTextAsset> reel_asset)
{
/* XXX: is Language compulsory? */
if (reel_asset->language()) {
diff --git a/src/wscript b/src/wscript
index f7bced72..2320fe0d 100644
--- a/src/wscript
+++ b/src/wscript
@@ -95,14 +95,11 @@ def build(bld):
reel.cc
reel_asset.cc
reel_atmos_asset.cc
- reel_closed_caption_asset.cc
reel_file_asset.cc
- reel_interop_closed_caption_asset.cc
reel_interop_text_asset.cc
reel_markers_asset.cc
reel_mono_picture_asset.cc
reel_picture_asset.cc
- reel_smpte_closed_caption_asset.cc
reel_smpte_text_asset.cc
reel_sound_asset.cc
reel_stereo_picture_asset.cc
@@ -212,14 +209,11 @@ def build(bld):
reel.h
reel_asset.h
reel_atmos_asset.h
- reel_closed_caption_asset.h
reel_file_asset.h
- reel_interop_closed_caption_asset.h
reel_interop_text_asset.h
reel_markers_asset.h
reel_mono_picture_asset.h
reel_picture_asset.h
- reel_smpte_closed_caption_asset.h
reel_smpte_text_asset.h
reel_sound_asset.h
reel_stereo_picture_asset.h
@@ -245,6 +239,7 @@ def build(bld):
subtitle_image.h
subtitle_standard.h
subtitle_string.h
+ text_type.h
transfer_function.h
types.h
utc_offset.h