/*
- Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2018 Carl Hetherington <cth@carlh.net>
This file is part of libdcp.
#include "interop_subtitle_asset.h"
#include "interop_load_font_node.h"
+#include "subtitle_asset_internal.h"
#include "xml.h"
#include "raw_convert.h"
#include "util.h"
#include "font_asset.h"
#include "dcp_assert.h"
+#include "compose.hpp"
+#include "subtitle_image.h"
#include <libxml++/libxml++.h>
#include <boost/foreach.hpp>
+#include <boost/weak_ptr.hpp>
#include <cmath>
#include <cstdio>
_reel_number = xml->string_child ("ReelNumber");
_language = xml->string_child ("Language");
_movie_title = xml->string_child ("MovieTitle");
- _load_font_nodes = type_children<dcp::InteropLoadFontNode> (xml, "LoadFont");
+ _load_font_nodes = type_children<InteropLoadFontNode> (xml, "LoadFont");
/* Now we need to drop down to xmlpp */
parse_subtitles (e, ps, optional<int>(), INTEROP);
}
}
+
+ BOOST_FOREACH (shared_ptr<Subtitle> i, _subtitles) {
+ shared_ptr<SubtitleImage> si = dynamic_pointer_cast<SubtitleImage>(i);
+ if (si) {
+ si->read_png_file (file.parent_path() / String::compose("%1.png", si->id()));
+ }
+ }
}
InteropSubtitleAsset::InteropSubtitleAsset ()
_file = p;
+ /* Image subtitles */
+ BOOST_FOREACH (shared_ptr<dcp::Subtitle> i, _subtitles) {
+ shared_ptr<dcp::SubtitleImage> im = dynamic_pointer_cast<dcp::SubtitleImage> (i);
+ if (im) {
+ im->write_png_file(p.parent_path() / String::compose("%1.png", im->id()));
+ }
+ }
+
+ /* Fonts */
BOOST_FOREACH (shared_ptr<InteropLoadFontNode> i, _load_font_nodes) {
boost::filesystem::path file = p.parent_path() / i->uri;
FILE* f = fopen_boost (file, "wb");
assets.push_back (shared_ptr<FontAsset> (new FontAsset (i.uuid, i.file.get ())));
}
}
+
+void
+InteropSubtitleAsset::write_to_assetmap (xmlpp::Node* node, boost::filesystem::path root) const
+{
+ Asset::write_to_assetmap (node, root);
+
+ BOOST_FOREACH (shared_ptr<dcp::Subtitle> i, _subtitles) {
+ shared_ptr<dcp::SubtitleImage> im = dynamic_pointer_cast<dcp::SubtitleImage> (i);
+ if (im) {
+ DCP_ASSERT (im->file());
+ write_file_to_assetmap (node, root, im->file().get(), im->id());
+ }
+ }
+}
+
+void
+InteropSubtitleAsset::add_to_pkl (shared_ptr<PKL> pkl, boost::filesystem::path root) const
+{
+ Asset::add_to_pkl (pkl, root);
+
+ BOOST_FOREACH (shared_ptr<dcp::Subtitle> i, _subtitles) {
+ shared_ptr<dcp::SubtitleImage> im = dynamic_pointer_cast<dcp::SubtitleImage> (i);
+ if (im) {
+ Data png_image = im->png_image ();
+ pkl->add_asset (im->id(), optional<string>(), make_digest(png_image), png_image.size(), "image/png");
+ }
+ }
+}