Reword again: Text -> Caption and Plain -> Text.
[dcpomatic.git] / src / lib / player.cc
index 35047c3aebd5cc699920a259a30a161dcfc31179..a7cd0fd94ce93bf402b2ac152d4f9842c09f694e 100644 (file)
@@ -168,7 +168,7 @@ Player::setup_pieces ()
                if (decoder->subtitle) {
                        decoder->subtitle->BitmapStart.connect (bind (&Player::bitmap_text_start, this, weak_ptr<Piece> (piece), _1));
                        decoder->subtitle->PlainStart.connect (bind (&Player::plain_text_start, this, weak_ptr<Piece> (piece), _1));
-                       decoder->subtitle->Stop.connect (bind (&Player::subtitle_stop, this, weak_ptr<Piece> (piece), _1));
+                       decoder->subtitle->Stop.connect (bind (&Player::subtitle_stop, this, weak_ptr<Piece> (piece), _1, _2));
                }
        }
 
@@ -663,7 +663,7 @@ Player::subtitles_for_frame (DCPTime time) const
 
        int const vfr = _film->video_frame_rate();
 
-       BOOST_FOREACH (PlayerText i, _active_subtitles.get_burnt (DCPTimePeriod(time, time + DCPTime::from_frames(1, vfr)), _always_burn_subtitles)) {
+       BOOST_FOREACH (PlayerCaption i, _active_text[TEXT_SUBTITLE].get_burnt (DCPTimePeriod(time, time + DCPTime::from_frames(1, vfr)), _always_burn_subtitles)) {
 
                /* Image subtitles */
                list<PositionImage> c = transform_bitmap_texts (i.image);
@@ -839,7 +839,7 @@ Player::audio (weak_ptr<Piece> wp, AudioStreamPtr stream, ContentAudio content_a
 }
 
 void
-Player::bitmap_text_start (weak_ptr<Piece> wp, ContentBitmapText subtitle)
+Player::bitmap_text_start (weak_ptr<Piece> wp, ContentBitmapCaption subtitle)
 {
        shared_ptr<Piece> piece = wp.lock ();
        if (!piece) {
@@ -858,22 +858,22 @@ Player::bitmap_text_start (weak_ptr<Piece> wp, ContentBitmapText subtitle)
        subtitle.sub.rectangle.width *= piece->content->subtitle->x_scale ();
        subtitle.sub.rectangle.height *= piece->content->subtitle->y_scale ();
 
-       PlayerText ps;
+       PlayerCaption ps;
        ps.image.push_back (subtitle.sub);
        DCPTime from (content_time_to_dcp (piece, subtitle.from()));
 
-       _active_subtitles.add_from (wp, ps, from);
+       _active_text[subtitle.type()].add_from (wp, ps, from);
 }
 
 void
-Player::plain_text_start (weak_ptr<Piece> wp, ContentPlainText subtitle)
+Player::plain_text_start (weak_ptr<Piece> wp, ContentTextCaption subtitle)
 {
        shared_ptr<Piece> piece = wp.lock ();
        if (!piece) {
                return;
        }
 
-       PlayerText ps;
+       PlayerCaption ps;
        DCPTime const from (content_time_to_dcp (piece, subtitle.from()));
 
        if (from > piece->content->end()) {
@@ -901,17 +901,17 @@ Player::plain_text_start (weak_ptr<Piece> wp, ContentPlainText subtitle)
                }
 
                s.set_in (dcp::Time(from.seconds(), 1000));
-               ps.text.push_back (PlainText (s, piece->content->subtitle->outline_width()));
+               ps.text.push_back (TextCaption (s, piece->content->subtitle->outline_width()));
                ps.add_fonts (piece->content->subtitle->fonts ());
        }
 
-       _active_subtitles.add_from (wp, ps, from);
+       _active_text[subtitle.type()].add_from (wp, ps, from);
 }
 
 void
-Player::subtitle_stop (weak_ptr<Piece> wp, ContentTime to)
+Player::subtitle_stop (weak_ptr<Piece> wp, ContentTime to, TextType type)
 {
-       if (!_active_subtitles.have (wp)) {
+       if (!_active_text[type].have (wp)) {
                return;
        }
 
@@ -926,10 +926,10 @@ Player::subtitle_stop (weak_ptr<Piece> wp, ContentTime to)
                return;
        }
 
-       pair<PlayerText, DCPTime> from = _active_subtitles.add_to (wp, dcp_to);
+       pair<PlayerCaption, DCPTime> from = _active_text[type].add_to (wp, dcp_to);
 
        if (piece->content->subtitle->use() && !_always_burn_subtitles && !piece->content->subtitle->burn()) {
-               Subtitle (from.first, DCPTimePeriod (from.second, dcp_to));
+               Text (from.first, type, DCPTimePeriod (from.second, dcp_to));
        }
 }
 
@@ -951,7 +951,9 @@ Player::seek (DCPTime time, bool accurate)
        }
 
        _audio_merger.clear ();
-       _active_subtitles.clear ();
+       for (int i = 0; i < TEXT_COUNT; ++i) {
+               _active_text[i].clear ();
+       }
 
        BOOST_FOREACH (shared_ptr<Piece> i, _pieces) {
                if (time < i->content->position()) {
@@ -1010,7 +1012,9 @@ void
 Player::do_emit_video (shared_ptr<PlayerVideo> pv, DCPTime time)
 {
        if (pv->eyes() == EYES_BOTH || pv->eyes() == EYES_RIGHT) {
-               _active_subtitles.clear_before (time);
+               for (int i = 0; i < TEXT_COUNT; ++i) {
+                       _active_text[i].clear_before (time);
+               }
        }
 
        optional<PositionImage> subtitles = subtitles_for_frame (time);