diff options
| -rw-r--r-- | src/asset.cc | 2 | ||||
| -rw-r--r-- | src/cpl.cc | 6 | ||||
| -rw-r--r-- | src/subtitle_asset.cc | 3 | ||||
| -rw-r--r-- | test/data/create_open_caption_test.xml | 30 | ||||
| -rw-r--r-- | test/open_caption_test.cc | 73 | ||||
| -rw-r--r-- | test/wscript | 1 |
6 files changed, 115 insertions, 0 deletions
diff --git a/src/asset.cc b/src/asset.cc index ef06ea8d..f2efb293 100644 --- a/src/asset.cc +++ b/src/asset.cc @@ -114,10 +114,12 @@ Asset::add_to_assetmap(AssetMap& asset_map, boost::filesystem::path root) const void Asset::add_file_to_assetmap(AssetMap& asset_map, boost::filesystem::path root, boost::filesystem::path file, string id) { + std::cout << "toot toot " << root << " " << file << "\n"; auto path = relative_to_root ( filesystem::canonical(root), filesystem::canonical(file) ); + std::cout << "addin " << *path << "\n"; if (!path) { /* The path of this asset is not within our DCP, so we assume it's an external @@ -615,6 +615,12 @@ add_file_assets (vector<shared_ptr<T>>& assets, vector<shared_ptr<Reel>> reels) if (i->main_subtitle ()) { assets.push_back (i->main_subtitle()); } + if (i->main_caption()) { + assets.push_back(i->main_caption()); + } + for (auto j: i->closed_subtitles()) { + assets.push_back (j); + } for (auto j: i->closed_captions()) { assets.push_back (j); } diff --git a/src/subtitle_asset.cc b/src/subtitle_asset.cc index 1cd4fc07..9203f508 100644 --- a/src/subtitle_asset.cc +++ b/src/subtitle_asset.cc @@ -567,8 +567,11 @@ vector<shared_ptr<const Subtitle>> SubtitleAsset::subtitles_during (Time from, Time to, bool starting) const { vector<shared_ptr<const Subtitle>> s; + // std::cout << "checkin " << _subtitles.size() << "\n"; for (auto i: _subtitles) { + // std::cout << "starting=" << starting << " " << from << " " << to << " " << i->in() << " " << i->out() << "\n"; if ((starting && from <= i->in() && i->in() < to) || (!starting && i->out() >= from && i->in() <= to)) { + std::cout << "given it up\n"; s.push_back (i); } } 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 |
