X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fcontent.cc;h=550a8cd0577333d88844ea014d2f41b60299c7f7;hb=59e769023c392c332331567a1aea94660002c463;hp=bbbe9b6ce4bdd4dd5ff6b8dcf231c8d08126e253;hpb=8d58a7c5f4320ad5c111e336c45e44d6b51ab509;p=dcpomatic.git diff --git a/src/lib/content.cc b/src/lib/content.cc index bbbe9b6ce..550a8cd05 100644 --- a/src/lib/content.cc +++ b/src/lib/content.cc @@ -21,22 +21,22 @@ * @brief Content class. */ -#include -#include -#include -#include #include "content.h" #include "util.h" #include "content_factory.h" #include "ui_signaller.h" #include "exceptions.h" #include "film.h" +#include "safe_stringstream.h" +#include "job.h" +#include +#include +#include +#include #include "i18n.h" using std::string; -using std::stringstream; -using std::set; using std::list; using std::cout; using std::vector; @@ -88,7 +88,7 @@ Content::Content (shared_ptr f, cxml::ConstNodePtr node) for (list::const_iterator i = path_children.begin(); i != path_children.end(); ++i) { _paths.push_back ((*i)->content ()); } - _digest = node->string_child ("Digest"); + _digest = node->optional_string_child ("Digest").get_value_or ("X"); _position = DCPTime (node->number_child ("Position")); _trim_start = DCPTime (node->number_child ("TrimStart")); _trim_end = DCPTime (node->number_child ("TrimEnd")); @@ -133,11 +133,19 @@ Content::as_xml (xmlpp::Node* node) const void Content::examine (shared_ptr job) { + if (job) { + job->sub (_("Computing digest")); + } + boost::mutex::scoped_lock lm (_mutex); vector p = _paths; lm.unlock (); - - string const d = md5_digest (p, job); + + /* Some content files are very big, so we use a poor's + digest here: a MD5 of the first and last 1e6 bytes with the + size of the first file tacked on the end as a string. + */ + string const d = md5_digest_head_tail (p, 1000000) + dcp::raw_convert (boost::filesystem::file_size (p.front ())); lm.lock (); _digest = d; @@ -225,7 +233,7 @@ Content::length_after_trim () const string Content::identifier () const { - stringstream s; + SafeStringStream s; s << Content::digest() << "_" << position().get() @@ -260,7 +268,7 @@ Content::path_summary () const { /* XXX: should handle multiple paths more gracefully */ - assert (number_of_paths ()); + DCPOMATIC_ASSERT (number_of_paths ()); string s = path(0).filename().string (); if (number_of_paths() > 1) {