X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Ffilm.cc;h=4e133a90dd8e5b59abce153bba33d2d90be43c8f;hb=dba7e1137282b52a1bd6ad1d56fe6371a8c97e30;hp=54267bc5686038d1006fd1c75ba62de41e641e3f;hpb=8a8c977c12fc65f1f50ea05099387e0fc8840e7d;p=dcpomatic.git diff --git a/src/lib/film.cc b/src/lib/film.cc index 54267bc56..4e133a90d 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -29,7 +29,6 @@ #include "audio_content.h" #include "audio_processor.h" #include "change_signaller.h" -#include "check_content_change_job.h" #include "cinema.h" #include "compose.hpp" #include "config.h" @@ -535,6 +534,8 @@ Film::read_metadata (optional path) } } + _last_written_by = f.optional_string_child("LastWrittenBy"); + _name = f.string_child ("Name"); if (_state_version >= 9) { _use_isdcf_name = f.bool_child ("UseISDCFName"); @@ -972,7 +973,10 @@ Film::isdcf_name (bool if_created_now) const if (_ratings.empty ()) { d += "-NR"; } else { - d += "-" + _ratings[0].label; + auto label = _ratings[0].label; + boost::erase_all(label, "+"); + boost::erase_all(label, "-"); + d += "-" + label; } } @@ -1754,7 +1758,7 @@ Film::audio_output_names () const vector n; for (int i = 0; i < audio_channels(); ++i) { - if (i != 8 && i != 9 && i != 15) { + if (Config::instance()->use_all_audio_channels() || (i != 8 && i != 9 && i != 15)) { n.push_back (NamedChannel(short_audio_channel_name(i), i)); } } @@ -2168,3 +2172,41 @@ Film::set_dirty (bool dirty) } } + +/** @return true if the metadata was (probably) last written by a version earlier + * than the given one; false if it definitely was not. + */ +bool +Film::last_written_by_earlier_than(int major, int minor, int micro) const +{ + if (!_last_written_by) { + return true; + } + + vector parts; + boost::split(parts, *_last_written_by, boost::is_any_of(".")); + + if (parts.size() != 3) { + /* Not sure what's going on, so let's say it was written by an old version */ + return true; + } + + if (boost::ends_with(parts[2], "pre")) { + parts[2] = parts[2].substr(0, parts[2].length() - 3); + } + + int our_major = dcp::raw_convert(parts[0]); + int our_minor = dcp::raw_convert(parts[1]); + int our_micro = dcp::raw_convert(parts[2]); + + if (our_major != major) { + return our_major < major; + } + + if (our_minor != minor) { + return our_minor < minor; + } + + return our_micro < micro; +} +