diff options
| author | Carl Hetherington <cth@carlh.net> | 2023-12-04 23:14:40 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2023-12-05 00:49:33 +0100 |
| commit | e3033879f7693d40f652f013b00c76deed6994da (patch) | |
| tree | 16c6a62810d61306e15b0e81e8f4ef92015d0473 /src | |
| parent | 6973568117ed23c300f5ffa538f7eae87a9a9927 (diff) | |
Rename everything.
Diffstat (limited to 'src')
| -rw-r--r-- | src/asset_factory.cc | 4 | ||||
| -rw-r--r-- | src/combine.cc | 4 | ||||
| -rw-r--r-- | src/dcp.cc | 12 | ||||
| -rw-r--r-- | src/interop_text_asset.cc (renamed from src/interop_subtitle_asset.cc) | 58 | ||||
| -rw-r--r-- | src/interop_text_asset.h (renamed from src/interop_subtitle_asset.h) | 38 | ||||
| -rw-r--r-- | src/reel.cc | 10 | ||||
| -rw-r--r-- | src/reel_closed_caption_asset.cc | 8 | ||||
| -rw-r--r-- | src/reel_closed_caption_asset.h | 12 | ||||
| -rw-r--r-- | src/reel_interop_closed_caption_asset.cc | 3 | ||||
| -rw-r--r-- | src/reel_interop_closed_caption_asset.h | 12 | ||||
| -rw-r--r-- | src/reel_interop_subtitle_asset.cc | 2 | ||||
| -rw-r--r-- | src/reel_interop_subtitle_asset.h | 16 | ||||
| -rw-r--r-- | src/reel_smpte_closed_caption_asset.cc | 2 | ||||
| -rw-r--r-- | src/reel_smpte_closed_caption_asset.h | 12 | ||||
| -rw-r--r-- | src/reel_smpte_subtitle_asset.cc | 4 | ||||
| -rw-r--r-- | src/reel_smpte_subtitle_asset.h | 14 | ||||
| -rw-r--r-- | src/reel_subtitle_asset.cc | 8 | ||||
| -rw-r--r-- | src/reel_subtitle_asset.h | 14 | ||||
| -rw-r--r-- | src/smpte_text_asset.cc (renamed from src/smpte_subtitle_asset.cc) | 100 | ||||
| -rw-r--r-- | src/smpte_text_asset.h (renamed from src/smpte_subtitle_asset.h) | 38 | ||||
| -rw-r--r-- | src/subtitle_image.cc | 8 | ||||
| -rw-r--r-- | src/subtitle_image.h | 6 | ||||
| -rw-r--r-- | src/text.cc (renamed from src/subtitle.cc) | 10 | ||||
| -rw-r--r-- | src/text.h (renamed from src/subtitle.h) | 20 | ||||
| -rw-r--r-- | src/text_asset.cc (renamed from src/subtitle_asset.cc) | 130 | ||||
| -rw-r--r-- | src/text_asset.h (renamed from src/subtitle_asset.h) | 48 | ||||
| -rw-r--r-- | src/text_asset_internal.cc (renamed from src/subtitle_asset_internal.cc) | 12 | ||||
| -rw-r--r-- | src/text_asset_internal.h (renamed from src/subtitle_asset_internal.h) | 12 | ||||
| -rw-r--r-- | src/text_standard.cc (renamed from src/subtitle_standard.cc) | 10 | ||||
| -rw-r--r-- | src/text_standard.h (renamed from src/subtitle_standard.h) | 10 | ||||
| -rw-r--r-- | src/text_string.cc (renamed from src/subtitle_string.cc) | 20 | ||||
| -rw-r--r-- | src/text_string.h (renamed from src/subtitle_string.h) | 26 | ||||
| -rw-r--r-- | src/verify.cc | 38 | ||||
| -rw-r--r-- | src/wscript | 30 |
34 files changed, 369 insertions, 382 deletions
diff --git a/src/asset_factory.cc b/src/asset_factory.cc index d326ba68..4884f090 100644 --- a/src/asset_factory.cc +++ b/src/asset_factory.cc @@ -41,7 +41,7 @@ #include "atmos_asset.h" #include "compose.hpp" #include "mono_picture_asset.h" -#include "smpte_subtitle_asset.h" +#include "smpte_text_asset.h" #include "sound_asset.h" #include "stereo_picture_asset.h" #include "stereo_picture_asset.h" @@ -90,7 +90,7 @@ dcp::asset_factory (boost::filesystem::path path, bool ignore_incorrect_picture_ case ASDCP::ESS_JPEG_2000_S: return make_shared<StereoPictureAsset>(path); case ASDCP::ESS_TIMED_TEXT: - return make_shared<SMPTESubtitleAsset>(path); + return make_shared<SMPTETextAsset>(path); case ASDCP::ESS_DCDATA_DOLBY_ATMOS: return make_shared<AtmosAsset>(path); default: diff --git a/src/combine.cc b/src/combine.cc index b7a625f0..74456bfb 100644 --- a/src/combine.cc +++ b/src/combine.cc @@ -45,7 +45,7 @@ #include "exceptions.h" #include "filesystem.h" #include "font_asset.h" -#include "interop_subtitle_asset.h" +#include "interop_text_asset.h" #include "raw_convert.h" #include <boost/filesystem.hpp> #include <set> @@ -139,7 +139,7 @@ dcp::combine ( continue; } - auto sub = dynamic_pointer_cast<dcp::InteropSubtitleAsset>(j); + auto sub = dynamic_pointer_cast<dcp::InteropTextAsset>(j); if (sub) { /* Interop fonts are really fiddly. The font files are assets (in the ASSETMAP) * and also linked from the font XML by filename. We have to fix both these things, @@ -49,7 +49,7 @@ #include "exceptions.h" #include "filesystem.h" #include "font_asset.h" -#include "interop_subtitle_asset.h" +#include "interop_text_asset.h" #include "metadata.h" #include "mono_picture_asset.h" #include "picture_asset.h" @@ -57,7 +57,7 @@ #include "raw_convert.h" #include "reel_asset.h" #include "reel_subtitle_asset.h" -#include "smpte_subtitle_asset.h" +#include "smpte_text_asset.h" #include "sound_asset.h" #include "stereo_picture_asset.h" #include "util.h" @@ -221,7 +221,7 @@ DCP::read (vector<dcp::VerificationNote>* notes, bool ignore_incorrect_picture_m if ( pkl_type == remove_parameters(CPL::static_pkl_type(standard)) || - pkl_type == remove_parameters(InteropSubtitleAsset::static_pkl_type(standard))) { + pkl_type == remove_parameters(InteropTextAsset::static_pkl_type(standard))) { auto p = new xmlpp::DomParser; try { p->parse_file(dcp::filesystem::fix_long_path(path).string()); @@ -243,13 +243,13 @@ DCP::read (vector<dcp::VerificationNote>* notes, bool ignore_incorrect_picture_m if (standard == Standard::SMPTE && notes) { notes->push_back (VerificationNote(VerificationNote::Type::ERROR, VerificationNote::Code::MISMATCHED_STANDARD)); } - other_assets.push_back (make_shared<InteropSubtitleAsset>(path)); + other_assets.push_back(make_shared<InteropTextAsset>(path)); } } else if ( *pkl_type == remove_parameters(PictureAsset::static_pkl_type(standard)) || *pkl_type == remove_parameters(SoundAsset::static_pkl_type(standard)) || *pkl_type == remove_parameters(AtmosAsset::static_pkl_type(standard)) || - *pkl_type == remove_parameters(SMPTESubtitleAsset::static_pkl_type(standard)) + *pkl_type == remove_parameters(SMPTETextAsset::static_pkl_type(standard)) ) { bool found_threed_marked_as_twod = false; @@ -542,7 +542,7 @@ DCP::assets (bool ignore_unresolved) const auto o = j->asset_ref().asset(); assets.push_back (o); /* More Interop special-casing */ - auto sub = dynamic_pointer_cast<InteropSubtitleAsset>(o); + auto sub = dynamic_pointer_cast<InteropTextAsset>(o); if (sub) { add_to_container(assets, sub->font_assets()); } diff --git a/src/interop_subtitle_asset.cc b/src/interop_text_asset.cc index 32c3f66a..d9515573 100644 --- a/src/interop_subtitle_asset.cc +++ b/src/interop_text_asset.cc @@ -33,7 +33,7 @@ /** @file src/interop_subtitle_asset.cc - * @brief InteropSubtitleAsset class + * @brief InteropTextAsset class */ @@ -44,10 +44,10 @@ #include "font_asset.h" #include "file.h" #include "interop_load_font_node.h" -#include "interop_subtitle_asset.h" +#include "interop_text_asset.h" #include "raw_convert.h" -#include "subtitle_asset_internal.h" #include "subtitle_image.h" +#include "text_asset_internal.h" #include "util.h" #include "warnings.h" #include "xml.h" @@ -70,8 +70,8 @@ using boost::optional; using namespace dcp; -InteropSubtitleAsset::InteropSubtitleAsset (boost::filesystem::path file) - : SubtitleAsset (file) +InteropTextAsset::InteropTextAsset(boost::filesystem::path file) + : TextAsset(file) { _raw_xml = dcp::file_to_string (file); @@ -89,11 +89,11 @@ InteropSubtitleAsset::InteropSubtitleAsset (boost::filesystem::path file) for (auto i: xml->node()->get_children()) { auto e = dynamic_cast<xmlpp::Element const *>(i); if (e && (e->get_name() == "Font" || e->get_name() == "Subtitle")) { - parse_subtitles (e, ps, optional<int>(), Standard::INTEROP); + parse_texts(e, ps, optional<int>(), Standard::INTEROP); } } - for (auto i: _subtitles) { + for (auto i: _texts) { auto si = dynamic_pointer_cast<SubtitleImage>(i); if (si) { si->read_png_file (file.parent_path() / String::compose("%1.png", si->id())); @@ -102,14 +102,8 @@ InteropSubtitleAsset::InteropSubtitleAsset (boost::filesystem::path file) } -InteropSubtitleAsset::InteropSubtitleAsset () -{ - -} - - string -InteropSubtitleAsset::xml_as_string () const +InteropTextAsset::xml_as_string() const { xmlpp::Document doc; auto root = doc.create_root_node ("DCSubtitle"); @@ -126,14 +120,14 @@ InteropSubtitleAsset::xml_as_string () const load_font->set_attribute ("URI", i->uri); } - subtitles_as_xml (root, 250, Standard::INTEROP); + texts_as_xml(root, 250, Standard::INTEROP); return format_xml(doc, {}); } void -InteropSubtitleAsset::add_font (string load_id, dcp::ArrayData data) +InteropTextAsset::add_font(string load_id, dcp::ArrayData data) { _fonts.push_back (Font(load_id, make_uuid(), data)); auto const uri = String::compose("font_%1.ttf", _load_font_nodes.size()); @@ -142,13 +136,13 @@ InteropSubtitleAsset::add_font (string load_id, dcp::ArrayData data) bool -InteropSubtitleAsset::equals(shared_ptr<const Asset> other_asset, EqualityOptions const& options, NoteHandler note) const +InteropTextAsset::equals(shared_ptr<const Asset> other_asset, EqualityOptions const& options, NoteHandler note) const { - if (!SubtitleAsset::equals (other_asset, options, note)) { + if (!TextAsset::equals(other_asset, options, note)) { return false; } - auto other = dynamic_pointer_cast<const InteropSubtitleAsset> (other_asset); + auto other = dynamic_pointer_cast<const InteropTextAsset>(other_asset); if (!other) { return false; } @@ -174,7 +168,7 @@ InteropSubtitleAsset::equals(shared_ptr<const Asset> other_asset, EqualityOption } if (_movie_title != other->_movie_title) { - note (NoteType::ERROR, "Subtitle movie titles differ"); + note (NoteType::ERROR, "Subtitle or closed caption movie titles differ"); return false; } @@ -183,7 +177,7 @@ InteropSubtitleAsset::equals(shared_ptr<const Asset> other_asset, EqualityOption vector<shared_ptr<LoadFontNode>> -InteropSubtitleAsset::load_font_nodes () const +InteropTextAsset::load_font_nodes() const { vector<shared_ptr<LoadFontNode>> lf; copy (_load_font_nodes.begin(), _load_font_nodes.end(), back_inserter (lf)); @@ -192,7 +186,7 @@ InteropSubtitleAsset::load_font_nodes () const void -InteropSubtitleAsset::write (boost::filesystem::path p) const +InteropTextAsset::write(boost::filesystem::path p) const { File f(p, "wb"); if (!f) { @@ -206,7 +200,7 @@ InteropSubtitleAsset::write (boost::filesystem::path p) const _file = p; /* Image subtitles */ - for (auto i: _subtitles) { + for (auto i: _texts) { auto im = dynamic_pointer_cast<dcp::SubtitleImage> (i); if (im) { im->write_png_file(p.parent_path() / String::compose("%1.png", im->id())); @@ -230,7 +224,7 @@ InteropSubtitleAsset::write (boost::filesystem::path p) const * a list of font ID, load ID and data. */ void -InteropSubtitleAsset::resolve_fonts (vector<shared_ptr<Asset>> assets) +InteropTextAsset::resolve_fonts(vector<shared_ptr<Asset>> assets) { for (auto asset: assets) { auto font = dynamic_pointer_cast<FontAsset>(asset); @@ -256,7 +250,7 @@ InteropSubtitleAsset::resolve_fonts (vector<shared_ptr<Asset>> assets) vector<shared_ptr<Asset>> -InteropSubtitleAsset::font_assets() +InteropTextAsset::font_assets() { vector<shared_ptr<Asset>> assets; for (auto const& i: _fonts) { @@ -268,7 +262,7 @@ InteropSubtitleAsset::font_assets() vector<shared_ptr<const Asset>> -InteropSubtitleAsset::font_assets() const +InteropTextAsset::font_assets() const { vector<shared_ptr<const Asset>> assets; for (auto const& i: _fonts) { @@ -280,11 +274,11 @@ InteropSubtitleAsset::font_assets() const void -InteropSubtitleAsset::add_to_assetmap (AssetMap& asset_map, boost::filesystem::path root) const +InteropTextAsset::add_to_assetmap(AssetMap& asset_map, boost::filesystem::path root) const { Asset::add_to_assetmap(asset_map, root); - for (auto i: _subtitles) { + for (auto i: _texts) { auto im = dynamic_pointer_cast<dcp::SubtitleImage>(i); if (im) { DCP_ASSERT(im->file()); @@ -295,11 +289,11 @@ InteropSubtitleAsset::add_to_assetmap (AssetMap& asset_map, boost::filesystem::p void -InteropSubtitleAsset::add_to_pkl (shared_ptr<PKL> pkl, boost::filesystem::path root) const +InteropTextAsset::add_to_pkl(shared_ptr<PKL> pkl, boost::filesystem::path root) const { Asset::add_to_pkl (pkl, root); - for (auto i: _subtitles) { + for (auto i: _texts) { auto im = dynamic_pointer_cast<dcp::SubtitleImage> (i); if (im) { auto png_image = im->png_image (); @@ -310,7 +304,7 @@ InteropSubtitleAsset::add_to_pkl (shared_ptr<PKL> pkl, boost::filesystem::path r void -InteropSubtitleAsset::set_font_file (string load_id, boost::filesystem::path file) +InteropTextAsset::set_font_file(string load_id, boost::filesystem::path file) { for (auto& i: _fonts) { if (i.load_id == load_id) { @@ -327,7 +321,7 @@ InteropSubtitleAsset::set_font_file (string load_id, boost::filesystem::path fil vector<string> -InteropSubtitleAsset::unresolved_fonts() const +InteropTextAsset::unresolved_fonts() const { vector<string> unresolved; for (auto load_font_node: _load_font_nodes) { diff --git a/src/interop_subtitle_asset.h b/src/interop_text_asset.h index f63740d5..b2602224 100644 --- a/src/interop_subtitle_asset.h +++ b/src/interop_text_asset.h @@ -32,17 +32,17 @@ */ -/** @file src/interop_subtitle_asset.h - * @brief InteropSubtitleAsset class +/** @file src/interop_text_asset.h + * @brief InteropTextAsset class */ -#ifndef DCP_INTEROP_SUBTITLE_ASSET_H -#define DCP_INTEROP_SUBTITLE_ASSET_H +#ifndef DCP_INTEROP_TEXT_ASSET_H +#define DCP_INTEROP_TEXT_ASSET_H -#include "subtitle_asset.h" -#include "subtitle_standard.h" +#include "text_asset.h" +#include "text_standard.h" #include <boost/filesystem.hpp> @@ -52,16 +52,16 @@ namespace dcp { class InteropLoadFontNode; -/** @class InteropSubtitleAsset - * @brief A set of subtitles to be read and/or written in the Inter-Op format +/** @class InteropTextAsset + * @brief A set of subtitles or closed captions to be read and/or written in the Inter-Op format * * Inter-Op subtitles are sometimes known as CineCanvas. */ -class InteropSubtitleAsset : public SubtitleAsset +class InteropTextAsset : public TextAsset { public: - InteropSubtitleAsset (); - explicit InteropSubtitleAsset (boost::filesystem::path file); + InteropTextAsset() = default; + explicit InteropTextAsset(boost::filesystem::path file); bool equals ( std::shared_ptr<const Asset>, @@ -93,38 +93,38 @@ public: std::vector<std::string> unresolved_fonts() const; /** Set the reel number or sub-element identifier - * of these subtitles. + * of these subtitles / closed captions. * @param n New reel number. */ void set_reel_number (std::string n) { _reel_number = n; } - /** Set the language tag of these subtitles. + /** Set the language tag of these subtitles / closed captions. * @param l New language. */ void set_language (std::string l) { _language = l; } - /** @return title of the movie that the subtitles are for */ + /** @return title of the movie that the subtitles / closed captions are for */ void set_movie_title (std::string m) { _movie_title = m; } /** @return reel number or sub-element of a programme that - * these subtitles refer to. + * these subtitles / closed captions refer to. */ std::string reel_number () const { return _reel_number; } - /** @return language used in the subtitles */ + /** @return language used in the subtitles / closed captions */ std::string language () const { return _language; } - /** @return movie title that these subtitles are for */ + /** @return movie title that these subtitles / closed captions are for */ std::string movie_title () const { return _movie_title; } @@ -134,8 +134,8 @@ public: return 1000; } - SubtitleStandard subtitle_standard() const override { - return SubtitleStandard::INTEROP; + TextStandard text_standard() const override { + return TextStandard::INTEROP; } static std::string static_pkl_type (Standard) { diff --git a/src/reel.cc b/src/reel.cc index a8481d59..95769140 100644 --- a/src/reel.cc +++ b/src/reel.cc @@ -40,7 +40,7 @@ #include "decrypted_kdm.h" #include "decrypted_kdm_key.h" #include "equality_options.h" -#include "interop_subtitle_asset.h" +#include "interop_text_asset.h" #include "mono_picture_asset.h" #include "picture_asset.h" #include "reel.h" @@ -55,10 +55,10 @@ #include "reel_sound_asset.h" #include "reel_stereo_picture_asset.h" #include "reel_subtitle_asset.h" -#include "smpte_subtitle_asset.h" +#include "smpte_text_asset.h" #include "sound_asset.h" #include "stereo_picture_asset.h" -#include "subtitle_asset.h" +#include "text_asset.h" #include "util.h" #include <libxml++/nodes/element.h> #include <stdint.h> @@ -409,7 +409,7 @@ Reel::resolve_refs (vector<shared_ptr<Asset>> assets) /* Interop subtitle handling is all special cases */ if (_main_subtitle->asset_ref().resolved()) { - auto iop = dynamic_pointer_cast<InteropSubtitleAsset> (_main_subtitle->asset_ref().asset()); + auto iop = dynamic_pointer_cast<InteropTextAsset>(_main_subtitle->asset_ref().asset()); if (iop) { iop->resolve_fonts (assets); } @@ -421,7 +421,7 @@ Reel::resolve_refs (vector<shared_ptr<Asset>> assets) /* Interop subtitle handling is all special cases */ if (i->asset_ref().resolved()) { - auto iop = dynamic_pointer_cast<InteropSubtitleAsset> (i->asset_ref().asset()); + auto iop = dynamic_pointer_cast<InteropTextAsset>(i->asset_ref().asset()); if (iop) { iop->resolve_fonts (assets); } diff --git a/src/reel_closed_caption_asset.cc b/src/reel_closed_caption_asset.cc index e5649d6a..a9ba32f5 100644 --- a/src/reel_closed_caption_asset.cc +++ b/src/reel_closed_caption_asset.cc @@ -39,8 +39,8 @@ #include "dcp_assert.h" #include "reel_closed_caption_asset.h" -#include "smpte_subtitle_asset.h" -#include "subtitle_asset.h" +#include "smpte_text_asset.h" +#include "text_asset.h" #include "warnings.h" LIBDCP_DISABLE_WARNINGS #include <libxml++/libxml++.h> @@ -53,10 +53,10 @@ 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) +ReelClosedCaptionAsset::ReelClosedCaptionAsset(std::shared_ptr<TextAsset> 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, + dynamic_pointer_cast<SMPTETextAsset>(asset) ? dynamic_pointer_cast<SMPTETextAsset>(asset)->key_id() : boost::none, asset->id(), edit_rate, intrinsic_duration, diff --git a/src/reel_closed_caption_asset.h b/src/reel_closed_caption_asset.h index 405de34b..adc1e1eb 100644 --- a/src/reel_closed_caption_asset.h +++ b/src/reel_closed_caption_asset.h @@ -44,7 +44,7 @@ #include "language_tag.h" #include "reel_asset.h" #include "reel_file_asset.h" -#include "subtitle_asset.h" +#include "text_asset.h" struct verify_invalid_language2; @@ -59,15 +59,15 @@ namespace dcp { class ReelClosedCaptionAsset : public ReelFileAsset { public: - ReelClosedCaptionAsset (std::shared_ptr<SubtitleAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point); + ReelClosedCaptionAsset(std::shared_ptr<TextAsset> 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<const TextAsset> asset () const { + return asset_of_type<const TextAsset>(); } - std::shared_ptr<SubtitleAsset> asset () { - return asset_of_type<SubtitleAsset>(); + std::shared_ptr<TextAsset> asset () { + return asset_of_type<TextAsset>(); } bool equals(std::shared_ptr<const ReelClosedCaptionAsset>, EqualityOptions const&, NoteHandler) const; diff --git a/src/reel_interop_closed_caption_asset.cc b/src/reel_interop_closed_caption_asset.cc index be968068..ea1b85c9 100644 --- a/src/reel_interop_closed_caption_asset.cc +++ b/src/reel_interop_closed_caption_asset.cc @@ -46,14 +46,13 @@ using std::string; using namespace dcp; -ReelInteropClosedCaptionAsset::ReelInteropClosedCaptionAsset (shared_ptr<InteropSubtitleAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point) +ReelInteropClosedCaptionAsset::ReelInteropClosedCaptionAsset(shared_ptr<InteropTextAsset> 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) { diff --git a/src/reel_interop_closed_caption_asset.h b/src/reel_interop_closed_caption_asset.h index 5e8f7c1e..7e1ee6c5 100644 --- a/src/reel_interop_closed_caption_asset.h +++ b/src/reel_interop_closed_caption_asset.h @@ -41,7 +41,7 @@ #define LIBDCP_REEL_INTEROP_CLOSED_CAPTION_ASSET_H -#include "interop_subtitle_asset.h" +#include "interop_text_asset.h" #include "reel_closed_caption_asset.h" @@ -51,15 +51,15 @@ namespace dcp { class ReelInteropClosedCaptionAsset : public ReelClosedCaptionAsset { public: - ReelInteropClosedCaptionAsset (std::shared_ptr<InteropSubtitleAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point); + ReelInteropClosedCaptionAsset(std::shared_ptr<InteropTextAsset> 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<const InteropTextAsset> interop_asset() const { + return asset_of_type<const InteropTextAsset>(); } - std::shared_ptr<InteropSubtitleAsset> interop_asset () { - return asset_of_type<InteropSubtitleAsset>(); + std::shared_ptr<InteropTextAsset> interop_asset() { + return asset_of_type<InteropTextAsset>(); } xmlpp::Node* write_to_cpl (xmlpp::Node* node, Standard standard) const override; diff --git a/src/reel_interop_subtitle_asset.cc b/src/reel_interop_subtitle_asset.cc index 5f295d53..6b9ef79c 100644 --- a/src/reel_interop_subtitle_asset.cc +++ b/src/reel_interop_subtitle_asset.cc @@ -50,7 +50,7 @@ using boost::optional; using namespace dcp; -ReelInteropSubtitleAsset::ReelInteropSubtitleAsset (std::shared_ptr<SubtitleAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point) +ReelInteropSubtitleAsset::ReelInteropSubtitleAsset(std::shared_ptr<TextAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point) : ReelSubtitleAsset (asset, edit_rate, intrinsic_duration, entry_point) { diff --git a/src/reel_interop_subtitle_asset.h b/src/reel_interop_subtitle_asset.h index 7e90e9e0..1a7da9d4 100644 --- a/src/reel_interop_subtitle_asset.h +++ b/src/reel_interop_subtitle_asset.h @@ -32,12 +32,12 @@ */ -/** @file src/reel_interop_subtitle_asset.h - * @brief ReelInteropSubtitleAsset class +/** @file src/reel_interop_text_asset.h + * @brief ReelInteropTextAsset class */ -#include "interop_subtitle_asset.h" +#include "interop_text_asset.h" #include "reel_file_asset.h" #include "reel_subtitle_asset.h" @@ -51,15 +51,15 @@ namespace dcp { class ReelInteropSubtitleAsset : public ReelSubtitleAsset { public: - ReelInteropSubtitleAsset (std::shared_ptr<SubtitleAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point); + ReelInteropSubtitleAsset(std::shared_ptr<TextAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point); explicit ReelInteropSubtitleAsset (std::shared_ptr<const cxml::Node>); - std::shared_ptr<const InteropSubtitleAsset> interop_asset () const { - return asset_of_type<const InteropSubtitleAsset>(); + std::shared_ptr<const InteropTextAsset> interop_asset () const { + return asset_of_type<const InteropTextAsset>(); } - std::shared_ptr<InteropSubtitleAsset> interop_asset () { - return asset_of_type<InteropSubtitleAsset>(); + std::shared_ptr<InteropTextAsset> interop_asset () { + return asset_of_type<InteropTextAsset>(); } }; diff --git a/src/reel_smpte_closed_caption_asset.cc b/src/reel_smpte_closed_caption_asset.cc index a2a68202..22f23b8e 100644 --- a/src/reel_smpte_closed_caption_asset.cc +++ b/src/reel_smpte_closed_caption_asset.cc @@ -51,7 +51,7 @@ using std::string; using namespace dcp; -ReelSMPTEClosedCaptionAsset::ReelSMPTEClosedCaptionAsset (shared_ptr<SMPTESubtitleAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point) +ReelSMPTEClosedCaptionAsset::ReelSMPTEClosedCaptionAsset(shared_ptr<SMPTETextAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point) : ReelClosedCaptionAsset (asset, edit_rate, intrinsic_duration, entry_point) { diff --git a/src/reel_smpte_closed_caption_asset.h b/src/reel_smpte_closed_caption_asset.h index 32a79efd..e4eb4f64 100644 --- a/src/reel_smpte_closed_caption_asset.h +++ b/src/reel_smpte_closed_caption_asset.h @@ -43,7 +43,7 @@ #include "reel_file_asset.h" #include "reel_closed_caption_asset.h" -#include "smpte_subtitle_asset.h" +#include "smpte_text_asset.h" namespace dcp { @@ -52,15 +52,15 @@ namespace dcp { class ReelSMPTEClosedCaptionAsset : public ReelClosedCaptionAsset { public: - ReelSMPTEClosedCaptionAsset (std::shared_ptr<SMPTESubtitleAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point); + ReelSMPTEClosedCaptionAsset(std::shared_ptr<SMPTETextAsset> 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<SMPTETextAsset> smpte_asset() { + return asset_of_type<SMPTETextAsset>(); } - std::shared_ptr<const SMPTESubtitleAsset> smpte_asset () const { - return asset_of_type<const SMPTESubtitleAsset>(); + std::shared_ptr<const SMPTETextAsset> smpte_asset() const { + return asset_of_type<const SMPTETextAsset>(); } xmlpp::Node* write_to_cpl (xmlpp::Node* node, Standard standard) const override; diff --git a/src/reel_smpte_subtitle_asset.cc b/src/reel_smpte_subtitle_asset.cc index 64440547..80762269 100644 --- a/src/reel_smpte_subtitle_asset.cc +++ b/src/reel_smpte_subtitle_asset.cc @@ -38,7 +38,7 @@ #include "reel_smpte_subtitle_asset.h" -#include "smpte_subtitle_asset.h" +#include "smpte_text_asset.h" #include "warnings.h" LIBDCP_DISABLE_WARNINGS #include <libxml++/libxml++.h> @@ -51,7 +51,7 @@ using boost::optional; using namespace dcp; -ReelSMPTESubtitleAsset::ReelSMPTESubtitleAsset (shared_ptr<SMPTESubtitleAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point) +ReelSMPTESubtitleAsset::ReelSMPTESubtitleAsset(shared_ptr<SMPTETextAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point) : ReelSubtitleAsset (asset, edit_rate, intrinsic_duration, entry_point) { diff --git a/src/reel_smpte_subtitle_asset.h b/src/reel_smpte_subtitle_asset.h index 2a097309..d2ba3fd4 100644 --- a/src/reel_smpte_subtitle_asset.h +++ b/src/reel_smpte_subtitle_asset.h @@ -38,13 +38,13 @@ #include "reel_subtitle_asset.h" -#include "smpte_subtitle_asset.h" +#include "smpte_text_asset.h" namespace dcp { -class SMPTESubtitleAsset; +class SMPTETextAsset; /** @class ReelSMPTESubtitleAsset @@ -53,15 +53,15 @@ class SMPTESubtitleAsset; class ReelSMPTESubtitleAsset : public ReelSubtitleAsset { public: - ReelSMPTESubtitleAsset (std::shared_ptr<SMPTESubtitleAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point); + ReelSMPTESubtitleAsset(std::shared_ptr<SMPTETextAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point); explicit ReelSMPTESubtitleAsset (std::shared_ptr<const cxml::Node>); - std::shared_ptr<const SMPTESubtitleAsset> smpte_asset () const { - return asset_of_type<const SMPTESubtitleAsset>(); + std::shared_ptr<const SMPTETextAsset> smpte_asset() const { + return asset_of_type<const SMPTETextAsset>(); } - std::shared_ptr<SMPTESubtitleAsset> smpte_asset () { - return asset_of_type<SMPTESubtitleAsset>(); + std::shared_ptr<SMPTETextAsset> smpte_asset() { + return asset_of_type<SMPTETextAsset>(); } private: diff --git a/src/reel_subtitle_asset.cc b/src/reel_subtitle_asset.cc index d856a05e..6e091c81 100644 --- a/src/reel_subtitle_asset.cc +++ b/src/reel_subtitle_asset.cc @@ -39,8 +39,8 @@ #include "language_tag.h" #include "reel_subtitle_asset.h" -#include "smpte_subtitle_asset.h" -#include "subtitle_asset.h" +#include "smpte_text_asset.h" +#include "text_asset.h" #include "warnings.h" LIBDCP_DISABLE_WARNINGS #include <libxml++/libxml++.h> @@ -54,10 +54,10 @@ using boost::optional; using namespace dcp; -ReelSubtitleAsset::ReelSubtitleAsset (std::shared_ptr<SubtitleAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point) +ReelSubtitleAsset::ReelSubtitleAsset(std::shared_ptr<TextAsset> 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, + dynamic_pointer_cast<SMPTETextAsset>(asset) ? dynamic_pointer_cast<SMPTETextAsset>(asset)->key_id() : boost::none, asset->id(), edit_rate, intrinsic_duration, diff --git a/src/reel_subtitle_asset.h b/src/reel_subtitle_asset.h index 8b694fd6..7bc38a0f 100644 --- a/src/reel_subtitle_asset.h +++ b/src/reel_subtitle_asset.h @@ -44,7 +44,7 @@ #include "language_tag.h" #include "reel_asset.h" #include "reel_file_asset.h" -#include "subtitle_asset.h" +#include "text_asset.h" struct verify_invalid_language1; @@ -53,7 +53,7 @@ struct verify_invalid_language1; namespace dcp { -class SubtitleAsset; +class TextAsset; /** @class ReelSubtitleAsset @@ -62,15 +62,15 @@ class SubtitleAsset; class ReelSubtitleAsset : public ReelFileAsset { public: - ReelSubtitleAsset (std::shared_ptr<SubtitleAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point); + ReelSubtitleAsset(std::shared_ptr<TextAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point); explicit ReelSubtitleAsset (std::shared_ptr<const cxml::Node>); - std::shared_ptr<const SubtitleAsset> asset () const { - return asset_of_type<const SubtitleAsset>(); + std::shared_ptr<const TextAsset> asset() const { + return asset_of_type<const TextAsset>(); } - std::shared_ptr<SubtitleAsset> asset () { - return asset_of_type<SubtitleAsset>(); + std::shared_ptr<TextAsset> asset() { + return asset_of_type<TextAsset>(); } xmlpp::Node* write_to_cpl (xmlpp::Node* node, Standard standard) const override; diff --git a/src/smpte_subtitle_asset.cc b/src/smpte_text_asset.cc index 0ff1d7ef..d373f86d 100644 --- a/src/smpte_subtitle_asset.cc +++ b/src/smpte_text_asset.cc @@ -45,7 +45,7 @@ #include "filesystem.h" #include "raw_convert.h" #include "smpte_load_font_node.h" -#include "smpte_subtitle_asset.h" +#include "smpte_text_asset.h" #include "subtitle_image.h" #include "util.h" #include "warnings.h" @@ -79,19 +79,19 @@ static string const subtitle_smpte_ns_2010 = "http://www.smpte-ra.org/schemas/42 static string const subtitle_smpte_ns_2014 = "http://www.smpte-ra.org/schemas/428-7/2014/DCST"; -SMPTESubtitleAsset::SMPTESubtitleAsset(SubtitleStandard standard) +SMPTETextAsset::SMPTETextAsset(TextStandard standard) : MXF(Standard::SMPTE) , _edit_rate (24, 1) , _time_code_rate (24) - , _subtitle_standard(standard) + , _text_standard(standard) , _xml_id (make_uuid()) { } -SMPTESubtitleAsset::SMPTESubtitleAsset (boost::filesystem::path file) - : SubtitleAsset (file) +SMPTETextAsset::SMPTETextAsset(boost::filesystem::path file) + : TextAsset(file) { auto xml = make_shared<cxml::Document>("SubtitleReel"); @@ -139,7 +139,7 @@ SMPTESubtitleAsset::SMPTESubtitleAsset (boost::filesystem::path file) /* Try to read PNG files from the same folder that the XML is in; the wisdom of this is debatable, at best... */ - for (auto i: _subtitles) { + for (auto i: _texts) { auto im = dynamic_pointer_cast<SubtitleImage>(i); if (im && im->png_image().size() == 0) { /* Even more dubious; allow <id>.png or urn:uuid:<id>.png */ @@ -158,7 +158,7 @@ SMPTESubtitleAsset::SMPTESubtitleAsset (boost::filesystem::path file) } /* Check that all required image data have been found */ - for (auto i: _subtitles) { + for (auto i: _texts) { auto im = dynamic_pointer_cast<SubtitleImage>(i); if (im && im->png_image().size() == 0) { throw MissingSubtitleImageError (im->id()); @@ -168,16 +168,16 @@ SMPTESubtitleAsset::SMPTESubtitleAsset (boost::filesystem::path file) void -SMPTESubtitleAsset::parse_xml (shared_ptr<cxml::Document> xml) +SMPTETextAsset::parse_xml(shared_ptr<cxml::Document> xml) { if (xml->namespace_uri() == subtitle_smpte_ns_2007) { - _subtitle_standard = SubtitleStandard::SMPTE_2007; + _text_standard = TextStandard::SMPTE_2007; } else if (xml->namespace_uri() == subtitle_smpte_ns_2010) { - _subtitle_standard = SubtitleStandard::SMPTE_2010; + _text_standard = TextStandard::SMPTE_2010; } else if (xml->namespace_uri() == subtitle_smpte_ns_2014) { - _subtitle_standard = SubtitleStandard::SMPTE_2014; + _text_standard = TextStandard::SMPTE_2014; } else { - throw XMLError("Unrecognised subtitle namespace " + xml->namespace_uri()); + throw XMLError("Unrecognised subtitle or closed caption namespace " + xml->namespace_uri()); } _xml_id = remove_urn_uuid(xml->string_child("Id")); _load_font_nodes = type_children<dcp::SMPTELoadFontNode> (xml, "LoadFont"); @@ -211,17 +211,17 @@ SMPTESubtitleAsset::parse_xml (shared_ptr<cxml::Document> xml) for (auto i: xml->node()->get_children()) { auto const e = dynamic_cast<xmlpp::Element const *>(i); if (e && e->get_name() == "SubtitleList") { - parse_subtitles (e, ps, _time_code_rate, Standard::SMPTE); + parse_texts(e, ps, _time_code_rate, Standard::SMPTE); } } /* Guess intrinsic duration */ - _intrinsic_duration = latest_subtitle_out().as_editable_units_ceil(_edit_rate.numerator / _edit_rate.denominator); + _intrinsic_duration = latest_text_out().as_editable_units_ceil(_edit_rate.numerator / _edit_rate.denominator); } void -SMPTESubtitleAsset::read_mxf_resources (shared_ptr<ASDCP::TimedText::MXFReader> reader, shared_ptr<DecryptionContext> dec) +SMPTETextAsset::read_mxf_resources(shared_ptr<ASDCP::TimedText::MXFReader> reader, shared_ptr<DecryptionContext> dec) { ASDCP::TimedText::TimedTextDescriptor descriptor; reader->FillTimedTextDescriptor (descriptor); @@ -265,12 +265,12 @@ SMPTESubtitleAsset::read_mxf_resources (shared_ptr<ASDCP::TimedText::MXFReader> } case ASDCP::TimedText::MT_PNG: { - auto j = _subtitles.begin(); - while (j != _subtitles.end() && ((!dynamic_pointer_cast<SubtitleImage>(*j)) || dynamic_pointer_cast<SubtitleImage>(*j)->id() != id)) { + auto j = _texts.begin(); + while (j != _texts.end() && ((!dynamic_pointer_cast<SubtitleImage>(*j)) || dynamic_pointer_cast<SubtitleImage>(*j)->id() != id)) { ++j; } - if (j != _subtitles.end()) { + if (j != _texts.end()) { dynamic_pointer_cast<SubtitleImage>(*j)->set_png_image(ArrayData(buffer.RoData(), buffer.Size())); } break; @@ -283,7 +283,7 @@ SMPTESubtitleAsset::read_mxf_resources (shared_ptr<ASDCP::TimedText::MXFReader> void -SMPTESubtitleAsset::read_mxf_descriptor (shared_ptr<ASDCP::TimedText::MXFReader> reader) +SMPTETextAsset::read_mxf_descriptor(shared_ptr<ASDCP::TimedText::MXFReader> reader) { ASDCP::TimedText::TimedTextDescriptor descriptor; reader->FillTimedTextDescriptor (descriptor); @@ -300,7 +300,7 @@ SMPTESubtitleAsset::read_mxf_descriptor (shared_ptr<ASDCP::TimedText::MXFReader> void -SMPTESubtitleAsset::set_key (Key key) +SMPTETextAsset::set_key(Key key) { /* See if we already have a key; if we do, and we have a file, we'll already have read that file. @@ -343,7 +343,7 @@ SMPTESubtitleAsset::set_key (Key key) vector<shared_ptr<LoadFontNode>> -SMPTESubtitleAsset::load_font_nodes () const +SMPTETextAsset::load_font_nodes() const { vector<shared_ptr<LoadFontNode>> lf; copy (_load_font_nodes.begin(), _load_font_nodes.end(), back_inserter(lf)); @@ -352,7 +352,7 @@ SMPTESubtitleAsset::load_font_nodes () const bool -SMPTESubtitleAsset::valid_mxf (boost::filesystem::path file) +SMPTETextAsset::valid_mxf(boost::filesystem::path file) { ASDCP::TimedText::MXFReader reader; Kumu::DefaultLogSink().UnsetFilterFlag(Kumu::LOG_ALLOW_ALL); @@ -363,7 +363,7 @@ SMPTESubtitleAsset::valid_mxf (boost::filesystem::path file) string -SMPTESubtitleAsset::xml_as_string () const +SMPTETextAsset::xml_as_string() const { xmlpp::Document doc; auto root = doc.create_root_node ("SubtitleReel"); @@ -393,14 +393,14 @@ SMPTESubtitleAsset::xml_as_string () const load_font->set_attribute ("ID", i->id); } - subtitles_as_xml (root->add_child("SubtitleList"), _time_code_rate, Standard::SMPTE); + texts_as_xml(root->add_child("SubtitleList"), _time_code_rate, Standard::SMPTE); return format_xml(doc, std::make_pair(string{}, schema_namespace())); } void -SMPTESubtitleAsset::write (boost::filesystem::path p) const +SMPTETextAsset::write(boost::filesystem::path p) const { EncryptionContext enc (key(), Standard::SMPTE); @@ -430,7 +430,7 @@ SMPTESubtitleAsset::write (boost::filesystem::path p) const /* Image subtitle references */ - for (auto i: _subtitles) { + for (auto i: _texts) { auto si = dynamic_pointer_cast<SubtitleImage>(i); if (si) { ASDCP::TimedText::TimedTextResourceDescriptor res; @@ -453,7 +453,7 @@ SMPTESubtitleAsset::write (boost::filesystem::path p) const /* This header size is a guess. Empirically it seems that each subtitle reference is 90 bytes, and we need some extra. The default size is not enough for some feature-length PNG sub projects (see DCP-o-matic #1561). */ - ASDCP::Result_t r = writer.OpenWrite(dcp::filesystem::fix_long_path(p).string().c_str(), writer_info, descriptor, _subtitles.size() * 90 + 16384); + ASDCP::Result_t r = writer.OpenWrite(dcp::filesystem::fix_long_path(p).string().c_str(), writer_info, descriptor, _texts.size() * 90 + 16384); if (ASDCP_FAILURE (r)) { boost::throw_exception (FileError ("could not open subtitle MXF for writing", p.string(), r)); } @@ -486,7 +486,7 @@ SMPTESubtitleAsset::write (boost::filesystem::path p) const /* Image subtitle payload */ - for (auto i: _subtitles) { + for (auto i: _texts) { auto si = dynamic_pointer_cast<SubtitleImage>(i); if (si) { ASDCP::TimedText::FrameBuffer buffer; @@ -505,15 +505,15 @@ SMPTESubtitleAsset::write (boost::filesystem::path p) const } bool -SMPTESubtitleAsset::equals(shared_ptr<const Asset> other_asset, EqualityOptions const& options, NoteHandler note) const +SMPTETextAsset::equals(shared_ptr<const Asset> other_asset, EqualityOptions const& options, NoteHandler note) const { - if (!SubtitleAsset::equals (other_asset, options, note)) { + if (!TextAsset::equals (other_asset, options, note)) { return false; } - auto other = dynamic_pointer_cast<const SMPTESubtitleAsset>(other_asset); + auto other = dynamic_pointer_cast<const SMPTETextAsset>(other_asset); if (!other) { - note (NoteType::ERROR, "Subtitles are in different standards"); + note(NoteType::ERROR, "subtitles or closed captions are in different standards"); return false; } @@ -536,46 +536,46 @@ SMPTESubtitleAsset::equals(shared_ptr<const Asset> other_asset, EqualityOptions } if (_content_title_text != other->_content_title_text) { - note (NoteType::ERROR, "Subtitle content title texts differ"); + note(NoteType::ERROR, "Subtitle / closed caption content title texts differ"); return false; } if (_language != other->_language) { - note (NoteType::ERROR, String::compose("Subtitle languages differ (`%1' vs `%2')", _language.get_value_or("[none]"), other->_language.get_value_or("[none]"))); + note(NoteType::ERROR, String::compose("Subtitle / closed caption languages differ (`%1' vs `%2')", _language.get_value_or("[none]"), other->_language.get_value_or("[none]"))); return false; } if (_annotation_text != other->_annotation_text) { - note (NoteType::ERROR, "Subtitle annotation texts differ"); + note(NoteType::ERROR, "Subtitle / closed caption annotation texts differ"); return false; } if (_issue_date != other->_issue_date) { if (options.issue_dates_can_differ) { - note (NoteType::NOTE, "Subtitle issue dates differ"); + note(NoteType::NOTE, "Subtitle / closed caption issue dates differ"); } else { - note (NoteType::ERROR, "Subtitle issue dates differ"); + note(NoteType::ERROR, "Subtitle / closed caption issue dates differ"); return false; } } if (_reel_number != other->_reel_number) { - note (NoteType::ERROR, "Subtitle reel numbers differ"); + note(NoteType::ERROR, "Subtitle / closed caption reel numbers differ"); return false; } if (_edit_rate != other->_edit_rate) { - note (NoteType::ERROR, "Subtitle edit rates differ"); + note(NoteType::ERROR, "Subtitle / closed caption edit rates differ"); return false; } if (_time_code_rate != other->_time_code_rate) { - note (NoteType::ERROR, "Subtitle time code rates differ"); + note(NoteType::ERROR, "Subtitle / closed caption time code rates differ"); return false; } if (_start_time != other->_start_time) { - note (NoteType::ERROR, "Subtitle start times differ"); + note(NoteType::ERROR, "Subtitle / closed caption start times differ"); return false; } @@ -584,7 +584,7 @@ SMPTESubtitleAsset::equals(shared_ptr<const Asset> other_asset, EqualityOptions void -SMPTESubtitleAsset::add_font (string load_id, dcp::ArrayData data) +SMPTETextAsset::add_font(string load_id, dcp::ArrayData data) { string const uuid = make_uuid (); _fonts.push_back (Font(load_id, uuid, data)); @@ -593,22 +593,22 @@ SMPTESubtitleAsset::add_font (string load_id, dcp::ArrayData data) void -SMPTESubtitleAsset::add (shared_ptr<Subtitle> s) +SMPTETextAsset::add(shared_ptr<Text> s) { - SubtitleAsset::add (s); - _intrinsic_duration = latest_subtitle_out().as_editable_units_ceil(_edit_rate.numerator / _edit_rate.denominator); + TextAsset::add(s); + _intrinsic_duration = latest_text_out().as_editable_units_ceil(_edit_rate.numerator / _edit_rate.denominator); } string -SMPTESubtitleAsset::schema_namespace() const +SMPTETextAsset::schema_namespace() const { - switch (_subtitle_standard) { - case SubtitleStandard::SMPTE_2007: + switch (_text_standard) { + case TextStandard::SMPTE_2007: return subtitle_smpte_ns_2007; - case SubtitleStandard::SMPTE_2010: + case TextStandard::SMPTE_2010: return subtitle_smpte_ns_2010; - case SubtitleStandard::SMPTE_2014: + case TextStandard::SMPTE_2014: return subtitle_smpte_ns_2014; default: DCP_ASSERT(false); diff --git a/src/smpte_subtitle_asset.h b/src/smpte_text_asset.h index 26144fe1..b052fa79 100644 --- a/src/smpte_subtitle_asset.h +++ b/src/smpte_text_asset.h @@ -32,12 +32,12 @@ */ -#ifndef LIBDCP_SMPTE_SUBTITLE_ASSET_H -#define LIBDCP_SMPTE_SUBTITLE_ASSET_H +#ifndef LIBDCP_SMPTE_TEXT_ASSET_H +#define LIBDCP_SMPTE_TEXT_ASSET_H -/** @file src/smpte_subtitle_asset.h - * @brief SMPTESubtitleAsset class +/** @file src/smpte_text_asset.h + * @brief SMPTETextAsset class */ @@ -45,8 +45,8 @@ #include "language_tag.h" #include "local_time.h" #include "mxf.h" -#include "subtitle_asset.h" -#include "subtitle_standard.h" +#include "text_asset.h" +#include "text_standard.h" #include <boost/filesystem.hpp> @@ -69,18 +69,18 @@ namespace dcp { class SMPTELoadFontNode; -/** @class SMPTESubtitleAsset - * @brief A set of subtitles to be read and/or written in the SMPTE format +/** @class SMPTETextAsset + * @brief A set of subtitles or closed captions to be read and/or written in the SMPTE format */ -class SMPTESubtitleAsset : public SubtitleAsset, public MXF +class SMPTETextAsset : public TextAsset, public MXF { public: - explicit SMPTESubtitleAsset(SubtitleStandard standard = SubtitleStandard::SMPTE_2014); + explicit SMPTETextAsset(TextStandard standard = TextStandard::SMPTE_2014); - /** Construct a SMPTESubtitleAsset by reading an MXF or XML file + /** Construct a SMPTETextAsset by reading an MXF or XML file * @param file Filename */ - explicit SMPTESubtitleAsset (boost::filesystem::path file); + explicit SMPTETextAsset(boost::filesystem::path file); bool equals ( std::shared_ptr<const Asset>, @@ -95,7 +95,7 @@ public: /** Write this content to a MXF file */ void write (boost::filesystem::path path) const override; - void add (std::shared_ptr<Subtitle>) override; + void add(std::shared_ptr<Text>) override; void add_font (std::string id, dcp::ArrayData data) override; void set_key (Key key) override; @@ -135,7 +135,7 @@ public: return _intrinsic_duration; } - /** @return title of the film that these subtitles are for, + /** @return title of the film that these subtitles / closed captions are for, * to be presented to the user */ std::string content_title_text () const { @@ -167,7 +167,7 @@ public: return _edit_rate; } - /** @return subdivision of 1 second that is used for subtitle times; + /** @return subdivision of 1 second that is used for subtitle / closed caption times; * e.g. a time_code_rate of 250 means that a subtitle time of 0:0:0:001 * represents 4ms. */ @@ -191,8 +191,8 @@ public: return _resource_id; } - SubtitleStandard subtitle_standard() const override { - return _subtitle_standard; + TextStandard text_standard() const override { + return _text_standard; } static bool valid_mxf (boost::filesystem::path); @@ -236,12 +236,12 @@ private: Fraction _edit_rate; int _time_code_rate = 0; boost::optional<Time> _start_time; - /** There are two SMPTE standards describing subtitles, 428-7:2010 and 428-7:2014, and they + /** There are three SMPTE standards describing subtitles: 427-7:2007, 428-7:2010 and 428-7:2014, and they * have different interpretations of what Vposition means. Though libdcp does not need to * know the difference, this variable stores the standard from the namespace that this asset was * written with (or will be written with). */ - SubtitleStandard _subtitle_standard; + TextStandard _text_standard; std::vector<std::shared_ptr<SMPTELoadFontNode>> _load_font_nodes; /** UUID for the XML inside the MXF, which should be the same as the ResourceID in the MXF (our _resource_id) diff --git a/src/subtitle_image.cc b/src/subtitle_image.cc index 9340bc54..df9e1178 100644 --- a/src/subtitle_image.cc +++ b/src/subtitle_image.cc @@ -62,7 +62,7 @@ SubtitleImage::SubtitleImage ( Time fade_up_time, Time fade_down_time ) - : Subtitle(in, out, h_position, h_align, v_position, v_align, z_position, fade_up_time, fade_down_time) + : Text(in, out, h_position, h_align, v_position, v_align, z_position, fade_up_time, fade_down_time) , _png_image (png_image) , _id (make_uuid ()) { @@ -83,7 +83,7 @@ SubtitleImage::SubtitleImage ( Time fade_up_time, Time fade_down_time ) - : Subtitle(in, out, h_position, h_align, v_position, v_align, z_position, fade_up_time, fade_down_time) + : Text(in, out, h_position, h_align, v_position, v_align, z_position, fade_up_time, fade_down_time) , _png_image (png_image) , _id (id) { @@ -134,9 +134,9 @@ dcp::operator!= (SubtitleImage const & a, SubtitleImage const & b) bool -SubtitleImage::equals(shared_ptr<const Subtitle> other_sub, EqualityOptions const& options, NoteHandler note) const +SubtitleImage::equals(shared_ptr<const Text> other_sub, EqualityOptions const& options, NoteHandler note) const { - if (!Subtitle::equals(other_sub, options, note)) { + if (!Text::equals(other_sub, options, note)) { return false; } diff --git a/src/subtitle_image.h b/src/subtitle_image.h index ae733fe4..af2ff37b 100644 --- a/src/subtitle_image.h +++ b/src/subtitle_image.h @@ -42,8 +42,8 @@ #include "array_data.h" -#include "subtitle.h" #include "dcp_time.h" +#include "text.h" #include <boost/optional.hpp> #include <string> @@ -54,7 +54,7 @@ namespace dcp { /** @class SubtitleImage * @brief A bitmap subtitle with all the associated attributes */ -class SubtitleImage : public Subtitle +class SubtitleImage : public Text { public: SubtitleImage ( @@ -104,7 +104,7 @@ public: return _file; } - bool equals(std::shared_ptr<const dcp::Subtitle> other_sub, EqualityOptions const& options, NoteHandler note) const override; + bool equals(std::shared_ptr<const dcp::Text> other_sub, EqualityOptions const& options, NoteHandler note) const override; private: ArrayData _png_image; diff --git a/src/subtitle.cc b/src/text.cc index 248d0cff..2762bb66 100644 --- a/src/subtitle.cc +++ b/src/text.cc @@ -32,15 +32,15 @@ */ -/** @file src/subtitle.cc - * @brief Subtitle class +/** @file src/text.cc + * @brief Text class */ #include "compose.hpp" #include "dcp_time.h" #include "equality_options.h" -#include "subtitle.h" +#include "text.h" using std::shared_ptr; @@ -48,7 +48,7 @@ using namespace dcp; /** @param v_position Vertical position as a fraction of the screen height (between 0 and 1) from v_align */ -Subtitle::Subtitle ( +Text::Text( Time in, Time out, float h_position, @@ -74,7 +74,7 @@ Subtitle::Subtitle ( bool -Subtitle::equals(shared_ptr<const Subtitle> other, EqualityOptions const& options, NoteHandler note) const +Text::equals(shared_ptr<const Text> other, EqualityOptions const& options, NoteHandler note) const { bool same = true; diff --git a/src/subtitle.h b/src/text.h index 1ca3f9d4..b8f15757 100644 --- a/src/subtitle.h +++ b/src/text.h @@ -32,13 +32,13 @@ */ -/** @file src/subtitle.h - * @brief Subtitle class +/** @file src/text.h + * @brief Text class */ -#ifndef LIBDCP_SUBTITLE_H -#define LIBDCP_SUBTITLE_H +#ifndef LIBDCP_TEXT_H +#define LIBDCP_TEXT_H #include "dcp_time.h" @@ -52,17 +52,17 @@ namespace dcp { class EqualityOptions; -class Subtitle +class Text { public: - virtual ~Subtitle () {} + virtual ~Text() {} - /** @return subtitle start time (relative to the start of the reel) */ + /** @return text start time (relative to the start of the reel) */ Time in () const { return _in; } - /** @return subtitle finish time (relative to the start of the reel) */ + /** @return text finish time (relative to the start of the reel) */ Time out () const { return _out; } @@ -130,11 +130,11 @@ public: _fade_down_time = t; } - virtual bool equals(std::shared_ptr<const dcp::Subtitle> other, EqualityOptions const& options, NoteHandler note) const; + virtual bool equals(std::shared_ptr<const dcp::Text> other, EqualityOptions const& options, NoteHandler note) const; protected: - Subtitle ( + Text( Time in, Time out, float h_position, diff --git a/src/subtitle_asset.cc b/src/text_asset.cc index 1cd4fc07..ff6c00c4 100644 --- a/src/subtitle_asset.cc +++ b/src/text_asset.cc @@ -32,8 +32,8 @@ */ -/** @file src/subtitle_asset.cc - * @brief SubtitleAsset class +/** @file src/text_asset.cc + * @brief TextAsset class */ @@ -42,10 +42,10 @@ #include "load_font_node.h" #include "raw_convert.h" #include "reel_asset.h" -#include "subtitle_asset.h" -#include "subtitle_asset_internal.h" #include "subtitle_image.h" -#include "subtitle_string.h" +#include "text_asset.h" +#include "text_asset_internal.h" +#include "text_string.h" #include "util.h" #include "xml.h" #include <asdcp/AS_DCP.h> @@ -71,13 +71,7 @@ using boost::optional; using namespace dcp; -SubtitleAsset::SubtitleAsset () -{ - -} - - -SubtitleAsset::SubtitleAsset (boost::filesystem::path file) +TextAsset::TextAsset (boost::filesystem::path file) : Asset (file) { @@ -133,8 +127,8 @@ optional_number_attribute (xmlpp::Element const * node, string name) } -SubtitleAsset::ParseState -SubtitleAsset::font_node_state (xmlpp::Element const * node, Standard standard) const +TextAsset::ParseState +TextAsset::font_node_state (xmlpp::Element const * node, Standard standard) const { ParseState ps; @@ -169,7 +163,7 @@ SubtitleAsset::font_node_state (xmlpp::Element const * node, Standard standard) } void -SubtitleAsset::position_align (SubtitleAsset::ParseState& ps, xmlpp::Element const * node) const +TextAsset::position_align (TextAsset::ParseState& ps, xmlpp::Element const * node) const { auto hp = optional_number_attribute<float> (node, "HPosition"); if (!hp) { @@ -210,8 +204,8 @@ SubtitleAsset::position_align (SubtitleAsset::ParseState& ps, xmlpp::Element con } -SubtitleAsset::ParseState -SubtitleAsset::text_node_state (xmlpp::Element const * node) const +TextAsset::ParseState +TextAsset::text_node_state (xmlpp::Element const * node) const { ParseState ps; @@ -228,8 +222,8 @@ SubtitleAsset::text_node_state (xmlpp::Element const * node) const } -SubtitleAsset::ParseState -SubtitleAsset::image_node_state (xmlpp::Element const * node) const +TextAsset::ParseState +TextAsset::image_node_state (xmlpp::Element const * node) const { ParseState ps; @@ -241,8 +235,8 @@ SubtitleAsset::image_node_state (xmlpp::Element const * node) const } -SubtitleAsset::ParseState -SubtitleAsset::subtitle_node_state (xmlpp::Element const * node, optional<int> tcr) const +TextAsset::ParseState +TextAsset::subtitle_node_state (xmlpp::Element const * node, optional<int> tcr) const { ParseState ps; ps.in = Time (string_attribute(node, "TimeIn"), tcr); @@ -254,7 +248,7 @@ SubtitleAsset::subtitle_node_state (xmlpp::Element const * node, optional<int> t Time -SubtitleAsset::fade_time (xmlpp::Element const * node, string name, optional<int> tcr) const +TextAsset::fade_time (xmlpp::Element const * node, string name, optional<int> tcr) const { auto const u = optional_string_attribute(node, name).get_value_or (""); Time t; @@ -276,7 +270,7 @@ SubtitleAsset::fade_time (xmlpp::Element const * node, string name, optional<int void -SubtitleAsset::parse_subtitles (xmlpp::Element const * node, vector<ParseState>& state, optional<int> tcr, Standard standard) +TextAsset::parse_texts(xmlpp::Element const * node, vector<ParseState>& state, optional<int> tcr, Standard standard) { if (node->get_name() == "Font") { state.push_back (font_node_state (node, standard)); @@ -366,7 +360,7 @@ SubtitleAsset::parse_subtitles (xmlpp::Element const * node, vector<ParseState>& /* Handle actual content e.g. text */ auto const v = dynamic_cast<xmlpp::ContentNode const *>(i); if (v) { - maybe_add_subtitle (v->get_content(), state, space_before, standard, rubies); + maybe_add_text(v->get_content(), state, space_before, standard, rubies); space_before = 0; } @@ -383,7 +377,7 @@ SubtitleAsset::parse_subtitles (xmlpp::Element const * node, vector<ParseState>& } space_before += raw_convert<float>(size); } else if (e->get_name() != "Ruby") { - parse_subtitles (e, state, tcr, standard); + parse_texts(e, state, tcr, standard); } } } @@ -393,7 +387,7 @@ SubtitleAsset::parse_subtitles (xmlpp::Element const * node, vector<ParseState>& void -SubtitleAsset::maybe_add_subtitle( +TextAsset::maybe_add_text( string text, vector<ParseState> const & parse_state, float space_before, @@ -474,7 +468,7 @@ SubtitleAsset::maybe_add_subtitle( } if (!ps.in || !ps.out) { - /* We're not in a <Subtitle> node; just ignore this content */ + /* We're not in a <Text> node; just ignore this content */ return; } @@ -482,8 +476,8 @@ SubtitleAsset::maybe_add_subtitle( switch (ps.type.get()) { case ParseState::Type::TEXT: - _subtitles.push_back ( - make_shared<SubtitleString>( + _texts.push_back( + make_shared<TextString>( ps.font_id, ps.italic.get_value_or (false), ps.bold.get_value_or (false), @@ -531,7 +525,7 @@ SubtitleAsset::maybe_add_subtitle( } /* Add a subtitle with no image data and we'll fill that in later */ - _subtitles.push_back ( + _texts.push_back( make_shared<SubtitleImage>( ArrayData(), text, @@ -552,22 +546,22 @@ SubtitleAsset::maybe_add_subtitle( } -vector<shared_ptr<const Subtitle>> -SubtitleAsset::subtitles () const +vector<shared_ptr<const Text>> +TextAsset::texts() const { - vector<shared_ptr<const Subtitle>> s; - for (auto i: _subtitles) { + vector<shared_ptr<const Text>> s; + for (auto i: _texts) { s.push_back (i); } return s; } -vector<shared_ptr<const Subtitle>> -SubtitleAsset::subtitles_during (Time from, Time to, bool starting) const +vector<shared_ptr<const Text>> +TextAsset::texts_during(Time from, Time to, bool starting) const { - vector<shared_ptr<const Subtitle>> s; - for (auto i: _subtitles) { + vector<shared_ptr<const Text>> s; + for (auto i: _texts) { if ((starting && from <= i->in() && i->in() < to) || (!starting && i->out() >= from && i->in() <= to)) { s.push_back (i); } @@ -578,17 +572,17 @@ SubtitleAsset::subtitles_during (Time from, Time to, bool starting) const void -SubtitleAsset::add (shared_ptr<Subtitle> s) +TextAsset::add(shared_ptr<Text> s) { - _subtitles.push_back (s); + _texts.push_back (s); } Time -SubtitleAsset::latest_subtitle_out () const +TextAsset::latest_text_out() const { Time t; - for (auto i: _subtitles) { + for (auto i: _texts) { if (i->out() > t) { t = i->out (); } @@ -599,30 +593,30 @@ SubtitleAsset::latest_subtitle_out () const bool -SubtitleAsset::equals(shared_ptr<const Asset> other_asset, EqualityOptions const& options, NoteHandler note) const +TextAsset::equals(shared_ptr<const Asset> other_asset, EqualityOptions const& options, NoteHandler note) const { if (!Asset::equals (other_asset, options, note)) { return false; } - auto other = dynamic_pointer_cast<const SubtitleAsset> (other_asset); + auto other = dynamic_pointer_cast<const TextAsset> (other_asset); if (!other) { return false; } - if (_subtitles.size() != other->_subtitles.size()) { - note (NoteType::ERROR, String::compose("different number of subtitles: %1 vs %2", _subtitles.size(), other->_subtitles.size())); + if (_texts.size() != other->_texts.size()) { + note(NoteType::ERROR, String::compose("different number of subtitles / closed captions: %1 vs %2", _texts.size(), other->_texts.size())); return false; } - auto i = _subtitles.begin(); - auto j = other->_subtitles.begin(); + auto i = _texts.begin(); + auto j = other->_texts.begin(); - while (i != _subtitles.end()) { - auto string_i = dynamic_pointer_cast<SubtitleString> (*i); - auto string_j = dynamic_pointer_cast<SubtitleString> (*j); - auto image_i = dynamic_pointer_cast<SubtitleImage> (*i); - auto image_j = dynamic_pointer_cast<SubtitleImage> (*j); + while (i != _texts.end()) { + auto string_i = dynamic_pointer_cast<TextString> (*i); + auto string_j = dynamic_pointer_cast<TextString> (*j); + auto image_i = dynamic_pointer_cast<SubtitleImage>(*i); + auto image_j = dynamic_pointer_cast<SubtitleImage>(*j); if ((string_i && !string_j) || (image_i && !image_j)) { note (NoteType::ERROR, "subtitles differ: string vs. image"); @@ -645,9 +639,9 @@ SubtitleAsset::equals(shared_ptr<const Asset> other_asset, EqualityOptions const } -struct SubtitleSorter +struct TextSorter { - bool operator() (shared_ptr<Subtitle> a, shared_ptr<Subtitle> b) { + bool operator() (shared_ptr<Text> a, shared_ptr<Text> b) { if (a->in() != b->in()) { return a->in() < b->in(); } @@ -660,7 +654,7 @@ struct SubtitleSorter void -SubtitleAsset::pull_fonts (shared_ptr<order::Part> part) +TextAsset::pull_fonts(shared_ptr<order::Part> part) { if (part->children.empty ()) { return; @@ -724,12 +718,12 @@ SubtitleAsset::pull_fonts (shared_ptr<order::Part> part) * class because the differences between the two are fairly subtle. */ void -SubtitleAsset::subtitles_as_xml (xmlpp::Element* xml_root, int time_code_rate, Standard standard) const +TextAsset::texts_as_xml(xmlpp::Element* xml_root, int time_code_rate, Standard standard) const { - auto sorted = _subtitles; - std::stable_sort(sorted.begin(), sorted.end(), SubtitleSorter()); + auto sorted = _texts; + std::stable_sort(sorted.begin(), sorted.end(), TextSorter()); - /* Gather our subtitles into a hierarchy of Subtitle/Text/String objects, writing + /* Gather our subtitles into a hierarchy of Text/Text/String objects, writing font information into the bottom level (String) objects. */ @@ -766,7 +760,7 @@ SubtitleAsset::subtitles_as_xml (xmlpp::Element* xml_root, int time_code_rate, S text.reset (); } - auto is = dynamic_pointer_cast<SubtitleString>(i); + auto is = dynamic_pointer_cast<TextString>(i); if (is) { if (!text || last_h_align != is->h_align() || @@ -824,7 +818,7 @@ SubtitleAsset::subtitles_as_xml (xmlpp::Element* xml_root, int time_code_rate, S map<string, ArrayData> -SubtitleAsset::font_data () const +TextAsset::font_data() const { map<string, ArrayData> out; for (auto const& i: _fonts) { @@ -835,7 +829,7 @@ SubtitleAsset::font_data () const map<string, boost::filesystem::path> -SubtitleAsset::font_filenames () const +TextAsset::font_filenames() const { map<string, boost::filesystem::path> out; for (auto const& i: _fonts) { @@ -852,7 +846,7 @@ SubtitleAsset::font_filenames () const * (see DCP-o-matic bug #1689). */ void -SubtitleAsset::fix_empty_font_ids () +TextAsset::fix_empty_font_ids() { bool have_empty = false; vector<string> ids; @@ -876,8 +870,8 @@ SubtitleAsset::fix_empty_font_ids () } } - for (auto i: _subtitles) { - auto j = dynamic_pointer_cast<SubtitleString> (i); + for (auto i: _texts) { + auto j = dynamic_pointer_cast<TextString> (i); if (j && j->font() && j->font().get() == "") { j->set_font (empty_id); } @@ -965,7 +959,7 @@ format_xml_node (xmlpp::Node const* node, State& state) * to get all namespaces with the libxml++ API. */ string -SubtitleAsset::format_xml(xmlpp::Document const& document, optional<pair<string, string>> xml_namespace) +TextAsset::format_xml(xmlpp::Document const& document, optional<pair<string, string>> xml_namespace) { auto root = document.get_root_node(); @@ -997,7 +991,7 @@ SubtitleAsset::format_xml(xmlpp::Document const& document, optional<pair<string, void -SubtitleAsset::ensure_font(string load_id, dcp::ArrayData data) +TextAsset::ensure_font(string load_id, dcp::ArrayData data) { if (std::find_if(_fonts.begin(), _fonts.end(), [load_id](Font const& font) { return font.load_id == load_id; }) == _fonts.end()) { add_font(load_id, data); diff --git a/src/subtitle_asset.h b/src/text_asset.h index 25758c2e..c8422c3d 100644 --- a/src/subtitle_asset.h +++ b/src/text_asset.h @@ -32,20 +32,20 @@ */ -/** @file src/subtitle_asset.h - * @brief SubtitleAsset class +/** @file src/text_asset.h + * @brief TextAsset class */ -#ifndef LIBDCP_SUBTITLE_ASSET_H -#define LIBDCP_SUBTITLE_ASSET_H +#ifndef LIBDCP_TEXT_ASSET_H +#define LIBDCP_TEXT_ASSET_H #include "array_data.h" #include "asset.h" #include "dcp_time.h" -#include "subtitle_standard.h" -#include "subtitle_string.h" +#include "text_standard.h" +#include "text_string.h" #include <libcxml/cxml.h> #include <boost/shared_array.hpp> #include <map> @@ -70,7 +70,7 @@ struct pull_fonts_test3; namespace dcp { -class SubtitleString; +class TextString; class SubtitleImage; class FontNode; class TextNode; @@ -85,19 +85,19 @@ namespace order { } -/** @class SubtitleAsset - * @brief A parent for classes representing a file containing subtitles +/** @class TextAsset + * @brief A parent for classes representing a file containing subtitles or closed captions * - * This class holds a list of Subtitle objects which it can extract + * This class holds a list of Text objects which it can extract * from the appropriate part of either an Interop or SMPTE XML file. - * Its subclasses InteropSubtitleAsset and SMPTESubtitleAsset handle the + * Its subclasses InteropTextAsset and SMPTETextAsset handle the * differences between the two types. */ -class SubtitleAsset : public Asset +class TextAsset : public Asset { public: - SubtitleAsset (); - explicit SubtitleAsset (boost::filesystem::path file); + TextAsset() = default; + explicit TextAsset(boost::filesystem::path file); bool equals ( std::shared_ptr<const Asset>, @@ -105,10 +105,10 @@ public: NoteHandler note ) const override; - std::vector<std::shared_ptr<const Subtitle>> subtitles_during (Time from, Time to, bool starting) const; - std::vector<std::shared_ptr<const Subtitle>> subtitles () const; + std::vector<std::shared_ptr<const Text>> texts_during(Time from, Time to, bool starting) const; + std::vector<std::shared_ptr<const Text>> texts() const; - virtual void add (std::shared_ptr<Subtitle>); + virtual void add(std::shared_ptr<Text>); virtual void add_font (std::string id, dcp::ArrayData data) = 0; void ensure_font(std::string id, dcp::ArrayData data); std::map<std::string, ArrayData> font_data () const; @@ -117,7 +117,7 @@ public: virtual void write (boost::filesystem::path) const = 0; virtual std::string xml_as_string () const = 0; - Time latest_subtitle_out () const; + Time latest_text_out() const; void fix_empty_font_ids (); @@ -133,7 +133,7 @@ public: return _raw_xml; } - virtual SubtitleStandard subtitle_standard() const = 0; + virtual TextStandard text_standard() const = 0; static std::string format_xml(xmlpp::Document const& document, boost::optional<std::pair<std::string, std::string>> xml_namespace); @@ -169,7 +169,7 @@ protected: float space_before = 0; }; - void parse_subtitles (xmlpp::Element const * node, std::vector<ParseState>& state, boost::optional<int> tcr, Standard standard); + void parse_texts(xmlpp::Element const * node, std::vector<ParseState>& state, boost::optional<int> tcr, Standard standard); ParseState font_node_state (xmlpp::Element const * node, Standard standard) const; ParseState text_node_state (xmlpp::Element const * node) const; ParseState image_node_state (xmlpp::Element const * node) const; @@ -177,10 +177,10 @@ protected: Time fade_time (xmlpp::Element const * node, std::string name, boost::optional<int> tcr) const; void position_align (ParseState& ps, xmlpp::Element const * node) const; - void subtitles_as_xml (xmlpp::Element* root, int time_code_rate, Standard standard) const; + void texts_as_xml(xmlpp::Element* root, int time_code_rate, Standard standard) const; - /** All our subtitles, in no particular order */ - std::vector<std::shared_ptr<Subtitle>> _subtitles; + /** All our subtitles / closed captions, in no particular order */ + std::vector<std::shared_ptr<Text>> _texts; class Font { @@ -216,7 +216,7 @@ private: friend struct ::pull_fonts_test2; friend struct ::pull_fonts_test3; - void maybe_add_subtitle( + void maybe_add_text( std::string text, std::vector<ParseState> const & parse_state, float space_before, diff --git a/src/subtitle_asset_internal.cc b/src/text_asset_internal.cc index 99d8411b..58a2553e 100644 --- a/src/subtitle_asset_internal.cc +++ b/src/text_asset_internal.cc @@ -32,24 +32,24 @@ */ -/** @file src/subtitle_asset_internal.cc - * @brief Internal SubtitleAsset helpers +/** @file src/text_asset_internal.cc + * @brief Internal TextAsset helpers */ -#include "subtitle_asset_internal.h" -#include "subtitle_string.h" +#include "text_asset_internal.h" +#include "text_string.h" #include "compose.hpp" #include <cmath> -using std::string; using std::map; using std::shared_ptr; +using std::string; using namespace dcp; -order::Font::Font (shared_ptr<SubtitleString> s, Standard standard) +order::Font::Font(shared_ptr<TextString> s, Standard standard) { if (s->font()) { if (standard == Standard::SMPTE) { diff --git a/src/subtitle_asset_internal.h b/src/text_asset_internal.h index 557db2e4..84915172 100644 --- a/src/subtitle_asset_internal.h +++ b/src/text_asset_internal.h @@ -32,13 +32,13 @@ */ -/** @file src/subtitle_asset_internal.h - * @brief Internal SubtitleAsset helpers +/** @file src/text_asset_internal.h + * @brief Internal TextAsset helpers */ -#ifndef LIBDCP_SUBTITLE_ASSET_INTERNAL_H -#define LIBDCP_SUBTITLE_ASSET_INTERNAL_H +#ifndef LIBDCP_TEXT_ASSET_INTERNAL_H +#define LIBDCP_TEXT_ASSET_INTERNAL_H #include "array_data.h" @@ -63,7 +63,7 @@ namespace dcp { class Ruby; -class SubtitleString; +class TextString; namespace order { @@ -82,7 +82,7 @@ class Font public: Font () {} - Font (std::shared_ptr<SubtitleString> s, Standard standard); + Font(std::shared_ptr<TextString> s, Standard standard); xmlpp::Element* as_xml (xmlpp::Element* parent, Context& context) const; diff --git a/src/subtitle_standard.cc b/src/text_standard.cc index 101f84d4..5582b79f 100644 --- a/src/subtitle_standard.cc +++ b/src/text_standard.cc @@ -32,26 +32,26 @@ */ -#include "subtitle_standard.h" +#include "text_standard.h" using namespace dcp; bool -dcp::uses_baseline(SubtitleStandard standard) +dcp::uses_baseline(TextStandard standard) { - return standard == SubtitleStandard::INTEROP || standard == SubtitleStandard::SMPTE_2014; + return standard == TextStandard::INTEROP || standard == TextStandard::SMPTE_2014; } bool -dcp::uses_bounding_box(SubtitleStandard standard) +dcp::uses_bounding_box(TextStandard standard) { /* I didn't check the 2007 version but I am assuming they didn't start out using Interop-style * then change their mind to bounding-box and then change it back again. */ - return standard == SubtitleStandard::SMPTE_2007 || standard == SubtitleStandard::SMPTE_2010; + return standard == TextStandard::SMPTE_2007 || standard == TextStandard::SMPTE_2010; } diff --git a/src/subtitle_standard.h b/src/text_standard.h index 95972e20..1d146034 100644 --- a/src/subtitle_standard.h +++ b/src/text_standard.h @@ -32,14 +32,14 @@ */ -#ifndef LIBDCP_SUBTITLE_STANDARD_H -#define LIBDCP_SUBTITLE_STANDARD_H +#ifndef LIBDCP_TEXT_STANDARD_H +#define LIBDCP_TEXT_STANDARD_H namespace dcp { -enum class SubtitleStandard { +enum class TextStandard { INTEROP, SMPTE_2007, SMPTE_2010, @@ -47,8 +47,8 @@ enum class SubtitleStandard { }; -bool uses_baseline(SubtitleStandard standard); -bool uses_bounding_box(SubtitleStandard standard); +bool uses_baseline(TextStandard standard); +bool uses_bounding_box(TextStandard standard); } diff --git a/src/subtitle_string.cc b/src/text_string.cc index af61d928..411829ef 100644 --- a/src/subtitle_string.cc +++ b/src/text_string.cc @@ -38,7 +38,7 @@ #include "compose.hpp" -#include "subtitle_string.h" +#include "text_string.h" #include "xml.h" #include <cmath> @@ -54,7 +54,7 @@ using boost::optional; using namespace dcp; -SubtitleString::SubtitleString ( +TextString::TextString( optional<string> font, bool italic, bool bold, @@ -78,7 +78,7 @@ SubtitleString::SubtitleString ( float space_before, vector<Ruby> rubies ) - : Subtitle(in, out, h_position, h_align, v_position, v_align, z_position, fade_up_time, fade_down_time) + : Text(in, out, h_position, h_align, v_position, v_align, z_position, fade_up_time, fade_down_time) , _font (font) , _italic (italic) , _bold (bold) @@ -98,7 +98,7 @@ SubtitleString::SubtitleString ( float -SubtitleString::size_in_pixels (int screen_height) const +TextString::size_in_pixels (int screen_height) const { /* Size in the subtitle file is given in points as if the screen height is 11 inches, so a 72pt font would be 1/11th of the screen @@ -110,7 +110,7 @@ SubtitleString::size_in_pixels (int screen_height) const bool -dcp::operator== (SubtitleString const & a, SubtitleString const & b) +dcp::operator==(TextString const & a, TextString const & b) { return ( a.font() == b.font() && @@ -140,14 +140,14 @@ dcp::operator== (SubtitleString const & a, SubtitleString const & b) bool -dcp::operator!= (SubtitleString const & a, SubtitleString const & b) +dcp::operator!=(TextString const & a, TextString const & b) { return !(a == b); } ostream& -dcp::operator<< (ostream& s, SubtitleString const & sub) +dcp::operator<<(ostream& s, TextString const & sub) { s << "\n`" << sub.text() << "' from " << sub.in() << " to " << sub.out() << ";\n" << "fade up " << sub.fade_up_time() << ", fade down " << sub.fade_down_time() << ";\n" @@ -188,13 +188,13 @@ dcp::operator<< (ostream& s, SubtitleString const & sub) bool -SubtitleString::equals(shared_ptr<const Subtitle> other_sub, EqualityOptions const& options, NoteHandler note) const +TextString::equals(shared_ptr<const Text> other_sub, EqualityOptions const& options, NoteHandler note) const { - if (!Subtitle::equals(other_sub, options, note)) { + if (!Text::equals(other_sub, options, note)) { return false; } - auto other = dynamic_pointer_cast<const SubtitleString>(other_sub); + auto other = dynamic_pointer_cast<const TextString>(other_sub); if (!other) { note(NoteType::ERROR, "Subtitle types differ: string vs image"); return false; diff --git a/src/subtitle_string.h b/src/text_string.h index 1ef57ff2..180a8b7b 100644 --- a/src/subtitle_string.h +++ b/src/text_string.h @@ -32,18 +32,18 @@ */ -/** @file src/subtitle_string.h - * @brief SubtitleString class +/** @file src/text_string.h + * @brief TextString class */ -#ifndef LIBDCP_SUBTITLE_STRING_H -#define LIBDCP_SUBTITLE_STRING_H +#ifndef LIBDCP_TEXT_STRING_H +#define LIBDCP_TEXT_STRING_H #include "dcp_time.h" #include "ruby.h" -#include "subtitle.h" +#include "text.h" #include <boost/optional.hpp> #include <string> @@ -51,10 +51,10 @@ namespace dcp { -/** @class SubtitleString - * @brief A single line of subtitle text with all the associated attributes. +/** @class TextString + * @brief A single line of subtitle or closed caption text with all the associated attributes. */ -class SubtitleString : public Subtitle +class TextString : public Text { public: /** @param font Font ID, or empty to use the default @@ -80,7 +80,7 @@ public: * @param fade_down_time Time to fade the text out * @param space_before Space to add before this string, in ems (could be negative to remove space). */ - SubtitleString ( + TextString( boost::optional<std::string> font, bool italic, bool bold, @@ -200,7 +200,7 @@ public: _rubies = std::move(rubies); } - bool equals(std::shared_ptr<const dcp::Subtitle> other_sub, EqualityOptions const& options, NoteHandler node) const override; + bool equals(std::shared_ptr<const dcp::Text> other_sub, EqualityOptions const& options, NoteHandler node) const override; private: /** font ID */ @@ -226,9 +226,9 @@ private: std::vector<Ruby> _rubies; }; -bool operator== (SubtitleString const & a, SubtitleString const & b); -bool operator!= (SubtitleString const & a, SubtitleString const & b); -std::ostream& operator<< (std::ostream& s, SubtitleString const & sub); +bool operator==(TextString const & a, TextString const & b); +bool operator!=(TextString const & a, TextString const & b); +std::ostream& operator<<(std::ostream& s, TextString const & sub); } diff --git a/src/verify.cc b/src/verify.cc index 960f0438..4e9c29c3 100644 --- a/src/verify.cc +++ b/src/verify.cc @@ -42,7 +42,7 @@ #include "dcp.h" #include "exceptions.h" #include "filesystem.h" -#include "interop_subtitle_asset.h" +#include "interop_text_asset.h" #include "mono_picture_asset.h" #include "mono_picture_frame.h" #include "raw_convert.h" @@ -54,7 +54,7 @@ #include "reel_sound_asset.h" #include "reel_smpte_subtitle_asset.h" #include "reel_subtitle_asset.h" -#include "smpte_subtitle_asset.h" +#include "smpte_text_asset.h" #include "stereo_picture_asset.h" #include "stereo_picture_frame.h" #include "verify.h" @@ -670,7 +670,7 @@ verify_closed_caption_reel (shared_ptr<const ReelClosedCaptionAsset> reel_asset, /** Verify stuff that is common to both subtitles and closed captions */ void verify_smpte_timed_text_asset ( - shared_ptr<const SMPTESubtitleAsset> asset, + shared_ptr<const SMPTETextAsset> asset, optional<int64_t> reel_asset_duration, vector<VerificationNote>& notes ) @@ -720,9 +720,9 @@ verify_smpte_timed_text_asset ( /** Verify Interop subtitle / CCAP stuff */ void -verify_interop_text_asset(shared_ptr<const InteropSubtitleAsset> asset, vector<VerificationNote>& notes) +verify_interop_text_asset(shared_ptr<const InteropTextAsset> asset, vector<VerificationNote>& notes) { - if (asset->subtitles().empty()) { + if (asset->texts().empty()) { notes.push_back({VerificationNote::Type::ERROR, VerificationNote::Code::MISSING_SUBTITLE, asset->id(), asset->file().get() }); } auto const unresolved = asset->unresolved_fonts(); @@ -735,7 +735,7 @@ verify_interop_text_asset(shared_ptr<const InteropSubtitleAsset> asset, vector<V /** Verify SMPTE subtitle-only stuff */ void verify_smpte_subtitle_asset ( - shared_ptr<const SMPTESubtitleAsset> asset, + shared_ptr<const SMPTETextAsset> asset, vector<VerificationNote>& notes, State& state ) @@ -778,7 +778,7 @@ verify_smpte_subtitle_asset ( /** Verify all subtitle stuff */ static void verify_subtitle_asset ( - shared_ptr<const SubtitleAsset> asset, + shared_ptr<const TextAsset> asset, optional<int64_t> reel_asset_duration, function<void (string, optional<boost::filesystem::path>)> stage, boost::filesystem::path xsd_dtd_directory, @@ -787,7 +787,7 @@ verify_subtitle_asset ( ) { stage ("Checking subtitle XML", asset->file()); - /* Note: we must not use SubtitleAsset::xml_as_string() here as that will mean the data on disk + /* Note: we must not use TextAsset::xml_as_string() here as that will mean the data on disk * gets passed through libdcp which may clean up and therefore hide errors. */ if (asset->raw_xml()) { @@ -796,7 +796,7 @@ verify_subtitle_asset ( notes.push_back ({VerificationNote::Type::WARNING, VerificationNote::Code::MISSED_CHECK_OF_ENCRYPTED}); } - auto namespace_count = [](shared_ptr<const SubtitleAsset> asset, string root_node) { + auto namespace_count = [](shared_ptr<const TextAsset> asset, string root_node) { cxml::Document doc(root_node); doc.read_string(asset->raw_xml().get()); auto root = dynamic_cast<xmlpp::Element*>(doc.node())->cobj(); @@ -807,7 +807,7 @@ verify_subtitle_asset ( return count; }; - auto interop = dynamic_pointer_cast<const InteropSubtitleAsset>(asset); + auto interop = dynamic_pointer_cast<const InteropTextAsset>(asset); if (interop) { verify_interop_text_asset(interop, notes); if (namespace_count(asset, "DCSubtitle") > 1) { @@ -815,7 +815,7 @@ verify_subtitle_asset ( } } - auto smpte = dynamic_pointer_cast<const SMPTESubtitleAsset>(asset); + auto smpte = dynamic_pointer_cast<const SMPTETextAsset>(asset); if (smpte) { verify_smpte_timed_text_asset (smpte, reel_asset_duration, notes); verify_smpte_subtitle_asset (smpte, notes, state); @@ -830,7 +830,7 @@ verify_subtitle_asset ( /** Verify all closed caption stuff */ static void verify_closed_caption_asset ( - shared_ptr<const SubtitleAsset> asset, + shared_ptr<const TextAsset> asset, optional<int64_t> reel_asset_duration, function<void (string, optional<boost::filesystem::path>)> stage, boost::filesystem::path xsd_dtd_directory, @@ -838,7 +838,7 @@ verify_closed_caption_asset ( ) { stage ("Checking closed caption XML", asset->file()); - /* Note: we must not use SubtitleAsset::xml_as_string() here as that will mean the data on disk + /* Note: we must not use TextAsset::xml_as_string() here as that will mean the data on disk * gets passed through libdcp which may clean up and therefore hide errors. */ auto raw_xml = asset->raw_xml(); @@ -851,12 +851,12 @@ verify_closed_caption_asset ( notes.push_back ({VerificationNote::Type::WARNING, VerificationNote::Code::MISSED_CHECK_OF_ENCRYPTED}); } - auto interop = dynamic_pointer_cast<const InteropSubtitleAsset>(asset); + auto interop = dynamic_pointer_cast<const InteropTextAsset>(asset); if (interop) { verify_interop_text_asset(interop, notes); } - auto smpte = dynamic_pointer_cast<const SMPTESubtitleAsset>(asset); + auto smpte = dynamic_pointer_cast<const SMPTETextAsset>(asset); if (smpte) { verify_smpte_timed_text_asset (smpte, reel_asset_duration, notes); } @@ -1161,7 +1161,7 @@ struct LinesCharactersResult static void verify_text_lines_and_characters ( - shared_ptr<SubtitleAsset> asset, + shared_ptr<TextAsset> asset, int warning_length, int error_length, LinesCharactersResult* result @@ -1189,7 +1189,7 @@ verify_text_lines_and_characters ( vector<shared_ptr<Event>> events; - auto position = [](shared_ptr<const SubtitleString> sub) { + auto position = [](shared_ptr<const TextString> sub) { switch (sub->v_align()) { case VAlign::TOP: return lrintf(sub->v_position() * 100); @@ -1202,8 +1202,8 @@ verify_text_lines_and_characters ( return 0L; }; - for (auto j: asset->subtitles()) { - auto text = dynamic_pointer_cast<const SubtitleString>(j); + for (auto j: asset->texts()) { + auto text = dynamic_pointer_cast<const TextString>(j); if (text) { auto in = make_shared<Event>(text->in(), position(text), text->text().length()); events.push_back(in); diff --git a/src/wscript b/src/wscript index 3bc8537b..6a2ad9c2 100644 --- a/src/wscript +++ b/src/wscript @@ -64,7 +64,7 @@ def build(bld): h_align.cc identity_transfer_function.cc interop_load_font_node.cc - interop_subtitle_asset.cc + interop_text_asset.cc j2k_transcode.cc key.cc language_tag.cc @@ -105,19 +105,19 @@ def build(bld): s_gamut3_transfer_function.cc search.cc smpte_load_font_node.cc - smpte_subtitle_asset.cc + smpte_text_asset.cc sound_asset.cc sound_asset_writer.cc sound_frame.cc stereo_picture_asset.cc stereo_picture_asset_writer.cc stereo_picture_frame.cc - subtitle.cc - subtitle_asset.cc - subtitle_asset_internal.cc subtitle_image.cc - subtitle_standard.cc - subtitle_string.cc + text.cc + text_asset.cc + text_asset_internal.cc + text_standard.cc + text_string.cc transfer_function.cc types.cc utc_offset.cc @@ -166,7 +166,7 @@ def build(bld): h_align.h identity_transfer_function.h interop_load_font_node.h - interop_subtitle_asset.h + interop_text_asset.h j2k_transcode.h key.h language_tag.h @@ -202,15 +202,15 @@ def build(bld): reel_picture_asset.h reel_sound_asset.h reel_smpte_closed_caption_asset.h - reel_smpte_subtitle_asset.h + reel_smpte_text_asset.h reel_stereo_picture_asset.h - reel_subtitle_asset.h + reel_text_asset.h ref.h ruby.h s_gamut3_transfer_function.h search.h smpte_load_font_node.h - smpte_subtitle_asset.h + smpte_text_asset.h sound_frame.h sound_asset.h sound_asset_reader.h @@ -219,11 +219,11 @@ def build(bld): stereo_picture_asset_reader.h stereo_picture_asset_writer.h stereo_picture_frame.h - subtitle.h - subtitle_asset.h subtitle_image.h - subtitle_standard.h - subtitle_string.h + text.h + text_asset.h + text_standard.h + text_string.h transfer_function.h types.h utc_offset.h |
