summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2018-07-19 21:23:26 +0100
committerCarl Hetherington <cth@carlh.net>2018-07-19 23:45:23 +0100
commit0ab83642f0c96ae2681beae04873b3226338a570 (patch)
tree0893f0bed5e4ee9f37947edde970e9095ddcb9ba /src/lib
parentff40ecd114547a2fc07bc49403c993c3fa5d40cc (diff)
Text to player with types.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/active_text.cc (renamed from src/lib/active_subtitles.cc)14
-rw-r--r--src/lib/active_text.h (renamed from src/lib/active_subtitles.h)8
-rw-r--r--src/lib/content_text.h19
-rw-r--r--src/lib/player.cc22
-rw-r--r--src/lib/player.h6
-rw-r--r--src/lib/text_decoder.cc6
-rw-r--r--src/lib/text_decoder.h2
-rw-r--r--src/lib/types.h3
-rw-r--r--src/lib/wscript2
9 files changed, 47 insertions, 35 deletions
diff --git a/src/lib/active_subtitles.cc b/src/lib/active_text.cc
index f309ba1e0..885aa034c 100644
--- a/src/lib/active_subtitles.cc
+++ b/src/lib/active_text.cc
@@ -18,7 +18,7 @@
*/
-#include "active_subtitles.h"
+#include "active_text.h"
#include "piece.h"
#include "text_content.h"
#include <boost/shared_ptr.hpp>
@@ -36,7 +36,7 @@ using boost::optional;
* @param always_burn_subtitles Always burn subtitles even if their content is not set to burn.
*/
list<PlayerText>
-ActiveSubtitles::get_burnt (DCPTimePeriod period, bool always_burn_subtitles) const
+ActiveText::get_burnt (DCPTimePeriod period, bool always_burn_subtitles) const
{
list<PlayerText> ps;
@@ -68,7 +68,7 @@ ActiveSubtitles::get_burnt (DCPTimePeriod period, bool always_burn_subtitles) co
* @param time Time to remove before.
*/
void
-ActiveSubtitles::clear_before (DCPTime time)
+ActiveText::clear_before (DCPTime time)
{
Map updated;
for (Map::const_iterator i = _data.begin(); i != _data.end(); ++i) {
@@ -91,7 +91,7 @@ ActiveSubtitles::clear_before (DCPTime time)
* @param from From time for these subtitles.
*/
void
-ActiveSubtitles::add_from (weak_ptr<Piece> piece, PlayerText ps, DCPTime from)
+ActiveText::add_from (weak_ptr<Piece> piece, PlayerText ps, DCPTime from)
{
if (_data.find(piece) == _data.end()) {
_data[piece] = list<Period>();
@@ -105,7 +105,7 @@ ActiveSubtitles::add_from (weak_ptr<Piece> piece, PlayerText ps, DCPTime from)
* @return Return the corresponding subtitles and their from time.
*/
pair<PlayerText, DCPTime>
-ActiveSubtitles::add_to (weak_ptr<Piece> piece, DCPTime to)
+ActiveText::add_to (weak_ptr<Piece> piece, DCPTime to)
{
DCPOMATIC_ASSERT (_data.find(piece) != _data.end());
@@ -122,7 +122,7 @@ ActiveSubtitles::add_to (weak_ptr<Piece> piece, DCPTime to)
* @return true if we have any active subtitles from this piece.
*/
bool
-ActiveSubtitles::have (weak_ptr<Piece> piece) const
+ActiveText::have (weak_ptr<Piece> piece) const
{
Map::const_iterator i = _data.find(piece);
if (i == _data.end()) {
@@ -133,7 +133,7 @@ ActiveSubtitles::have (weak_ptr<Piece> piece) const
}
void
-ActiveSubtitles::clear ()
+ActiveText::clear ()
{
_data.clear ();
}
diff --git a/src/lib/active_subtitles.h b/src/lib/active_text.h
index 2dd0a4b16..09ef1cdaf 100644
--- a/src/lib/active_subtitles.h
+++ b/src/lib/active_text.h
@@ -18,8 +18,8 @@
*/
-/** @file src/lib/active_subtitles.h
- * @brief ActiveSubtitles class.
+/** @file src/lib/active_text.h
+ * @brief ActiveText class.
*/
#include "dcpomatic_time.h"
@@ -30,10 +30,10 @@
class Piece;
-/** @class ActiveSubtitles
+/** @class ActiveText
* @brief A class to maintain information on active subtitles for Player.
*/
-class ActiveSubtitles : public boost::noncopyable
+class ActiveText : public boost::noncopyable
{
public:
std::list<PlayerText> get_burnt (DCPTimePeriod period, bool always_burn_subtitles) const;
diff --git a/src/lib/content_text.h b/src/lib/content_text.h
index 17ec579df..eaba64ecf 100644
--- a/src/lib/content_text.h
+++ b/src/lib/content_text.h
@@ -23,6 +23,7 @@
#include "dcpomatic_time.h"
#include "rect.h"
+#include "types.h"
#include "bitmap_text.h"
#include <dcp/subtitle_string.h>
#include <list>
@@ -32,23 +33,29 @@ class Image;
class ContentText
{
public:
- explicit ContentText (ContentTime f)
+ explicit ContentText (ContentTime f, TextType t)
: _from (f)
+ , _type (t)
{}
ContentTime from () const {
return _from;
}
+ TextType type () const {
+ return _type;
+ }
+
private:
ContentTime _from;
+ TextType _type;
};
class ContentBitmapText : public ContentText
{
public:
- ContentBitmapText (ContentTime f, boost::shared_ptr<Image> im, dcpomatic::Rect<double> r)
- : ContentText (f)
+ ContentBitmapText (ContentTime f, TextType type, boost::shared_ptr<Image> im, dcpomatic::Rect<double> r)
+ : ContentText (f, type)
, sub (im, r)
{}
@@ -56,15 +63,15 @@ public:
BitmapText sub;
};
-/** A text subtitle. We store the time period separately (as well as in the dcp::SubtitleStrings)
+/** 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 ContentPlainText : public ContentText
{
public:
- ContentPlainText (ContentTime f, std::list<dcp::SubtitleString> s)
- : ContentText (f)
+ ContentPlainText (ContentTime f, TextType type, std::list<dcp::SubtitleString> s)
+ : ContentText (f, type)
, subs (s)
{}
diff --git a/src/lib/player.cc b/src/lib/player.cc
index 35047c3ae..36ffd1868 100644
--- a/src/lib/player.cc
+++ b/src/lib/player.cc
@@ -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 (PlayerText 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);
@@ -862,7 +862,7 @@ Player::bitmap_text_start (weak_ptr<Piece> wp, ContentBitmapText subtitle)
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
@@ -905,13 +905,13 @@ Player::plain_text_start (weak_ptr<Piece> wp, ContentPlainText subtitle)
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,7 +926,7 @@ Player::subtitle_stop (weak_ptr<Piece> wp, ContentTime to)
return;
}
- pair<PlayerText, DCPTime> from = _active_subtitles.add_to (wp, dcp_to);
+ pair<PlayerText, 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));
@@ -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);
diff --git a/src/lib/player.h b/src/lib/player.h
index 2f1baa53c..a4170f83e 100644
--- a/src/lib/player.h
+++ b/src/lib/player.h
@@ -22,7 +22,7 @@
#define DCPOMATIC_PLAYER_H
#include "player_text.h"
-#include "active_subtitles.h"
+#include "active_text.h"
#include "content_text.h"
#include "film.h"
#include "content.h"
@@ -128,7 +128,7 @@ private:
void audio (boost::weak_ptr<Piece>, AudioStreamPtr, ContentAudio);
void bitmap_text_start (boost::weak_ptr<Piece>, ContentBitmapText);
void plain_text_start (boost::weak_ptr<Piece>, ContentPlainText);
- void subtitle_stop (boost::weak_ptr<Piece>, ContentTime);
+ void subtitle_stop (boost::weak_ptr<Piece>, ContentTime, TextType);
DCPTime one_video_frame () const;
void fill_audio (DCPTimePeriod period);
std::pair<boost::shared_ptr<AudioBuffers>, DCPTime> discard_audio (
@@ -196,7 +196,7 @@ private:
Empty _black;
Empty _silent;
- ActiveSubtitles _active_subtitles;
+ ActiveText _active_text[TEXT_COUNT];
boost::shared_ptr<AudioProcessor> _audio_processor;
boost::signals2::scoped_connection _film_changed_connection;
diff --git a/src/lib/text_decoder.cc b/src/lib/text_decoder.cc
index a7271601d..2423fc738 100644
--- a/src/lib/text_decoder.cc
+++ b/src/lib/text_decoder.cc
@@ -60,7 +60,7 @@ TextDecoder::TextDecoder (
void
TextDecoder::emit_bitmap_start (ContentTime from, shared_ptr<Image> image, dcpomatic::Rect<double> rect)
{
- BitmapStart (ContentBitmapText (from, image, rect));
+ BitmapStart (ContentBitmapText (from, _content->type(), image, rect));
_position = from;
}
@@ -94,7 +94,7 @@ TextDecoder::emit_plain_start (ContentTime from, list<dcp::SubtitleString> s)
}
}
- PlainStart (ContentPlainText (from, s));
+ PlainStart (ContentPlainText (from, _content->type(), s));
_position = from;
}
@@ -233,7 +233,7 @@ TextDecoder::emit_plain_start (ContentTime from, sub::Subtitle const & subtitle)
void
TextDecoder::emit_stop (ContentTime to)
{
- Stop (to);
+ Stop (to, _content->type());
}
void
diff --git a/src/lib/text_decoder.h b/src/lib/text_decoder.h
index f9d021b3f..96eba80e2 100644
--- a/src/lib/text_decoder.h
+++ b/src/lib/text_decoder.h
@@ -64,7 +64,7 @@ public:
boost::signals2::signal<void (ContentBitmapText)> BitmapStart;
boost::signals2::signal<void (ContentPlainText)> PlainStart;
- boost::signals2::signal<void (ContentTime)> Stop;
+ boost::signals2::signal<void (ContentTime, TextType)> Stop;
private:
boost::shared_ptr<const TextContent> _content;
diff --git a/src/lib/types.h b/src/lib/types.h
index 5707cf5ce..e52daca00 100644
--- a/src/lib/types.h
+++ b/src/lib/types.h
@@ -132,7 +132,8 @@ enum ReelType
enum TextType
{
TEXT_SUBTITLE,
- TEXT_CLOSED_CAPTION
+ TEXT_CLOSED_CAPTION,
+ TEXT_COUNT
};
extern std::string text_type_to_string (TextType t);
diff --git a/src/lib/wscript b/src/lib/wscript
index ee5a583ac..ddbc1d4ff 100644
--- a/src/lib/wscript
+++ b/src/lib/wscript
@@ -21,7 +21,7 @@ import os
import i18n
sources = """
- active_subtitles.cc
+ active_text.cc
analyse_audio_job.cc
atmos_mxf_content.cc
audio_analysis.cc