/*
- Copyright (C) 2014-2016 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2017 Carl Hetherington <cth@carlh.net>
This file is part of libdcp.
#include "interop_subtitle_asset.h"
#include "smpte_subtitle_asset.h"
#include "reel_atmos_asset.h"
+#include "reel_closed_caption_asset.h"
#include <libxml++/nodes/element.h>
using std::string;
_main_subtitle.reset (new ReelSubtitleAsset (main_subtitle));
}
+ /* XXX: it's not ideal that we silently tolerate Interop or SMPTE nodes here */
+ shared_ptr<cxml::Node> closed_caption = asset_list->optional_node_child ("cc-cpl:MainClosedCaption");
+ if (closed_caption) {
+ _closed_caption.reset (new ReelClosedCaptionAsset (closed_caption));
+ }
+ closed_caption = asset_list->optional_node_child ("tt:ClosedCaption");
+ if (closed_caption) {
+ _closed_caption.reset (new ReelClosedCaptionAsset (closed_caption));
+ }
+
shared_ptr<cxml::Node> atmos = asset_list->optional_node_child ("AuxData");
if (atmos) {
_atmos.reset (new ReelAtmosAsset (atmos));
_main_subtitle->write_to_cpl (asset_list, standard);
}
+ if (_closed_caption) {
+ _closed_caption->write_to_cpl (asset_list, standard);
+ }
+
if (_main_picture && dynamic_pointer_cast<ReelStereoPictureAsset> (_main_picture)) {
/* ... but stereo pictures must come after */
_main_picture->write_to_cpl (asset_list, standard);
return false;
}
+ if (_closed_caption && !_closed_caption->equals (other->_closed_caption, opt, note)) {
+ return false;
+ }
+
if ((_atmos && !other->_atmos) || (!_atmos && other->_atmos)) {
note (DCP_ERROR, "Reel: assets differ");
return false;
return (
(_main_picture && _main_picture->encrypted ()) ||
(_main_sound && _main_sound->encrypted ()) ||
+ (_main_subtitle && _main_subtitle->encrypted ()) ||
+ (_closed_caption && _closed_caption->encrypted ()) ||
(_atmos && _atmos->encrypted ())
);
}
s->set_key (i->key ());
}
}
+ if (_closed_caption && i->id() == _closed_caption->key_id()) {
+ shared_ptr<SMPTESubtitleAsset> s = dynamic_pointer_cast<SMPTESubtitleAsset> (_closed_caption->asset());
+ if (s) {
+ s->set_key (i->key ());
+ }
+ }
if (_atmos && i->id() == _atmos->key_id()) {
_atmos->asset()->set_key (i->key ());
}
shared_ptr<ReelPictureAsset> p = dynamic_pointer_cast<ReelPictureAsset> (asset);
shared_ptr<ReelSoundAsset> so = dynamic_pointer_cast<ReelSoundAsset> (asset);
shared_ptr<ReelSubtitleAsset> su = dynamic_pointer_cast<ReelSubtitleAsset> (asset);
+ shared_ptr<ReelClosedCaptionAsset> c = dynamic_pointer_cast<ReelClosedCaptionAsset> (asset);
shared_ptr<ReelAtmosAsset> a = dynamic_pointer_cast<ReelAtmosAsset> (asset);
if (p) {
_main_picture = p;
_main_sound = so;
} else if (su) {
_main_subtitle = su;
+ } else if (c) {
+ _closed_caption = c;
} else if (a) {
_atmos = a;
}
}
}
+ if (_closed_caption) {
+ _closed_caption->asset_ref().resolve(assets);
+
+ /* Interop subtitle handling is all special cases */
+ if (_closed_caption->asset_ref().resolved()) {
+ shared_ptr<InteropSubtitleAsset> iop = dynamic_pointer_cast<InteropSubtitleAsset> (_closed_caption->asset_ref().asset());
+ if (iop) {
+ iop->resolve_fonts (assets);
+ }
+ }
+ }
+
if (_atmos) {
_atmos->asset_ref().resolve (assets);
}
if (_main_subtitle) {
d = max (d, _main_subtitle->duration ());
}
+ if (_closed_caption) {
+ d = max (d, _closed_caption->duration ());
+ }
if (_atmos) {
d = max (d, _atmos->duration ());
}
class ReelPictureAsset;
class ReelSoundAsset;
class ReelSubtitleAsset;
+class ReelClosedCaptionAsset;
class ReelAtmosAsset;
class Content;
boost::shared_ptr<ReelPictureAsset> _main_picture;
boost::shared_ptr<ReelSoundAsset> _main_sound;
boost::shared_ptr<ReelSubtitleAsset> _main_subtitle;
+ boost::shared_ptr<ReelClosedCaptionAsset> _closed_caption;
boost::shared_ptr<ReelAtmosAsset> _atmos;
};
void
ReelAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const
{
- xmlpp::Element* a = node->add_child (cpl_node_name ());
+ xmlpp::Element* a = node->add_child (cpl_node_name (standard));
pair<string, string> const attr = cpl_node_attribute (standard);
if (!attr.first.empty ()) {
a->set_attribute (attr.first, attr.second);
}
- pair<string, string> const ns = cpl_node_namespace ();
+ pair<string, string> const ns = cpl_node_namespace (standard);
if (!ns.first.empty ()) {
a->set_namespace_declaration (ns.first, ns.second);
}
}
pair<string, string>
-ReelAsset::cpl_node_namespace () const
+ReelAsset::cpl_node_namespace (Standard) const
{
return make_pair ("", "");
}
/** @return the node name that this asset uses in the CPL's <Reel> node
* e.g. MainPicture, MainSound etc.
*/
- virtual std::string cpl_node_name () const = 0;
+ virtual std::string cpl_node_name (Standard) const = 0;
/** @return Any attribute 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 () const;
+ virtual std::pair<std::string, std::string> cpl_node_namespace (Standard) const;
/** Reference to the asset (MXF or XML file) that this reel entry
* applies to.
/*
- Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2016-2017 Carl Hetherington <cth@carlh.net>
This file is part of libdcp.
}
string
-ReelAtmosAsset::cpl_node_name () const
+ReelAtmosAsset::cpl_node_name (Standard) const
{
return "axd:AuxData";
}
pair<string, string>
-ReelAtmosAsset::cpl_node_namespace () const
+ReelAtmosAsset::cpl_node_namespace (Standard) const
{
return make_pair ("http://www.dolby.com/schemas/2012/AD", "axd");
}
ReelAsset::write_to_cpl (node, standard);
/* Find <axd:AuxData> */
- xmlpp::Node* mp = find_child (node, cpl_node_name ());
+ xmlpp::Node* mp = find_child (node, cpl_node_name (standard));
mp->add_child("axd:DataType")->add_child_text ("urn:smpte:ul:060e2b34.04010105.0e090604.00000000");
}
/*
- Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2016-2017 Carl Hetherington <cth@carlh.net>
This file is part of libdcp.
private:
std::string key_type () const;
- std::string cpl_node_name () const;
- std::pair<std::string, std::string> cpl_node_namespace () const;
+ std::string cpl_node_name (Standard standard) const;
+ std::pair<std::string, std::string> cpl_node_namespace (Standard) const;
};
}
--- /dev/null
+/*
+ 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 ());
+ }
+}
--- /dev/null
+/*
+ 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.h
+ * @brief ReelClosedCaptionAsset class.
+ */
+
+#ifndef LIBDCP_REEL_CLOSED_CAPTION_ASSET_H
+#define LIBDCP_REEL_CLOSED_CAPTION_ASSET_H
+
+#include "reel_asset.h"
+#include "reel_mxf.h"
+#include "subtitle_asset.h"
+
+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 ReelMXF
+{
+public:
+ ReelClosedCaptionAsset (boost::shared_ptr<SubtitleAsset> asset, Fraction edit_rate, int64_t instrinsic_duration, int64_t entry_point);
+ explicit ReelClosedCaptionAsset (boost::shared_ptr<const cxml::Node>);
+
+ void write_to_cpl (xmlpp::Node* node, Standard standard) const;
+
+ boost::shared_ptr<SubtitleAsset> asset () const {
+ return asset_of_type<SubtitleAsset> ();
+ }
+
+private:
+ 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;
+};
+
+}
+
+#endif
/*
- Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2017 Carl Hetherington <cth@carlh.net>
This file is part of libdcp.
}
string
-ReelMonoPictureAsset::cpl_node_name () const
+ReelMonoPictureAsset::cpl_node_name (Standard) const
{
return "MainPicture";
}
/*
- Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2017 Carl Hetherington <cth@carlh.net>
This file is part of libdcp.
}
private:
- std::string cpl_node_name () const;
+ std::string cpl_node_name (Standard standard) const;
};
}
ReelAsset::write_to_cpl (node, standard);
/* Find <MainPicture> */
- xmlpp::Node* mp = find_child (node, cpl_node_name ());
+ xmlpp::Node* mp = find_child (node, cpl_node_name (standard));
mp->add_child ("FrameRate")->add_child_text (String::compose ("%1 %2", _frame_rate.numerator, _frame_rate.denominator));
if (standard == INTEROP) {
}
string
-ReelSoundAsset::cpl_node_name () const
+ReelSoundAsset::cpl_node_name (Standard) const
{
return "MainSound";
}
if (key_id ()) {
/* Find <MainSound> */
- xmlpp::Node* ms = find_child (node, cpl_node_name ());
+ 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 ());
private:
std::string key_type () const;
- std::string cpl_node_name () const;
+ std::string cpl_node_name (Standard standard) const;
};
}
}
string
-ReelStereoPictureAsset::cpl_node_name () const
+ReelStereoPictureAsset::cpl_node_name (Standard) const
{
return "msp-cpl:MainStereoscopicPicture";
}
pair<string, string>
ReelStereoPictureAsset::cpl_node_attribute (Standard standard) const
{
- if (standard == INTEROP) {
+ switch (standard) {
+ case INTEROP:
return make_pair ("xmlns:msp-cpl", "http://www.digicine.com/schemas/437-Y/2007/Main-Stereo-Picture-CPL");
- } else {
+ case SMPTE:
return make_pair ("xmlns:msp-cpl", "http://www.smpte-ra.org/schemas/429-10/2008/Main-Stereo-Picture-CPL");
}
- return make_pair ("", "");
+ DCP_ASSERT (false);
}
}
private:
- std::string cpl_node_name () const;
+ std::string cpl_node_name (Standard standard) const;
std::pair<std::string, std::string> cpl_node_attribute (Standard standard) const;
};
/*
- Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2017 Carl Hetherington <cth@carlh.net>
This file is part of libdcp.
}
string
-ReelSubtitleAsset::cpl_node_name () const
+ReelSubtitleAsset::cpl_node_name (Standard) const
{
return "MainSubtitle";
}
if (key_id ()) {
/* Find <MainSubtitle> */
- xmlpp::Node* ms = find_child (node, cpl_node_name ());
+ 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 ());
/*
- Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2017 Carl Hetherington <cth@carlh.net>
This file is part of libdcp.
private:
std::string key_type () const;
- std::string cpl_node_name () const;
+ std::string cpl_node_name (Standard standard) const;
};
}
reel.cc
reel_asset.cc
reel_atmos_asset.cc
+ reel_closed_caption_asset.cc
reel_mono_picture_asset.cc
reel_mxf.cc
reel_picture_asset.cc
reel.h
reel_asset.h
reel_atmos_asset.h
+ reel_closed_caption_asset.h
reel_mono_picture_asset.h
reel_mxf.h
reel_picture_asset.h