X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fcontent.cc;h=2b4f02b903c90d8027d48c1f0fe1fbb36ac49380;hb=fe771b1f0ed9f794bc98faa4cca2a15651f28e87;hp=b9e8367e1c3025ba0b0ea992c6a5c8830de60efb;hpb=65274489101d5b5c503ea94d61d7ac5eb1372636;p=dcpomatic.git diff --git a/src/lib/content.cc b/src/lib/content.cc index b9e8367e1..2b4f02b90 100644 --- a/src/lib/content.cc +++ b/src/lib/content.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2014 Carl Hetherington + Copyright (C) 2013-2015 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 @@ -40,6 +40,7 @@ using std::list; using std::cout; using std::vector; using std::max; +using std::pair; using boost::shared_ptr; int const ContentProperty::PATH = 400; @@ -48,8 +49,8 @@ int const ContentProperty::LENGTH = 402; int const ContentProperty::TRIM_START = 403; int const ContentProperty::TRIM_END = 404; -Content::Content (shared_ptr f) - : _film (f) +Content::Content (shared_ptr film) + : _film (film) , _position (0) , _trim_start (0) , _trim_end (0) @@ -58,8 +59,8 @@ Content::Content (shared_ptr f) } -Content::Content (shared_ptr f, DCPTime p) - : _film (f) +Content::Content (shared_ptr film, DCPTime p) + : _film (film) , _position (p) , _trim_start (0) , _trim_end (0) @@ -68,8 +69,8 @@ Content::Content (shared_ptr f, DCPTime p) } -Content::Content (shared_ptr f, boost::filesystem::path p) - : _film (f) +Content::Content (shared_ptr film, boost::filesystem::path p) + : _film (film) , _position (0) , _trim_start (0) , _trim_end (0) @@ -78,8 +79,8 @@ Content::Content (shared_ptr f, boost::filesystem::path p) _paths.push_back (p); } -Content::Content (shared_ptr f, cxml::ConstNodePtr node) - : _film (f) +Content::Content (shared_ptr film, cxml::ConstNodePtr node) + : _film (film) , _change_signals_frequent (false) { list path_children = node->node_children ("Path"); @@ -92,8 +93,8 @@ Content::Content (shared_ptr f, cxml::ConstNodePtr node) _trim_end = DCPTime (node->number_child ("TrimEnd")); } -Content::Content (shared_ptr f, vector > c) - : _film (f) +Content::Content (shared_ptr film, vector > c) + : _film (film) , _position (c.front()->position ()) , _trim_start (c.front()->trim_start ()) , _trim_end (c.back()->trim_end ()) @@ -134,12 +135,12 @@ Content::examine (shared_ptr job) if (job) { job->sub (_("Computing digest")); } - + boost::mutex::scoped_lock lm (_mutex); vector p = _paths; lm.unlock (); - /* Some content files are very big, so we use a poor's + /* Some content files are very big, so we use a poor man'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. */ @@ -163,7 +164,7 @@ Content::set_position (DCPTime p) if (p == _position) { return; } - + _position = p; } @@ -200,7 +201,7 @@ Content::clone () const if (!film) { return shared_ptr (); } - + /* This is a bit naughty, but I can't think of a compelling reason not to do it ... */ xmlpp::Document doc; xmlpp::Node* node = doc.create_root_node ("Content"); @@ -230,7 +231,7 @@ string Content::identifier () const { SafeStringStream s; - + s << Content::digest() << "_" << position().get() << "_" << trim_start().get() @@ -273,3 +274,14 @@ Content::path_summary () const return s; } + +/** @return a list of properties that might be interesting to the user; first string is the property name, + * second is the value. + */ +list > +Content::properties () const +{ + list > p; + add_properties (p); + return p; +}