Split ReelClosedCaptionAsset into Interop and SMPTE parts.
authorCarl Hetherington <cth@carlh.net>
Sun, 11 Apr 2021 22:20:44 +0000 (00:20 +0200)
committerCarl Hetherington <cth@carlh.net>
Sun, 11 Apr 2021 23:22:10 +0000 (01:22 +0200)
15 files changed:
src/cpl.cc
src/reel.cc
src/reel_asset.cc
src/reel_asset.h
src/reel_atmos_asset.cc
src/reel_atmos_asset.h
src/reel_closed_caption_asset.cc
src/reel_closed_caption_asset.h
src/reel_interop_closed_caption_asset.cc [new file with mode: 0644]
src/reel_interop_closed_caption_asset.h [new file with mode: 0644]
src/reel_smpte_closed_caption_asset.cc [new file with mode: 0644]
src/reel_smpte_closed_caption_asset.h [new file with mode: 0644]
src/wscript
test/test.cc
test/verify_test.cc

index 3867c238c222033aa727a4dc0a2aea36b219b14c..1257484abf40577e95d3a5c53dd16094a347ab90 100644 (file)
@@ -555,7 +555,9 @@ add_encryptable_assets (vector<shared_ptr<T>>& assets, vector<shared_ptr<Reel>>
                        }
                }
                for (auto j: i->closed_captions()) {
                        }
                }
                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());
                }
                if (i->atmos ()) {
                        assets.push_back (i->atmos());
index becac8983c02b328155adc087c09cfd91f8d00d9..4baa2fc9bfe981283b2e625539b3bf2346200030 100644 (file)
@@ -47,7 +47,9 @@
 #include "reel_mono_picture_asset.h"
 #include "reel_stereo_picture_asset.h"
 #include "reel_sound_asset.h"
 #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_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"
 #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 = 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");
        }
 
        auto atmos = asset_list->optional_node_child ("AuxData");
@@ -265,8 +274,10 @@ Reel::any_encrypted () const
 {
        auto ecc = false;
        for (auto i: _closed_captions) {
 {
        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) {
 {
        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) {
                        }
                }
                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()) {
                        }
                }
                if (_atmos && i.id() == _atmos->key_id()) {
index 0f47e08dc5dc6c37b180c6cf7db31f1cc8b051de..cd54ccba753f43fc93a11fcfb2ecfb2efc185063 100644 (file)
@@ -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);
        }
        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);
                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>
 
 
 pair<string, string>
-ReelAsset::cpl_node_namespace (Standard) const
+ReelAsset::cpl_node_namespace () const
 {
        return make_pair ("", "");
 }
 {
        return make_pair ("", "");
 }
index ba08c267f36585c0ed3623c5db28a25e3d0af665..00355335ec10e716604ad2ba29debe86246690a1 100644 (file)
@@ -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_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;
 
 
        xmlpp::Node* write_to_cpl_asset (xmlpp::Node* node, Standard standard, boost::optional<std::string> hash) const;
 
index bd354bf79f91f9d24374ab3007987658c6526c17..32ebbcf53d12eb376b5f1d3e99909cfdca42a476 100644 (file)
@@ -77,7 +77,7 @@ ReelAtmosAsset::cpl_node_name (Standard) const
 
 
 pair<string, string>
 
 
 pair<string, string>
-ReelAtmosAsset::cpl_node_namespace (Standard) const
+ReelAtmosAsset::cpl_node_namespace () const
 {
        return { "http://www.dolby.com/schemas/2012/AD", "axd" };
 }
 {
        return { "http://www.dolby.com/schemas/2012/AD", "axd" };
 }
index 1fd6ce49c9288a7612d8af497d68458d0304de87..6f452c3a208f7e7d1a80414a315554dbd1a08ffa 100644 (file)
@@ -65,13 +65,13 @@ public:
                return asset_of_type<AtmosAsset> ();
        }
 
                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:
        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;
 };
 
 
 };
 
 
index b751efaf9225fc50ccf8417680ef9739a58c5571..a29d6e3730eda6c94033b251102003e6987f8ca5 100644 (file)
@@ -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)
 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)
 ReelClosedCaptionAsset::ReelClosedCaptionAsset (std::shared_ptr<const cxml::Node> node)
        : ReelAsset (node)
        , ReelFileAsset (node)
-       , ReelEncryptableAsset (node)
 {
        _language = node->optional_string_child ("Language");
 {
        _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;
 }
 
 
 }
 
 
index 80421ca22479295ab8d305fd98a97957b3456688..44ae83f3226e30b4defab566af77da2de1203ef2 100644 (file)
@@ -42,9 +42,9 @@
 
 
 #include "language_tag.h"
 
 
 #include "language_tag.h"
-#include "subtitle_asset.h"
 #include "reel_asset.h"
 #include "reel_asset.h"
-#include "reel_encryptable_asset.h"
+#include "reel_file_asset.h"
+#include "subtitle_asset.h"
 
 
 struct verify_invalid_language2;
 
 
 struct verify_invalid_language2;
@@ -53,23 +53,19 @@ struct verify_invalid_language2;
 namespace dcp {
 
 
 namespace dcp {
 
 
-class SubtitleAsset;
-
-
 /** @class ReelClosedCaptionAsset
  *  @brief Part of a Reel's description which refers to a closed caption XML/MXF file
  */
 /** @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>);
 
 {
 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 {
        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) {
        }
 
        void set_language (dcp::LanguageTag l) {
@@ -84,13 +80,9 @@ public:
                return _language;
        }
 
                return _language;
        }
 
-private:
+protected:
        friend struct ::verify_invalid_language2;
 
        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;
 };
 
        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 (file)
index 0000000..0730f77
--- /dev/null
@@ -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 (file)
index 0000000..8031142
--- /dev/null
@@ -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 (file)
index 0000000..4412503
--- /dev/null
@@ -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 (file)
index 0000000..32fe511
--- /dev/null
@@ -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
+
index b50966e77c36fc408ce28d066abaf10105ba22e3..f6e0d15b00269bb1790ae559d682f9f3690e26dc 100644 (file)
@@ -84,10 +84,12 @@ def build(bld):
              reel_closed_caption_asset.cc
              reel_encryptable_asset.cc
              reel_file_asset.cc
              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_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
              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.h
               reel_asset.h
               reel_atmos_asset.h
-              reel_closed_caption_asset.h
               reel_encryptable_asset.h
               reel_file_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_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
               reel_smpte_subtitle_asset.h
               reel_stereo_picture_asset.h
               reel_subtitle_asset.h
index 3bebff5322957e4cf63461529a79930c863c16dd..d46c657b9fd3fe9a543ad7253254bf892609c58c 100644 (file)
 #include "picture_asset_writer.h"
 #include "reel.h"
 #include "reel_asset.h"
 #include "picture_asset_writer.h"
 #include "reel.h"
 #include "reel_asset.h"
-#include "reel_closed_caption_asset.h"
+#include "reel_interop_closed_caption_asset.h"
 #include "reel_interop_subtitle_asset.h"
 #include "reel_markers_asset.h"
 #include "reel_mono_picture_asset.h"
 #include "reel_mono_picture_asset.h"
 #include "reel_interop_subtitle_asset.h"
 #include "reel_markers_asset.h"
 #include "reel_mono_picture_asset.h"
 #include "reel_mono_picture_asset.h"
+#include "reel_smpte_closed_caption_asset.h"
 #include "reel_smpte_subtitle_asset.h"
 #include "reel_sound_asset.h"
 #include "smpte_subtitle_asset.h"
 #include "reel_smpte_subtitle_asset.h"
 #include "reel_sound_asset.h"
 #include "smpte_subtitle_asset.h"
@@ -459,8 +460,8 @@ make_simple_with_interop_ccaps (boost::filesystem::path path)
        subs->add (simple_subtitle());
        subs->write (path / "ccap.xml");
 
        subs->add (simple_subtitle());
        subs->write (path / "ccap.xml");
 
-       auto reel_caps = make_shared<dcp::ReelClosedCaptionAsset>(subs, dcp::Fraction(24, 1), 240, 0);
-       dcp->cpls().front()->reels().front()->add (reel_caps);
+       auto reel_caps = make_shared<dcp::ReelInteropClosedCaptionAsset>(subs, dcp::Fraction(24, 1), 240, 0);
+       dcp->cpls()[0]->reels()[0]->add (reel_caps);
 
        return dcp;
 }
 
        return dcp;
 }
@@ -477,7 +478,7 @@ make_simple_with_smpte_ccaps (boost::filesystem::path path)
        subs->add (simple_subtitle());
        subs->write (path / "ccap.mxf");
 
        subs->add (simple_subtitle());
        subs->write (path / "ccap.mxf");
 
-       auto reel_caps = make_shared<dcp::ReelClosedCaptionAsset>(subs, dcp::Fraction(24, 1), 192, 0);
+       auto reel_caps = make_shared<dcp::ReelSMPTEClosedCaptionAsset>(subs, dcp::Fraction(24, 1), 192, 0);
        dcp->cpls()[0]->reels()[0]->add(reel_caps);
 
        return dcp;
        dcp->cpls()[0]->reels()[0]->add(reel_caps);
 
        return dcp;
index 162d2913d659dac403d46f7752fbdded54b30fe2..4e26c66e5e225e860e52ea13b3a59e8d79fbae23 100644 (file)
 #include "openjpeg_image.h"
 #include "raw_convert.h"
 #include "reel.h"
 #include "openjpeg_image.h"
 #include "raw_convert.h"
 #include "reel.h"
-#include "reel_closed_caption_asset.h"
+#include "reel_interop_closed_caption_asset.h"
 #include "reel_interop_subtitle_asset.h"
 #include "reel_markers_asset.h"
 #include "reel_mono_picture_asset.h"
 #include "reel_sound_asset.h"
 #include "reel_stereo_picture_asset.h"
 #include "reel_interop_subtitle_asset.h"
 #include "reel_markers_asset.h"
 #include "reel_mono_picture_asset.h"
 #include "reel_sound_asset.h"
 #include "reel_stereo_picture_asset.h"
+#include "reel_smpte_closed_caption_asset.h"
 #include "reel_smpte_subtitle_asset.h"
 #include "smpte_subtitle_asset.h"
 #include "stereo_picture_asset.h"
 #include "reel_smpte_subtitle_asset.h"
 #include "smpte_subtitle_asset.h"
 #include "stereo_picture_asset.h"
@@ -925,7 +926,7 @@ BOOST_AUTO_TEST_CASE (verify_invalid_language2)
        auto asset = make_shared<dcp::SMPTESubtitleAsset>(dir / "subs.mxf");
        asset->_language = "wrong-andbad";
        asset->write (dir / "subs.mxf");
        auto asset = make_shared<dcp::SMPTESubtitleAsset>(dir / "subs.mxf");
        asset->_language = "wrong-andbad";
        asset->write (dir / "subs.mxf");
-       auto reel_asset = make_shared<dcp::ReelClosedCaptionAsset>(asset, dcp::Fraction(24, 1), 6046, 0);
+       auto reel_asset = make_shared<dcp::ReelSMPTEClosedCaptionAsset>(asset, dcp::Fraction(24, 1), 6046, 0);
        reel_asset->_language = "badlang";
        auto cpl = write_dcp_with_single_asset (dir, reel_asset);
 
        reel_asset->_language = "badlang";
        auto cpl = write_dcp_with_single_asset (dir, reel_asset);
 
@@ -1177,7 +1178,7 @@ BOOST_AUTO_TEST_CASE (verify_invalid_closed_caption_xml_size_in_bytes)
        }
        asset->set_language (dcp::LanguageTag("de-DE"));
        asset->write (dir / "subs.mxf");
        }
        asset->set_language (dcp::LanguageTag("de-DE"));
        asset->write (dir / "subs.mxf");
-       auto reel_asset = make_shared<dcp::ReelClosedCaptionAsset>(asset, dcp::Fraction(24, 1), 49148, 0);
+       auto reel_asset = make_shared<dcp::ReelSMPTEClosedCaptionAsset>(asset, dcp::Fraction(24, 1), 49148, 0);
        auto cpl = write_dcp_with_single_asset (dir, reel_asset);
 
        check_verify_result (
        auto cpl = write_dcp_with_single_asset (dir, reel_asset);
 
        check_verify_result (
@@ -1239,7 +1240,7 @@ verify_timed_text_asset_too_large (string name)
 BOOST_AUTO_TEST_CASE (verify_subtitle_asset_too_large)
 {
        verify_timed_text_asset_too_large<dcp::ReelSMPTESubtitleAsset>("verify_subtitle_asset_too_large");
 BOOST_AUTO_TEST_CASE (verify_subtitle_asset_too_large)
 {
        verify_timed_text_asset_too_large<dcp::ReelSMPTESubtitleAsset>("verify_subtitle_asset_too_large");
-       verify_timed_text_asset_too_large<dcp::ReelClosedCaptionAsset>("verify_closed_caption_asset_too_large");
+       verify_timed_text_asset_too_large<dcp::ReelSMPTEClosedCaptionAsset>("verify_closed_caption_asset_too_large");
 }
 
 
 }
 
 
@@ -1349,7 +1350,7 @@ BOOST_AUTO_TEST_CASE (verify_multiple_closed_caption_languages_allowed)
                ccaps->set_language (dcp::LanguageTag("de-DE"));
                ccaps->add (simple_subtitle());
                ccaps->write (path / "subs1.mxf");
                ccaps->set_language (dcp::LanguageTag("de-DE"));
                ccaps->add (simple_subtitle());
                ccaps->write (path / "subs1.mxf");
-               auto reel_ccaps = make_shared<dcp::ReelClosedCaptionAsset>(ccaps, dcp::Fraction(24, 1), reel_length, 0);
+               auto reel_ccaps = make_shared<dcp::ReelSMPTEClosedCaptionAsset>(ccaps, dcp::Fraction(24, 1), reel_length, 0);
                cpl->reels()[0]->add(reel_ccaps);
        }
 
                cpl->reels()[0]->add(reel_ccaps);
        }
 
@@ -1358,7 +1359,7 @@ BOOST_AUTO_TEST_CASE (verify_multiple_closed_caption_languages_allowed)
                ccaps->set_language (dcp::LanguageTag("en-US"));
                ccaps->add (simple_subtitle());
                ccaps->write (path / "subs2.mxf");
                ccaps->set_language (dcp::LanguageTag("en-US"));
                ccaps->add (simple_subtitle());
                ccaps->write (path / "subs2.mxf");
-               auto reel_ccaps = make_shared<dcp::ReelClosedCaptionAsset>(ccaps, dcp::Fraction(24, 1), reel_length, 0);
+               auto reel_ccaps = make_shared<dcp::ReelSMPTEClosedCaptionAsset>(ccaps, dcp::Fraction(24, 1), reel_length, 0);
                cpl->reels()[1]->add(reel_ccaps);
        }
 
                cpl->reels()[1]->add(reel_ccaps);
        }
 
@@ -1772,7 +1773,7 @@ BOOST_AUTO_TEST_CASE (verify_invalid_subtitle_line_length2)
 BOOST_AUTO_TEST_CASE (verify_valid_closed_caption_line_count1)
 {
        auto const dir = path ("build/test/verify_valid_closed_caption_line_count1");
 BOOST_AUTO_TEST_CASE (verify_valid_closed_caption_line_count1)
 {
        auto const dir = path ("build/test/verify_valid_closed_caption_line_count1");
-       auto cpl = dcp_with_text<dcp::ReelClosedCaptionAsset> (
+       auto cpl = dcp_with_text<dcp::ReelSMPTEClosedCaptionAsset> (
                dir,
                {
                        { 96, 200, 0.0, "We" },
                dir,
                {
                        { 96, 200, 0.0, "We" },
@@ -1792,7 +1793,7 @@ BOOST_AUTO_TEST_CASE (verify_valid_closed_caption_line_count1)
 BOOST_AUTO_TEST_CASE (verify_valid_closed_caption_line_count2)
 {
        auto const dir = path ("build/test/verify_valid_closed_caption_line_count2");
 BOOST_AUTO_TEST_CASE (verify_valid_closed_caption_line_count2)
 {
        auto const dir = path ("build/test/verify_valid_closed_caption_line_count2");
-       auto cpl = dcp_with_text<dcp::ReelClosedCaptionAsset> (
+       auto cpl = dcp_with_text<dcp::ReelSMPTEClosedCaptionAsset> (
                dir,
                {
                        { 96, 200, 0.0, "We" },
                dir,
                {
                        { 96, 200, 0.0, "We" },
@@ -1806,7 +1807,7 @@ BOOST_AUTO_TEST_CASE (verify_valid_closed_caption_line_count2)
 BOOST_AUTO_TEST_CASE (verify_invalid_closed_caption_line_count3)
 {
        auto const dir = path ("build/test/verify_invalid_closed_caption_line_count3");
 BOOST_AUTO_TEST_CASE (verify_invalid_closed_caption_line_count3)
 {
        auto const dir = path ("build/test/verify_invalid_closed_caption_line_count3");
-       auto cpl = dcp_with_text<dcp::ReelClosedCaptionAsset> (
+       auto cpl = dcp_with_text<dcp::ReelSMPTEClosedCaptionAsset> (
                dir,
                {
                        { 96, 300, 0.0, "We" },
                dir,
                {
                        { 96, 300, 0.0, "We" },
@@ -1826,7 +1827,7 @@ BOOST_AUTO_TEST_CASE (verify_invalid_closed_caption_line_count3)
 BOOST_AUTO_TEST_CASE (verify_valid_closed_caption_line_count4)
 {
        auto const dir = path ("build/test/verify_valid_closed_caption_line_count4");
 BOOST_AUTO_TEST_CASE (verify_valid_closed_caption_line_count4)
 {
        auto const dir = path ("build/test/verify_valid_closed_caption_line_count4");
-       auto cpl = dcp_with_text<dcp::ReelClosedCaptionAsset> (
+       auto cpl = dcp_with_text<dcp::ReelSMPTEClosedCaptionAsset> (
                dir,
                {
                        { 96, 300, 0.0, "We" },
                dir,
                {
                        { 96, 300, 0.0, "We" },
@@ -1841,7 +1842,7 @@ BOOST_AUTO_TEST_CASE (verify_valid_closed_caption_line_count4)
 BOOST_AUTO_TEST_CASE (verify_invalid_closed_caption_line_length)
 {
        auto const dir = path ("build/test/verify_invalid_closed_caption_line_length");
 BOOST_AUTO_TEST_CASE (verify_invalid_closed_caption_line_length)
 {
        auto const dir = path ("build/test/verify_invalid_closed_caption_line_length");
-       auto cpl = dcp_with_text<dcp::ReelClosedCaptionAsset> (
+       auto cpl = dcp_with_text<dcp::ReelSMPTEClosedCaptionAsset> (
                dir,
                {
                        { 96, 300, 0.0, "0123456789012345678901234567890123" }
                dir,
                {
                        { 96, 300, 0.0, "0123456789012345678901234567890123" }
@@ -2092,7 +2093,7 @@ verify_closed_captions_must_be_in_all_reels_check (path dir, int caps_in_reel1,
                );
 
        for (int i = 0; i < caps_in_reel1; ++i) {
                );
 
        for (int i = 0; i < caps_in_reel1; ++i) {
-               reel1->add (make_shared<dcp::ReelClosedCaptionAsset>(subs, dcp::Fraction(24, 1), reel_length, 0));
+               reel1->add (make_shared<dcp::ReelSMPTEClosedCaptionAsset>(subs, dcp::Fraction(24, 1), reel_length, 0));
        }
 
        auto markers1 = make_shared<dcp::ReelMarkersAsset>(dcp::Fraction(24, 1), reel_length, 0);
        }
 
        auto markers1 = make_shared<dcp::ReelMarkersAsset>(dcp::Fraction(24, 1), reel_length, 0);
@@ -2107,7 +2108,7 @@ verify_closed_captions_must_be_in_all_reels_check (path dir, int caps_in_reel1,
                );
 
        for (int i = 0; i < caps_in_reel2; ++i) {
                );
 
        for (int i = 0; i < caps_in_reel2; ++i) {
-               reel2->add (make_shared<dcp::ReelClosedCaptionAsset>(subs, dcp::Fraction(24, 1), reel_length, 0));
+               reel2->add (make_shared<dcp::ReelSMPTEClosedCaptionAsset>(subs, dcp::Fraction(24, 1), reel_length, 0));
        }
 
        auto markers2 = make_shared<dcp::ReelMarkersAsset>(dcp::Fraction(24, 1), reel_length, 0);
        }
 
        auto markers2 = make_shared<dcp::ReelMarkersAsset>(dcp::Fraction(24, 1), reel_length, 0);
@@ -2219,18 +2220,18 @@ BOOST_AUTO_TEST_CASE (verify_text_entry_point)
                        }
                );
 
                        }
                );
 
-       verify_text_entry_point_check<dcp::ReelClosedCaptionAsset> (
+       verify_text_entry_point_check<dcp::ReelSMPTEClosedCaptionAsset> (
                "build/test/verify_closed_caption_entry_point_must_be_present",
                dcp::VerificationNote::Code::MISSING_CLOSED_CAPTION_ENTRY_POINT,
                "build/test/verify_closed_caption_entry_point_must_be_present",
                dcp::VerificationNote::Code::MISSING_CLOSED_CAPTION_ENTRY_POINT,
-               [](shared_ptr<dcp::ReelClosedCaptionAsset> asset) {
+               [](shared_ptr<dcp::ReelSMPTEClosedCaptionAsset> asset) {
                        asset->unset_entry_point ();
                        }
                );
 
                        asset->unset_entry_point ();
                        }
                );
 
-       verify_text_entry_point_check<dcp::ReelClosedCaptionAsset> (
+       verify_text_entry_point_check<dcp::ReelSMPTEClosedCaptionAsset> (
                "build/test/verify_closed_caption_entry_point_must_be_zero",
                dcp::VerificationNote::Code::INCORRECT_CLOSED_CAPTION_ENTRY_POINT,
                "build/test/verify_closed_caption_entry_point_must_be_zero",
                dcp::VerificationNote::Code::INCORRECT_CLOSED_CAPTION_ENTRY_POINT,
-               [](shared_ptr<dcp::ReelClosedCaptionAsset> asset) {
+               [](shared_ptr<dcp::ReelSMPTEClosedCaptionAsset> asset) {
                        asset->set_entry_point (9);
                        }
                );
                        asset->set_entry_point (9);
                        }
                );