Tell user we need a KDM when we have none, and content is encrypted.
[dcpomatic.git] / src / lib / dcpomatic_time_coalesce.h
index e103e80e67750947a35dfdc403af5183959f875f..56f82bcb680932b1bb8ff86a263dddf594093892 100644 (file)
@@ -21,6 +21,8 @@
 #include "dcpomatic_time.h"
 #include <iostream>
 
+namespace dcpomatic {
+
 /** @param periods Set of periods in ascending order of from time */
 template <class T>
 std::list<TimePeriod<T> > coalesce (std::list<TimePeriod<T> > periods)
@@ -30,11 +32,11 @@ std::list<TimePeriod<T> > coalesce (std::list<TimePeriod<T> > periods)
        do {
                coalesced.clear ();
                did_something = false;
-               for (typename std::list<TimePeriod<T> >::const_iterator i = periods.begin(); i != periods.end(); ++i) {
-                       typename std::list<TimePeriod<T> >::const_iterator j = i;
+               for (auto i = periods.begin(); i != periods.end(); ++i) {
+                       auto j = i;
                        ++j;
                        if (j != periods.end() && (i->overlap(*j) || i->to == j->from)) {
-                               coalesced.push_back (TimePeriod<T> (i->from, j->to));
+                               coalesced.push_back(TimePeriod<T>(std::min(i->from, j->from), std::max(i->to, j->to)));
                                did_something = true;
                                ++i;
                        } else {
@@ -46,3 +48,5 @@ std::list<TimePeriod<T> > coalesce (std::list<TimePeriod<T> > periods)
 
        return periods;
 }
+
+}