#include "ui_signaller.h"
using std::string;
+using std::stringstream;
using std::set;
using boost::shared_ptr;
using boost::lexical_cast;
-int const ContentProperty::POSITION = 400;
-int const ContentProperty::LENGTH = 401;
-int const ContentProperty::TRIM_START = 402;
-int const ContentProperty::TRIM_END = 403;
+int const ContentProperty::PATH = 400;
+int const ContentProperty::POSITION = 401;
+int const ContentProperty::LENGTH = 402;
+int const ContentProperty::TRIM_START = 403;
+int const ContentProperty::TRIM_END = 404;
Content::Content (shared_ptr<const Film> f, Time p)
: _film (f)
Content::as_xml (xmlpp::Node* node) const
{
boost::mutex::scoped_lock lm (_mutex);
+
node->add_child("Path")->add_child_text (_path.string());
node->add_child("Digest")->add_child_text (_digest);
node->add_child("Position")->add_child_text (lexical_cast<string> (_position));
}
void
-Content::examine (shared_ptr<Job>)
+Content::examine (shared_ptr<Job> job)
{
+ boost::mutex::scoped_lock lm (_mutex);
+ boost::filesystem::path p = _path;
+ lm.unlock ();
+
string d;
- if (boost::filesystem::is_regular_file (_path)) {
- d = md5_digest (_path);
+ if (boost::filesystem::is_regular_file (p)) {
+ d = md5_digest (p);
} else {
- d = md5_digest_directory (_path);
+ d = md5_digest_directory (p, job);
}
-
- boost::mutex::scoped_lock lm (_mutex);
+
+ lm.lock ();
_digest = d;
}
xmlpp::Document doc;
xmlpp::Node* node = doc.create_root_node ("Content");
as_xml (node);
- return content_factory (film, shared_ptr<cxml::Node> (new cxml::Node (node)));
+ return content_factory (film, cxml::NodePtr(new cxml::Node (node)));
}
string
Time
Content::length_after_trim () const
{
- return full_length () - _trim_start - _trim_end;
+ return full_length() - trim_start() - trim_end();
}
/** @param t A time relative to the start of this content (not the position).
{
return (t < trim_start() || t > (full_length() - trim_end ()));
}
+
+/** @return string which includes everything about how this content affects
+ * its playlist.
+ */
+string
+Content::identifier () const
+{
+ stringstream s;
+
+ s << Content::digest()
+ << "_" << position()
+ << "_" << trim_start()
+ << "_" << trim_end();
+
+ return s.str ();
+}
+
+bool
+Content::path_valid () const
+{
+ return boost::filesystem::exists (_path);
+}
+
+void
+Content::set_path (boost::filesystem::path path)
+{
+ _path = path;
+ signal_changed (ContentProperty::PATH);
+}
+
+