More automated renaming.
[dcpomatic.git] / src / lib / dcp_encoder.cc
index 3a4a793a87c5fdcfa35c5a1db3b150ce88440a07..42984887daa029dc48e6f06c766d6809ddcc8c95 100644 (file)
@@ -35,7 +35,7 @@
 #include "writer.h"
 #include "compose.hpp"
 #include "referenced_reel_asset.h"
-#include "subtitle_content.h"
+#include "text_content.h"
 #include "player_video.h"
 #include <boost/signals2.hpp>
 #include <boost/foreach.hpp>
@@ -61,11 +61,13 @@ DCPEncoder::DCPEncoder (shared_ptr<const Film> film, weak_ptr<Job> job)
 {
        _player_video_connection = _player->Video.connect (bind (&DCPEncoder::video, this, _1, _2));
        _player_audio_connection = _player->Audio.connect (bind (&DCPEncoder::audio, this, _1, _2));
-       _player_subtitle_connection = _player->Subtitle.connect (bind (&DCPEncoder::subtitle, this, _1, _2));
+       _player_caption_connection = _player->Caption.connect (bind (&DCPEncoder::caption, this, _1, _2, _3));
 
        BOOST_FOREACH (shared_ptr<const Content> c, film->content ()) {
-               if (c->subtitle && c->subtitle->use() && !c->subtitle->burn()) {
-                       _non_burnt_subtitles = true;
+               BOOST_FOREACH (shared_ptr<TextContent> i, c->caption) {
+                       if (i->use() && !i->burn()) {
+                               _non_burnt_subtitles = true;
+                       }
                }
        }
 }
@@ -75,7 +77,7 @@ DCPEncoder::~DCPEncoder ()
        /* We must stop receiving more video data before we die */
        _player_video_connection.release ();
        _player_audio_connection.release ();
-       _player_subtitle_connection.release ();
+       _player_caption_connection.release ();
 }
 
 void
@@ -94,7 +96,18 @@ DCPEncoder::go ()
        }
 
        if (_non_burnt_subtitles) {
-               _writer->write (_player->get_subtitle_fonts ());
+               list<shared_ptr<Font> > fonts = _player->get_subtitle_fonts ();
+
+               if (fonts.size() > 1 && _film->interop()) {
+                       /* Interop will ignore second and subsequent <LoadFont>s so don't even
+                          write them as they upset some validators.
+                       */
+                       shared_ptr<Font> first = fonts.front ();
+                       fonts.clear ();
+                       fonts.push_back (first);
+               }
+
+               _writer->write (fonts);
        }
 
        while (!_player->pass ()) {}
@@ -130,10 +143,10 @@ DCPEncoder::audio (shared_ptr<AudioBuffers> data, DCPTime time)
 }
 
 void
-DCPEncoder::subtitle (PlayerSubtitles data, DCPTimePeriod period)
+DCPEncoder::caption (PlayerText data, TextType type, DCPTimePeriod period)
 {
-       if (_non_burnt_subtitles) {
-               _writer->write (data, period);
+       if (type == CAPTION_CLOSED || _non_burnt_subtitles) {
+               _writer->write (data, type, period);
        }
 }