X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fcontent.cc;h=6e02183233da9f6f288794d61de2835bc439c8d1;hb=c008066160d85b9ec9e5485375d7baaa5d27bda2;hp=814d9c1a5c00afc2ade07ed4d70f9b92cc536293;hpb=a4c19a34244aeaf183c25878933b570fc5c0ee34;p=dcpomatic.git diff --git a/src/lib/content.cc b/src/lib/content.cc index 814d9c1a5..6e0218323 100644 --- a/src/lib/content.cc +++ b/src/lib/content.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Carl Hetherington + Copyright (C) 2013-2014 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,26 +17,33 @@ */ +/** @file src/lib/content.cc + * @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 "i18n.h" using std::string; -using std::stringstream; using std::set; using std::list; using std::cout; using std::vector; +using std::max; using boost::shared_ptr; -using boost::lexical_cast; +using dcp::raw_convert; int const ContentProperty::PATH = 400; int const ContentProperty::POSITION = 401; @@ -74,7 +81,7 @@ Content::Content (shared_ptr f, boost::filesystem::path p) _paths.push_back (p); } -Content::Content (shared_ptr f, shared_ptr node) +Content::Content (shared_ptr f, cxml::ConstNodePtr node) : _film (f) , _change_signals_frequent (false) { @@ -119,14 +126,20 @@ Content::as_xml (xmlpp::Node* node) const node->add_child("Path")->add_child_text (i->string ()); } node->add_child("Digest")->add_child_text (_digest); - node->add_child("Position")->add_child_text (lexical_cast (_position.get ())); - node->add_child("TrimStart")->add_child_text (lexical_cast (_trim_start.get ())); - node->add_child("TrimEnd")->add_child_text (lexical_cast (_trim_end.get ())); + node->add_child("Position")->add_child_text (raw_convert (_position.get ())); + node->add_child("TrimStart")->add_child_text (raw_convert (_trim_start.get ())); + node->add_child("TrimEnd")->add_child_text (raw_convert (_trim_end.get ())); } void -Content::examine (shared_ptr job) +Content::examine (shared_ptr job, bool calculate_digest) { + if (!calculate_digest) { + return; + } + + job->sub (_("Computing digest")); + boost::mutex::scoped_lock lm (_mutex); vector p = _paths; lm.unlock (); @@ -195,7 +208,10 @@ Content::clone () const xmlpp::Document doc; xmlpp::Node* node = doc.create_root_node ("Content"); as_xml (node); - return content_factory (film, cxml::NodePtr (new cxml::Node (node)), Film::current_state_version); + + /* notes is unused here (we assume) */ + list notes; + return content_factory (film, cxml::NodePtr (new cxml::Node (node)), Film::current_state_version, notes); } string @@ -207,7 +223,7 @@ Content::technical_summary () const DCPTime Content::length_after_trim () const { - return full_length() - trim_start() - trim_end(); + return max (DCPTime (), full_length() - trim_start() - trim_end()); } /** @return string which includes everything about how this content affects @@ -216,7 +232,7 @@ Content::length_after_trim () const string Content::identifier () const { - stringstream s; + SafeStringStream s; s << Content::digest() << "_" << position().get()