diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-12-08 23:54:25 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-12-09 02:38:50 +0100 |
| commit | 1df6f4a08a2f3b67c1637068ae4714c1cba2e1e7 (patch) | |
| tree | 92be307e0ba7a6659b8943245d44703d48354bb2 /src/dcp.cc | |
| parent | f043af026316728c4ac2b84357a77d84082c06a1 (diff) | |
Add DCP::cpl_summaries().v1.10.42
DCP-o-matic needs to know some basic CPL details as quickly as possible,
and this is faster than doing read() and then cpls().
Diffstat (limited to 'src/dcp.cc')
| -rw-r--r-- | src/dcp.cc | 53 |
1 files changed, 53 insertions, 0 deletions
@@ -58,6 +58,7 @@ #include "raw_convert.h" #include "reel_asset.h" #include "reel_text_asset.h" +#include "scope_guard.h" #include "smpte_text_asset.h" #include "sound_asset.h" #include "stereo_j2k_picture_asset.h" @@ -638,3 +639,55 @@ DCP::set_annotation_text(string annotation_text) _new_annotation_text = annotation_text; } + +vector<CPLSummary> +DCP::cpl_summaries() const +{ + auto asset_map = read_assetmap(); + vector<PKL> pkls; + for (auto const& i: asset_map.pkl_paths()) { + pkls.push_back(PKL(i)); + } + + vector<CPLSummary> cpls; + + for (auto const& id_and_path: asset_map.asset_ids_and_paths()) { + optional<string> pkl_type; + for (auto const& pkl: pkls) { + pkl_type = pkl.type(id_and_path.first); + if (pkl_type) { + break; + } + } + + if (!pkl_type) { + continue; + } + + if ( + pkl_type == remove_parameters(CPL::static_pkl_type(Standard::INTEROP)) || + pkl_type == remove_parameters(CPL::static_pkl_type(Standard::SMPTE))) { + + auto parser = new xmlpp::DomParser; + dcp::ScopeGuard sg = [parser]() { delete parser; }; + + try { + parser->parse_file(dcp::filesystem::fix_long_path(id_and_path.second).string()); + } catch (std::exception& e) { + throw ReadError(String::compose("XML error in %1", id_and_path.second.string()), e.what()); + } + + if (parser->get_document()->get_root_node()->get_name() == "CompositionPlaylist") { + auto cpl = CPL(id_and_path.second); + cpls.push_back( + CPLSummary( + _directory, cpl.id(), cpl.annotation_text(), *cpl.file(), cpl.any_encrypted(), filesystem::last_write_time(_directory) + ) + ); + } + } + } + + return cpls; +} + |
