Clean up after previous commit.
[dcpomatic.git] / src / lib / reel_writer.cc
index 16c20a536f2b363be981046f9b42a845b5d83639..8fb15c133c100684e3eb2c70c1041c838e346956 100644 (file)
@@ -27,6 +27,7 @@
 #include "font.h"
 #include "compose.hpp"
 #include "audio_buffers.h"
+#include "image.h"
 #include <dcp/mono_picture_asset.h>
 #include <dcp/stereo_picture_asset.h>
 #include <dcp/sound_asset.h>
@@ -42,6 +43,7 @@
 #include <dcp/interop_subtitle_asset.h>
 #include <dcp/smpte_subtitle_asset.h>
 #include <dcp/raw_convert.h>
+#include <dcp/subtitle_image.h>
 #include <boost/foreach.hpp>
 
 #include "i18n.h"
@@ -526,8 +528,10 @@ ReelWriter::write (shared_ptr<const AudioBuffers> audio)
 }
 
 void
-ReelWriter::write (PlayerSubtitles subs)
+ReelWriter::write (PlayerCaption subs, CaptionType type, DCPTimePeriod period)
 {
+       /* XXX: we need separate libdcp asset types here and to know how different they are */
+
        if (!_subtitle_asset) {
                string lang = _film->subtitle_language ();
                if (lang.empty ()) {
@@ -554,10 +558,25 @@ ReelWriter::write (PlayerSubtitles subs)
                }
        }
 
-       BOOST_FOREACH (SubtitleString i, subs.text) {
+       BOOST_FOREACH (TextCaption i, subs.text) {
+               /* XXX: couldn't / shouldn't we use period here rather than getting time from the subtitle? */
                i.set_in  (i.in()  - dcp::Time (_period.from.seconds(), i.in().tcr));
                i.set_out (i.out() - dcp::Time (_period.from.seconds(), i.out().tcr));
-               _subtitle_asset->add (i);
+               _subtitle_asset->add (shared_ptr<dcp::Subtitle>(new dcp::SubtitleString(i)));
+       }
+
+       BOOST_FOREACH (BitmapCaption i, subs.image) {
+               _subtitle_asset->add (
+                       shared_ptr<dcp::Subtitle>(
+                               new dcp::SubtitleImage(
+                                       i.image->as_png(),
+                                       dcp::Time(period.from.seconds(), _film->video_frame_rate()),
+                                       dcp::Time(period.to.seconds(), _film->video_frame_rate()),
+                                       i.rectangle.x, dcp::HALIGN_LEFT, i.rectangle.y, dcp::VALIGN_TOP,
+                                       dcp::Time(), dcp::Time()
+                                       )
+                               )
+                       );
        }
 }