X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Ffilm.cc;h=18e99247800ac40274d600849a982efffb69bb51;hb=4dbc6ef917aeceb906b1ef1caf6911033e7e2c54;hp=577c29e3a55afeb8a7c85e29883c2bf7c30bcff6;hpb=22b9f3b2090d8bdfe52cda1e69d3acbe874f1ce5;p=dcpomatic.git diff --git a/src/lib/film.cc b/src/lib/film.cc index 577c29e3a..18e992478 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -17,23 +17,6 @@ */ -#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" @@ -54,6 +37,25 @@ #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" @@ -68,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; @@ -92,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. @@ -146,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 { @@ -159,7 +164,7 @@ Film::Film (boost::filesystem::path dir, bool log) string Film::video_identifier () const { - assert (container ()); + DCPOMATIC_ASSERT (container ()); SafeStringStream s; s.imbue (std::locale::classic ()); @@ -266,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()); { @@ -465,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; } @@ -591,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; } } @@ -939,20 +946,20 @@ Film::content () const } void -Film::examine_content (shared_ptr c) +Film::examine_content (shared_ptr c, bool calculate_digest) { - shared_ptr j (new ExamineContentJob (shared_from_this(), c)); + shared_ptr j (new ExamineContentJob (shared_from_this(), c, calculate_digest)); JobManager::instance()->add (j); } void -Film::examine_and_add_content (shared_ptr c) +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); } @@ -1062,7 +1069,7 @@ Film::full_frame () const return dcp::Size (4096, 2160); } - assert (false); + DCPOMATIC_ASSERT (false); return dcp::Size (); } @@ -1137,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; +}