/*
- Copyright (C) 2015-2016 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2015-2019 Carl Hetherington <cth@carlh.net>
This file is part of libdcp.
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 "interop_subtitle_asset.h"
#include "smpte_subtitle_asset.h"
#include "subtitle_string.h"
+#include "subtitle_image.h"
#include "subtitle_asset_internal.h"
+#include "reel_subtitle_asset.h"
+#include "reel.h"
+#include "cpl.h"
+#include "dcp.h"
#include "test.h"
+#include "util.h"
#include <boost/test/unit_test.hpp>
using std::list;
using std::string;
+using boost::optional;
using boost::shared_ptr;
/** Test dcp::order::Font::take_intersection */
);
}
+/* Write some subtitle content as Interop XML using bitmaps and check that it is right */
+BOOST_AUTO_TEST_CASE (write_interop_subtitle_test3)
+{
+ RNGFixer fix;
+
+ shared_ptr<dcp::InteropSubtitleAsset> c (new dcp::InteropSubtitleAsset());
+ c->set_reel_number ("1");
+ c->set_language ("EN");
+ c->set_movie_title ("Test");
+
+ c->add (
+ shared_ptr<dcp::Subtitle> (
+ new dcp::SubtitleImage (
+ dcp::Data ("test/data/sub.png"),
+ dcp::Time (0, 4, 9, 22, 24),
+ dcp::Time (0, 4, 11, 22, 24),
+ 0,
+ dcp::HALIGN_CENTER,
+ 0.8,
+ dcp::VALIGN_TOP,
+ dcp::Time (0, 0, 0, 0, 24),
+ dcp::Time (0, 0, 0, 0, 24)
+ )
+ )
+ );
+
+ c->_id = "a6c58cff-3e1e-4b38-acec-a42224475ef6";
+ boost::filesystem::remove_all ("build/test/write_interop_subtitle_test3");
+ boost::filesystem::create_directories ("build/test/write_interop_subtitle_test3");
+ c->write ("build/test/write_interop_subtitle_test3/subs.xml");
+
+ shared_ptr<dcp::Reel> reel (new dcp::Reel());
+ reel->add(shared_ptr<dcp::ReelSubtitleAsset>(new dcp::ReelSubtitleAsset(c, dcp::Fraction(24, 1), 6046, 0)));
+
+ string const issue_date = "2018-09-02T04:45:18+00:00";
+ string const issuer = "libdcp";
+ string const creator = "libdcp";
+ string const annotation_text = "Created by libdcp";
+
+ shared_ptr<dcp::CPL> cpl (new dcp::CPL ("My film", dcp::FEATURE));
+ cpl->add (reel);
+ cpl->set_issuer (issuer);
+ cpl->set_creator (creator);
+ cpl->set_issue_date (issue_date);
+ cpl->set_annotation_text (annotation_text);
+ optional<dcp::ContentVersion> cv = cpl->content_version();
+ BOOST_REQUIRE (cv);
+ cv->label_text = "foo";
+ cpl->set_content_version (*cv);
+
+ dcp::DCP dcp ("build/test/write_interop_subtitle_test3");
+ dcp.add (cpl);
+ dcp.write_xml (dcp::INTEROP, issuer, creator, issue_date, annotation_text);
+
+ check_xml (
+ dcp::file_to_string("test/ref/write_interop_subtitle_test3/subs.xml"),
+ dcp::file_to_string("build/test/write_interop_subtitle_test3/subs.xml"),
+ list<string>()
+ );
+ check_file ("build/test/write_interop_subtitle_test3/d36f4bb3-c4fa-4a95-9915-6fec3110cd71.png", "test/data/sub.png");
+
+ check_xml (
+ dcp::file_to_string("test/ref/write_interop_subtitle_test3/ASSETMAP"),
+ dcp::file_to_string("build/test/write_interop_subtitle_test3/ASSETMAP"),
+ list<string>()
+ );
+
+ check_xml (
+ dcp::file_to_string("test/ref/write_interop_subtitle_test3/pkl.xml"),
+ dcp::file_to_string("build/test/write_interop_subtitle_test3/pkl_6a9e31a6-50a4-4ecb-8683-fa667848470a.xml"),
+ list<string>()
+ );
+}
+
/* Write some subtitle content as SMPTE XML and check that it is right */
BOOST_AUTO_TEST_CASE (write_smpte_subtitle_test)
{
list<string> ()
);
}
+
+/* Write some subtitle content as SMPTE using bitmaps and check that it is right */
+BOOST_AUTO_TEST_CASE (write_smpte_subtitle_test3)
+{
+ dcp::SMPTESubtitleAsset c;
+ c.set_reel_number (1);
+ c.set_language ("EN");
+ c.set_content_title_text ("Test");
+
+ c.add (
+ shared_ptr<dcp::Subtitle> (
+ new dcp::SubtitleImage (
+ dcp::Data ("test/data/sub.png"),
+ dcp::Time (0, 4, 9, 22, 24),
+ dcp::Time (0, 4, 11, 22, 24),
+ 0,
+ dcp::HALIGN_CENTER,
+ 0.8,
+ dcp::VALIGN_TOP,
+ dcp::Time (0, 0, 0, 0, 24),
+ dcp::Time (0, 0, 0, 0, 24)
+ )
+ )
+ );
+
+ c._id = "a6c58cff-3e1e-4b38-acec-a42224475ef6";
+
+ boost::filesystem::create_directories ("build/test/write_smpte_subtitle_test3");
+ c.write ("build/test/write_smpte_subtitle_test3/subs.mxf");
+
+ /* XXX: check this result when we can read them back in again */
+}