summaryrefslogtreecommitdiff
path: root/src/reel.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/reel.cc')
-rw-r--r--src/reel.cc178
1 files changed, 113 insertions, 65 deletions
diff --git a/src/reel.cc b/src/reel.cc
index a8481d59..ce654f6f 100644
--- a/src/reel.cc
+++ b/src/reel.cc
@@ -40,25 +40,22 @@
#include "decrypted_kdm.h"
#include "decrypted_kdm_key.h"
#include "equality_options.h"
-#include "interop_subtitle_asset.h"
-#include "mono_picture_asset.h"
-#include "picture_asset.h"
+#include "interop_text_asset.h"
+#include "mono_j2k_picture_asset.h"
+#include "j2k_picture_asset.h"
#include "reel.h"
#include "reel_atmos_asset.h"
-#include "reel_closed_caption_asset.h"
-#include "reel_interop_closed_caption_asset.h"
-#include "reel_interop_subtitle_asset.h"
+#include "reel_interop_text_asset.h"
#include "reel_markers_asset.h"
#include "reel_mono_picture_asset.h"
-#include "reel_smpte_closed_caption_asset.h"
-#include "reel_smpte_subtitle_asset.h"
+#include "reel_smpte_text_asset.h"
#include "reel_sound_asset.h"
#include "reel_stereo_picture_asset.h"
-#include "reel_subtitle_asset.h"
-#include "smpte_subtitle_asset.h"
+#include "reel_text_asset.h"
+#include "smpte_text_asset.h"
#include "sound_asset.h"
-#include "stereo_picture_asset.h"
-#include "subtitle_asset.h"
+#include "stereo_j2k_picture_asset.h"
+#include "text_asset.h"
#include "util.h"
#include <libxml++/nodes/element.h>
#include <stdint.h>
@@ -79,38 +76,56 @@ Reel::Reel (std::shared_ptr<const cxml::Node> node, dcp::Standard standard)
{
auto asset_list = node->node_child ("AssetList");
- auto main_picture = asset_list->optional_node_child ("MainPicture");
- if (main_picture) {
+ if (auto main_picture = asset_list->optional_node_child("MainPicture")) {
_main_picture = make_shared<ReelMonoPictureAsset>(main_picture);
}
- auto main_stereoscopic_picture = asset_list->optional_node_child ("MainStereoscopicPicture");
- if (main_stereoscopic_picture) {
+ if (auto main_stereoscopic_picture = asset_list->optional_node_child("MainStereoscopicPicture")) {
_main_picture = make_shared<ReelStereoPictureAsset>(main_stereoscopic_picture);
}
- auto main_sound = asset_list->optional_node_child ("MainSound");
- if (main_sound) {
+ if (auto main_sound = asset_list->optional_node_child("MainSound")) {
_main_sound = make_shared<ReelSoundAsset>(main_sound);
}
- auto main_subtitle = asset_list->optional_node_child ("MainSubtitle");
- if (main_subtitle) {
+ if (auto main_subtitle = asset_list->optional_node_child("MainSubtitle")) {
switch (standard) {
- case Standard::INTEROP:
- _main_subtitle = make_shared<ReelInteropSubtitleAsset>(main_subtitle);
- break;
- case Standard::SMPTE:
- _main_subtitle = make_shared<ReelSMPTESubtitleAsset>(main_subtitle);
- break;
+ case Standard::INTEROP:
+ _main_subtitle = make_shared<ReelInteropTextAsset>(main_subtitle);
+ break;
+ case Standard::SMPTE:
+ _main_subtitle = make_shared<ReelSMPTETextAsset>(main_subtitle);
+ break;
}
}
- auto main_markers = asset_list->optional_node_child ("MainMarkers");
- if (main_markers) {
+ if (auto main_caption = asset_list->optional_node_child("MainCaption")) {
+ switch (standard) {
+ case Standard::INTEROP:
+ DCP_ASSERT(false);
+ break;
+ case Standard::SMPTE:
+ _main_caption = make_shared<ReelSMPTETextAsset>(main_caption);
+ break;
+ }
+ }
+
+ if (auto main_markers = asset_list->optional_node_child("MainMarkers")) {
_main_markers = make_shared<ReelMarkersAsset>(main_markers);
}
+ auto closed_subtitles = asset_list->node_children("ClosedSubtitle");
+ for (auto i: closed_subtitles) {
+ switch (standard) {
+ case Standard::INTEROP:
+ DCP_ASSERT(false);
+ break;
+ case Standard::SMPTE:
+ _closed_subtitles.push_back(make_shared<ReelSMPTETextAsset>(i));
+ break;
+ }
+ }
+
/* XXX: it's not ideal that we silently tolerate Interop or SMPTE nodes here */
/* XXX: not sure if Interop supports multiple closed captions */
auto closed_captions = asset_list->node_children ("MainClosedCaption");
@@ -119,17 +134,16 @@ Reel::Reel (std::shared_ptr<const cxml::Node> node, dcp::Standard standard)
}
for (auto i: closed_captions) {
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;
+ case Standard::INTEROP:
+ _closed_captions.push_back(make_shared<ReelInteropTextAsset>(i));
+ break;
+ case Standard::SMPTE:
+ _closed_captions.push_back(make_shared<ReelSMPTETextAsset>(i));
+ break;
}
}
- auto atmos = asset_list->optional_node_child ("AuxData");
- if (atmos) {
+ if (auto atmos = asset_list->optional_node_child("AuxData")) {
_atmos = make_shared<ReelAtmosAsset>(atmos);
}
@@ -141,9 +155,9 @@ Reel::Reel (std::shared_ptr<const cxml::Node> node, dcp::Standard standard)
xmlpp::Element *
Reel::write_to_cpl (xmlpp::Element* node, Standard standard) const
{
- auto reel = node->add_child ("Reel");
- reel->add_child("Id")->add_child_text("urn:uuid:" + _id);
- xmlpp::Element* asset_list = reel->add_child ("AssetList");
+ auto reel = cxml::add_child(node, "Reel");
+ cxml::add_text_child(reel, "Id", "urn:uuid:" + _id);
+ auto asset_list = cxml::add_child(reel, "AssetList");
if (_main_markers) {
_main_markers->write_to_cpl (asset_list, standard);
@@ -162,6 +176,14 @@ Reel::write_to_cpl (xmlpp::Element* node, Standard standard) const
_main_subtitle->write_to_cpl (asset_list, standard);
}
+ if (_main_caption) {
+ _main_caption->write_to_cpl(asset_list, standard);
+ }
+
+ for (auto i: _closed_subtitles) {
+ i->write_to_cpl(asset_list, standard);
+ }
+
for (auto i: _closed_captions) {
i->write_to_cpl (asset_list, standard);
}
@@ -208,8 +230,8 @@ Reel::equals(std::shared_ptr<const Reel> other, EqualityOptions const& opt, Note
bool same_type = false;
{
- auto interop = dynamic_pointer_cast<ReelInteropSubtitleAsset>(_main_subtitle);
- auto interop_other = dynamic_pointer_cast<ReelInteropSubtitleAsset>(other->_main_subtitle);
+ auto interop = dynamic_pointer_cast<ReelInteropTextAsset>(_main_subtitle);
+ auto interop_other = dynamic_pointer_cast<ReelInteropTextAsset>(other->_main_subtitle);
if (interop && interop_other) {
same_type = true;
if (!interop->equals(interop_other, opt, note)) {
@@ -219,8 +241,8 @@ Reel::equals(std::shared_ptr<const Reel> other, EqualityOptions const& opt, Note
}
{
- auto smpte = dynamic_pointer_cast<ReelSMPTESubtitleAsset>(_main_subtitle);
- auto smpte_other = dynamic_pointer_cast<ReelSMPTESubtitleAsset>(other->_main_subtitle);
+ auto smpte = dynamic_pointer_cast<ReelSMPTETextAsset>(_main_subtitle);
+ auto smpte_other = dynamic_pointer_cast<ReelSMPTETextAsset>(other->_main_subtitle);
if (smpte && smpte_other) {
same_type = true;
if (!smpte->equals(smpte_other, opt, note)) {
@@ -327,19 +349,19 @@ Reel::give_kdm_to_assets (DecryptedKDM const & kdm)
{
for (auto const& i: kdm.keys()) {
if (_main_picture && i.id() == _main_picture->key_id() && _main_picture->asset_ref().resolved()) {
- _main_picture->asset()->set_key (i.key());
+ _main_picture->j2k_asset()->set_key(i.key());
}
if (_main_sound && i.id() == _main_sound->key_id() && _main_sound->asset_ref().resolved()) {
_main_sound->asset()->set_key (i.key());
}
if (_main_subtitle) {
- auto smpte = dynamic_pointer_cast<ReelSMPTESubtitleAsset>(_main_subtitle);
+ auto smpte = dynamic_pointer_cast<ReelSMPTETextAsset>(_main_subtitle);
if (smpte && i.id() == smpte->key_id() && smpte->asset_ref().resolved()) {
smpte->smpte_asset()->set_key(i.key());
}
}
for (auto j: _closed_captions) {
- auto smpte = dynamic_pointer_cast<ReelSMPTESubtitleAsset>(j);
+ auto smpte = dynamic_pointer_cast<ReelSMPTETextAsset>(j);
if (smpte && i.id() == smpte->key_id() && smpte->asset_ref().resolved()) {
smpte->smpte_asset()->set_key(i.key());
}
@@ -358,12 +380,23 @@ Reel::add (shared_ptr<ReelAsset> asset)
_main_picture = p;
} else if (auto so = dynamic_pointer_cast<ReelSoundAsset>(asset)) {
_main_sound = so;
- } else if (auto su = dynamic_pointer_cast<ReelSubtitleAsset>(asset)) {
- _main_subtitle = su;
+ } else if (auto te = dynamic_pointer_cast<ReelTextAsset>(asset)) {
+ switch (te->type()) {
+ case TextType::OPEN_SUBTITLE:
+ _main_subtitle = te;
+ break;
+ case TextType::OPEN_CAPTION:
+ _main_caption = te;
+ break;
+ case TextType::CLOSED_SUBTITLE:
+ _closed_subtitles.push_back(te);
+ break;
+ case TextType::CLOSED_CAPTION:
+ _closed_captions.push_back(te);
+ break;
+ }
} else if (auto m = dynamic_pointer_cast<ReelMarkersAsset>(asset)) {
_main_markers = m;
- } else if (auto c = dynamic_pointer_cast<ReelClosedCaptionAsset>(asset)) {
- _closed_captions.push_back (c);
} else if (auto a = dynamic_pointer_cast<ReelAtmosAsset>(asset)) {
_atmos = a;
} else {
@@ -385,6 +418,10 @@ Reel::assets () const
if (_main_subtitle) {
a.push_back (_main_subtitle);
}
+ if (_main_caption) {
+ a.push_back(_main_caption);
+ }
+ std::copy (_closed_subtitles.begin(), _closed_subtitles.end(), back_inserter(a));
std::copy (_closed_captions.begin(), _closed_captions.end(), back_inserter(a));
if (_atmos) {
a.push_back (_atmos);
@@ -404,28 +441,33 @@ Reel::resolve_refs (vector<shared_ptr<Asset>> assets)
_main_sound->asset_ref().resolve(assets);
}
- if (_main_subtitle) {
- _main_subtitle->asset_ref().resolve(assets);
-
+ auto resolve_interop_fonts = [&assets](shared_ptr<ReelTextAsset>(asset)) {
/* Interop subtitle handling is all special cases */
- if (_main_subtitle->asset_ref().resolved()) {
- auto iop = dynamic_pointer_cast<InteropSubtitleAsset> (_main_subtitle->asset_ref().asset());
- if (iop) {
- iop->resolve_fonts (assets);
+ if (asset->asset_ref().resolved()) {
+ if (auto iop = dynamic_pointer_cast<InteropTextAsset>(asset->asset_ref().asset())) {
+ iop->resolve_fonts(assets);
}
}
+
+ };
+
+ if (_main_subtitle) {
+ _main_subtitle->asset_ref().resolve(assets);
+ resolve_interop_fonts(_main_subtitle);
}
- for (auto i: _closed_captions) {
+ if (_main_caption) {
+ _main_caption->asset_ref().resolve(assets);
+ }
+
+ for (auto i: _closed_subtitles) {
i->asset_ref().resolve(assets);
+ resolve_interop_fonts(i);
+ }
- /* Interop subtitle handling is all special cases */
- if (i->asset_ref().resolved()) {
- auto iop = dynamic_pointer_cast<InteropSubtitleAsset> (i->asset_ref().asset());
- if (iop) {
- iop->resolve_fonts (assets);
- }
- }
+ for (auto i: _closed_captions) {
+ i->asset_ref().resolve(assets);
+ resolve_interop_fonts(i);
}
if (_atmos) {
@@ -453,9 +495,15 @@ Reel::duration () const
if (_main_subtitle) {
d = min (d, _main_subtitle->actual_duration());
}
+ if (_main_caption) {
+ d = min(d, _main_caption->actual_duration());
+ }
if (_main_markers) {
d = min (d, _main_markers->actual_duration());
}
+ for (auto i: _closed_subtitles) {
+ d = min(d, i->actual_duration());
+ }
for (auto i: _closed_captions) {
d = min (d, i->actual_duration());
}