diff options
| author | Carl Hetherington <cth@carlh.net> | 2021-04-11 20:49:18 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2021-04-11 20:50:12 +0200 |
| commit | 3370a67e8a9aeaec45911ba1c714a0d259781fdf (patch) | |
| tree | e1d49c3d59eeb94dfa836b90f8c9042df3528c82 | |
| parent | 3a94f95d49e99fe5936e19977c28de25033488a8 (diff) | |
Small bits of tidying up.
| -rw-r--r-- | src/cpl.cc | 15 | ||||
| -rw-r--r-- | src/reel_encryptable_asset.cc | 2 | ||||
| -rw-r--r-- | test/combine_test.cc | 4 | ||||
| -rw-r--r-- | test/cpl_metadata_test.cc | 9 | ||||
| -rw-r--r-- | test/dcp_font_test.cc | 11 | ||||
| -rw-r--r-- | test/reel_asset_test.cc | 10 | ||||
| -rw-r--r-- | test/test.cc | 43 |
7 files changed, 52 insertions, 42 deletions
@@ -58,16 +58,17 @@ #include <boost/algorithm/string.hpp> -using std::string; +using std::cout; +using std::dynamic_pointer_cast; using std::list; -using std::pair; using std::make_pair; -using std::cout; +using std::make_shared; +using std::pair; using std::set; -using std::vector; using std::shared_ptr; +using std::string; +using std::vector; using boost::optional; -using std::dynamic_pointer_cast; using namespace dcp; @@ -291,9 +292,9 @@ CPL::read_composition_metadata_asset (cxml::ConstNodePtr node) /* If the first language on SubtitleLanguageList is the same as the language of the first subtitle we'll ignore it */ size_t first = 0; if (!_reels.empty()) { - shared_ptr<dcp::ReelSubtitleAsset> sub = _reels.front()->main_subtitle(); + auto sub = _reels.front()->main_subtitle(); if (sub) { - optional<string> lang = sub->language(); + auto lang = sub->language(); if (lang && lang == sll_split[0]) { first = 1; } diff --git a/src/reel_encryptable_asset.cc b/src/reel_encryptable_asset.cc index feb71b59..82dc9c89 100644 --- a/src/reel_encryptable_asset.cc +++ b/src/reel_encryptable_asset.cc @@ -59,7 +59,7 @@ ReelEncryptableAsset::ReelEncryptableAsset (optional<string> key_id) ReelEncryptableAsset::ReelEncryptableAsset (shared_ptr<const cxml::Node> node) - : _key_id (node->optional_string_child ("KeyId")) + : _key_id (node->optional_string_child("KeyId")) { if (_key_id) { _key_id = remove_urn_uuid (*_key_id); diff --git a/test/combine_test.cc b/test/combine_test.cc index 59931be7..99795592 100644 --- a/test/combine_test.cc +++ b/test/combine_test.cc @@ -195,10 +195,10 @@ BOOST_AUTO_TEST_CASE (combine_two_dcps_with_interop_subs_test) using namespace boost::filesystem; boost::filesystem::path const out = "build/test/combine_two_dcps_with_interop_subs_test"; - shared_ptr<dcp::DCP> first = make_simple_with_interop_subs ("build/test/combine_input1"); + auto first = make_simple_with_interop_subs ("build/test/combine_input1"); first->write_xml (dcp::Standard::INTEROP); - shared_ptr<dcp::DCP> second = make_simple_with_interop_subs ("build/test/combine_input2"); + auto second = make_simple_with_interop_subs ("build/test/combine_input2"); second->write_xml (dcp::Standard::INTEROP); remove_all (out); diff --git a/test/cpl_metadata_test.cc b/test/cpl_metadata_test.cc index c9ee3b9b..2c88d6a8 100644 --- a/test/cpl_metadata_test.cc +++ b/test/cpl_metadata_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2020 Carl Hetherington <cth@carlh.net> + Copyright (C) 2020-2021 Carl Hetherington <cth@carlh.net> This file is part of libdcp. @@ -37,7 +37,7 @@ #include "exceptions.h" #include "language_tag.h" #include "reel.h" -#include "reel_subtitle_asset.h" +#include "reel_smpte_subtitle_asset.h" #include "stream_operators.h" #include "test.h" #include <memory> @@ -45,9 +45,10 @@ using std::list; +using std::make_shared; +using std::shared_ptr; using std::string; using std::vector; -using std::shared_ptr; BOOST_AUTO_TEST_CASE (cpl_metadata_bad_values_test) @@ -301,7 +302,7 @@ BOOST_AUTO_TEST_CASE (cpl_metadata_write_test1) shared_ptr<dcp::Reel> reel(new dcp::Reel()); reel->add (black_picture_asset("build/test/cpl_metadata_write_test1")); - reel->add (shared_ptr<dcp::ReelSubtitleAsset>(new dcp::ReelSubtitleAsset(doc))); + reel->add (make_shared<dcp::ReelSMPTESubtitleAsset>(doc)); cpl.add (reel); vector<dcp::LanguageTag> lt; diff --git a/test/dcp_font_test.cc b/test/dcp_font_test.cc index da9d3000..2ac68273 100644 --- a/test/dcp_font_test.cc +++ b/test/dcp_font_test.cc @@ -31,6 +31,7 @@ files in the program, then also delete it here. */ + #include "interop_subtitle_asset.h" #include "smpte_subtitle_asset.h" #include "dcp.h" @@ -38,10 +39,12 @@ #include "test.h" #include "reel.h" #include "util.h" -#include "reel_subtitle_asset.h" +#include "reel_interop_subtitle_asset.h" +#include "reel_smpte_subtitle_asset.h" #include <boost/test/unit_test.hpp> #include <cstdio> + using std::list; using std::string; using std::shared_ptr; @@ -55,13 +58,13 @@ BOOST_AUTO_TEST_CASE (interop_dcp_font_test) boost::filesystem::path directory = "build/test/interop_dcp_font_test"; dcp::DCP dcp (directory); - shared_ptr<dcp::InteropSubtitleAsset> subs (new dcp::InteropSubtitleAsset ()); + auto subs = make_shared<dcp::InteropSubtitleAsset>(); subs->add_font ("theFontId", dcp::ArrayData("test/data/dummy.ttf")); subs->write (directory / "frobozz.xml"); check_file ("test/data/dummy.ttf", "build/test/interop_dcp_font_test/font_0.ttf"); auto reel = make_shared<dcp::Reel>(); - reel->add (make_shared<dcp::ReelSubtitleAsset>(subs, dcp::Fraction (24, 1), 24, 0)); + reel->add (make_shared<dcp::ReelInteropSubtitleAsset>(subs, dcp::Fraction (24, 1), 24, 0)); auto cpl = make_shared<dcp::CPL>("", dcp::ContentKind::TRAILER); cpl->add (reel); @@ -98,7 +101,7 @@ BOOST_AUTO_TEST_CASE (smpte_dcp_font_test) subs->write (directory / "frobozz.mxf"); auto reel = make_shared<dcp::Reel>(); - reel->add (make_shared<dcp::ReelSubtitleAsset>(subs, dcp::Fraction (24, 1), 24, 0)); + reel->add (make_shared<dcp::ReelSMPTESubtitleAsset>(subs, dcp::Fraction (24, 1), 24, 0)); auto cpl = make_shared<dcp::CPL>("", dcp::ContentKind::TRAILER); cpl->add (reel); diff --git a/test/reel_asset_test.cc b/test/reel_asset_test.cc index e0c7f781..8d7a8971 100644 --- a/test/reel_asset_test.cc +++ b/test/reel_asset_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2015-2020 Carl Hetherington <cth@carlh.net> + Copyright (C) 2015-2021 Carl Hetherington <cth@carlh.net> This file is part of libdcp. @@ -31,23 +31,25 @@ files in the program, then also delete it here. */ + #include "reel_mono_picture_asset.h" -#include "reel_subtitle_asset.h" +#include "reel_smpte_subtitle_asset.h" #include <libcxml/cxml.h> #include <boost/test/unit_test.hpp> #include "stream_operators.h" #include "test.h" +using std::make_shared; using std::string; -using boost::optional; using std::shared_ptr; +using boost::optional; /** Test the XML constructor of ReelPictureAsset */ BOOST_AUTO_TEST_CASE (reel_picture_asset_test) { - shared_ptr<cxml::Document> doc (new cxml::Document ("MainPicture")); + auto doc = make_shared<cxml::Document>("MainPicture"); doc->read_string ( "<MainPicture>" diff --git a/test/test.cc b/test/test.cc index 069d02ec..c48ecffe 100644 --- a/test/test.cc +++ b/test/test.cc @@ -37,25 +37,26 @@ #include "cpl.h" #include "dcp.h" #include "interop_subtitle_asset.h" +#include "j2k_transcode.h" +#include "mono_picture_asset.h" #include "mono_picture_asset.h" +#include "openjpeg_image.h" +#include "picture_asset_writer.h" #include "picture_asset_writer.h" #include "reel.h" +#include "reel_asset.h" +#include "reel_closed_caption_asset.h" +#include "reel_interop_subtitle_asset.h" +#include "reel_markers_asset.h" +#include "reel_mono_picture_asset.h" #include "reel_mono_picture_asset.h" +#include "reel_smpte_subtitle_asset.h" #include "reel_sound_asset.h" -#include "reel_closed_caption_asset.h" -#include "reel_subtitle_asset.h" +#include "smpte_subtitle_asset.h" #include "sound_asset.h" #include "sound_asset_writer.h" -#include "smpte_subtitle_asset.h" -#include "mono_picture_asset.h" -#include "openjpeg_image.h" -#include "j2k_transcode.h" -#include "picture_asset_writer.h" -#include "reel_mono_picture_asset.h" -#include "reel_asset.h" #include "test.h" #include "util.h" -#include "reel_markers_asset.h" #include <asdcp/KM_util.h> #include <asdcp/KM_prng.h> #include <sndfile.h> @@ -64,6 +65,7 @@ #include <cstdio> #include <iostream> + using std::string; using std::min; using std::vector; @@ -95,6 +97,7 @@ struct TestConfig } }; + void check_xml (xmlpp::Element* ref, xmlpp::Element* test, vector<string> ignore_tags, bool ignore_whitespace) { @@ -186,12 +189,12 @@ check_xml (xmlpp::Element* ref, xmlpp::Element* test, vector<string> ignore_tags void check_xml (string ref, string test, vector<string> ignore, bool ignore_whitespace) { - xmlpp::DomParser* ref_parser = new xmlpp::DomParser (); + auto ref_parser = new xmlpp::DomParser (); ref_parser->parse_memory (ref); - xmlpp::Element* ref_root = ref_parser->get_document()->get_root_node (); - xmlpp::DomParser* test_parser = new xmlpp::DomParser (); + auto ref_root = ref_parser->get_document()->get_root_node (); + auto test_parser = new xmlpp::DomParser (); test_parser->parse_memory (test); - xmlpp::Element* test_root = test_parser->get_document()->get_root_node (); + auto test_root = test_parser->get_document()->get_root_node (); check_xml (ref_root, test_root, ignore, ignore_whitespace); } @@ -201,14 +204,14 @@ check_file (boost::filesystem::path ref, boost::filesystem::path check) { uintmax_t size = boost::filesystem::file_size (ref); BOOST_CHECK_EQUAL (size, boost::filesystem::file_size(check)); - FILE* ref_file = dcp::fopen_boost (ref, "rb"); + auto ref_file = dcp::fopen_boost (ref, "rb"); BOOST_REQUIRE (ref_file); - FILE* check_file = dcp::fopen_boost (check, "rb"); + auto check_file = dcp::fopen_boost (check, "rb"); BOOST_REQUIRE (check_file); int const buffer_size = 65536; - uint8_t* ref_buffer = new uint8_t[buffer_size]; - uint8_t* check_buffer = new uint8_t[buffer_size]; + auto ref_buffer = new uint8_t[buffer_size]; + auto check_buffer = new uint8_t[buffer_size]; uintmax_t pos = 0; @@ -421,7 +424,7 @@ make_simple_with_interop_subs (boost::filesystem::path path) subs->add_font ("afont", data); subs->write (path / "subs" / "subs.xml"); - shared_ptr<dcp::ReelSubtitleAsset> reel_subs(new dcp::ReelSubtitleAsset(subs, dcp::Fraction(24, 1), 240, 0)); + auto reel_subs = make_shared<dcp::ReelInteropSubtitleAsset>(subs, dcp::Fraction(24, 1), 240, 0); dcp->cpls().front()->reels().front()->add (reel_subs); return dcp; @@ -440,7 +443,7 @@ make_simple_with_smpte_subs (boost::filesystem::path path) subs->write (path / "subs.mxf"); - shared_ptr<dcp::ReelSubtitleAsset> reel_subs(new dcp::ReelSubtitleAsset(subs, dcp::Fraction(24, 1), 192, 0)); + auto reel_subs = make_shared<dcp::ReelSMPTESubtitleAsset>(subs, dcp::Fraction(24, 1), 192, 0); dcp->cpls().front()->reels().front()->add (reel_subs); return dcp; |
