Fix windows build
[dcpomatic.git] / src / lib / playlist.cc
index a1b209a1199cafc94c4fa1544160615f446d7526..7c8ca0530a8f357f911df8d5b96e0b502a1ca3a8 100644 (file)
@@ -33,6 +33,7 @@
 #include <libxml++/libxml++.h>
 #include <boost/shared_ptr.hpp>
 #include <boost/foreach.hpp>
+#include <iostream>
 
 #include "i18n.h"
 
@@ -263,6 +264,7 @@ Playlist::best_dcp_frame_rate () const
        return best->dcp;
 }
 
+/** @return length of the playlist from time 0 to the last thing on the playlist */
 DCPTime
 Playlist::length () const
 {
@@ -274,6 +276,22 @@ Playlist::length () const
        return len;
 }
 
+/** @return position of the first thing on the playlist, if it's not empty */
+optional<DCPTime>
+Playlist::start () const
+{
+       if (_content.empty ()) {
+               return optional<DCPTime> ();
+       }
+
+       DCPTime start = DCPTime::max ();
+       BOOST_FOREACH (shared_ptr<Content> i, _content) {
+               start = min (start, i->position ());
+       }
+
+       return start;
+}
+
 void
 Playlist::reconnect ()
 {