summaryrefslogtreecommitdiff
path: root/src/reel_closed_caption_asset.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2017-09-04 23:34:11 +0100
committerCarl Hetherington <cth@carlh.net>2017-09-04 23:34:11 +0100
commit926aff7db1e5ad6c02743608e3792fdca39eea4a (patch)
treeff35ec79b85c259f524ee7e44fd3b129ebf38adb /src/reel_closed_caption_asset.cc
parent8b72edd4068deaf4a9ea5e469475419898976a9d (diff)
Add basic CCAP support.
Diffstat (limited to 'src/reel_closed_caption_asset.cc')
-rw-r--r--src/reel_closed_caption_asset.cc111
1 files changed, 111 insertions, 0 deletions
diff --git a/src/reel_closed_caption_asset.cc b/src/reel_closed_caption_asset.cc
new file mode 100644
index 00000000..4fb729c6
--- /dev/null
+++ b/src/reel_closed_caption_asset.cc
@@ -0,0 +1,111 @@
+/*
+ Copyright (C) 2012-2017 Carl Hetherington <cth@carlh.net>
+
+ This file is part of libdcp.
+
+ libdcp is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ libdcp is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with libdcp. If not, see <http://www.gnu.org/licenses/>.
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of portions of this program with the
+ OpenSSL library under certain conditions as described in each
+ individual source file, and distribute linked combinations
+ including the two.
+
+ You must obey the GNU General Public License in all respects
+ for all of the code used other than OpenSSL. If you modify
+ file(s) with this exception, you may extend this exception to your
+ version of the file(s), but you are not obligated to do so. If you
+ do not wish to do so, delete this exception statement from your
+ version. If you delete this exception statement from all source
+ files in the program, then also delete it here.
+*/
+
+/** @file src/reel_closed_caption_asset.cc
+ * @brief ReelClosedCaptionAsset class.
+ */
+
+#include "subtitle_asset.h"
+#include "reel_closed_caption_asset.h"
+#include "smpte_subtitle_asset.h"
+#include "dcp_assert.h"
+#include <libxml++/libxml++.h>
+
+using std::string;
+using std::pair;
+using std::make_pair;
+using boost::shared_ptr;
+using boost::dynamic_pointer_cast;
+using boost::optional;
+using namespace dcp;
+
+ReelClosedCaptionAsset::ReelClosedCaptionAsset (boost::shared_ptr<SubtitleAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point)
+ : ReelAsset (asset, edit_rate, intrinsic_duration, entry_point)
+ , ReelMXF (dynamic_pointer_cast<SMPTESubtitleAsset>(asset) ? dynamic_pointer_cast<SMPTESubtitleAsset>(asset)->key_id() : optional<string>())
+{
+
+}
+
+ReelClosedCaptionAsset::ReelClosedCaptionAsset (boost::shared_ptr<const cxml::Node> node)
+ : ReelAsset (node)
+ , ReelMXF (node)
+{
+ node->ignore_child ("Language");
+ node->done ();
+}
+
+string
+ReelClosedCaptionAsset::cpl_node_name (Standard standard) const
+{
+ switch (standard) {
+ case INTEROP:
+ return "cc-cpl:MainClosedCaption";
+ case SMPTE:
+ return "tt:ClosedCaption";
+ }
+
+ DCP_ASSERT (false);
+}
+
+pair<string, string>
+ReelClosedCaptionAsset::cpl_node_namespace (Standard standard) const
+{
+ switch (standard) {
+ case INTEROP:
+ return make_pair ("http://www.digicine.com/PROTO-ASDCP-CC-CPL-20070926#", "cc-cpl");
+ case 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";
+}
+
+void
+ReelClosedCaptionAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const
+{
+ ReelAsset::write_to_cpl (node, standard);
+
+ if (key_id ()) {
+ /* Find our main tag */
+ xmlpp::Node* ms = find_child (node, cpl_node_name (standard));
+ /* Find <Hash> */
+ xmlpp::Node* hash = find_child (ms, "Hash");
+ ms->add_child_before (hash, "KeyId")->add_child_text ("urn:uuid:" + key_id().get ());
+ }
+}