/*
- Copyright (C) 2013-2017 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "text_decoder.h"
#include "text_content.h"
#include "util.h"
#include <boost/algorithm/string.hpp>
#include <iostream>
+
using std::list;
using std::cout;
using std::string;
using std::max;
using std::shared_ptr;
using boost::optional;
-using boost::function;
using namespace dcpomatic;
+
TextDecoder::TextDecoder (
Decoder* parent,
shared_ptr<const TextContent> c,
}
+
/** Called by subclasses when an image subtitle is starting.
* @param from From time of the subtitle.
* @param image Subtitle image.
* of the video frame)
*/
void
-TextDecoder::emit_bitmap_start (ContentTime from, shared_ptr<Image> image, dcpomatic::Rect<double> rect)
+TextDecoder::emit_bitmap_start (ContentTime from, shared_ptr<const Image> image, dcpomatic::Rect<double> rect)
{
BitmapStart (ContentBitmapText (from, image, rect));
_position = from;
}
+
void
TextDecoder::emit_plain_start (ContentTime from, list<dcp::SubtitleString> s)
{
for (auto& i: s) {
- /* We must escape < and > in strings, otherwise they might confuse our subtitle
- renderer (which uses some HTML-esque markup to do bold/italic etc.)
+ /* We must escape some things, otherwise they might confuse our subtitle
+ renderer (which uses entities and some HTML-esque markup to do bold/italic etc.)
*/
string t = i.text ();
+ boost::algorithm::replace_all (t, "&", "&");
boost::algorithm::replace_all (t, "<", "<");
boost::algorithm::replace_all (t, ">", ">");
i.set_text (t);
_position = from;
}
+
void
TextDecoder::emit_plain_start (ContentTime from, sub::Subtitle const & subtitle)
{
emit_plain_start (from, out);
}
+
void
TextDecoder::emit_stop (ContentTime to)
{
Stop (to);
}
+
void
TextDecoder::emit_plain (ContentTimePeriod period, list<dcp::SubtitleString> s)
{
emit_stop (period.to);
}
+
void
TextDecoder::emit_plain (ContentTimePeriod period, sub::Subtitle const & s)
{
emit_stop (period.to);
}
+
/* @param rect Area expressed as a fraction of the video frame that this subtitle
* is for (e.g. a width of 0.5 means the width of the subtitle is half the width
* of the video frame)
*/
void
-TextDecoder::emit_bitmap (ContentTimePeriod period, shared_ptr<Image> image, dcpomatic::Rect<double> rect)
+TextDecoder::emit_bitmap (ContentTimePeriod period, shared_ptr<const Image> image, dcpomatic::Rect<double> rect)
{
emit_bitmap_start (period.from, image, rect);
emit_stop (period.to);
}
+
void
TextDecoder::seek ()
{