summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2024-06-28 17:46:42 +0200
committerCarl Hetherington <cth@carlh.net>2024-06-28 17:46:42 +0200
commit85eebdf558ca89ce53bb59a0127f1c804e82981b (patch)
treebb7e6c654ed281ced61cece92452481a7f396288 /test
parent632fd6b46be907c044474a09ffffad6cccb14d08 (diff)
Diffstat (limited to 'test')
-rw-r--r--test/data/create_open_caption_test.xml30
-rw-r--r--test/open_caption_test.cc73
-rw-r--r--test/wscript1
3 files changed, 104 insertions, 0 deletions
diff --git a/test/data/create_open_caption_test.xml b/test/data/create_open_caption_test.xml
new file mode 100644
index 00000000..37685d62
--- /dev/null
+++ b/test/data/create_open_caption_test.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<CompositionPlaylist xmlns="http://www.smpte-ra.org/schemas/429-7/2006/CPL">
+ <Id>urn:uuid:d40b0977-d657-477b-897d-89a3fd858eaa</Id>
+ <AnnotationText>Foo</AnnotationText>
+ <IssueDate>2024-06-26T19:36:18+02:00</IssueDate>
+ <Issuer>libdcp</Issuer>
+ <Creator>libdcp</Creator>
+ <ContentTitleText>Foo</ContentTitleText>
+ <ContentKind>feature</ContentKind>
+ <ContentVersion>
+ <Id>urn:uuid:283534ca-79de-4bbd-9387-3bcec3b515d6</Id>
+ <LabelText>urn:uuid:283534ca-79de-4bbd-9387-3bcec3b515d62024-06-26T19:36:18+02:00</LabelText>
+ </ContentVersion>
+ <RatingList/>
+ <ReelList>
+ <Reel>
+ <Id>urn:uuid:f2a0d248-da4d-4570-a507-2a8fc053ee91</Id>
+ <AssetList>
+ <tt:MainCaption xmlns:tt="http://www.smpte-ra.org/schemas/429-12/2008/TT">
+ <Id>urn:uuid:a6c58cff-3e1e-4b38-acec-a42224475ef6</Id>
+ <EditRate>24 1</EditRate>
+ <IntrinsicDuration>480</IntrinsicDuration>
+ <EntryPoint>0</EntryPoint>
+ <Duration>480</Duration>
+ <Hash>dPD3HYwXr6yr0+++d3x4pm/AIRM=</Hash>
+ </tt:MainCaption>
+ </AssetList>
+ </Reel>
+ </ReelList>
+</CompositionPlaylist>
diff --git a/test/open_caption_test.cc b/test/open_caption_test.cc
new file mode 100644
index 00000000..f0dce3f7
--- /dev/null
+++ b/test/open_caption_test.cc
@@ -0,0 +1,73 @@
+/*
+ Copyright (C) 2024 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.
+*/
+
+
+#include "cpl.h"
+#include "reel.h"
+#include "reel_smpte_caption_asset.h"
+#include "smpte_subtitle_asset.h"
+#include "test.h"
+#include <boost/test/unit_test.hpp>
+
+
+using std::make_shared;
+
+
+BOOST_AUTO_TEST_CASE(create_open_caption_test)
+{
+ auto subs = make_shared<dcp::SMPTESubtitleAsset>("test/data/subs.mxf");
+ auto reel_asset = make_shared<dcp::ReelSMPTECaptionAsset>(subs, dcp::Fraction{24, 1}, 480, 0, dcp::TextType::OPEN);
+
+ auto reel = make_shared<dcp::Reel>();
+ reel->add(reel_asset);
+
+ auto cpl = make_shared<dcp::CPL>("Foo", dcp::ContentKind::FEATURE, dcp::Standard::SMPTE);
+ cpl->add(reel);
+
+ auto dcp_dir = boost::filesystem::path("build/test/create_open_caption_test");
+ boost::system::error_code ec;
+ boost::filesystem::remove_all(dcp_dir, ec);
+ boost::filesystem::create_directories(dcp_dir);
+
+ cpl->write_xml("build/test/create_open_caption_test/cpl.xml", {});
+ check_xml(dcp::file_to_string("test/data/create_open_caption_test.xml"), dcp::file_to_string("build/test/create_open_caption_test/cpl.xml"), {"Id", "IssueDate", "LabelText"});
+
+ /* XXX */
+
+ auto dcp = make_simple(dcp_dir, 1, 24 * 60 * 5, dcp::Standard::SMPTE, {});
+ boost::filesystem::copy_file(*subs->file(), dcp_dir / "subs.mxf");
+ subs->set_file(dcp_dir / "subs.mxf");
+ dcp->cpls()[0]->reels()[0]->add(reel_asset);
+ dcp->write_xml();
+}
+
diff --git a/test/wscript b/test/wscript
index 64b3ed59..ab552eb7 100644
--- a/test/wscript
+++ b/test/wscript
@@ -96,6 +96,7 @@ def build(bld):
mca_test.cc
mono_mpeg2_picture_read_test.cc
mono_mpeg2_picture_write_test.cc
+ open_caption_test.cc
kdm_test.cc
key_test.cc
language_tag_test.cc