using std::copy;
using std::back_inserter;
using std::map;
+using std::exception;
using boost::shared_ptr;
using boost::weak_ptr;
using boost::dynamic_pointer_cast;
_state_version = f.number_child<int> ("Version");
if (_state_version > current_state_version) {
throw runtime_error (_("This film was created with a newer version of DCP-o-matic, and it cannot be loaded into this version. Sorry!"));
+ } else if (_state_version < current_state_version) {
+ /* This is an older version; save a copy (if we haven't already) */
+ boost::filesystem::path const older = path->parent_path() / String::compose("metadata.%1.xml", _state_version);
+ if (!boost::filesystem::is_regular_file(older)) {
+ try {
+ boost::filesystem::copy_file(*path, older);
+ } catch (...) {
+ /* Never mind; at least we tried */
+ }
+ }
}
_name = f.string_child ("Name");
_isdcf_date = boost::gregorian::from_undelimited_string (f.string_child ("DCIDate"));
}
+
{
optional<string> c = f.optional_string_child ("DCPContentType");
if (c) {
_user_explicit_video_frame_rate = f.optional_bool_child("UserExplicitVideoFrameRate").get_value_or(false);
list<string> notes;
- /* This method is the only one that can return notes (so far) */
_playlist->set_from_xml (shared_from_this(), f.node_child ("Playlist"), _state_version, notes);
/* Write backtraces to this film's directory, until another film is loaded */
if (!dm.audio_language.empty ()) {
d += "_" + dm.audio_language;
- if (!dm.subtitle_language.empty()) {
- /* I'm not clear on the precise details of the convention for CCAP labelling;
- for now I'm just appending -CCAP if we have any closed captions.
- */
+ /* I'm not clear on the precise details of the convention for CCAP labelling;
+ for now I'm just appending -CCAP if we have any closed captions.
+ */
- bool burnt_in = true;
- bool ccap = false;
- BOOST_FOREACH (shared_ptr<Content> i, content()) {
- BOOST_FOREACH (shared_ptr<TextContent> j, i->text) {
- if (j->type() == TEXT_OPEN_SUBTITLE && j->use() && !j->burn()) {
+ optional<string> subtitle_language;
+ bool burnt_in = true;
+ bool ccap = false;
+ BOOST_FOREACH (shared_ptr<Content> i, content()) {
+ BOOST_FOREACH (shared_ptr<TextContent> j, i->text) {
+ if (j->type() == TEXT_OPEN_SUBTITLE && j->use()) {
+ subtitle_language = j->language ();
+ if (!j->burn()) {
burnt_in = false;
- } else if (j->type() == TEXT_CLOSED_CAPTION) {
- ccap = true;
}
+ } else if (j->type() == TEXT_CLOSED_CAPTION && j->use()) {
+ ccap = true;
}
}
+ }
- string language = dm.subtitle_language;
- if (burnt_in && language != "XX") {
- transform (language.begin(), language.end(), language.begin(), ::tolower);
+ if (dm.subtitle_language) {
+ /* Subtitle language is overridden in ISDCF metadata, primarily to handle
+ content with pre-burnt subtitles.
+ */
+ d += "-" + *dm.subtitle_language;
+ if (ccap) {
+ d += "-CCAP";
+ }
+ } else if (subtitle_language) {
+ /* Language is worked out from the content */
+ if (burnt_in && *subtitle_language != "XX") {
+ transform (subtitle_language->begin(), subtitle_language->end(), subtitle_language->begin(), ::tolower);
} else {
- transform (language.begin(), language.end(), language.begin(), ::toupper);
+ transform (subtitle_language->begin(), subtitle_language->end(), subtitle_language->begin(), ::toupper);
}
- d += "-" + language;
+ d += "-" + *subtitle_language;
if (ccap) {
d += "-CCAP";
}
} else {
+ /* No subtitles */
d += "-XX";
}
}
return file (p);
}
-/** Find all the DCPs in our directory that can be dcp::DCP::read() and return details of their CPLs */
+static
+bool
+cpl_summary_compare (CPLSummary const & a, CPLSummary const & b)
+{
+ return a.last_write_time > b.last_write_time;
+}
+
+/** Find all the DCPs in our directory that can be dcp::DCP::read() and return details of their CPLs.
+ * The list will be returned in reverse order of timestamp (i.e. most recent first).
+ */
vector<CPLSummary>
Film::cpls () const
{
) {
try {
- dcp::DCP dcp (*i);
- dcp.read ();
- DCPOMATIC_ASSERT (dcp.cpls().front()->file());
- out.push_back (
- CPLSummary (
- i->path().leaf().string(),
- dcp.cpls().front()->id(),
- dcp.cpls().front()->annotation_text(),
- dcp.cpls().front()->file().get()
- )
- );
+ out.push_back (CPLSummary(*i));
} catch (...) {
}
}
}
+ sort (out.begin(), out.end(), cpl_summary_compare);
+
return out;
}
list<DCPTextTrack> tt;
BOOST_FOREACH (shared_ptr<Content> i, content()) {
BOOST_FOREACH (shared_ptr<TextContent> j, i->text) {
- /* XXX: Empty DCPTextTrack ends up being a magic value here */
+ /* XXX: Empty DCPTextTrack ends up being a magic value here - the "unknown" or "not specified" track */
DCPTextTrack dtt = j->dcp_track().get_value_or(DCPTextTrack());
if (j->type() == TEXT_CLOSED_CAPTION && find(tt.begin(), tt.end(), dtt) == tt.end()) {
tt.push_back (dtt);