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 ();
_isdcf_date = boost::gregorian::from_undelimited_string (f.string_child ("DCIDate"));
}
- list<string> 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<string> c = f.optional_string_child ("DCPContentType");
_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<string> 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 */
}
}
- 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 {
d += "-CCAP";
}
} else {
+ /* No subtitles */
d += "-XX";
}
}
/* Count mapped audio channels */
- pair<int, int> ch = audio_channel_types (mapped_audio_channels(), audio_channels());
+ list<int> mapped = mapped_audio_channels ();
+
+ pair<int, int> 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<int>(dcp::HI) && find(mapped.begin(), mapped.end(), dcp::HI) != mapped.end()) {
+ d += "-HI";
+ }
+ if (audio_channels() > static_cast<int>(dcp::VI) && find(mapped.begin(), mapped.end(), dcp::VI) != mapped.end()) {
+ d += "-VI";
+ }
d += "_" + resolution_to_string (_resolution);
break;
case REELTYPE_BY_VIDEO_CONTENT:
{
- optional<DCPTime> last_split;
+ DCPTime last_split;
shared_ptr<Content> last_video;
BOOST_FOREACH (shared_ptr<Content> 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) {
return tt;
}
+
+shared_ptr<InfoFileHandle>
+Film::info_file_handle (DCPTimePeriod period, bool read) const
+{
+ return shared_ptr<InfoFileHandle> (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);
+}