diff options
| author | Carl Hetherington <cth@carlh.net> | 2021-01-08 21:49:47 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2021-01-08 21:49:53 +0100 |
| commit | 56b6a62a28734ad66d0f4c8ea9452b89f4cc5f45 (patch) | |
| tree | 7150f6cc02654723bb7466c4942601eb624bf258 /src | |
| parent | 4245000bfc5aa1d61428a6a983c2b0425d17ae42 (diff) | |
More c++11 tidying.
Diffstat (limited to 'src')
| -rw-r--r-- | src/cpl.cc | 113 | ||||
| -rw-r--r-- | src/dcp.cc | 106 | ||||
| -rw-r--r-- | src/encrypted_kdm.cc | 101 | ||||
| -rw-r--r-- | src/reel.cc | 89 |
4 files changed, 202 insertions, 207 deletions
@@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2018 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net> This file is part of libdcp. @@ -50,7 +50,6 @@ #include <libxml/parser.h> #include <libxml++/libxml++.h> #include <boost/algorithm/string.hpp> -#include <boost/foreach.hpp> using std::string; using std::list; @@ -124,20 +123,20 @@ CPL::CPL (boost::filesystem::path file) /* ContentVersion is required in SMPTE */ throw XMLError ("Missing ContentVersion tag in CPL"); } - cxml::ConstNodePtr rating_list = f.node_child ("RatingList"); + auto rating_list = f.node_child ("RatingList"); if (rating_list) { - BOOST_FOREACH (cxml::ConstNodePtr i, rating_list->node_children("Rating")) { + for (auto i: rating_list->node_children("Rating")) { _ratings.push_back (Rating(i)); } } _reels = type_grand_children<Reel> (f, "ReelList", "Reel"); - cxml::ConstNodePtr reel_list = f.node_child ("ReelList"); + auto reel_list = f.node_child ("ReelList"); if (reel_list) { - list<cxml::NodePtr> reels = reel_list->node_children("Reel"); + auto reels = reel_list->node_children("Reel"); if (!reels.empty()) { - cxml::ConstNodePtr asset_list = reels.front()->node_child("AssetList"); - cxml::ConstNodePtr metadata = asset_list->optional_node_child("CompositionMetadataAsset"); + auto asset_list = reels.front()->node_child("AssetList"); + auto metadata = asset_list->optional_node_child("CompositionMetadataAsset"); if (metadata) { read_composition_metadata_asset (metadata); } @@ -192,16 +191,16 @@ CPL::write_xml (boost::filesystem::path file, Standard standard, shared_ptr<cons _content_versions[0].as_xml (root); } - xmlpp::Element* rating_list = root->add_child("RatingList"); - BOOST_FOREACH (Rating i, _ratings) { + auto rating_list = root->add_child("RatingList"); + for (auto i: _ratings) { i.as_xml (rating_list->add_child("Rating")); } - xmlpp::Element* reel_list = root->add_child ("ReelList"); + auto reel_list = root->add_child ("ReelList"); bool first = true; - BOOST_FOREACH (shared_ptr<Reel> i, _reels) { - xmlpp::Element* asset_list = i->write_to_cpl (reel_list, standard); + for (auto i: _reels) { + auto asset_list = i->write_to_cpl (reel_list, standard); if (first && standard == dcp::SMPTE) { maybe_write_composition_metadata_asset (asset_list); first = false; @@ -223,17 +222,17 @@ CPL::write_xml (boost::filesystem::path file, Standard standard, shared_ptr<cons void CPL::read_composition_metadata_asset (cxml::ConstNodePtr node) { - cxml::ConstNodePtr fctt = node->node_child("FullContentTitleText"); + auto fctt = node->node_child("FullContentTitleText"); _full_content_title_text = fctt->content(); _full_content_title_text_language = fctt->optional_string_attribute("language"); _release_territory = node->optional_string_child("ReleaseTerritory"); - cxml::ConstNodePtr vn = node->optional_node_child("VersionNumber"); + auto vn = node->optional_node_child("VersionNumber"); if (vn) { _version_number = raw_convert<int>(vn->content()); /* I decided to check for this number being non-negative on being set, and in the verifier, but not here */ - optional<string> vn_status = vn->optional_string_attribute("status"); + auto vn_status = vn->optional_string_attribute("status"); if (vn_status) { _status = string_to_status (*vn_status); } @@ -243,21 +242,21 @@ CPL::read_composition_metadata_asset (cxml::ConstNodePtr node) _distributor = node->optional_string_child("Distributor"); _facility = node->optional_string_child("Facility"); - cxml::ConstNodePtr acv = node->optional_node_child("AlternateContentVersionList"); + auto acv = node->optional_node_child("AlternateContentVersionList"); if (acv) { - BOOST_FOREACH (cxml::ConstNodePtr i, acv->node_children("ContentVersion")) { + for (auto i: acv->node_children("ContentVersion")) { _content_versions.push_back (ContentVersion(i)); } } - cxml::ConstNodePtr lum = node->optional_node_child("Luminance"); + auto lum = node->optional_node_child("Luminance"); if (lum) { _luminance = Luminance (lum); } _main_sound_configuration = node->optional_string_child("MainSoundConfiguration"); - optional<string> sr = node->optional_string_child("MainSoundSampleRate"); + auto sr = node->optional_string_child("MainSoundSampleRate"); if (sr) { vector<string> sr_bits; boost::split (sr_bits, *sr, boost::is_any_of(" ")); @@ -275,7 +274,7 @@ CPL::read_composition_metadata_asset (cxml::ConstNodePtr node) node->node_child("MainPictureActiveArea")->number_child<int>("Height") ); - optional<string> sll = node->optional_string_child("MainSubtitleLanguageList"); + auto sll = node->optional_string_child("MainSubtitleLanguageList"); if (sll) { vector<string> sll_split; boost::split (sll_split, *sll, boost::is_any_of(" ")); @@ -293,7 +292,7 @@ CPL::read_composition_metadata_asset (cxml::ConstNodePtr node) } } - for (size_t i = first; i < sll_split.size(); ++i) { + for (auto i = first; i < sll_split.size(); ++i) { _additional_subtitle_languages.push_back (sll_split[i]); } } @@ -317,16 +316,16 @@ CPL::maybe_write_composition_metadata_asset (xmlpp::Element* node) const return; } - xmlpp::Element* meta = node->add_child("meta:CompositionMetadataAsset"); + auto meta = node->add_child("meta:CompositionMetadataAsset"); meta->set_namespace_declaration (cpl_metadata_ns, "meta"); meta->add_child("Id")->add_child_text("urn:uuid:" + make_uuid()); - shared_ptr<dcp::ReelPictureAsset> mp = _reels.front()->main_picture(); + auto mp = _reels.front()->main_picture(); meta->add_child("EditRate")->add_child_text(mp->edit_rate().as_string()); meta->add_child("IntrinsicDuration")->add_child_text(raw_convert<string>(mp->intrinsic_duration())); - xmlpp::Element* fctt = meta->add_child("FullContentTitleText", "meta"); + auto fctt = meta->add_child("FullContentTitleText", "meta"); if (_full_content_title_text) { fctt->add_child_text (*_full_content_title_text); } @@ -372,16 +371,16 @@ CPL::maybe_write_composition_metadata_asset (xmlpp::Element* node) const meta->add_child("MainSoundConfiguration", "meta")->add_child_text(*_main_sound_configuration); meta->add_child("MainSoundSampleRate", "meta")->add_child_text(raw_convert<string>(*_main_sound_sample_rate) + " 1"); - xmlpp::Element* stored = meta->add_child("MainPictureStoredArea", "meta"); + auto stored = meta->add_child("MainPictureStoredArea", "meta"); stored->add_child("Width", "meta")->add_child_text(raw_convert<string>(_main_picture_stored_area->width)); stored->add_child("Height", "meta")->add_child_text(raw_convert<string>(_main_picture_stored_area->height)); - xmlpp::Element* active = meta->add_child("MainPictureActiveArea", "meta"); + auto active = meta->add_child("MainPictureActiveArea", "meta"); active->add_child("Width", "meta")->add_child_text(raw_convert<string>(_main_picture_active_area->width)); active->add_child("Height", "meta")->add_child_text(raw_convert<string>(_main_picture_active_area->height)); optional<string> first_subtitle_language; - BOOST_FOREACH (shared_ptr<const Reel> i, _reels) { + for (auto i: _reels) { if (i->main_subtitle()) { first_subtitle_language = i->main_subtitle()->language(); if (first_subtitle_language) { @@ -395,7 +394,7 @@ CPL::maybe_write_composition_metadata_asset (xmlpp::Element* node) const if (first_subtitle_language) { lang = *first_subtitle_language; } - BOOST_FOREACH (string const& i, _additional_subtitle_languages) { + for (auto const& i: _additional_subtitle_languages) { if (!lang.empty()) { lang += " "; } @@ -405,28 +404,28 @@ CPL::maybe_write_composition_metadata_asset (xmlpp::Element* node) const } /* SMPTE Bv2.1 8.6.3 */ - xmlpp::Element* extension = meta->add_child("ExtensionMetadataList", "meta")->add_child("ExtensionMetadata", "meta"); + auto extension = meta->add_child("ExtensionMetadataList", "meta")->add_child("ExtensionMetadata", "meta"); extension->set_attribute("scope", "http://isdcf.com/ns/cplmd/app"); extension->add_child("Name", "meta")->add_child_text("Application"); - xmlpp::Element* property = extension->add_child("PropertyList", "meta")->add_child("Property", "meta"); + auto property = extension->add_child("PropertyList", "meta")->add_child("Property", "meta"); property->add_child("Name", "meta")->add_child_text("DCP Constraints Profile"); property->add_child("Value", "meta")->add_child_text("SMPTE-RDD-52:2020-Bv2.1"); if (_reels.front()->main_sound()) { - shared_ptr<const SoundAsset> asset = _reels.front()->main_sound()->asset(); + auto asset = _reels.front()->main_sound()->asset(); if (asset) { - shared_ptr<SoundAssetReader> reader = asset->start_read (); + auto reader = asset->start_read (); ASDCP::MXF::SoundfieldGroupLabelSubDescriptor* soundfield; ASDCP::Result_t r = reader->reader()->OP1aHeader().GetMDObjectByType( asdcp_smpte_dict->ul(ASDCP::MDD_SoundfieldGroupLabelSubDescriptor), reinterpret_cast<ASDCP::MXF::InterchangeObject**>(&soundfield) ); if (KM_SUCCESS(r)) { - xmlpp::Element* mca_subs = meta->add_child("mca:MCASubDescriptors"); + auto mca_subs = meta->add_child("mca:MCASubDescriptors"); mca_subs->set_namespace_declaration (mca_sub_descriptors_ns, "mca"); mca_subs->set_namespace_declaration (smpte_395_ns, "r0"); mca_subs->set_namespace_declaration (smpte_335_ns, "r1"); - xmlpp::Element* sf = mca_subs->add_child("SoundfieldGroupLabelSubDescriptor", "r0"); + auto sf = mca_subs->add_child("SoundfieldGroupLabelSubDescriptor", "r0"); char buffer[64]; soundfield->InstanceUID.EncodeString(buffer, sizeof(buffer)); sf->add_child("InstanceID", "r1")->add_child_text("urn:uuid:" + string(buffer)); @@ -446,14 +445,14 @@ CPL::maybe_write_composition_metadata_asset (xmlpp::Element* node) const } list<ASDCP::MXF::InterchangeObject*> channels; - ASDCP::Result_t r = reader->reader()->OP1aHeader().GetMDObjectsByType( + auto r = reader->reader()->OP1aHeader().GetMDObjectsByType( asdcp_smpte_dict->ul(ASDCP::MDD_AudioChannelLabelSubDescriptor), channels ); - BOOST_FOREACH (ASDCP::MXF::InterchangeObject* i, channels) { - ASDCP::MXF::AudioChannelLabelSubDescriptor* channel = reinterpret_cast<ASDCP::MXF::AudioChannelLabelSubDescriptor*>(i); - xmlpp::Element* ch = mca_subs->add_child("AudioChannelLabelSubDescriptor", "r0"); + for (auto i: channels) { + auto channel = reinterpret_cast<ASDCP::MXF::AudioChannelLabelSubDescriptor*>(i); + auto ch = mca_subs->add_child("AudioChannelLabelSubDescriptor", "r0"); channel->InstanceUID.EncodeString(buffer, sizeof(buffer)); ch->add_child("InstanceID", "r1")->add_child_text("urn:uuid:" + string(buffer)); channel->MCALabelDictionaryID.EncodeString(buffer, sizeof(buffer)); @@ -484,12 +483,12 @@ CPL::maybe_write_composition_metadata_asset (xmlpp::Element* node) const } -list<shared_ptr<ReelMXF> > +list<shared_ptr<ReelMXF>> CPL::reel_mxfs () { - list<shared_ptr<ReelMXF> > c; + list<shared_ptr<ReelMXF>> c; - BOOST_FOREACH (shared_ptr<Reel> i, _reels) { + for (auto i: _reels) { if (i->main_picture ()) { c.push_back (i->main_picture()); } @@ -499,7 +498,7 @@ CPL::reel_mxfs () if (i->main_subtitle ()) { c.push_back (i->main_subtitle()); } - BOOST_FOREACH (shared_ptr<ReelClosedCaptionAsset> j, i->closed_captions()) { + for (auto j: i->closed_captions()) { c.push_back (j); } if (i->atmos ()) { @@ -510,12 +509,12 @@ CPL::reel_mxfs () return c; } -list<shared_ptr<const ReelMXF> > +list<shared_ptr<const ReelMXF>> CPL::reel_mxfs () const { - list<shared_ptr<const ReelMXF> > c; + list<shared_ptr<const ReelMXF>> c; - BOOST_FOREACH (shared_ptr<Reel> i, _reels) { + for (auto i: _reels) { if (i->main_picture ()) { c.push_back (i->main_picture()); } @@ -525,7 +524,7 @@ CPL::reel_mxfs () const if (i->main_subtitle ()) { c.push_back (i->main_subtitle()); } - BOOST_FOREACH (shared_ptr<ReelClosedCaptionAsset> j, i->closed_captions()) { + for (auto j: i->closed_captions()) { c.push_back (j); } if (i->atmos ()) { @@ -539,7 +538,7 @@ CPL::reel_mxfs () const bool CPL::equals (shared_ptr<const Asset> other, EqualityOptions opt, NoteHandler note) const { - shared_ptr<const CPL> other_cpl = dynamic_pointer_cast<const CPL> (other); + auto other_cpl = dynamic_pointer_cast<const CPL>(other); if (!other_cpl) { return false; } @@ -560,8 +559,8 @@ CPL::equals (shared_ptr<const Asset> other, EqualityOptions opt, NoteHandler not return false; } - list<shared_ptr<Reel> >::const_iterator a = _reels.begin (); - list<shared_ptr<Reel> >::const_iterator b = other_cpl->_reels.begin (); + auto a = _reels.begin(); + auto b = other_cpl->_reels.begin(); while (a != _reels.end ()) { if (!(*a)->equals (*b, opt, note)) { @@ -578,7 +577,7 @@ CPL::equals (shared_ptr<const Asset> other, EqualityOptions opt, NoteHandler not bool CPL::encrypted () const { - BOOST_FOREACH (shared_ptr<Reel> i, _reels) { + for (auto i: _reels) { if (i->encrypted ()) { return true; } @@ -594,15 +593,15 @@ CPL::encrypted () const void CPL::add (DecryptedKDM const & kdm) { - BOOST_FOREACH (shared_ptr<Reel> i, _reels) { + for (auto i: _reels) { i->add (kdm); } } void -CPL::resolve_refs (list<shared_ptr<Asset> > assets) +CPL::resolve_refs (list<shared_ptr<Asset>> assets) { - BOOST_FOREACH (shared_ptr<Reel> i, _reels) { + for (auto i: _reels) { i->resolve_refs (assets); } } @@ -630,7 +629,7 @@ int64_t CPL::duration () const { int64_t d = 0; - BOOST_FOREACH (shared_ptr<Reel> i, _reels) { + for (auto i: _reels) { d += i->duration (); } return d; @@ -652,7 +651,7 @@ void CPL::set_content_versions (vector<ContentVersion> v) { set<string> ids; - BOOST_FOREACH (ContentVersion i, v) { + for (auto i: v) { if (!ids.insert(i.id).second) { throw DuplicateIdError ("Duplicate ID in ContentVersion list"); } @@ -677,7 +676,7 @@ void CPL::set_additional_subtitle_languages (vector<dcp::LanguageTag> const& langs) { _additional_subtitle_languages.clear (); - BOOST_FOREACH (dcp::LanguageTag const& i, langs) { + for (auto const& i: langs) { _additional_subtitle_languages.push_back (i.to_string()); } } @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2020 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net> This file is part of libdcp. @@ -65,7 +65,6 @@ #include <libxml++/libxml++.h> #include <boost/filesystem.hpp> #include <boost/algorithm/string.hpp> -#include <boost/foreach.hpp> using std::string; using std::list; @@ -74,6 +73,7 @@ using std::cout; using std::make_pair; using std::map; using std::cerr; +using std::make_shared; using std::exception; using std::shared_ptr; using std::dynamic_pointer_cast; @@ -131,14 +131,14 @@ DCP::read (list<dcp::VerificationNote>* notes, bool ignore_incorrect_picture_mxf boost::throw_exception (XMLError ("Unrecognised Assetmap namespace " + asset_map.namespace_uri())); } - list<shared_ptr<cxml::Node> > asset_nodes = asset_map.node_child("AssetList")->node_children ("Asset"); + auto asset_nodes = asset_map.node_child("AssetList")->node_children ("Asset"); map<string, boost::filesystem::path> paths; list<boost::filesystem::path> pkl_paths; - BOOST_FOREACH (shared_ptr<cxml::Node> i, asset_nodes) { + for (auto i: asset_nodes) { if (i->node_child("ChunkList")->node_children("Chunk").size() != 1) { boost::throw_exception (XMLError ("unsupported asset chunk count")); } - string p = i->node_child("ChunkList")->node_child("Chunk")->string_child ("Path"); + auto p = i->node_child("ChunkList")->node_child("Chunk")->string_child ("Path"); if (starts_with (p, "file://")) { p = p.substr (7); } @@ -152,7 +152,7 @@ DCP::read (list<dcp::VerificationNote>* notes, bool ignore_incorrect_picture_mxf break; case SMPTE: { - optional<string> pkl_bool = i->optional_string_child("PackingList"); + auto pkl_bool = i->optional_string_child("PackingList"); if (pkl_bool && *pkl_bool == "true") { pkl_paths.push_back (p); } else { @@ -167,8 +167,8 @@ DCP::read (list<dcp::VerificationNote>* notes, bool ignore_incorrect_picture_mxf boost::throw_exception (XMLError ("No packing lists found in asset map")); } - BOOST_FOREACH (boost::filesystem::path i, pkl_paths) { - _pkls.push_back (shared_ptr<PKL>(new PKL(_directory / i))); + for (auto i: pkl_paths) { + _pkls.push_back (make_shared<PKL>(_directory / i)); } /* Now we have: @@ -181,12 +181,12 @@ DCP::read (list<dcp::VerificationNote>* notes, bool ignore_incorrect_picture_mxf /* Make a list of non-CPL/PKL assets so that we can resolve the references from the CPLs. */ - list<shared_ptr<Asset> > other_assets; + list<shared_ptr<Asset>> other_assets; - for (map<string, boost::filesystem::path>::const_iterator i = paths.begin(); i != paths.end(); ++i) { - boost::filesystem::path path = _directory / i->second; + for (auto i: paths) { + auto path = _directory / i.second; - if (i->second.empty()) { + if (i.second.empty()) { /* I can't see how this is valid, but it's been seen in the wild with a DCP that claims to come from ClipsterDCI 5.10.0.5. @@ -206,8 +206,8 @@ DCP::read (list<dcp::VerificationNote>* notes, bool ignore_incorrect_picture_mxf /* Find the <Type> for this asset from the PKL that contains the asset */ optional<string> pkl_type; - BOOST_FOREACH (shared_ptr<PKL> j, _pkls) { - pkl_type = j->type(i->first); + for (auto j: _pkls) { + pkl_type = j->type(i.first); if (pkl_type) { break; } @@ -221,7 +221,7 @@ DCP::read (list<dcp::VerificationNote>* notes, bool ignore_incorrect_picture_mxf } if (*pkl_type == CPL::static_pkl_type(*_standard) || *pkl_type == InteropSubtitleAsset::static_pkl_type(*_standard)) { - xmlpp::DomParser* p = new xmlpp::DomParser; + auto p = new xmlpp::DomParser; try { p->parse_file (path.string()); } catch (std::exception& e) { @@ -229,11 +229,11 @@ DCP::read (list<dcp::VerificationNote>* notes, bool ignore_incorrect_picture_mxf throw ReadError(String::compose("XML error in %1", path.string()), e.what()); } - string const root = p->get_document()->get_root_node()->get_name (); + auto const root = p->get_document()->get_root_node()->get_name (); delete p; if (root == "CompositionPlaylist") { - shared_ptr<CPL> cpl (new CPL (path)); + auto cpl = make_shared<CPL>(path); if (_standard && cpl->standard() && cpl->standard().get() != _standard.get() && notes) { notes->push_back (VerificationNote(VerificationNote::VERIFY_ERROR, VerificationNote::MISMATCHED_STANDARD)); } @@ -242,7 +242,7 @@ DCP::read (list<dcp::VerificationNote>* notes, bool ignore_incorrect_picture_mxf if (_standard && _standard.get() == SMPTE && notes) { notes->push_back (VerificationNote(VerificationNote::VERIFY_ERROR, VerificationNote::MISMATCHED_STANDARD)); } - other_assets.push_back (shared_ptr<InteropSubtitleAsset> (new InteropSubtitleAsset (path))); + other_assets.push_back (make_shared<InteropSubtitleAsset>(path)); } } else if ( *pkl_type == PictureAsset::static_pkl_type(*_standard) || @@ -253,7 +253,7 @@ DCP::read (list<dcp::VerificationNote>* notes, bool ignore_incorrect_picture_mxf other_assets.push_back (asset_factory(path, ignore_incorrect_picture_mxf_type)); } else if (*pkl_type == FontAsset::static_pkl_type(*_standard)) { - other_assets.push_back (shared_ptr<FontAsset> (new FontAsset (i->first, path))); + other_assets.push_back (make_shared<FontAsset>(i.first, path)); } else if (*pkl_type == "image/png") { /* It's an Interop PNG subtitle; let it go */ } else { @@ -265,8 +265,8 @@ DCP::read (list<dcp::VerificationNote>* notes, bool ignore_incorrect_picture_mxf /* While we've got the ASSETMAP lets look and see if this DCP refers to things that are not in its ASSETMAP */ if (notes) { - BOOST_FOREACH (shared_ptr<CPL> i, cpls()) { - BOOST_FOREACH (shared_ptr<const ReelMXF> j, i->reel_mxfs()) { + for (auto i: cpls()) { + for (auto j: i->reel_mxfs()) { if (!j->asset_ref().resolved() && paths.find(j->asset_ref().id()) == paths.end()) { notes->push_back (VerificationNote(VerificationNote::VERIFY_WARNING, VerificationNote::EXTERNAL_ASSET, j->asset_ref().id())); } @@ -276,9 +276,9 @@ DCP::read (list<dcp::VerificationNote>* notes, bool ignore_incorrect_picture_mxf } void -DCP::resolve_refs (list<shared_ptr<Asset> > assets) +DCP::resolve_refs (list<shared_ptr<Asset>> assets) { - BOOST_FOREACH (shared_ptr<CPL> i, cpls ()) { + for (auto i: cpls()) { i->resolve_refs (assets); } } @@ -286,8 +286,8 @@ DCP::resolve_refs (list<shared_ptr<Asset> > assets) bool DCP::equals (DCP const & other, EqualityOptions opt, NoteHandler note) const { - list<shared_ptr<CPL> > a = cpls (); - list<shared_ptr<CPL> > b = other.cpls (); + auto a = cpls (); + auto b = other.cpls (); if (a.size() != b.size()) { note (DCP_ERROR, String::compose ("CPL counts differ: %1 vs %2", a.size(), b.size())); @@ -296,8 +296,8 @@ DCP::equals (DCP const & other, EqualityOptions opt, NoteHandler note) const bool r = true; - BOOST_FOREACH (shared_ptr<CPL> i, a) { - list<shared_ptr<CPL> >::const_iterator j = b.begin (); + for (auto i: a) { + auto j = b.begin(); while (j != b.end() && !(*j)->equals (i, opt, note)) { ++j; } @@ -319,8 +319,8 @@ DCP::add (std::shared_ptr<CPL> cpl) bool DCP::encrypted () const { - BOOST_FOREACH (shared_ptr<CPL> i, cpls ()) { - if (i->encrypted ()) { + for (auto i: cpls()) { + if (i->encrypted()) { return true; } } @@ -335,10 +335,10 @@ DCP::encrypted () const void DCP::add (DecryptedKDM const & kdm) { - list<DecryptedKDMKey> keys = kdm.keys (); + auto keys = kdm.keys (); - BOOST_FOREACH (shared_ptr<CPL> i, cpls ()) { - BOOST_FOREACH (DecryptedKDMKey const & j, kdm.keys ()) { + for (auto i: cpls()) { + for (auto const& j: kdm.keys()) { if (j.cpl_id() == i->id()) { i->add (kdm); } @@ -388,7 +388,7 @@ DCP::write_assetmap ( string issuer, string creator, string issue_date, string annotation_text ) const { - boost::filesystem::path p = _directory; + auto p = _directory; switch (standard) { case INTEROP: @@ -435,19 +435,19 @@ DCP::write_assetmap ( DCP_ASSERT (false); } - xmlpp::Node* asset_list = root->add_child ("AssetList"); + auto asset_list = root->add_child ("AssetList"); - xmlpp::Node* asset = asset_list->add_child ("Asset"); + auto asset = asset_list->add_child ("Asset"); asset->add_child("Id")->add_child_text ("urn:uuid:" + pkl_uuid); asset->add_child("PackingList")->add_child_text ("true"); - xmlpp::Node* chunk_list = asset->add_child ("ChunkList"); - xmlpp::Node* chunk = chunk_list->add_child ("Chunk"); + auto chunk_list = asset->add_child ("ChunkList"); + auto chunk = chunk_list->add_child ("Chunk"); chunk->add_child("Path")->add_child_text (pkl_path.filename().string()); chunk->add_child("VolumeIndex")->add_child_text ("1"); chunk->add_child("Offset")->add_child_text ("0"); chunk->add_child("Length")->add_child_text (raw_convert<string> (boost::filesystem::file_size (pkl_path))); - BOOST_FOREACH (shared_ptr<Asset> i, assets ()) { + for (auto i: assets()) { i->write_to_assetmap (asset_list, _directory); } @@ -471,7 +471,7 @@ DCP::write_xml ( NameFormat name_format ) { - BOOST_FOREACH (shared_ptr<CPL> i, cpls ()) { + for (auto i: cpls()) { NameFormat::Map values; values['t'] = "cpl"; i->write_xml (_directory / (name_format.get(values, "_" + i->id() + ".xml")), standard, signer); @@ -480,9 +480,9 @@ DCP::write_xml ( shared_ptr<PKL> pkl; if (_pkls.empty()) { - pkl.reset (new PKL(standard, annotation_text, issue_date, issuer, creator)); + pkl = make_shared<PKL>(standard, annotation_text, issue_date, issuer, creator); _pkls.push_back (pkl); - BOOST_FOREACH (shared_ptr<Asset> i, assets ()) { + for (auto i: assets()) { i->add_to_pkl (pkl, _directory); } } else { @@ -491,14 +491,14 @@ DCP::write_xml ( NameFormat::Map values; values['t'] = "pkl"; - boost::filesystem::path pkl_path = _directory / name_format.get(values, "_" + pkl->id() + ".xml"); + auto pkl_path = _directory / name_format.get(values, "_" + pkl->id() + ".xml"); pkl->write (pkl_path, signer); write_volindex (standard); write_assetmap (standard, pkl->id(), pkl_path, issuer, creator, issue_date, annotation_text); } -list<shared_ptr<CPL> > +list<shared_ptr<CPL>> DCP::cpls () const { return _cpls; @@ -508,30 +508,30 @@ DCP::cpls () const * an exception is thrown if they are found. * @return All assets (including CPLs). */ -list<shared_ptr<Asset> > +list<shared_ptr<Asset>> DCP::assets (bool ignore_unresolved) const { - list<shared_ptr<Asset> > assets; - BOOST_FOREACH (shared_ptr<CPL> i, cpls ()) { + list<shared_ptr<Asset>> assets; + for (auto i: cpls()) { assets.push_back (i); - BOOST_FOREACH (shared_ptr<const ReelMXF> j, i->reel_mxfs()) { + for (auto j: i->reel_mxfs()) { if (ignore_unresolved && !j->asset_ref().resolved()) { continue; } - string const id = j->asset_ref().id(); - bool already_got = false; - BOOST_FOREACH (shared_ptr<Asset> k, assets) { + auto const id = j->asset_ref().id(); + auto already_got = false; + for (auto k: assets) { if (k->id() == id) { already_got = true; } } if (!already_got) { - shared_ptr<Asset> o = j->asset_ref().asset(); + auto o = j->asset_ref().asset(); assets.push_back (o); /* More Interop special-casing */ - shared_ptr<InteropSubtitleAsset> sub = dynamic_pointer_cast<InteropSubtitleAsset> (o); + auto sub = dynamic_pointer_cast<InteropSubtitleAsset>(o); if (sub) { sub->add_font_assets (assets); } @@ -547,7 +547,7 @@ vector<boost::filesystem::path> DCP::directories_from_files (vector<boost::filesystem::path> files) { vector<boost::filesystem::path> d; - BOOST_FOREACH (boost::filesystem::path i, files) { + for (auto i: files) { if (i.filename() == "ASSETMAP" || i.filename() == "ASSETMAP.xml") { d.push_back (i.parent_path ()); } diff --git a/src/encrypted_kdm.cc b/src/encrypted_kdm.cc index ca2a8346..77345a5d 100644 --- a/src/encrypted_kdm.cc +++ b/src/encrypted_kdm.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2018 Carl Hetherington <cth@carlh.net> + Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net> This file is part of libdcp. @@ -42,12 +42,12 @@ #include <libxml/parser.h> #include <boost/algorithm/string.hpp> #include <boost/date_time/posix_time/posix_time.hpp> -#include <boost/foreach.hpp> #include <boost/format.hpp> using std::list; using std::vector; using std::string; +using std::make_shared; using std::map; using std::pair; using std::shared_ptr; @@ -141,12 +141,11 @@ public: explicit SignedInfo (shared_ptr<const cxml::Node> node) { - list<shared_ptr<cxml::Node> > references = node->node_children ("Reference"); - for (list<shared_ptr<cxml::Node> >::const_iterator i = references.begin(); i != references.end(); ++i) { - if ((*i)->string_attribute ("URI") == "#ID_AuthenticatedPublic") { - authenticated_public = Reference (*i); - } else if ((*i)->string_attribute ("URI") == "#ID_AuthenticatedPrivate") { - authenticated_private = Reference (*i); + for (auto i: node->node_children ("Reference")) { + if (i->string_attribute("URI") == "#ID_AuthenticatedPublic") { + authenticated_public = Reference(i); + } else if (i->string_attribute("URI") == "#ID_AuthenticatedPrivate") { + authenticated_private = Reference(i); } /* XXX: do something if we don't recognise the node */ @@ -181,9 +180,8 @@ public: : signed_info (node->node_child ("SignedInfo")) , signature_value (node->string_child ("SignatureValue")) { - list<shared_ptr<cxml::Node> > x509_data_nodes = node->node_child("KeyInfo")->node_children ("X509Data"); - for (list<shared_ptr<cxml::Node> >::const_iterator i = x509_data_nodes.begin(); i != x509_data_nodes.end(); ++i) { - x509_data.push_back (X509Data (*i)); + for (auto i: node->node_child("KeyInfo")->node_children ("X509Data")) { + x509_data.push_back(X509Data(i)); } } @@ -192,9 +190,9 @@ public: signed_info.as_xml (node->add_child ("SignedInfo", "ds")); node->add_child("SignatureValue", "ds")->add_child_text (signature_value); - xmlpp::Element* key_info_node = node->add_child ("KeyInfo", "ds"); - for (std::list<X509Data>::const_iterator i = x509_data.begin(); i != x509_data.end(); ++i) { - i->as_xml (key_info_node->add_child ("X509Data", "ds")); + auto key_info_node = node->add_child("KeyInfo", "ds"); + for (auto i: x509_data) { + i.as_xml (key_info_node->add_child("X509Data", "ds")); } } @@ -210,9 +208,8 @@ public: explicit AuthenticatedPrivate (shared_ptr<const cxml::Node> node) { - list<shared_ptr<cxml::Node> > encrypted_key_nodes = node->node_children ("EncryptedKey"); - for (list<shared_ptr<cxml::Node> >::const_iterator i = encrypted_key_nodes.begin(); i != encrypted_key_nodes.end(); ++i) { - encrypted_key.push_back ((*i)->node_child("CipherData")->string_child ("CipherValue")); + for (auto i: node->node_children ("EncryptedKey")) { + encrypted_key.push_back (i->node_child("CipherData")->string_child("CipherValue")); } } @@ -220,18 +217,18 @@ public: { references["ID_AuthenticatedPrivate"] = node->set_attribute ("Id", "ID_AuthenticatedPrivate"); - for (list<string>::const_iterator i = encrypted_key.begin(); i != encrypted_key.end(); ++i) { - xmlpp::Element* encrypted_key = node->add_child ("EncryptedKey", "enc"); + for (auto i: encrypted_key) { + auto encrypted_key = node->add_child ("EncryptedKey", "enc"); /* XXX: hack for testing with Dolby */ encrypted_key->set_namespace_declaration ("http://www.w3.org/2001/04/xmlenc#", "enc"); - xmlpp::Element* encryption_method = encrypted_key->add_child ("EncryptionMethod", "enc"); + auto encryption_method = encrypted_key->add_child("EncryptionMethod", "enc"); encryption_method->set_attribute ("Algorithm", "http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p"); - xmlpp::Element* digest_method = encryption_method->add_child ("DigestMethod", "ds"); + auto digest_method = encryption_method->add_child ("DigestMethod", "ds"); /* XXX: hack for testing with Dolby */ digest_method->set_namespace_declaration ("http://www.w3.org/2000/09/xmldsig#", "ds"); digest_method->set_attribute ("Algorithm", "http://www.w3.org/2000/09/xmldsig#sha1"); - xmlpp::Element* cipher_data = encrypted_key->add_child ("CipherData", "enc"); - cipher_data->add_child("CipherValue", "enc")->add_child_text (*i); + auto cipher_data = encrypted_key->add_child("CipherData", "enc"); + cipher_data->add_child("CipherValue", "enc")->add_child_text (i); } } @@ -279,16 +276,15 @@ public: explicit KeyIdList (shared_ptr<const cxml::Node> node) { - list<shared_ptr<cxml::Node> > typed_key_id_nodes = node->node_children ("TypedKeyId"); - for (list<shared_ptr<cxml::Node> >::const_iterator i = typed_key_id_nodes.begin(); i != typed_key_id_nodes.end(); ++i) { - typed_key_id.push_back (TypedKeyId (*i)); + for (auto i: node->node_children ("TypedKeyId")) { + typed_key_id.push_back(TypedKeyId(i)); } } void as_xml (xmlpp::Element* node) const { - for (list<TypedKeyId>::const_iterator i = typed_key_id.begin(); i != typed_key_id.end(); ++i) { - i->as_xml (node->add_child("TypedKeyId")); + for (auto const& i: typed_key_id) { + i.as_xml (node->add_child("TypedKeyId")); } } @@ -304,7 +300,7 @@ public: : device_list_identifier (remove_urn_uuid (node->string_child ("DeviceListIdentifier"))) , device_list_description (node->optional_string_child ("DeviceListDescription")) { - BOOST_FOREACH (cxml::ConstNodePtr i, node->node_child("DeviceList")->node_children("CertificateThumbprint")) { + for (auto i: node->node_child("DeviceList")->node_children("CertificateThumbprint")) { certificate_thumbprints.push_back (i->content ()); } } @@ -315,8 +311,8 @@ public: if (device_list_description) { node->add_child ("DeviceListDescription")->add_child_text (device_list_description.get()); } - xmlpp::Element* device_list = node->add_child ("DeviceList"); - BOOST_FOREACH (string i, certificate_thumbprints) { + auto device_list = node->add_child ("DeviceList"); + for (auto i: certificate_thumbprints) { device_list->add_child("CertificateThumbprint")->add_child_text (i); } } @@ -388,14 +384,14 @@ public: disable_forensic_marking_picture = false; disable_forensic_marking_audio = optional<int>(); if (node->optional_node_child("ForensicMarkFlagList")) { - BOOST_FOREACH (cxml::ConstNodePtr i, node->node_child("ForensicMarkFlagList")->node_children("ForensicMarkFlag")) { + for (auto i: node->node_child("ForensicMarkFlagList")->node_children("ForensicMarkFlag")) { if (i->content() == picture_disable) { disable_forensic_marking_picture = true; } else if (starts_with(i->content(), audio_disable)) { disable_forensic_marking_audio = 0; string const above = audio_disable + "-above-channel-"; if (starts_with(i->content(), above)) { - string above_number = i->content().substr(above.length()); + auto above_number = i->content().substr(above.length()); if (above_number == "") { throw KDMFormatError("Badly-formatted ForensicMarkFlag"); } @@ -424,12 +420,12 @@ public: key_id_list.as_xml (node->add_child ("KeyIdList")); if (disable_forensic_marking_picture || disable_forensic_marking_audio) { - xmlpp::Element* forensic_mark_flag_list = node->add_child ("ForensicMarkFlagList"); + auto forensic_mark_flag_list = node->add_child ("ForensicMarkFlagList"); if (disable_forensic_marking_picture) { forensic_mark_flag_list->add_child("ForensicMarkFlag")->add_child_text(picture_disable); } if (disable_forensic_marking_audio) { - string mrkflg = audio_disable; + auto mrkflg = audio_disable; if (*disable_forensic_marking_audio > 0) { mrkflg += String::compose ("-above-channel-%1", *disable_forensic_marking_audio); } @@ -550,8 +546,8 @@ public: authenticated_private.as_xml (root->add_child ("AuthenticatedPrivate"), references); signature.as_xml (root->add_child ("Signature", "ds")); - for (map<string, xmlpp::Attribute*>::const_iterator i = references.begin(); i != references.end(); ++i) { - xmlAddID (0, document->cobj(), (const xmlChar *) i->first.c_str(), i->second->cobj ()); + for (auto i: references) { + xmlAddID (0, document->cobj(), (const xmlChar *) i.first.c_str(), i.second->cobj()); } indent (document->get_root_node(), 0); @@ -569,7 +565,7 @@ public: EncryptedKDM::EncryptedKDM (string s) { try { - shared_ptr<cxml::Document> doc (new cxml::Document ("DCinemaSecurityMessage")); + auto doc = make_shared<cxml::Document>("DCinemaSecurityMessage"); doc->read_string (s); _data = new data::EncryptedKDMData (doc); } catch (xmlpp::parse_error& e) { @@ -611,7 +607,7 @@ EncryptedKDM::EncryptedKDM ( aup.signer.x509_serial_number = signer->leaf().serial (); aup.annotation_text = annotation_text; - data::KDMRequiredExtensions& kre = _data->authenticated_public.required_extensions.kdm_required_extensions; + auto& kre = _data->authenticated_public.required_extensions.kdm_required_extensions; kre.recipient.x509_issuer_serial.x509_issuer_name = recipient.issuer (); kre.recipient.x509_issuer_serial.x509_serial_number = recipient.serial (); kre.recipient.x509_subject_name = recipient.subject (); @@ -628,7 +624,7 @@ EncryptedKDM::EncryptedKDM ( if (formulation != MODIFIED_TRANSITIONAL_TEST) { kre.authorized_device_info = data::AuthorizedDeviceInfo (); kre.authorized_device_info->device_list_identifier = make_uuid (); - string n = recipient.subject_common_name (); + auto n = recipient.subject_common_name (); if (n.find (".") != string::npos) { n = n.substr (n.find (".") + 1); } @@ -653,30 +649,29 @@ EncryptedKDM::EncryptedKDM ( recipient's thumbprint (recipient.thumbprint()). Waimea uses only the trusted devices here, too. */ - BOOST_FOREACH (string i, trusted_devices) { - kre.authorized_device_info->certificate_thumbprints.push_back (i); + for (auto i: trusted_devices) { + kre.authorized_device_info->certificate_thumbprints.push_back(i); } } } } - for (list<pair<string, string> >::const_iterator i = key_ids.begin(); i != key_ids.end(); ++i) { - kre.key_id_list.typed_key_id.push_back (data::TypedKeyId (i->first, i->second)); + for (auto i: key_ids) { + kre.key_id_list.typed_key_id.push_back(data::TypedKeyId(i.first, i.second)); } _data->authenticated_private.encrypted_key = keys; /* Read the XML so far and sign it */ - shared_ptr<xmlpp::Document> doc = _data->as_xml (); - xmlpp::Node::NodeList children = doc->get_root_node()->get_children (); - for (xmlpp::Node::NodeList::const_iterator i = children.begin(); i != children.end(); ++i) { - if ((*i)->get_name() == "Signature") { - signer->add_signature_value (dynamic_cast<xmlpp::Element*>(*i), "ds", false); + auto doc = _data->as_xml (); + for (auto i: doc->get_root_node()->get_children()) { + if (i->get_name() == "Signature") { + signer->add_signature_value(dynamic_cast<xmlpp::Element*>(i), "ds", false); } } /* Read the bits that add_signature_value did back into our variables */ - shared_ptr<cxml::Node> signed_doc (new cxml::Node (doc->get_root_node ())); + auto signed_doc = make_shared<cxml::Node>(doc->get_root_node()); _data->signature = data::Signature (signed_doc->node_child ("Signature")); } @@ -706,11 +701,11 @@ EncryptedKDM::~EncryptedKDM () void EncryptedKDM::as_xml (boost::filesystem::path path) const { - FILE* f = fopen_boost (path, "w"); + auto f = fopen_boost (path, "w"); if (!f) { throw FileError ("Could not open KDM file for writing", path, errno); } - string const x = as_xml (); + auto const x = as_xml (); size_t const written = fwrite (x.c_str(), 1, x.length(), f); fclose (f); if (written != x.length()) { @@ -782,7 +777,7 @@ CertificateChain EncryptedKDM::signer_certificate_chain () const { CertificateChain chain; - BOOST_FOREACH (data::X509Data const & i, _data->signature.x509_data) { + for (auto const& i: _data->signature.x509_data) { string s = "-----BEGIN CERTIFICATE-----\n" + i.x509_certificate + "\n-----END CERTIFICATE-----"; chain.add (Certificate(s)); } diff --git a/src/reel.cc b/src/reel.cc index a8f66ae5..8b748424 100644 --- a/src/reel.cc +++ b/src/reel.cc @@ -62,6 +62,7 @@ using std::string; using std::list; using std::cout; using std::min; +using std::make_shared; using std::shared_ptr; using std::dynamic_pointer_cast; using namespace dcp; @@ -69,46 +70,46 @@ using namespace dcp; Reel::Reel (std::shared_ptr<const cxml::Node> node) : Object (remove_urn_uuid (node->string_child ("Id"))) { - shared_ptr<cxml::Node> asset_list = node->node_child ("AssetList"); + auto asset_list = node->node_child ("AssetList"); - shared_ptr<cxml::Node> main_picture = asset_list->optional_node_child ("MainPicture"); + auto main_picture = asset_list->optional_node_child ("MainPicture"); if (main_picture) { _main_picture.reset (new ReelMonoPictureAsset (main_picture)); } - shared_ptr<cxml::Node> main_stereoscopic_picture = asset_list->optional_node_child ("MainStereoscopicPicture"); + auto main_stereoscopic_picture = asset_list->optional_node_child ("MainStereoscopicPicture"); if (main_stereoscopic_picture) { _main_picture.reset (new ReelStereoPictureAsset (main_stereoscopic_picture)); } - shared_ptr<cxml::Node> main_sound = asset_list->optional_node_child ("MainSound"); + auto main_sound = asset_list->optional_node_child ("MainSound"); if (main_sound) { _main_sound.reset (new ReelSoundAsset (main_sound)); } - shared_ptr<cxml::Node> main_subtitle = asset_list->optional_node_child ("MainSubtitle"); + auto main_subtitle = asset_list->optional_node_child ("MainSubtitle"); if (main_subtitle) { _main_subtitle.reset (new ReelSubtitleAsset (main_subtitle)); } - shared_ptr<cxml::Node> main_markers = asset_list->optional_node_child ("MainMarkers"); + auto main_markers = asset_list->optional_node_child ("MainMarkers"); if (main_markers) { _main_markers.reset (new ReelMarkersAsset (main_markers)); } /* XXX: it's not ideal that we silently tolerate Interop or SMPTE nodes here */ /* XXX: not sure if Interop supports multiple closed captions */ - list<shared_ptr<cxml::Node> > closed_captions = asset_list->node_children ("MainClosedCaption"); + auto closed_captions = asset_list->node_children ("MainClosedCaption"); if (closed_captions.empty()) { closed_captions = asset_list->node_children ("ClosedCaption"); } - BOOST_FOREACH (shared_ptr<cxml::Node> i, closed_captions) { - _closed_captions.push_back (shared_ptr<ReelClosedCaptionAsset>(new ReelClosedCaptionAsset(i))); + for (auto i: closed_captions) { + _closed_captions.push_back (make_shared<ReelClosedCaptionAsset>(i)); } - shared_ptr<cxml::Node> atmos = asset_list->optional_node_child ("AuxData"); + auto atmos = asset_list->optional_node_child ("AuxData"); if (atmos) { - _atmos.reset (new ReelAtmosAsset (atmos)); + _atmos = make_shared<ReelAtmosAsset>(atmos); } node->ignore_child ("AnnotationText"); @@ -118,7 +119,7 @@ Reel::Reel (std::shared_ptr<const cxml::Node> node) xmlpp::Element * Reel::write_to_cpl (xmlpp::Element* node, Standard standard) const { - xmlpp::Element* reel = node->add_child ("Reel"); + auto reel = node->add_child ("Reel"); reel->add_child("Id")->add_child_text("urn:uuid:" + _id); xmlpp::Element* asset_list = reel->add_child ("AssetList"); @@ -139,7 +140,7 @@ Reel::write_to_cpl (xmlpp::Element* node, Standard standard) const _main_subtitle->write_to_cpl (asset_list, standard); } - BOOST_FOREACH (shared_ptr<ReelClosedCaptionAsset> i, _closed_captions) { + for (auto i: _closed_captions) { i->write_to_cpl (asset_list, standard); } @@ -199,8 +200,8 @@ Reel::equals (std::shared_ptr<const Reel> other, EqualityOptions opt, NoteHandle return false; } - list<shared_ptr<ReelClosedCaptionAsset> >::const_iterator i = _closed_captions.begin(); - list<shared_ptr<ReelClosedCaptionAsset> >::const_iterator j = other->_closed_captions.begin(); + auto i = _closed_captions.begin(); + auto j = other->_closed_captions.begin(); while (i != _closed_captions.end()) { if (!(*i)->equals(*j, opt, note)) { return false; @@ -224,8 +225,8 @@ Reel::equals (std::shared_ptr<const Reel> other, EqualityOptions opt, NoteHandle bool Reel::encrypted () const { - bool ecc = false; - BOOST_FOREACH (shared_ptr<ReelClosedCaptionAsset> i, _closed_captions) { + auto ecc = false; + for (auto i: _closed_captions) { if (i->encrypted()) { ecc = true; } @@ -243,31 +244,31 @@ Reel::encrypted () const void Reel::add (DecryptedKDM const & kdm) { - list<DecryptedKDMKey> keys = kdm.keys (); + auto keys = kdm.keys (); - for (list<DecryptedKDMKey>::iterator i = keys.begin(); i != keys.end(); ++i) { - if (_main_picture && i->id() == _main_picture->key_id()) { - _main_picture->asset()->set_key (i->key ()); + for (auto const& i: keys) { + if (_main_picture && i.id() == _main_picture->key_id()) { + _main_picture->asset()->set_key (i.key()); } - if (_main_sound && i->id() == _main_sound->key_id()) { - _main_sound->asset()->set_key (i->key ()); + if (_main_sound && i.id() == _main_sound->key_id()) { + _main_sound->asset()->set_key (i.key()); } - if (_main_subtitle && i->id() == _main_subtitle->key_id()) { + if (_main_subtitle && i.id() == _main_subtitle->key_id()) { shared_ptr<SMPTESubtitleAsset> s = dynamic_pointer_cast<SMPTESubtitleAsset> (_main_subtitle->asset()); if (s) { - s->set_key (i->key ()); + s->set_key (i.key()); } } - BOOST_FOREACH (shared_ptr<ReelClosedCaptionAsset> j, _closed_captions) { - if (i->id() == j->key_id()) { - shared_ptr<SMPTESubtitleAsset> s = dynamic_pointer_cast<SMPTESubtitleAsset> (j->asset()); + for (auto j: _closed_captions) { + if (i.id() == j->key_id()) { + auto s = dynamic_pointer_cast<SMPTESubtitleAsset> (j->asset()); if (s) { - s->set_key (i->key ()); + s->set_key (i.key()); } } } - if (_atmos && i->id() == _atmos->key_id()) { - _atmos->asset()->set_key (i->key ()); + if (_atmos && i.id() == _atmos->key_id()) { + _atmos->asset()->set_key (i.key()); } } } @@ -275,12 +276,12 @@ Reel::add (DecryptedKDM const & kdm) void Reel::add (shared_ptr<ReelAsset> asset) { - shared_ptr<ReelPictureAsset> p = dynamic_pointer_cast<ReelPictureAsset> (asset); - shared_ptr<ReelSoundAsset> so = dynamic_pointer_cast<ReelSoundAsset> (asset); - shared_ptr<ReelSubtitleAsset> su = dynamic_pointer_cast<ReelSubtitleAsset> (asset); - shared_ptr<ReelMarkersAsset> m = dynamic_pointer_cast<ReelMarkersAsset> (asset); - shared_ptr<ReelClosedCaptionAsset> c = dynamic_pointer_cast<ReelClosedCaptionAsset> (asset); - shared_ptr<ReelAtmosAsset> a = dynamic_pointer_cast<ReelAtmosAsset> (asset); + auto p = dynamic_pointer_cast<ReelPictureAsset> (asset); + auto so = dynamic_pointer_cast<ReelSoundAsset> (asset); + auto su = dynamic_pointer_cast<ReelSubtitleAsset> (asset); + auto m = dynamic_pointer_cast<ReelMarkersAsset> (asset); + auto c = dynamic_pointer_cast<ReelClosedCaptionAsset> (asset); + auto a = dynamic_pointer_cast<ReelAtmosAsset> (asset); if (p) { _main_picture = p; } else if (so) { @@ -296,10 +297,10 @@ Reel::add (shared_ptr<ReelAsset> asset) } } -list<shared_ptr<ReelAsset> > +list<shared_ptr<ReelAsset>> Reel::assets () const { - list<shared_ptr<ReelAsset> > a; + list<shared_ptr<ReelAsset>> a; if (_main_picture) { a.push_back (_main_picture); } @@ -317,7 +318,7 @@ Reel::assets () const } void -Reel::resolve_refs (list<shared_ptr<Asset> > assets) +Reel::resolve_refs (list<shared_ptr<Asset>> assets) { if (_main_picture) { _main_picture->asset_ref().resolve (assets); @@ -332,19 +333,19 @@ Reel::resolve_refs (list<shared_ptr<Asset> > assets) /* Interop subtitle handling is all special cases */ if (_main_subtitle->asset_ref().resolved()) { - shared_ptr<InteropSubtitleAsset> iop = dynamic_pointer_cast<InteropSubtitleAsset> (_main_subtitle->asset_ref().asset()); + auto iop = dynamic_pointer_cast<InteropSubtitleAsset> (_main_subtitle->asset_ref().asset()); if (iop) { iop->resolve_fonts (assets); } } } - BOOST_FOREACH (shared_ptr<ReelClosedCaptionAsset> i, _closed_captions) { + for (auto i: _closed_captions) { i->asset_ref().resolve(assets); /* Interop subtitle handling is all special cases */ if (i->asset_ref().resolved()) { - shared_ptr<InteropSubtitleAsset> iop = dynamic_pointer_cast<InteropSubtitleAsset> (i->asset_ref().asset()); + auto iop = dynamic_pointer_cast<InteropSubtitleAsset> (i->asset_ref().asset()); if (iop) { iop->resolve_fonts (assets); } @@ -374,7 +375,7 @@ Reel::duration () const if (_main_markers) { d = min (d, _main_markers->actual_duration()); } - BOOST_FOREACH (shared_ptr<ReelClosedCaptionAsset> i, _closed_captions) { + for (auto i: _closed_captions) { d = min (d, i->actual_duration()); } if (_atmos) { |
