X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Flib%2Ffilm.cc;h=d311c76cb4b519f78e22c5b1791be4f5387eb77d;hp=c70e82cdacb0c2890d993777779fb370d4c522ba;hb=eefc143f08e4b4dc26ebbd2136488f5c95e6cc2a;hpb=cd22846b748141261db1243588fe11d1a1504ce4 diff --git a/src/lib/film.cc b/src/lib/film.cc index c70e82cda..d311c76cb 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -177,7 +177,8 @@ Film::Film (optional dir) boost::filesystem::path result; for (boost::filesystem::path::iterator i = p.begin(); i != p.end(); ++i) { if (*i == "..") { - if (boost::filesystem::is_symlink (result) || result.filename() == "..") { + boost::system::error_code ec; + if (boost::filesystem::is_symlink(result, ec) || result.filename() == "..") { result /= *i; } else { result = result.parent_path (); @@ -478,12 +479,6 @@ Film::read_metadata (optional path) _isdcf_date = boost::gregorian::from_undelimited_string (f.string_child ("DCIDate")); } - list notes; - - if (_isdcf_metadata.has_subtitle_language) { - notes.push_back(_("This film had a subtitle language, configured within the ISDCF metadata dialogue, which will be ignored by this version of DCP-o-matic. " - "Please set the language for each piece of subtitle or closed-caption content in the film.")); - } { optional c = f.optional_string_child ("DCPContentType"); @@ -537,6 +532,7 @@ Film::read_metadata (optional path) _reencode_j2k = f.optional_bool_child("ReencodeJ2K").get_value_or(false); _user_explicit_video_frame_rate = f.optional_bool_child("UserExplicitVideoFrameRate").get_value_or(false); + list notes; _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 */ @@ -748,7 +744,16 @@ Film::isdcf_name (bool if_created_now) const } } - if (subtitle_language) { + 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 { @@ -760,6 +765,7 @@ Film::isdcf_name (bool if_created_now) const d += "-CCAP"; } } else { + /* No subtitles */ d += "-XX"; } } @@ -775,14 +781,21 @@ Film::isdcf_name (bool if_created_now) const /* Count mapped audio channels */ - pair ch = audio_channel_types (mapped_audio_channels(), audio_channels()); + list mapped = mapped_audio_channels (); + + pair ch = audio_channel_types (mapped, audio_channels()); if (!ch.first && !ch.second) { d += "_MOS"; } else if (ch.first) { d += String::compose("_%1%2", ch.first, ch.second); } - /* XXX: HI/VI */ + if (audio_channels() > static_cast(dcp::HI) && find(mapped.begin(), mapped.end(), dcp::HI) != mapped.end()) { + d += "-HI"; + } + if (audio_channels() > static_cast(dcp::VI) && find(mapped.begin(), mapped.end(), dcp::VI) != mapped.end()) { + d += "-VI"; + } d += "_" + resolution_to_string (_resolution); @@ -1550,24 +1563,24 @@ Film::reels () const break; case REELTYPE_BY_VIDEO_CONTENT: { - optional last_split; + DCPTime last_split; shared_ptr last_video; BOOST_FOREACH (shared_ptr c, content ()) { if (c->video) { BOOST_FOREACH (DCPTime t, c->reel_split_points(shared_from_this())) { - if (last_split) { - p.push_back (DCPTimePeriod (last_split.get(), t)); + if (last_split != t) { + p.push_back (DCPTimePeriod(last_split, t)); + last_split = t; } - last_split = t; } last_video = c; } } DCPTime video_end = last_video ? last_video->end(shared_from_this()) : DCPTime(0); - if (last_split) { + if (last_split != video_end) { /* Definitely go from the last split to the end of the video content */ - p.push_back (DCPTimePeriod (last_split.get(), video_end)); + p.push_back (DCPTimePeriod(last_split, video_end)); } if (video_end < len) { @@ -1680,3 +1693,37 @@ Film::closed_caption_tracks () const return tt; } + +shared_ptr +Film::info_file_handle (DCPTimePeriod period, bool read) const +{ + return shared_ptr (new InfoFileHandle(_info_file_mutex, info_file(period), read)); +} + +InfoFileHandle::InfoFileHandle (boost::mutex& mutex, boost::filesystem::path file, bool read) + : _lock (mutex) + , _file (file) +{ + if (read) { + _handle = fopen_boost (file, "rb"); + if (!_handle) { + throw OpenFileError (file, errno, OpenFileError::READ); + } + } else { + bool const exists = boost::filesystem::exists (file); + if (exists) { + _handle = fopen_boost (file, "r+b"); + } else { + _handle = fopen_boost (file, "wb"); + } + + if (!_handle) { + throw OpenFileError (file, errno, exists ? OpenFileError::READ_WRITE : OpenFileError::WRITE); + } + } +} + +InfoFileHandle::~InfoFileHandle () +{ + fclose (_handle); +}