Remove subtitle language from text content.
[dcpomatic.git] / src / lib / writer.cc
index 0b1d8e06d08d3604ec6848c8ff95e3344c2f577c..79e5ad73b4efa276d4ea75925d412cb7406e78a9 100644 (file)
@@ -62,7 +62,11 @@ using boost::shared_ptr;
 using boost::weak_ptr;
 using boost::dynamic_pointer_cast;
 using boost::optional;
+#if BOOST_VERSION >= 106100
+using namespace boost::placeholders;
+#endif
 using dcp::Data;
+using dcp::ArrayData;
 using namespace dcpomatic;
 
 Writer::Writer (shared_ptr<const Film> film, weak_ptr<Job> j)
@@ -127,7 +131,7 @@ Writer::~Writer ()
  *  @param eyes Eyes that this frame image is for.
  */
 void
-Writer::write (Data encoded, Frame frame, Eyes eyes)
+Writer::write (shared_ptr<const Data> encoded, Frame frame, Eyes eyes)
 {
        boost::mutex::scoped_lock lock (_state_mutex);
 
@@ -423,7 +427,7 @@ try
                        case QueueItem::FULL:
                                LOG_DEBUG_ENCODE (N_("Writer FULL-writes %1 (%2)"), qi.frame, (int) qi.eyes);
                                if (!qi.encoded) {
-                                       qi.encoded = Data (_film->j2c_path (qi.reel, qi.frame, qi.eyes, false));
+                                       qi.encoded.reset (new ArrayData(_film->j2c_path(qi.reel, qi.frame, qi.eyes, false)));
                                }
                                reel.write (qi.encoded, qi.frame, qi.eyes);
                                ++_full_written;
@@ -599,10 +603,10 @@ Writer::finish ()
        cpl->set_luminance (_film->luminance());
 
        list<int> ac = _film->mapped_audio_channels ();
-       dcp::MainSoundConfiguration::Field field = (
+       dcp::MCASoundField field = (
                find(ac.begin(), ac.end(), static_cast<int>(dcp::BSL)) != ac.end() ||
                find(ac.begin(), ac.end(), static_cast<int>(dcp::BSR)) != ac.end()
-               ) ? dcp::MainSoundConfiguration::SEVEN_POINT_ONE : dcp::MainSoundConfiguration::FIVE_POINT_ONE;
+               ) ? dcp::SEVEN_POINT_ONE : dcp::FIVE_POINT_ONE;
 
        dcp::MainSoundConfiguration msc (field, _film->audio_channels());
        BOOST_FOREACH (int i, ac) {
@@ -656,15 +660,12 @@ Writer::write_cover_sheet ()
        boost::algorithm::replace_all (text, "$CONTAINER", _film->container()->container_nickname());
        boost::algorithm::replace_all (text, "$AUDIO_LANGUAGE", _film->isdcf_metadata().audio_language);
 
-       optional<string> subtitle_language;
-       BOOST_FOREACH (shared_ptr<Content> i, _film->content()) {
-               BOOST_FOREACH (shared_ptr<TextContent> j, i->text) {
-                       if (j->type() == TEXT_OPEN_SUBTITLE && j->use()) {
-                               subtitle_language = j->language ();
-                       }
-               }
+       vector<dcp::LanguageTag> subtitle_languages = _film->subtitle_languages();
+       if (subtitle_languages.empty()) {
+               boost::algorithm::replace_all (text, "$SUBTITLE_LANGUAGE", "None");
+       } else {
+               boost::algorithm::replace_all (text, "$SUBTITLE_LANGUAGE", subtitle_languages.front().description());
        }
-       boost::algorithm::replace_all (text, "$SUBTITLE_LANGUAGE", subtitle_language.get_value_or("None"));
 
        boost::uintmax_t size = 0;
        for (