projects
/
dcpomatic.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Hand-apply 63142d58947cf10ed6f6eaeb42508eaa374a6a93 from master; fix calls to new...
[dcpomatic.git]
/
src
/
lib
/
content.cc
diff --git
a/src/lib/content.cc
b/src/lib/content.cc
index 1fb4681a251b2810c662426912114f6a2af181e7..cc29345a298f9b15d25444f439e3d2580dca8efa 100644
(file)
--- a/
src/lib/content.cc
+++ b/
src/lib/content.cc
@@
-1,5
+1,5
@@
/*
/*
- Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013
-2014
Carl Hetherington <cth@carlh.net>
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
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,32
@@
*/
*/
-#include <boost/thread/mutex.hpp>
-#include <libxml++/libxml++.h>
-#include <libcxml/cxml.h>
+/** @file src/lib/content.cc
+ * @brief Content class.
+ */
+
#include "content.h"
#include "util.h"
#include "content_factory.h"
#include "ui_signaller.h"
#include "exceptions.h"
#include "film.h"
#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 <libcxml/cxml.h>
+#include <dcp/raw_convert.h>
+#include <libxml++/libxml++.h>
+#include <boost/thread/mutex.hpp>
#include "i18n.h"
using std::string;
#include "i18n.h"
using std::string;
-using std::stringstream;
-using std::set;
using std::list;
using std::cout;
using std::vector;
using std::list;
using std::cout;
using std::vector;
+using std::max;
using boost::shared_ptr;
using boost::shared_ptr;
-using
boost::lexical_cas
t;
+using
dcp::raw_conver
t;
int const ContentProperty::PATH = 400;
int const ContentProperty::POSITION = 401;
int const ContentProperty::PATH = 400;
int const ContentProperty::POSITION = 401;
@@
-74,7
+80,7
@@
Content::Content (shared_ptr<const Film> f, boost::filesystem::path p)
_paths.push_back (p);
}
_paths.push_back (p);
}
-Content::Content (shared_ptr<const Film> f,
shared_ptr<const cxml::Node>
node)
+Content::Content (shared_ptr<const Film> f,
cxml::ConstNodePtr
node)
: _film (f)
, _change_signals_frequent (false)
{
: _film (f)
, _change_signals_frequent (false)
{
@@
-82,7
+88,7
@@
Content::Content (shared_ptr<const Film> f, shared_ptr<const cxml::Node> node)
for (list<cxml::NodePtr>::const_iterator i = path_children.begin(); i != path_children.end(); ++i) {
_paths.push_back ((*i)->content ());
}
for (list<cxml::NodePtr>::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");
_position = DCPTime (node->number_child<double> ("Position"));
_trim_start = DCPTime (node->number_child<double> ("TrimStart"));
_trim_end = DCPTime (node->number_child<double> ("TrimEnd"));
_position = DCPTime (node->number_child<double> ("Position"));
_trim_start = DCPTime (node->number_child<double> ("TrimStart"));
_trim_end = DCPTime (node->number_child<double> ("TrimEnd"));
@@
-118,15
+124,23
@@
Content::as_xml (xmlpp::Node* node) const
for (vector<boost::filesystem::path>::const_iterator i = _paths.begin(); i != _paths.end(); ++i) {
node->add_child("Path")->add_child_text (i->string ());
}
for (vector<boost::filesystem::path>::const_iterator i = _paths.begin(); i != _paths.end(); ++i) {
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<string> (_position.get ()));
- node->add_child("TrimStart")->add_child_text (lexical_cast<string> (_trim_start.get ()));
- node->add_child("TrimEnd")->add_child_text (lexical_cast<string> (_trim_end.get ()));
+ if (_digest) {
+ node->add_child("Digest")->add_child_text (_digest.get ());
+ }
+ node->add_child("Position")->add_child_text (raw_convert<string> (_position.get ()));
+ node->add_child("TrimStart")->add_child_text (raw_convert<string> (_trim_start.get ()));
+ node->add_child("TrimEnd")->add_child_text (raw_convert<string> (_trim_end.get ()));
}
void
}
void
-Content::examine (shared_ptr<Job> job)
+Content::examine (shared_ptr<Job> job
, bool calculate_digest
)
{
{
+ if (!calculate_digest) {
+ return;
+ }
+
+ job->sub (_("Computing digest"));
+
boost::mutex::scoped_lock lm (_mutex);
vector<boost::filesystem::path> p = _paths;
lm.unlock ();
boost::mutex::scoped_lock lm (_mutex);
vector<boost::filesystem::path> p = _paths;
lm.unlock ();
@@
-204,13
+218,13
@@
Content::clone () const
string
Content::technical_summary () const
{
string
Content::technical_summary () const
{
- return String::compose ("%1 %2 %3", path_summary(), digest(), position().seconds());
+ return String::compose ("%1 %2 %3", path_summary(), digest()
.get_value_or("X")
, position().seconds());
}
DCPTime
Content::length_after_trim () 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
}
/** @return string which includes everything about how this content affects
@@
-219,9
+233,9
@@
Content::length_after_trim () const
string
Content::identifier () const
{
string
Content::identifier () const
{
-
strings
tream s;
+
SafeStringS
tream s;
- s << Content::digest()
+ s << Content::digest()
.get_value_or("X")
<< "_" << position().get()
<< "_" << trim_start().get()
<< "_" << trim_end().get();
<< "_" << position().get()
<< "_" << trim_start().get()
<< "_" << trim_end().get();