Merge 1.0
[dcpomatic.git] / src / lib / content.cc
index eaa55790ba063eb31bbfc36231f756f2b6ba3054..fa0031abfe27c32bb539da792d7691136a8239b6 100644 (file)
@@ -25,6 +25,7 @@
 #include "content_factory.h"
 #include "ui_signaller.h"
 #include "exceptions.h"
+#include "film.h"
 
 #include "i18n.h"
 
@@ -53,7 +54,7 @@ Content::Content (shared_ptr<const Film> f)
 
 }
 
-Content::Content (shared_ptr<const Film> f, Time p)
+Content::Content (shared_ptr<const Film> f, DCPTime p)
        : _film (f)
        , _position (p)
        , _trim_start (0)
@@ -82,9 +83,9 @@ Content::Content (shared_ptr<const Film> f, shared_ptr<const cxml::Node> node)
                _paths.push_back ((*i)->content ());
        }
        _digest = node->string_child ("Digest");
-       _position = node->number_child<Time> ("Position");
-       _trim_start = node->number_child<Time> ("TrimStart");
-       _trim_end = node->number_child<Time> ("TrimEnd");
+       _position = node->number_child<DCPTime> ("Position");
+       _trim_start = node->number_child<DCPTime> ("TrimStart");
+       _trim_end = node->number_child<DCPTime> ("TrimEnd");
 }
 
 Content::Content (shared_ptr<const Film> f, vector<shared_ptr<Content> > c)
@@ -102,6 +103,10 @@ Content::Content (shared_ptr<const Film> f, vector<shared_ptr<Content> > c)
                if (i < (c.size() - 1) && c[i]->trim_end ()) {
                        throw JoinError (_("Only the last piece of content to be joined can have an end trim."));
                }
+
+               for (size_t j = 0; j < c[i]->number_of_paths(); ++j) {
+                       _paths.push_back (c[i]->path (j));
+               }
        }
 }
 
@@ -141,7 +146,7 @@ Content::signal_changed (int p)
 }
 
 void
-Content::set_position (Time p)
+Content::set_position (DCPTime p)
 {
        {
                boost::mutex::scoped_lock lm (_mutex);
@@ -152,7 +157,7 @@ Content::set_position (Time p)
 }
 
 void
-Content::set_trim_start (Time t)
+Content::set_trim_start (DCPTime t)
 {
        {
                boost::mutex::scoped_lock lm (_mutex);
@@ -163,7 +168,7 @@ Content::set_trim_start (Time t)
 }
 
 void
-Content::set_trim_end (Time t)
+Content::set_trim_end (DCPTime t)
 {
        {
                boost::mutex::scoped_lock lm (_mutex);
@@ -186,7 +191,7 @@ Content::clone () const
        xmlpp::Document doc;
        xmlpp::Node* node = doc.create_root_node ("Content");
        as_xml (node);
-       return content_factory (film, cxml::NodePtr(new cxml::Node (node)));
+       return content_factory (film, cxml::NodePtr (new cxml::Node (node)), Film::state_version);
 }
 
 string
@@ -195,7 +200,7 @@ Content::technical_summary () const
        return String::compose ("%1 %2 %3", path_summary(), digest(), position());
 }
 
-Time
+DCPTime
 Content::length_after_trim () const
 {
        return full_length() - trim_start() - trim_end();
@@ -205,7 +210,7 @@ Content::length_after_trim () const
  *  @return true if this time is trimmed by our trim settings.
  */
 bool
-Content::trimmed (Time t) const
+Content::trimmed (DCPTime t) const
 {
        return (t < trim_start() || t > (full_length() - trim_end ()));
 }
@@ -227,7 +232,7 @@ Content::identifier () const
 }
 
 bool
-Content::path_valid () const
+Content::paths_valid () const
 {
        for (vector<boost::filesystem::path>::const_iterator i = _paths.begin(); i != _paths.end(); ++i) {
                if (!boost::filesystem::exists (*i)) {
@@ -251,6 +256,8 @@ Content::path_summary () const
 {
        /* XXX: should handle multiple paths more gracefully */
 
+       assert (number_of_paths ());
+
        string s = path(0).filename().string ();
        if (number_of_paths() > 1) {
                s += " ...";