summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2021-05-04 11:05:36 +0200
committerCarl Hetherington <cth@carlh.net>2021-05-07 09:29:59 +0200
commit41885408b723c29ab3ae48cae5999a9934240bf2 (patch)
tree7918e6d06cb85ebe7e0444b34f03c19e84f49539
parentc99c72164a6b598f13b4af5ec08f42205565cb34 (diff)
Rename ContentText and subclasses to PieceText... and pass subtitles through Piece.
-rw-r--r--src/lib/content_text.h75
-rw-r--r--src/lib/piece.cc30
-rw-r--r--src/lib/piece.h7
-rw-r--r--src/lib/piece_text.h103
-rw-r--r--src/lib/player.cc54
-rw-r--r--src/lib/player.h8
-rw-r--r--src/lib/text_decoder.cc4
-rw-r--r--src/lib/text_decoder.h8
-rw-r--r--src/wx/text_view.cc46
-rw-r--r--src/wx/text_view.h9
-rw-r--r--test/dcp_subtitle_test.cc70
11 files changed, 236 insertions, 178 deletions
diff --git a/src/lib/content_text.h b/src/lib/content_text.h
deleted file mode 100644
index c6d7d6ec2..000000000
--- a/src/lib/content_text.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- Copyright (C) 2014-2018 Carl Hetherington <cth@carlh.net>
-
- This file is part of DCP-o-matic.
-
- DCP-o-matic is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- DCP-o-matic is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#ifndef DCPOMATIC_CONTENT_TEXT_H
-#define DCPOMATIC_CONTENT_TEXT_H
-
-#include "dcpomatic_time.h"
-#include "rect.h"
-#include "types.h"
-#include "bitmap_text.h"
-#include <dcp/subtitle_string.h>
-#include <list>
-
-class Image;
-
-class ContentText
-{
-public:
- explicit ContentText (dcpomatic::ContentTime f)
- : _from (f)
- {}
-
- dcpomatic::ContentTime from () const {
- return _from;
- }
-
-private:
- dcpomatic::ContentTime _from;
-};
-
-class ContentBitmapText : public ContentText
-{
-public:
- ContentBitmapText (dcpomatic::ContentTime f, std::shared_ptr<Image> im, dcpomatic::Rect<double> r)
- : ContentText (f)
- , sub (im, r)
- {}
-
- /* Our text, with its rectangle unmodified by any offsets or scales that the content specifies */
- BitmapText sub;
-};
-
-/** A text caption. We store the time period separately (as well as in the dcp::SubtitleStrings)
- * as the dcp::SubtitleString timings are sometimes quite heavily quantised and this causes problems
- * when we want to compare the quantised periods to the unquantised ones.
- */
-class ContentStringText : public ContentText
-{
-public:
- ContentStringText (dcpomatic::ContentTime f, std::list<dcp::SubtitleString> s)
- : ContentText (f)
- , subs (s)
- {}
-
- std::list<dcp::SubtitleString> subs;
-};
-
-#endif
diff --git a/src/lib/piece.cc b/src/lib/piece.cc
index bf180bc84..69469c02e 100644
--- a/src/lib/piece.cc
+++ b/src/lib/piece.cc
@@ -30,11 +30,14 @@
#include "piece_video.h"
#include "player_video.h"
#include "resampler.h"
+#include "text_content.h"
+#include "text_decoder.h"
#include "video_content.h"
#include "video_decoder.h"
using std::dynamic_pointer_cast;
+using std::list;
using std::make_shared;
using std::shared_ptr;
using std::vector;
@@ -65,6 +68,12 @@ Piece::Piece (weak_ptr<const Film> film, shared_ptr<Content> content, shared_ptr
_decoder->audio->Data.connect (boost::bind(&Piece::audio, this, _1, _2, _3));
}
+ for (auto i: _decoder->text) {
+ i->BitmapStart.connect (boost::bind(&Piece::bitmap_start, this, content, i->content(), _1, _2, _3));
+ i->StringStart.connect (boost::bind(&Piece::string_start, this, content, i->content(), _1, _2));
+ i->Stop.connect (boost::bind(&Piece::stop, this, content, i->content(), _1));
+ }
+
_decoder->Flush.connect (boost::bind(&Piece::flush, this));
}
@@ -123,6 +132,27 @@ Piece::audio (AudioStreamPtr stream, shared_ptr<const AudioBuffers> audio, Frame
void
+Piece::bitmap_start (weak_ptr<const Content> content, weak_ptr<const TextContent> text, dcpomatic::ContentTime time, shared_ptr<Image> image, dcpomatic::Rect<double> area)
+{
+ BitmapTextStart (PieceBitmapTextStart(content, text, time, image, area));
+}
+
+
+void
+Piece::string_start (weak_ptr<const Content> content, weak_ptr<const TextContent> text, dcpomatic::ContentTime time, list<dcp::SubtitleString> subs)
+{
+ StringTextStart (PieceStringTextStart(content, text, time, subs));
+}
+
+
+void
+Piece::stop (weak_ptr<const Content> content, weak_ptr<const TextContent> text, dcpomatic::ContentTime time)
+{
+ TextStop (PieceTextStop(content, text, time));
+}
+
+
+void
Piece::update_pull_to (DCPTime& pull_to) const
{
if (_done) {
diff --git a/src/lib/piece.h b/src/lib/piece.h
index 66603f797..2e4eded89 100644
--- a/src/lib/piece.h
+++ b/src/lib/piece.h
@@ -28,6 +28,7 @@
#include "font_data.h"
#include "frame_rate_change.h"
#include "piece_audio.h"
+#include "piece_text.h"
#include "piece_video.h"
#include "types.h"
#include <boost/signals2.hpp>
@@ -88,6 +89,9 @@ public:
boost::signals2::signal<void (PieceVideo)> Video;
boost::signals2::signal<void (PieceAudio)> Audio;
+ boost::signals2::signal<void (PieceBitmapTextStart)> BitmapTextStart;
+ boost::signals2::signal<void (PieceStringTextStart)> StringTextStart;
+ boost::signals2::signal<void (PieceTextStop)> TextStop;
private:
friend struct overlap_video_test1;
@@ -95,6 +99,9 @@ private:
void video (std::shared_ptr<const ImageProxy> image, Frame frame, Eyes eyes, Part part);
void audio (std::shared_ptr<AudioStream> stream, std::shared_ptr<const AudioBuffers> audio, Frame frame);
+ void bitmap_start (std::weak_ptr<const Content> content, std::weak_ptr<const TextContent> text, dcpomatic::ContentTime time, std::shared_ptr<Image> image, dcpomatic::Rect<double> area);
+ void string_start (std::weak_ptr<const Content> content, std::weak_ptr<const TextContent> text, dcpomatic::ContentTime time, std::list<dcp::SubtitleString> subs);
+ void stop (std::weak_ptr<const Content> content, std::weak_ptr<const TextContent> text, dcpomatic::ContentTime time);
void flush ();
diff --git a/src/lib/piece_text.h b/src/lib/piece_text.h
new file mode 100644
index 000000000..ff57658f5
--- /dev/null
+++ b/src/lib/piece_text.h
@@ -0,0 +1,103 @@
+/*
+ Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net>
+
+ This file is part of DCP-o-matic.
+
+ DCP-o-matic is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ DCP-o-matic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#ifndef DCPOMATIC_PIECE_TEXT_H
+#define DCPOMATIC_PIECE_TEXT_H
+
+
+#include "bitmap_text.h"
+#include "dcpomatic_time.h"
+#include "rect.h"
+#include "types.h"
+#include <dcp/subtitle_string.h>
+#include <list>
+
+
+class Image;
+
+
+class PieceText
+{
+public:
+ explicit PieceText (std::weak_ptr<const Content> content, std::weak_ptr<const TextContent> text, dcpomatic::ContentTime time)
+ : _content (content)
+ , _text (text)
+ , _time (time)
+ {}
+
+ std::weak_ptr<const Content> content() const {
+ return _content;
+ }
+
+ std::weak_ptr<const TextContent> text() const {
+ return _text;
+ }
+
+ dcpomatic::ContentTime time () const {
+ return _time;
+ }
+
+private:
+ std::weak_ptr<const Content> _content;
+ std::weak_ptr<const TextContent> _text;
+ dcpomatic::ContentTime _time;
+};
+
+
+class PieceBitmapTextStart : public PieceText
+{
+public:
+ PieceBitmapTextStart (std::weak_ptr<const Content> content, std::weak_ptr<const TextContent> text, dcpomatic::ContentTime time, std::shared_ptr<Image> image, dcpomatic::Rect<double> area)
+ : PieceText (content, text, time)
+ , sub (image, area)
+ {}
+
+ /* Our text, with its rectangle unmodified by any offsets or scales that the content specifies */
+ BitmapText sub;
+};
+
+
+/** A text caption. We store the time period separately (as well as in the dcp::SubtitleStrings)
+ * as the dcp::SubtitleString timings are sometimes quite heavily quantised and this causes problems
+ * when we want to compare the quantised periods to the unquantised ones.
+ */
+class PieceStringTextStart : public PieceText
+{
+public:
+ PieceStringTextStart (std::weak_ptr<const Content> content, std::weak_ptr<const TextContent> text, dcpomatic::ContentTime time, std::list<dcp::SubtitleString> s)
+ : PieceText (content, text, time)
+ , subs (s)
+ {}
+
+ std::list<dcp::SubtitleString> subs;
+};
+
+
+class PieceTextStop : public PieceText
+{
+public:
+ PieceTextStop (std::weak_ptr<const Content> content, std::weak_ptr<const TextContent> text, dcpomatic::ContentTime time)
+ : PieceText (content, text, time)
+ {}
+};
+
+
+#endif
diff --git a/src/lib/player.cc b/src/lib/player.cc
index 564adf5ce..ad23ea47d 100644
--- a/src/lib/player.cc
+++ b/src/lib/player.cc
@@ -293,21 +293,9 @@ Player::setup_pieces_unlocked ()
piece->Audio.connect (bind(&Player::audio, this, weak_ptr<Piece>(piece), _1));
}
- auto j = decoder->text.begin();
-
- while (j != decoder->text.end()) {
- (*j)->BitmapStart.connect (
- bind(&Player::bitmap_text_start, this, weak_ptr<Piece>(piece), i, weak_ptr<const TextContent>((*j)->content()), _1)
- );
- (*j)->PlainStart.connect (
- bind(&Player::plain_text_start, this, weak_ptr<Piece>(piece), i, weak_ptr<const TextContent>((*j)->content()), _1)
- );
- (*j)->Stop.connect (
- bind(&Player::subtitle_stop, this, weak_ptr<Piece>(piece), i, weak_ptr<const TextContent>((*j)->content()), _1)
- );
-
- ++j;
- }
+ piece->BitmapTextStart.connect (bind(&Player::bitmap_text_start, this, weak_ptr<Piece>(piece), _1));
+ piece->StringTextStart.connect (bind(&Player::string_text_start, this, weak_ptr<Piece>(piece), _1));
+ piece->TextStop.connect (bind(&Player::subtitle_stop, this, weak_ptr<Piece>(piece), _1));
if (decoder->atmos) {
decoder->atmos->Data.connect (bind(&Player::atmos, this, weak_ptr<Piece>(piece), _1));
@@ -983,11 +971,11 @@ Player::audio (weak_ptr<Piece> wp, PieceAudio piece_audio)
void
-Player::bitmap_text_start (weak_ptr<Piece> wp, weak_ptr<const Content> wc, weak_ptr<const TextContent> wt, ContentBitmapText subtitle)
+Player::bitmap_text_start (weak_ptr<Piece> wp, PieceBitmapTextStart subtitle)
{
auto piece = wp.lock ();
- auto content = wc.lock ();
- auto text = wt.lock ();
+ auto content = subtitle.content().lock();
+ auto text = subtitle.text().lock();
if (!piece || !content || !text) {
return;
}
@@ -1016,25 +1004,25 @@ Player::bitmap_text_start (weak_ptr<Piece> wp, weak_ptr<const Content> wc, weak_
dcp::Size scaled_size (width, height);
ps.bitmap.push_back (BitmapText(image->scale(scaled_size, dcp::YUVToRGB::REC601, image->pixel_format(), true, _fast), subtitle.sub.rectangle));
- auto from = piece->content_time_to_dcp(content, subtitle.from());
+ auto from = piece->content_time_to_dcp(content, subtitle.time());
DCPOMATIC_ASSERT (from);
- _active_texts[static_cast<int>(text->type())].add_from (wt, ps, *from);
+ _active_texts[static_cast<int>(text->type())].add_from(text, ps, *from);
}
void
-Player::plain_text_start (weak_ptr<Piece> wp, weak_ptr<const Content> wc, weak_ptr<const TextContent> wt, ContentStringText subtitle)
+Player::string_text_start (weak_ptr<Piece> wp, PieceStringTextStart subtitle)
{
auto piece = wp.lock ();
- auto content = wc.lock ();
- auto text = wt.lock ();
+ auto content = subtitle.content().lock();
+ auto text = subtitle.text().lock();
if (!piece || !content || !text) {
return;
}
PlayerText ps;
- auto const from = piece->content_time_to_dcp(content, subtitle.from());
+ auto const from = piece->content_time_to_dcp(content, subtitle.time());
DCPOMATIC_ASSERT (from);
if (from > piece->end()) {
@@ -1042,8 +1030,8 @@ Player::plain_text_start (weak_ptr<Piece> wp, weak_ptr<const Content> wc, weak_p
}
for (auto s: subtitle.subs) {
- s.set_h_position (s.h_position() + text->x_offset ());
- s.set_v_position (s.v_position() + text->y_offset ());
+ s.set_h_position (s.h_position() + text->x_offset());
+ s.set_v_position (s.v_position() + text->y_offset());
float const xs = text->x_scale();
float const ys = text->y_scale();
float size = s.size();
@@ -1066,20 +1054,20 @@ Player::plain_text_start (weak_ptr<Piece> wp, weak_ptr<const Content> wc, weak_p
ps.add_fonts (text->fonts ());
}
- _active_texts[static_cast<int>(text->type())].add_from (wt, ps, *from);
+ _active_texts[static_cast<int>(text->type())].add_from(text, ps, *from);
}
void
-Player::subtitle_stop (weak_ptr<Piece> wp, weak_ptr<const Content> wc, weak_ptr<const TextContent> wt, ContentTime to)
+Player::subtitle_stop (weak_ptr<Piece> wp, PieceTextStop stop)
{
- auto content = wc.lock ();
- auto text = wt.lock ();
+ auto content = stop.content().lock();
+ auto text = stop.text().lock();
if (!text) {
return;
}
- if (!_active_texts[static_cast<int>(text->type())].have(wt)) {
+ if (!_active_texts[static_cast<int>(text->type())].have(stop.text())) {
return;
}
@@ -1088,14 +1076,14 @@ Player::subtitle_stop (weak_ptr<Piece> wp, weak_ptr<const Content> wc, weak_ptr<
return;
}
- auto const dcp_to = piece->content_time_to_dcp(content, to);
+ auto const dcp_to = piece->content_time_to_dcp(content, stop.time());
DCPOMATIC_ASSERT (dcp_to);
if (*dcp_to > piece->end()) {
return;
}
- auto from = _active_texts[static_cast<int>(text->type())].add_to(wt, *dcp_to);
+ auto from = _active_texts[static_cast<int>(text->type())].add_to(stop.text(), *dcp_to);
bool const always = (text->type() == TextType::OPEN_SUBTITLE && _always_burn_open_subtitles);
if (text->use() && !always && !text->burn()) {
diff --git a/src/lib/player.h b/src/lib/player.h
index 797fac72f..d7e297985 100644
--- a/src/lib/player.h
+++ b/src/lib/player.h
@@ -29,11 +29,11 @@
#include "audio_stream.h"
#include "content.h"
#include "content_atmos.h"
-#include "content_text.h"
#include "empty.h"
#include "film.h"
#include "piece.h"
#include "piece_audio.h"
+#include "piece_text.h"
#include "piece_video.h"
#include "player_text.h"
#include "position_image.h"
@@ -140,9 +140,9 @@ private:
void video (std::weak_ptr<Piece>, PieceVideo);
void audio (std::weak_ptr<Piece>, PieceAudio);
- void bitmap_text_start (std::weak_ptr<Piece>, std::weak_ptr<const Content>, std::weak_ptr<const TextContent>, ContentBitmapText);
- void plain_text_start (std::weak_ptr<Piece>, std::weak_ptr<const Content>, std::weak_ptr<const TextContent>, ContentStringText);
- void subtitle_stop (std::weak_ptr<Piece>, std::weak_ptr<const Content>, std::weak_ptr<const TextContent>, dcpomatic::ContentTime);
+ void bitmap_text_start (std::weak_ptr<Piece>, PieceBitmapTextStart);
+ void string_text_start (std::weak_ptr<Piece>, PieceStringTextStart);
+ void subtitle_stop (std::weak_ptr<Piece>, PieceTextStop);
void atmos (std::weak_ptr<Piece>, ContentAtmos);
dcpomatic::DCPTime one_video_frame () const;
diff --git a/src/lib/text_decoder.cc b/src/lib/text_decoder.cc
index 673271b2e..353bb03da 100644
--- a/src/lib/text_decoder.cc
+++ b/src/lib/text_decoder.cc
@@ -62,7 +62,7 @@ TextDecoder::TextDecoder (
void
TextDecoder::emit_bitmap_start (ContentTime from, shared_ptr<Image> image, dcpomatic::Rect<double> rect)
{
- BitmapStart (ContentBitmapText (from, image, rect));
+ BitmapStart (from, image, rect);
_position = from;
}
@@ -97,7 +97,7 @@ TextDecoder::emit_plain_start (ContentTime from, list<dcp::SubtitleString> s)
}
}
- PlainStart (ContentStringText (from, s));
+ StringStart (from, s);
_position = from;
}
diff --git a/src/lib/text_decoder.h b/src/lib/text_decoder.h
index 6e96b6b91..ac998f548 100644
--- a/src/lib/text_decoder.h
+++ b/src/lib/text_decoder.h
@@ -24,10 +24,10 @@
#include "decoder.h"
+#include "decoder_part.h"
+#include "piece_text.h"
#include "rect.h"
#include "types.h"
-#include "content_text.h"
-#include "decoder_part.h"
#include <dcp/subtitle_string.h>
#include <boost/signals2.hpp>
@@ -66,8 +66,8 @@ public:
return _content;
}
- boost::signals2::signal<void (ContentBitmapText)> BitmapStart;
- boost::signals2::signal<void (ContentStringText)> PlainStart;
+ boost::signals2::signal<void (dcpomatic::ContentTime, std::shared_ptr<Image>, dcpomatic::Rect<double>)> BitmapStart;
+ boost::signals2::signal<void (dcpomatic::ContentTime, std::list<dcp::SubtitleString>)> StringStart;
boost::signals2::signal<void (dcpomatic::ContentTime)> Stop;
private:
diff --git a/src/wx/text_view.cc b/src/wx/text_view.cc
index 3b674b5c1..abe73a5a9 100644
--- a/src/wx/text_view.cc
+++ b/src/wx/text_view.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2014-2018 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
@@ -18,28 +18,31 @@
*/
-#include "text_view.h"
+
#include "film_viewer.h"
+#include "text_view.h"
#include "wx_util.h"
-#include "lib/string_text_file_decoder.h"
-#include "lib/content_text.h"
-#include "lib/video_decoder.h"
#include "lib/audio_decoder.h"
-#include "lib/film.h"
#include "lib/config.h"
+#include "lib/film.h"
+#include "lib/piece_text.h"
#include "lib/string_text_file_content.h"
+#include "lib/string_text_file_decoder.h"
#include "lib/text_decoder.h"
+#include "lib/video_decoder.h"
+
+using std::dynamic_pointer_cast;
using std::list;
using std::shared_ptr;
using std::weak_ptr;
using boost::bind;
-using std::dynamic_pointer_cast;
using namespace dcpomatic;
#if BOOST_VERSION >= 106100
using namespace boost::placeholders;
#endif
+
TextView::TextView (
wxWindow* parent, shared_ptr<Film> film, shared_ptr<Content> content, shared_ptr<TextContent> text, shared_ptr<Decoder> decoder, weak_ptr<FilmViewer> viewer
)
@@ -73,7 +76,7 @@ TextView::TextView (
_list->InsertColumn (2, ip);
}
- wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL);
+ auto sizer = new wxBoxSizer (wxVERTICAL);
sizer->Add (_list, 1, wxEXPAND | wxALL, DCPOMATIC_SIZER_X_GAP);
_list->Bind (wxEVT_LIST_ITEM_SELECTED, boost::bind (&TextView::subtitle_selected, this, _1));
@@ -96,30 +99,32 @@ TextView::TextView (
/* Find the decoder that is being used for our TextContent and attach to it */
for (auto i: decoder->text) {
if (i->content() == text) {
- i->PlainStart.connect (bind (&TextView::data_start, this, _1));
- i->Stop.connect (bind (&TextView::data_stop, this, _1));
+ i->StringStart.connect (bind(&TextView::data_start, this, _1, _2));
+ i->Stop.connect (bind(&TextView::data_stop, this, _1));
}
}
while (!decoder->pass ()) {}
SetSizerAndFit (sizer);
}
+
void
-TextView::data_start (ContentStringText cts)
+TextView::data_start (ContentTime time, list<dcp::SubtitleString> subs)
{
- for (auto const& i: cts.subs) {
+ for (auto const& i: subs) {
wxListItem list_item;
list_item.SetId (_subs);
_list->InsertItem (list_item);
- _list->SetItem (_subs, 0, std_to_wx (cts.from().timecode (_frc->source)));
- _list->SetItem (_subs, 2, std_to_wx (i.text ()));
- _start_times.push_back (cts.from ());
+ _list->SetItem (_subs, 0, std_to_wx(time.timecode(_frc->source)));
+ _list->SetItem (_subs, 2, std_to_wx(i.text ()));
+ _start_times.push_back (time);
++_subs;
}
- _last_count = cts.subs.size ();
+ _last_count = subs.size ();
}
+
void
TextView::data_stop (ContentTime time)
{
@@ -128,21 +133,22 @@ TextView::data_stop (ContentTime time)
}
for (int i = _subs - *_last_count; i < _subs; ++i) {
- _list->SetItem (i, 1, std_to_wx (time.timecode (_frc->source)));
+ _list->SetItem (i, 1, std_to_wx(time.timecode(_frc->source)));
}
}
+
void
TextView::subtitle_selected (wxListEvent& ev)
{
- if (!Config::instance()->jump_to_selected ()) {
+ if (!Config::instance()->jump_to_selected()) {
return;
}
DCPOMATIC_ASSERT (ev.GetIndex() < int(_start_times.size()));
- shared_ptr<Content> lc = _content.lock ();
+ auto lc = _content.lock ();
DCPOMATIC_ASSERT (lc);
- shared_ptr<FilmViewer> fv = _film_viewer.lock ();
+ auto fv = _film_viewer.lock ();
DCPOMATIC_ASSERT (fv);
/* Add on a frame here to work around any rounding errors and make sure land in the subtitle */
fv->seek (lc, _start_times[ev.GetIndex()] + ContentTime::from_frames(1, _frc->source), true);
diff --git a/src/wx/text_view.h b/src/wx/text_view.h
index b44742b63..bbdbdb217 100644
--- a/src/wx/text_view.h
+++ b/src/wx/text_view.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2014-2018 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
@@ -18,17 +18,20 @@
*/
-#include "lib/content_text.h"
+
+#include "lib/piece_text.h"
#include "lib/warnings.h"
DCPOMATIC_DISABLE_WARNINGS
#include <wx/wx.h>
DCPOMATIC_ENABLE_WARNINGS
#include <wx/listctrl.h>
+
class Decoder;
class FilmViewer;
class Film;
+
class TextView : public wxDialog
{
public:
@@ -42,7 +45,7 @@ public:
);
private:
- void data_start (ContentStringText cts);
+ void data_start (dcpomatic::ContentTime time, std::list<dcp::SubtitleString> subs);
void data_stop (dcpomatic::ContentTime time);
void subtitle_selected (wxListEvent &);
diff --git a/test/dcp_subtitle_test.cc b/test/dcp_subtitle_test.cc
index b56d3dae6..2b05d0bc9 100644
--- a/test/dcp_subtitle_test.cc
+++ b/test/dcp_subtitle_test.cc
@@ -25,19 +25,19 @@
*/
-#include <boost/test/unit_test.hpp>
-#include "lib/film.h"
-#include "lib/dcp_subtitle_content.h"
#include "lib/dcp_content.h"
-#include "lib/ratio.h"
-#include "lib/dcp_decoder.h"
#include "lib/dcp_content_type.h"
+#include "lib/dcp_decoder.h"
+#include "lib/dcp_subtitle_content.h"
#include "lib/dcp_subtitle_decoder.h"
-#include "lib/text_content.h"
-#include "lib/content_text.h"
+#include "lib/film.h"
#include "lib/font.h"
+#include "lib/piece_text.h"
+#include "lib/ratio.h"
+#include "lib/text_content.h"
#include "lib/text_decoder.h"
#include "test.h"
+#include <boost/test/unit_test.hpp>
#include <iostream>
@@ -53,18 +53,16 @@ using namespace boost::placeholders;
using namespace dcpomatic;
-optional<ContentStringText> stored;
+ContentTime stored_time;
+list<dcp::SubtitleString> stored;
static void
-store (ContentStringText sub)
+store (ContentTime time, list<dcp::SubtitleString> subs)
{
- if (!stored) {
- stored = sub;
- } else {
- for (auto i: sub.subs) {
- stored->subs.push_back (i);
- }
+ stored_time = time;
+ for (auto i: subs) {
+ stored.push_back (i);
}
}
@@ -74,7 +72,7 @@ BOOST_AUTO_TEST_CASE (dcp_subtitle_test)
{
auto film = new_test_film ("dcp_subtitle_test");
film->set_container (Ratio::from_id ("185"));
- film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR"));
+ film->set_dcp_content_type (DCPContentType::from_isdcf_name("TLR"));
film->set_name ("frobozz");
film->set_interop (false);
auto content = make_shared<DCPSubtitleContent>("test/data/dcp_sub.xml");
@@ -109,15 +107,14 @@ BOOST_AUTO_TEST_CASE (dcp_subtitle_within_dcp_test)
BOOST_REQUIRE (!wait_for_jobs ());
shared_ptr<DCPDecoder> decoder (new DCPDecoder (film, content, false, shared_ptr<DCPDecoder>()));
- decoder->only_text()->PlainStart.connect (bind (store, _1));
+ decoder->only_text()->StringStart.connect (bind(store, _1, _2));
- stored = optional<ContentStringText> ();
- while (!decoder->pass() && !stored) {}
+ stored.clear();
+ while (!decoder->pass() && stored.empty()) {}
- BOOST_REQUIRE (stored);
- BOOST_REQUIRE_EQUAL (stored->subs.size(), 2U);
- BOOST_CHECK_EQUAL (stored->subs.front().text(), "Noch mal.");
- BOOST_CHECK_EQUAL (stored->subs.back().text(), "Encore une fois.");
+ BOOST_REQUIRE_EQUAL (stored.size(), 2U);
+ BOOST_CHECK_EQUAL (stored.front().text(), "Noch mal.");
+ BOOST_CHECK_EQUAL (stored.back().text(), "Encore une fois.");
}
/** Test subtitles whose text includes things like &lt;b&gt; */
@@ -132,12 +129,12 @@ BOOST_AUTO_TEST_CASE (dcp_subtitle_test2)
BOOST_REQUIRE (!wait_for_jobs ());
auto decoder = make_shared<DCPSubtitleDecoder>(film, content);
- decoder->only_text()->PlainStart.connect (bind (store, _1));
+ decoder->only_text()->StringStart.connect (bind(store, _1, _2));
- stored = optional<ContentStringText> ();
+ stored.clear();
while (!decoder->pass()) {
- if (stored && stored->from() == ContentTime(0)) {
- BOOST_CHECK_EQUAL (stored->subs.front().text(), "&lt;b&gt;Hello world!&lt;/b&gt;");
+ if (!stored.empty() && stored_time == ContentTime(0)) {
+ BOOST_CHECK_EQUAL (stored.front().text(), "&lt;b&gt;Hello world!&lt;/b&gt;");
}
}
}
@@ -158,21 +155,20 @@ BOOST_AUTO_TEST_CASE (dcp_subtitle_test3)
make_and_verify_dcp (film, { dcp::VerificationNote::Code::INVALID_STANDARD });
auto decoder = make_shared<DCPSubtitleDecoder>(film, content);
- stored = optional<ContentStringText> ();
+ stored.clear();
while (!decoder->pass ()) {
- decoder->only_text()->PlainStart.connect (bind (store, _1));
- if (stored && stored->from() == ContentTime::from_seconds(0.08)) {
- auto s = stored->subs;
- auto i = s.begin ();
+ decoder->only_text()->StringStart.connect (bind (store, _1, _2));
+ if (!stored.empty() && stored_time == ContentTime::from_seconds(0.08)) {
+ auto i = stored.begin ();
BOOST_CHECK_EQUAL (i->text(), "This");
++i;
- BOOST_REQUIRE (i != s.end ());
+ BOOST_REQUIRE (i != stored.end());
BOOST_CHECK_EQUAL (i->text(), " is ");
++i;
- BOOST_REQUIRE (i != s.end ());
+ BOOST_REQUIRE (i != stored.end());
BOOST_CHECK_EQUAL (i->text(), "wrong.");
++i;
- BOOST_REQUIRE (i == s.end ());
+ BOOST_REQUIRE (i == stored.end());
}
}
}
@@ -186,8 +182,8 @@ BOOST_AUTO_TEST_CASE (dcp_subtitle_test4)
auto film = new_test_film2 ("dcp_subtitle_test4", {content, content2});
film->set_interop (true);
- content->only_text()->add_font (shared_ptr<Font> (new Font ("font1")));
- content2->only_text()->add_font (shared_ptr<Font> (new Font ("font2")));
+ content->only_text()->add_font(make_shared<Font>("font1"));
+ content2->only_text()->add_font(make_shared<Font>("font2"));
make_and_verify_dcp (film, { dcp::VerificationNote::Code::INVALID_STANDARD });