X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Ffilm.cc;h=93459661be39463c8cd257ee3ac3611ea85e33f1;hb=96f7dd41a2c8627bc1ea0d24d84142eb04b4ffef;hp=efc89e0eb6be3b27c6a7c04a31b82ee32c68f54b;hpb=c4403784febdbdd42e9c32e67fadb147f11fe566;p=dcpomatic.git diff --git a/src/lib/film.cc b/src/lib/film.cc index efc89e0eb..93459661b 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -93,6 +93,7 @@ using std::copy; using std::back_inserter; using std::map; using std::exception; +using std::find; using boost::shared_ptr; using boost::weak_ptr; using boost::dynamic_pointer_cast; @@ -161,6 +162,7 @@ Film::Film (optional dir) , _user_explicit_video_frame_rate (false) , _state_version (current_state_version) , _dirty (false) + , _tolerant (false) { set_isdcf_date_today (); @@ -297,9 +299,12 @@ Film::audio_analysis_path (shared_ptr playlist) const return p; } -/** Add suitable Jobs to the JobManager to create a DCP for this Film */ +/** Add suitable Jobs to the JobManager to create a DCP for this Film. + * @param gui true if this is being called from a GUI tool. + * @param check true to check the content in the project for changes before making the DCP. + */ void -Film::make_dcp () +Film::make_dcp (bool gui, bool check) { if (dcp_name().find ("/") != string::npos) { throw BadSettingError (_("name"), _("Cannot contain slashes")); @@ -353,8 +358,12 @@ Film::make_dcp () shared_ptr tj (new TranscodeJob (shared_from_this())); tj->set_encoder (shared_ptr (new DCPEncoder (shared_from_this(), tj))); - shared_ptr cc (new CheckContentChangeJob (shared_from_this(), tj)); - JobManager::instance()->add (cc); + if (check) { + shared_ptr cc (new CheckContentChangeJob(shared_from_this(), tj, gui)); + JobManager::instance()->add (cc); + } else { + JobManager::instance()->add (tj); + } } /** Start a job to send our DCP to the configured TMS */ @@ -534,6 +543,13 @@ Film::read_metadata (optional path) _audio_processor = 0; } + if (_audio_processor && !Config::instance()->show_experimental_audio_processors()) { + list ap = AudioProcessor::visible(); + if (find(ap.begin(), ap.end(), _audio_processor) == ap.end()) { + Config::instance()->set_show_experimental_audio_processors(true); + } + } + _reel_type = static_cast (f.optional_number_child("ReelType").get_value_or (static_cast(REELTYPE_SINGLE))); _reel_length = f.optional_number_child("ReelLength").get_value_or (2000000000); _upload_after_make_dcp = f.optional_bool_child("UploadAfterMakeDCP").get_value_or (false); @@ -1420,7 +1436,7 @@ Film::make_kdm ( * @param disable_forensic_marking_audio if not set, don't disable forensic marking of audio. If set to 0, * disable all forensic marking; if set above 0, disable forensic marking above that channel. */ -list +list > Film::make_kdms ( list > screens, boost::filesystem::path cpl_file, @@ -1431,7 +1447,7 @@ Film::make_kdms ( optional disable_forensic_marking_audio ) const { - list kdms; + list > kdms; BOOST_FOREACH (shared_ptr i, screens) { if (i->recipient) { @@ -1446,7 +1462,7 @@ Film::make_kdms ( disable_forensic_marking_audio ); - kdms.push_back (ScreenKDM (i, kdm)); + kdms.push_back (shared_ptr(new DCPScreenKDM(i, kdm))); } } @@ -1732,3 +1748,37 @@ Film::marker (dcp::Marker type) const } return i->second; } + +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); +}