X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Ffilm.cc;h=18e99247800ac40274d600849a982efffb69bb51;hb=4dbc6ef917aeceb906b1ef1caf6911033e7e2c54;hp=85dc5b168d2012e0d98d78606656fcc221225dd4;hpb=8d58a7c5f4320ad5c111e336c45e44d6b51ab509;p=dcpomatic.git diff --git a/src/lib/film.cc b/src/lib/film.cc index 85dc5b168..18e992478 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -17,25 +17,6 @@ */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include "film.h" #include "job.h" #include "util.h" @@ -55,11 +36,30 @@ #include "ratio.h" #include "cross.h" #include "cinema.h" +#include "safe_stringstream.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "i18n.h" using std::string; -using std::stringstream; using std::multimap; using std::pair; using std::map; @@ -70,6 +70,7 @@ using std::make_pair; using std::endl; using std::cout; using std::list; +using std::set; using boost::shared_ptr; using boost::weak_ptr; using boost::dynamic_pointer_cast; @@ -94,6 +95,8 @@ using dcp::raw_convert; * Use tag in rather than . * 8 -> 9 * DCI -> ISDCF + * 9 -> 10 + * Subtitle X and Y scale. * * Bumped to 32 for 2.0 branch; some times are expressed in Times rather * than frames now. @@ -148,7 +151,7 @@ Film::Film (boost::filesystem::path dir, bool log) } } - set_directory (result); + set_directory (result.make_preferred ()); if (log) { _log.reset (new FileLog (file ("log"))); } else { @@ -161,9 +164,9 @@ Film::Film (boost::filesystem::path dir, bool log) string Film::video_identifier () const { - assert (container ()); + DCPOMATIC_ASSERT (container ()); - stringstream s; + SafeStringStream s; s.imbue (std::locale::classic ()); s << container()->id() @@ -268,11 +271,6 @@ Film::make_dcp () throw BadSettingError (_("name"), _("cannot contain slashes")); } - /* It seems to make sense to auto-save metadata here, since the make DCP may last - a long time, and crashes/power failures are moderately likely. - */ - write_metadata (); - LOG_GENERAL ("DCP-o-matic %1 git %2 using %3", dcpomatic_version, dcpomatic_git_commit, dependency_version_summary()); { @@ -467,6 +465,9 @@ Film::read_metadata () /* 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 */ + set_backtrace_file (file ("backtrace.txt")); + _dirty = false; return notes; } @@ -505,7 +506,7 @@ Film::file (boost::filesystem::path f) const string Film::isdcf_name (bool if_created_now) const { - stringstream d; + SafeStringStream d; string raw_name = name (); @@ -593,18 +594,22 @@ Film::isdcf_name (bool if_created_now) const d << "_" << container()->isdcf_name(); } - /* XXX: this only works for content which has been scaled to a given ratio, - and uses the first bit of content only. - */ + /* XXX: this uses the first bit of content only */ /* The standard says we don't do this for trailers, for some strange reason */ if (dcp_content_type() && dcp_content_type()->libdcp_kind() != dcp::TRAILER) { ContentList cl = content (); Ratio const * content_ratio = 0; - for (ContentList::const_iterator i = cl.begin(); i != cl.end(); ++i) { + for (ContentList::iterator i = cl.begin(); i != cl.end(); ++i) { shared_ptr vc = dynamic_pointer_cast (*i); - if (vc && (content_ratio == 0 || vc->scale().ratio() != content_ratio)) { - content_ratio = vc->scale().ratio(); + if (vc) { + /* Here's the first piece of video content */ + if (vc->scale().ratio ()) { + content_ratio = vc->scale().ratio (); + } else { + content_ratio = Ratio::from_ratio (vc->video_size().ratio ()); + } + break; } } @@ -828,7 +833,7 @@ Film::info_path (int f, Eyes e) const boost::filesystem::path p; p /= info_dir (); - stringstream s; + SafeStringStream s; s.width (8); s << setfill('0') << f; @@ -855,7 +860,7 @@ Film::j2c_path (int f, Eyes e, bool t) const p /= "j2c"; p /= video_identifier (); - stringstream s; + SafeStringStream s; s.width (8); s << setfill('0') << f; @@ -941,13 +946,20 @@ Film::content () const } void -Film::examine_and_add_content (shared_ptr c) +Film::examine_content (shared_ptr c, bool calculate_digest) +{ + shared_ptr j (new ExamineContentJob (shared_from_this(), c, calculate_digest)); + JobManager::instance()->add (j); +} + +void +Film::examine_and_add_content (shared_ptr c, bool calculate_digest) { if (dynamic_pointer_cast (c)) { run_ffprobe (c->path(0), file ("ffprobe.log"), _log); } - shared_ptr j (new ExamineContentJob (shared_from_this(), c)); + shared_ptr j (new ExamineContentJob (shared_from_this(), c, calculate_digest)); j->Finished.connect (bind (&Film::maybe_add_content, this, boost::weak_ptr (j), boost::weak_ptr (c))); JobManager::instance()->add (j); } @@ -1057,7 +1069,7 @@ Film::full_frame () const return dcp::Size (4096, 2160); } - assert (false); + DCPOMATIC_ASSERT (false); return dcp::Size (); } @@ -1065,12 +1077,12 @@ Film::full_frame () const dcp::Size Film::frame_size () const { - return fit_ratio_within (container()->ratio(), full_frame ()); + return fit_ratio_within (container()->ratio(), full_frame (), 1); } dcp::EncryptedKDM Film::make_kdm ( - shared_ptr target, + dcp::Certificate target, boost::filesystem::path cpl_file, dcp::LocalTime from, dcp::LocalTime until, @@ -1078,9 +1090,14 @@ Film::make_kdm ( ) const { shared_ptr cpl (new dcp::CPL (cpl_file)); + shared_ptr signer = Config::instance()->signer(); + if (!signer->valid ()) { + throw InvalidSignerError (); + } + return dcp::DecryptedKDM ( - cpl, from, until, "DCP-o-matic", cpl->content_title_text(), dcp::LocalTime().as_string() - ).encrypt (make_signer(), target, formulation); + cpl, key(), from, until, "DCP-o-matic", cpl->content_title_text(), dcp::LocalTime().as_string() + ).encrypt (signer, target, formulation); } list @@ -1095,7 +1112,9 @@ Film::make_kdms ( list kdms; for (list >::iterator i = screens.begin(); i != screens.end(); ++i) { - kdms.push_back (make_kdm ((*i)->certificate, dcp, from, until, formulation)); + if ((*i)->certificate) { + kdms.push_back (make_kdm ((*i)->certificate.get(), dcp, from, until, formulation)); + } } return kdms; @@ -1125,3 +1144,28 @@ Film::should_be_enough_disk_space (double& required, double& available) const available = double (s.available) / 1073741824.0f; return (available - required) > 1; } + +string +Film::subtitle_language () const +{ + set languages; + + ContentList cl = content (); + BOOST_FOREACH (shared_ptr& c, cl) { + shared_ptr sc = dynamic_pointer_cast (c); + if (sc) { + languages.insert (sc->subtitle_language ()); + } + } + + string all; + BOOST_FOREACH (string s, languages) { + if (!all.empty ()) { + all += "/" + s; + } else { + all += s; + } + } + + return all; +}