diff options
| author | Carl Hetherington <cth@carlh.net> | 2021-04-12 00:20:44 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2021-04-12 01:22:10 +0200 |
| commit | 2fa5b7bfeb3826c20f2fe80f272b556d61935063 (patch) | |
| tree | 20ff8625f91de07ee48411fed91caa941d5dd09e /src | |
| parent | 2c5e61891e7975f4c2d33a5f2ed144645e3078f9 (diff) | |
Split ReelClosedCaptionAsset into Interop and SMPTE parts.
Diffstat (limited to 'src')
| -rw-r--r-- | src/cpl.cc | 4 | ||||
| -rw-r--r-- | src/reel.cc | 31 | ||||
| -rw-r--r-- | src/reel_asset.cc | 6 | ||||
| -rw-r--r-- | src/reel_asset.h | 2 | ||||
| -rw-r--r-- | src/reel_atmos_asset.cc | 2 | ||||
| -rw-r--r-- | src/reel_atmos_asset.h | 8 | ||||
| -rw-r--r-- | src/reel_closed_caption_asset.cc | 59 | ||||
| -rw-r--r-- | src/reel_closed_caption_asset.h | 18 | ||||
| -rw-r--r-- | src/reel_interop_closed_caption_asset.cc | 85 | ||||
| -rw-r--r-- | src/reel_interop_closed_caption_asset.h | 73 | ||||
| -rw-r--r-- | src/reel_smpte_closed_caption_asset.cc | 93 | ||||
| -rw-r--r-- | src/reel_smpte_closed_caption_asset.h | 79 | ||||
| -rw-r--r-- | src/wscript | 5 |
13 files changed, 372 insertions, 93 deletions
@@ -555,7 +555,9 @@ add_encryptable_assets (vector<shared_ptr<T>>& assets, vector<shared_ptr<Reel>> } } for (auto j: i->closed_captions()) { - assets.push_back (j); + if (auto enc = dynamic_pointer_cast<ReelEncryptableAsset>(j)) { + assets.push_back (enc); + } } if (i->atmos ()) { assets.push_back (i->atmos()); diff --git a/src/reel.cc b/src/reel.cc index becac898..4baa2fc9 100644 --- a/src/reel.cc +++ b/src/reel.cc @@ -47,7 +47,9 @@ #include "reel_mono_picture_asset.h" #include "reel_stereo_picture_asset.h" #include "reel_sound_asset.h" +#include "reel_interop_closed_caption_asset.h" #include "reel_interop_subtitle_asset.h" +#include "reel_smpte_closed_caption_asset.h" #include "reel_smpte_subtitle_asset.h" #include "reel_subtitle_asset.h" #include "reel_markers_asset.h" @@ -115,7 +117,14 @@ Reel::Reel (std::shared_ptr<const cxml::Node> node, dcp::Standard standard) closed_captions = asset_list->node_children ("ClosedCaption"); } for (auto i: closed_captions) { - _closed_captions.push_back (make_shared<ReelClosedCaptionAsset>(i)); + switch (standard) { + case Standard::INTEROP: + _closed_captions.push_back (make_shared<ReelInteropClosedCaptionAsset>(i)); + break; + case Standard::SMPTE: + _closed_captions.push_back (make_shared<ReelSMPTEClosedCaptionAsset>(i)); + break; + } } auto atmos = asset_list->optional_node_child ("AuxData"); @@ -265,8 +274,10 @@ Reel::any_encrypted () const { auto ecc = false; for (auto i: _closed_captions) { - if (i->encrypted()) { - ecc = true; + if (auto enc = dynamic_pointer_cast<ReelEncryptableAsset>(i)) { + if (enc->encrypted()) { + ecc = true; + } } } @@ -292,8 +303,10 @@ Reel::all_encrypted () const { auto ecc = true; for (auto i: _closed_captions) { - if (!i->encrypted()) { - ecc = false; + if (auto enc = dynamic_pointer_cast<ReelEncryptableAsset>(i)) { + if (!enc->encrypted()) { + ecc = false; + } } } @@ -334,11 +347,9 @@ Reel::add (DecryptedKDM const & kdm) } } for (auto j: _closed_captions) { - if (i.id() == j->key_id()) { - auto s = dynamic_pointer_cast<SMPTESubtitleAsset> (j->asset()); - if (s) { - s->set_key (i.key()); - } + auto smpte = dynamic_pointer_cast<ReelSMPTESubtitleAsset>(j); + if (smpte && i.id() == smpte->key_id()) { + smpte->smpte_asset()->set_key(i.key()); } } if (_atmos && i.id() == _atmos->key_id()) { diff --git a/src/reel_asset.cc b/src/reel_asset.cc index 0f47e08d..cd54ccba 100644 --- a/src/reel_asset.cc +++ b/src/reel_asset.cc @@ -85,8 +85,8 @@ ReelAsset::write_to_cpl_asset (xmlpp::Node* node, Standard standard, optional<st if (!attr.first.empty ()) { a->set_attribute (attr.first, attr.second); } - auto const ns = cpl_node_namespace (standard); - if (!ns.first.empty ()) { + auto const ns = cpl_node_namespace (); + if (!ns.first.empty()) { a->set_namespace_declaration (ns.first, ns.second); } a->add_child("Id")->add_child_text ("urn:uuid:" + _id); @@ -114,7 +114,7 @@ ReelAsset::cpl_node_attribute (Standard) const pair<string, string> -ReelAsset::cpl_node_namespace (Standard) const +ReelAsset::cpl_node_namespace () const { return make_pair ("", ""); } diff --git a/src/reel_asset.h b/src/reel_asset.h index ba08c267..00355335 100644 --- a/src/reel_asset.h +++ b/src/reel_asset.h @@ -137,7 +137,7 @@ protected: virtual std::pair<std::string, std::string> cpl_node_attribute (Standard) const; /** @return Any namespace that should be used on the asset's node in the CPL */ - virtual std::pair<std::string, std::string> cpl_node_namespace (Standard) const; + virtual std::pair<std::string, std::string> cpl_node_namespace () const; xmlpp::Node* write_to_cpl_asset (xmlpp::Node* node, Standard standard, boost::optional<std::string> hash) const; diff --git a/src/reel_atmos_asset.cc b/src/reel_atmos_asset.cc index bd354bf7..32ebbcf5 100644 --- a/src/reel_atmos_asset.cc +++ b/src/reel_atmos_asset.cc @@ -77,7 +77,7 @@ ReelAtmosAsset::cpl_node_name (Standard) const pair<string, string> -ReelAtmosAsset::cpl_node_namespace (Standard) const +ReelAtmosAsset::cpl_node_namespace () const { return { "http://www.dolby.com/schemas/2012/AD", "axd" }; } diff --git a/src/reel_atmos_asset.h b/src/reel_atmos_asset.h index 1fd6ce49..6f452c3a 100644 --- a/src/reel_atmos_asset.h +++ b/src/reel_atmos_asset.h @@ -65,13 +65,13 @@ public: return asset_of_type<AtmosAsset> (); } - xmlpp::Node* write_to_cpl (xmlpp::Node* node, Standard standard) const; + xmlpp::Node* write_to_cpl (xmlpp::Node* node, Standard standard) const override; bool equals (std::shared_ptr<const ReelAtmosAsset>, EqualityOptions, NoteHandler) const; private: - std::string key_type () const; - std::string cpl_node_name (Standard standard) const; - std::pair<std::string, std::string> cpl_node_namespace (Standard) const; + std::string key_type () const override; + 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_closed_caption_asset.cc b/src/reel_closed_caption_asset.cc index b751efaf..a29d6e37 100644 --- a/src/reel_closed_caption_asset.cc +++ b/src/reel_closed_caption_asset.cc @@ -56,7 +56,6 @@ using namespace dcp; ReelClosedCaptionAsset::ReelClosedCaptionAsset (std::shared_ptr<SubtitleAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point) : ReelAsset (asset->id(), edit_rate, intrinsic_duration, entry_point) , ReelFileAsset (asset) - , ReelEncryptableAsset (dynamic_pointer_cast<SMPTESubtitleAsset>(asset) ? dynamic_pointer_cast<SMPTESubtitleAsset>(asset)->key_id() : optional<string>()) { } @@ -65,66 +64,8 @@ ReelClosedCaptionAsset::ReelClosedCaptionAsset (std::shared_ptr<SubtitleAsset> a ReelClosedCaptionAsset::ReelClosedCaptionAsset (std::shared_ptr<const cxml::Node> node) : ReelAsset (node) , ReelFileAsset (node) - , ReelEncryptableAsset (node) { _language = node->optional_string_child ("Language"); - node->done (); -} - - -string -ReelClosedCaptionAsset::cpl_node_name (Standard standard) const -{ - switch (standard) { - case Standard::INTEROP: - return "cc-cpl:MainClosedCaption"; - case Standard::SMPTE: - return "tt:ClosedCaption"; - } - - DCP_ASSERT (false); -} - - -pair<string, string> -ReelClosedCaptionAsset::cpl_node_namespace (Standard standard) const -{ - switch (standard) { - case Standard::INTEROP: - return make_pair ("http://www.digicine.com/PROTO-ASDCP-CC-CPL-20070926#", "cc-cpl"); - case Standard::SMPTE: - return make_pair ("http://www.smpte-ra.org/schemas/429-12/2008/TT", "tt"); - } - - DCP_ASSERT (false); -} - - -string -ReelClosedCaptionAsset::key_type () const -{ - return "MDSK"; -} - - -xmlpp::Node * -ReelClosedCaptionAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const -{ - auto asset = write_to_cpl_asset (node, standard, hash()); - write_to_cpl_encryptable (asset); - - if (_language) { - switch (standard) { - case Standard::INTEROP: - asset->add_child("Language")->add_child_text(*_language); - break; - case Standard::SMPTE: - asset->add_child("Language", "tt")->add_child_text(*_language); - break; - } - } - - return asset; } diff --git a/src/reel_closed_caption_asset.h b/src/reel_closed_caption_asset.h index 80421ca2..44ae83f3 100644 --- a/src/reel_closed_caption_asset.h +++ b/src/reel_closed_caption_asset.h @@ -42,9 +42,9 @@ #include "language_tag.h" -#include "subtitle_asset.h" #include "reel_asset.h" -#include "reel_encryptable_asset.h" +#include "reel_file_asset.h" +#include "subtitle_asset.h" struct verify_invalid_language2; @@ -53,23 +53,19 @@ struct verify_invalid_language2; namespace dcp { -class SubtitleAsset; - - /** @class ReelClosedCaptionAsset * @brief Part of a Reel's description which refers to a closed caption XML/MXF file */ -class ReelClosedCaptionAsset : public ReelAsset, public ReelFileAsset, public ReelEncryptableAsset +class ReelClosedCaptionAsset : public ReelAsset, public ReelFileAsset { public: ReelClosedCaptionAsset (std::shared_ptr<SubtitleAsset> asset, Fraction edit_rate, int64_t instrinsic_duration, int64_t entry_point); explicit ReelClosedCaptionAsset (std::shared_ptr<const cxml::Node>); - xmlpp::Node* write_to_cpl (xmlpp::Node* node, Standard standard) const; bool equals (std::shared_ptr<const ReelClosedCaptionAsset>, EqualityOptions, NoteHandler) const; std::shared_ptr<SubtitleAsset> asset () const { - return asset_of_type<SubtitleAsset> (); + return std::dynamic_pointer_cast<SubtitleAsset>(_asset_ref.asset()); } void set_language (dcp::LanguageTag l) { @@ -84,13 +80,9 @@ public: return _language; } -private: +protected: friend struct ::verify_invalid_language2; - std::string key_type () const; - std::string cpl_node_name (Standard standard) const; - std::pair<std::string, std::string> cpl_node_namespace (Standard standard) const; - boost::optional<std::string> _language; }; diff --git a/src/reel_interop_closed_caption_asset.cc b/src/reel_interop_closed_caption_asset.cc new file mode 100644 index 00000000..0730f77e --- /dev/null +++ b/src/reel_interop_closed_caption_asset.cc @@ -0,0 +1,85 @@ +/* + 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 <libxml++/libxml++.h> + + +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 (); +} + + +xmlpp::Node * +ReelInteropClosedCaptionAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const +{ + auto asset = write_to_cpl_asset (node, standard, hash()); + if (_language) { + asset->add_child("Language")->add_child_text(*_language); + } + + return asset; +} + + +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"); +} + diff --git a/src/reel_interop_closed_caption_asset.h b/src/reel_interop_closed_caption_asset.h new file mode 100644 index 00000000..8031142d --- /dev/null +++ b/src/reel_interop_closed_caption_asset.h @@ -0,0 +1,73 @@ +/* + 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_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 +{ +public: + ReelInteropClosedCaptionAsset (std::shared_ptr<InteropSubtitleAsset> asset, Fraction edit_rate, int64_t instrinsic_duration, int64_t entry_point); + explicit ReelInteropClosedCaptionAsset (std::shared_ptr<const cxml::Node>); + + std::shared_ptr<InteropSubtitleAsset> interop_asset () const { + return std::dynamic_pointer_cast<InteropSubtitleAsset>(asset()); + } + + xmlpp::Node* write_to_cpl (xmlpp::Node* node, Standard standard) const; + +private: + std::string cpl_node_name (Standard) const; + std::pair<std::string, std::string> cpl_node_namespace () const override; +}; + + +}; + + +#endif + diff --git a/src/reel_smpte_closed_caption_asset.cc b/src/reel_smpte_closed_caption_asset.cc new file mode 100644 index 00000000..44125037 --- /dev/null +++ b/src/reel_smpte_closed_caption_asset.cc @@ -0,0 +1,93 @@ +/* + 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 <libxml++/libxml++.h> + + +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) + , ReelEncryptableAsset (asset->key_id()) +{ + +} + + +ReelSMPTEClosedCaptionAsset::ReelSMPTEClosedCaptionAsset (shared_ptr<const cxml::Node> node) + : ReelClosedCaptionAsset (node) + , ReelEncryptableAsset (node) +{ + node->done (); +} + + +xmlpp::Node * +ReelSMPTEClosedCaptionAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const +{ + auto asset = write_to_cpl_asset (node, standard, hash()); + write_to_cpl_encryptable (asset); + + if (_language) { + asset->add_child("Language", "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 new file mode 100644 index 00000000..32fe5117 --- /dev/null +++ b/src/reel_smpte_closed_caption_asset.h @@ -0,0 +1,79 @@ +/* + 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_encryptable_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 ReelEncryptableAsset +{ +public: + ReelSMPTEClosedCaptionAsset (std::shared_ptr<SMPTESubtitleAsset> asset, Fraction edit_rate, int64_t instrinsic_duration, int64_t entry_point); + explicit ReelSMPTEClosedCaptionAsset (std::shared_ptr<const cxml::Node>); + + xmlpp::Node* write_to_cpl (xmlpp::Node* node, Standard standard) const override; + + std::shared_ptr<SMPTESubtitleAsset> smpte_asset () const { + return std::dynamic_pointer_cast<SMPTESubtitleAsset>(asset()); + } + +private: + std::string key_type () const override { + return "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/wscript b/src/wscript index b50966e7..f6e0d15b 100644 --- a/src/wscript +++ b/src/wscript @@ -84,10 +84,12 @@ def build(bld): reel_closed_caption_asset.cc reel_encryptable_asset.cc reel_file_asset.cc + reel_interop_closed_caption_asset.cc reel_interop_subtitle_asset.cc reel_mono_picture_asset.cc reel_picture_asset.cc reel_markers_asset.cc + reel_smpte_closed_caption_asset.cc reel_smpte_subtitle_asset.cc reel_sound_asset.cc reel_stereo_picture_asset.cc @@ -171,14 +173,15 @@ def build(bld): reel.h reel_asset.h reel_atmos_asset.h - reel_closed_caption_asset.h reel_encryptable_asset.h reel_file_asset.h + reel_interop_closed_caption_asset.h reel_interop_subtitle_asset.h reel_markers_asset.h reel_mono_picture_asset.h reel_picture_asset.h reel_sound_asset.h + reel_smpte_closed_caption_asset.h reel_smpte_subtitle_asset.h reel_stereo_picture_asset.h reel_subtitle_asset.h |
