Tidying.
[dcpomatic.git] / src / lib / content.cc
index 49ab944be54c79c3d478469ad09762a9555768fe..4167031c2aeb54eeecaf9b16ea489bbe7c36c1ad 100644 (file)
  */
 
 
-#include "content.h"
+#include "audio_content.h"
 #include "change_signaller.h"
-#include "util.h"
+#include "compose.hpp"
+#include "content.h"
 #include "content_factory.h"
-#include "video_content.h"
-#include "audio_content.h"
-#include "text_content.h"
 #include "exceptions.h"
 #include "film.h"
 #include "job.h"
-#include "compose.hpp"
+#include "text_content.h"
+#include "util.h"
+#include "video_content.h"
 #include <dcp/locale_convert.h>
 #include <dcp/raw_convert.h>
 #include <libcxml/cxml.h>
@@ -48,8 +48,6 @@
 using std::cout;
 using std::list;
 using std::make_shared;
-using std::max;
-using std::pair;
 using std::shared_ptr;
 using std::string;
 using std::vector;
@@ -255,6 +253,8 @@ Content::set_position (shared_ptr<const Film> film, DCPTime p, bool force_emit)
 void
 Content::set_trim_start (ContentTime t)
 {
+       DCPOMATIC_ASSERT (t.get() >= 0);
+
        /* video and audio content can modify its start trim */
 
        if (video) {
@@ -278,6 +278,8 @@ Content::set_trim_start (ContentTime t)
 void
 Content::set_trim_end (ContentTime t)
 {
+       DCPOMATIC_ASSERT (t.get() >= 0);
+
        ContentChangeSignaller cc (this, ContentProperty::TRIM_END);
 
        {
@@ -541,3 +543,18 @@ Content::add_path (boost::filesystem::path p)
        auto last_write = boost::filesystem::last_write_time(p, ec);
        _last_write_times.push_back (ec ? 0 : last_write);
 }
+
+
+bool
+Content::changed () const
+{
+       bool write_time_changed = false;
+       for (auto i = 0U; i < _paths.size(); ++i) {
+               if (boost::filesystem::last_write_time(_paths[i]) != last_write_time(i)) {
+                       write_time_changed = true;
+                       break;
+               }
+       }
+
+       return (write_time_changed || calculate_digest() != digest());
+}