Hand-apply d849d411cff28ef5453085791d0b4d7cd73bd070 from master; replace all assert...
[dcpomatic.git] / src / lib / film.cc
index af58dcefb5167db4359cc3ba19220981e73f8339..18e99247800ac40274d600849a982efffb69bb51 100644 (file)
@@ -48,6 +48,7 @@
 #include <boost/filesystem.hpp>
 #include <boost/algorithm/string.hpp>
 #include <boost/lexical_cast.hpp>
+#include <boost/foreach.hpp>
 #include <unistd.h>
 #include <stdexcept>
 #include <iostream>
@@ -69,6 +70,7 @@ using std::make_pair;
 using std::endl;
 using std::cout;
 using std::list;
+using std::set;
 using boost::shared_ptr;
 using boost::weak_ptr;
 using boost::dynamic_pointer_cast;
@@ -149,7 +151,7 @@ Film::Film (boost::filesystem::path dir, bool log)
                }
        }
 
-       set_directory (result);
+       set_directory (result.make_preferred ());
        if (log) {
                _log.reset (new FileLog (file ("log")));
        } else {
@@ -162,7 +164,7 @@ Film::Film (boost::filesystem::path dir, bool log)
 string
 Film::video_identifier () const
 {
-       assert (container ());
+       DCPOMATIC_ASSERT (container ());
 
        SafeStringStream s;
        s.imbue (std::locale::classic ());
@@ -1067,7 +1069,7 @@ Film::full_frame () const
                return dcp::Size (4096, 2160);
        }
 
-       assert (false);
+       DCPOMATIC_ASSERT (false);
        return dcp::Size ();
 }
 
@@ -1142,3 +1144,28 @@ Film::should_be_enough_disk_space (double& required, double& available) const
        available = double (s.available) / 1073741824.0f;
        return (available - required) > 1;
 }
+
+string
+Film::subtitle_language () const
+{
+       set<string> languages;
+       
+       ContentList cl = content ();
+       BOOST_FOREACH (shared_ptr<Content>& c, cl) {
+               shared_ptr<SubtitleContent> sc = dynamic_pointer_cast<SubtitleContent> (c);
+               if (sc) {
+                       languages.insert (sc->subtitle_language ());
+               }
+       }
+
+       string all;
+       BOOST_FOREACH (string s, languages) {
+               if (!all.empty ()) {
+                       all += "/" + s;
+               } else {
+                       all += s;
+               }
+       }
+
+       return all;
+}