summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2018-06-11 23:50:59 +0100
committerCarl Hetherington <cth@carlh.net>2018-07-19 23:36:56 +0100
commitd7ac100c0eb1b5efdcfbec59be870fd869252840 (patch)
tree74643ed748e14ea25948c2f68ae2799ebae9d62b /src/lib
parent00ae2c28501bb757a6a45ba47ad4ecbe32412933 (diff)
Rename Subtitle -> Text
sed -i "s/SubtitleContent/TextContent/g" src/lib/*.cc src/lib/*.h src/wx/*.cc src/wx/*.h src/tools/*.cc test/*.cc sed -i "s/SubtitleDecoder/TextDecoder/g" src/lib/*.cc src/lib/*.h src/wx/*.cc src/wx/*.h src/tools/*.cc test/*.cc sed -i "s/subtitle_content/text_content/g" src/lib/*.cc src/lib/*.h src/wx/*.cc src/wx/*.h src/tools/*.cc test/*.cc src/lib/wscript src/wx/wscript sed -i "s/subtitle_decoder/text_decoder/g" src/lib/*.cc src/lib/*.h src/wx/*.cc src/wx/*.h src/tools/*.cc test/*.cc src/lib/wscript mv src/lib/subtitle_decoder.cc src/lib/text_decoder.cc mv src/lib/subtitle_decoder.h src/lib/text_decoder.h mv src/lib/subtitle_content.cc src/lib/text_content.cc mv src/lib/subtitle_content.h src/lib/text_content.h mv src/lib/dcp_subtitle_decoder.cc src/lib/dcp_text_decoder.cc mv src/lib/dcp_subtitle_decoder.h src/lib/dcp_text_decoder.h mv src/lib/dcp_subtitle_content.cc src/lib/dcp_text_content.cc mv src/lib/dcp_subtitle_content.h src/lib/dcp_text_content.h mv src/lib/text_subtitle_content.cc src/lib/text_text_content.cc mv src/lib/text_subtitle_content.h src/lib/text_text_content.h mv src/lib/text_subtitle_decoder.cc src/lib/text_text_decoder.cc mv src/lib/text_subtitle_decoder.h src/lib/text_text_decoder.h mv src/wx/timeline_subtitle_content_view.cc src/wx/timeline_text_content_view.cc mv src/wx/timeline_subtitle_content_view.h src/wx/timeline_text_content_view.h
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/active_subtitles.cc2
-rw-r--r--src/lib/content.cc2
-rw-r--r--src/lib/content.h2
-rw-r--r--src/lib/content_factory.cc14
-rw-r--r--src/lib/dcp_content.cc6
-rw-r--r--src/lib/dcp_decoder.cc4
-rw-r--r--src/lib/dcp_encoder.cc2
-rw-r--r--src/lib/dcp_text_content.cc (renamed from src/lib/dcp_subtitle_content.cc)22
-rw-r--r--src/lib/dcp_text_content.h (renamed from src/lib/dcp_subtitle_content.h)6
-rw-r--r--src/lib/dcp_text_decoder.cc (renamed from src/lib/dcp_subtitle_decoder.cc)16
-rw-r--r--src/lib/dcp_text_decoder.h (renamed from src/lib/dcp_subtitle_decoder.h)8
-rw-r--r--src/lib/decoder.cc2
-rw-r--r--src/lib/decoder.h4
-rw-r--r--src/lib/decoder_factory.cc16
-rw-r--r--src/lib/ffmpeg_content.cc8
-rw-r--r--src/lib/ffmpeg_decoder.cc6
-rw-r--r--src/lib/film.cc2
-rw-r--r--src/lib/hints.cc2
-rw-r--r--src/lib/image_subtitle.h2
-rw-r--r--src/lib/player.cc30
-rw-r--r--src/lib/playlist.cc2
-rw-r--r--src/lib/text_content.cc (renamed from src/lib/subtitle_content.cc)146
-rw-r--r--src/lib/text_content.h (renamed from src/lib/subtitle_content.h)16
-rw-r--r--src/lib/text_decoder.cc (renamed from src/lib/subtitle_decoder.cc)22
-rw-r--r--src/lib/text_decoder.h (renamed from src/lib/subtitle_decoder.h)10
-rw-r--r--src/lib/text_file.cc96
-rw-r--r--src/lib/text_file.h46
-rw-r--r--src/lib/text_file_decoder.cc84
-rw-r--r--src/lib/text_file_decoder.h43
-rw-r--r--src/lib/text_subtitle.cc4
-rw-r--r--src/lib/text_subtitle.h6
-rw-r--r--src/lib/text_text_content.cc (renamed from src/lib/text_subtitle_content.cc)22
-rw-r--r--src/lib/text_text_content.h (renamed from src/lib/text_subtitle_content.h)12
-rw-r--r--src/lib/text_text_decoder.cc (renamed from src/lib/text_subtitle_decoder.cc)16
-rw-r--r--src/lib/text_text_decoder.h (renamed from src/lib/text_subtitle_decoder.h)8
-rw-r--r--src/lib/types.h2
-rw-r--r--src/lib/wscript12
37 files changed, 486 insertions, 217 deletions
diff --git a/src/lib/active_subtitles.cc b/src/lib/active_subtitles.cc
index bc34a8942..f1d201798 100644
--- a/src/lib/active_subtitles.cc
+++ b/src/lib/active_subtitles.cc
@@ -20,7 +20,7 @@
#include "active_subtitles.h"
#include "piece.h"
-#include "subtitle_content.h"
+#include "text_content.h"
#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>
diff --git a/src/lib/content.cc b/src/lib/content.cc
index 2e4e77f8d..1a8bc9eb2 100644
--- a/src/lib/content.cc
+++ b/src/lib/content.cc
@@ -27,7 +27,7 @@
#include "content_factory.h"
#include "video_content.h"
#include "audio_content.h"
-#include "subtitle_content.h"
+#include "text_content.h"
#include "exceptions.h"
#include "film.h"
#include "job.h"
diff --git a/src/lib/content.h b/src/lib/content.h
index ea764907a..63d03fd71 100644
--- a/src/lib/content.h
+++ b/src/lib/content.h
@@ -182,7 +182,7 @@ public:
boost::shared_ptr<VideoContent> video;
boost::shared_ptr<AudioContent> audio;
- boost::shared_ptr<SubtitleContent> subtitle;
+ boost::shared_ptr<TextContent> subtitle;
void signal_changed (int);
diff --git a/src/lib/content_factory.cc b/src/lib/content_factory.cc
index 51dc4e1b3..14ca579e9 100644
--- a/src/lib/content_factory.cc
+++ b/src/lib/content_factory.cc
@@ -26,9 +26,9 @@
#include "audio_content.h"
#include "image_content.h"
#include "atmos_mxf_content.h"
-#include "text_subtitle_content.h"
+#include "text_text_content.h"
#include "dcp_content.h"
-#include "dcp_subtitle_content.h"
+#include "dcp_text_content.h"
#include "util.h"
#include "ffmpeg_audio_stream.h"
#include "video_mxf_content.h"
@@ -88,11 +88,11 @@ content_factory (shared_ptr<const Film> film, cxml::NodePtr node, int version, l
);
} else if (type == "SubRip" || type == "TextSubtitle") {
- content.reset (new TextSubtitleContent (film, node, version));
+ content.reset (new TextTextContent (film, node, version));
} else if (type == "DCP") {
content.reset (new DCPContent (film, node, version));
} else if (type == "DCPSubtitle") {
- content.reset (new DCPSubtitleContent (film, node, version));
+ content.reset (new DCPTextContent (film, node, version));
} else if (type == "VideoMXF") {
content.reset (new VideoMXFContent (film, node, version));
} else if (type == "AtmosMXF") {
@@ -210,16 +210,16 @@ content_factory (shared_ptr<const Film> film, boost::filesystem::path path)
if (valid_image_file (path)) {
single.reset (new ImageContent (film, path));
} else if (ext == ".srt" || ext == ".ssa" || ext == ".ass") {
- single.reset (new TextSubtitleContent (film, path));
+ single.reset (new TextTextContent (film, path));
} else if (ext == ".xml") {
cxml::Document doc;
doc.read_file (path);
if (doc.root_name() == "DCinemaSecurityMessage") {
throw KDMAsContentError ();
}
- single.reset (new DCPSubtitleContent (film, path));
+ single.reset (new DCPTextContent (film, path));
} else if (ext == ".mxf" && dcp::SMPTESubtitleAsset::valid_mxf (path)) {
- single.reset (new DCPSubtitleContent (film, path));
+ single.reset (new DCPTextContent (film, path));
} else if (ext == ".mxf" && VideoMXFContent::valid_mxf (path)) {
single.reset (new VideoMXFContent (film, path));
} else if (ext == ".mxf" && AtmosMXFContent::valid_mxf (path)) {
diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc
index ad1f07718..d4891ad45 100644
--- a/src/lib/dcp_content.cc
+++ b/src/lib/dcp_content.cc
@@ -28,7 +28,7 @@
#include "overlaps.h"
#include "compose.hpp"
#include "dcp_decoder.h"
-#include "subtitle_content.h"
+#include "text_content.h"
#include <dcp/dcp.h>
#include <dcp/raw_convert.h>
#include <dcp/exceptions.h>
@@ -81,7 +81,7 @@ DCPContent::DCPContent (shared_ptr<const Film> film, cxml::ConstNodePtr node, in
{
video = VideoContent::from_xml (this, node, version);
audio = AudioContent::from_xml (this, node, version);
- subtitle = SubtitleContent::from_xml (this, node, version);
+ subtitle = TextContent::from_xml (this, node, version);
if (video && audio) {
audio->set_stream (
@@ -179,7 +179,7 @@ DCPContent::examine (shared_ptr<Job> job)
boost::mutex::scoped_lock lm (_mutex);
_name = examiner->name ();
if (examiner->has_subtitles ()) {
- subtitle.reset (new SubtitleContent (this));
+ subtitle.reset (new TextContent (this));
} else {
subtitle.reset ();
}
diff --git a/src/lib/dcp_decoder.cc b/src/lib/dcp_decoder.cc
index 9893cf7fc..03bd95d90 100644
--- a/src/lib/dcp_decoder.cc
+++ b/src/lib/dcp_decoder.cc
@@ -24,7 +24,7 @@
#include "video_decoder.h"
#include "audio_decoder.h"
#include "j2k_image_proxy.h"
-#include "subtitle_decoder.h"
+#include "text_decoder.h"
#include "image.h"
#include "config.h"
#include <dcp/dcp.h>
@@ -64,7 +64,7 @@ DCPDecoder::DCPDecoder (shared_ptr<const DCPContent> c, shared_ptr<Log> log, boo
}
if (c->subtitle) {
/* XXX: this time here should be the time of the first subtitle, not 0 */
- subtitle.reset (new SubtitleDecoder (this, c->subtitle, log, ContentTime()));
+ subtitle.reset (new TextDecoder (this, c->subtitle, log, ContentTime()));
}
list<shared_ptr<dcp::CPL> > cpl_list = cpls ();
diff --git a/src/lib/dcp_encoder.cc b/src/lib/dcp_encoder.cc
index f1e819083..9121e9d53 100644
--- a/src/lib/dcp_encoder.cc
+++ b/src/lib/dcp_encoder.cc
@@ -35,7 +35,7 @@
#include "writer.h"
#include "compose.hpp"
#include "referenced_reel_asset.h"
-#include "subtitle_content.h"
+#include "text_content.h"
#include "player_video.h"
#include <boost/signals2.hpp>
#include <boost/foreach.hpp>
diff --git a/src/lib/dcp_subtitle_content.cc b/src/lib/dcp_text_content.cc
index 8fee0b2ed..9e7524be3 100644
--- a/src/lib/dcp_subtitle_content.cc
+++ b/src/lib/dcp_text_content.cc
@@ -19,9 +19,9 @@
*/
#include "font.h"
-#include "dcp_subtitle_content.h"
+#include "dcp_text_content.h"
#include "film.h"
-#include "subtitle_content.h"
+#include "text_content.h"
#include <dcp/raw_convert.h>
#include <dcp/interop_subtitle_asset.h>
#include <dcp/smpte_subtitle_asset.h>
@@ -37,21 +37,21 @@ using boost::shared_ptr;
using boost::dynamic_pointer_cast;
using dcp::raw_convert;
-DCPSubtitleContent::DCPSubtitleContent (shared_ptr<const Film> film, boost::filesystem::path path)
+DCPTextContent::DCPTextContent (shared_ptr<const Film> film, boost::filesystem::path path)
: Content (film, path)
{
- subtitle.reset (new SubtitleContent (this));
+ subtitle.reset (new TextContent (this));
}
-DCPSubtitleContent::DCPSubtitleContent (shared_ptr<const Film> film, cxml::ConstNodePtr node, int version)
+DCPTextContent::DCPTextContent (shared_ptr<const Film> film, cxml::ConstNodePtr node, int version)
: Content (film, node)
, _length (node->number_child<ContentTime::Type> ("Length"))
{
- subtitle = SubtitleContent::from_xml (this, node, version);
+ subtitle = TextContent::from_xml (this, node, version);
}
void
-DCPSubtitleContent::examine (shared_ptr<Job> job)
+DCPTextContent::examine (shared_ptr<Job> job)
{
Content::examine (job);
@@ -82,26 +82,26 @@ DCPSubtitleContent::examine (shared_ptr<Job> job)
}
DCPTime
-DCPSubtitleContent::full_length () const
+DCPTextContent::full_length () const
{
FrameRateChange const frc (active_video_frame_rate(), film()->video_frame_rate());
return DCPTime (_length, frc);
}
string
-DCPSubtitleContent::summary () const
+DCPTextContent::summary () const
{
return path_summary() + " " + _("[subtitles]");
}
string
-DCPSubtitleContent::technical_summary () const
+DCPTextContent::technical_summary () const
{
return Content::technical_summary() + " - " + _("DCP XML subtitles");
}
void
-DCPSubtitleContent::as_xml (xmlpp::Node* node, bool with_paths) const
+DCPTextContent::as_xml (xmlpp::Node* node, bool with_paths) const
{
node->add_child("Type")->add_child_text ("DCPSubtitle");
Content::as_xml (node, with_paths);
diff --git a/src/lib/dcp_subtitle_content.h b/src/lib/dcp_text_content.h
index 36945adcd..894cc0384 100644
--- a/src/lib/dcp_subtitle_content.h
+++ b/src/lib/dcp_text_content.h
@@ -21,11 +21,11 @@
#include "dcp_subtitle.h"
#include "content.h"
-class DCPSubtitleContent : public DCPSubtitle, public Content
+class DCPTextContent : public DCPSubtitle, public Content
{
public:
- DCPSubtitleContent (boost::shared_ptr<const Film>, boost::filesystem::path);
- DCPSubtitleContent (boost::shared_ptr<const Film>, cxml::ConstNodePtr, int);
+ DCPTextContent (boost::shared_ptr<const Film>, boost::filesystem::path);
+ DCPTextContent (boost::shared_ptr<const Film>, cxml::ConstNodePtr, int);
void examine (boost::shared_ptr<Job>);
std::string summary () const;
diff --git a/src/lib/dcp_subtitle_decoder.cc b/src/lib/dcp_text_decoder.cc
index 46256e93e..741bbb8bc 100644
--- a/src/lib/dcp_subtitle_decoder.cc
+++ b/src/lib/dcp_text_decoder.cc
@@ -18,8 +18,8 @@
*/
-#include "dcp_subtitle_decoder.h"
-#include "dcp_subtitle_content.h"
+#include "dcp_text_decoder.h"
+#include "dcp_text_content.h"
#include <dcp/interop_subtitle_asset.h>
#include <iostream>
@@ -29,7 +29,7 @@ using boost::shared_ptr;
using boost::dynamic_pointer_cast;
using boost::bind;
-DCPSubtitleDecoder::DCPSubtitleDecoder (shared_ptr<const DCPSubtitleContent> content, shared_ptr<Log> log)
+DCPTextDecoder::DCPTextDecoder (shared_ptr<const DCPTextContent> content, shared_ptr<Log> log)
{
shared_ptr<dcp::SubtitleAsset> c (load (content->path (0)));
_subtitles = c->subtitles ();
@@ -39,11 +39,11 @@ DCPSubtitleDecoder::DCPSubtitleDecoder (shared_ptr<const DCPSubtitleContent> con
if (_next != _subtitles.end()) {
first = content_time_period(*_next).from;
}
- subtitle.reset (new SubtitleDecoder (this, content->subtitle, log, first));
+ subtitle.reset (new TextDecoder (this, content->subtitle, log, first));
}
void
-DCPSubtitleDecoder::seek (ContentTime time, bool accurate)
+DCPTextDecoder::seek (ContentTime time, bool accurate)
{
Decoder::seek (time, accurate);
@@ -55,7 +55,7 @@ DCPSubtitleDecoder::seek (ContentTime time, bool accurate)
}
bool
-DCPSubtitleDecoder::pass ()
+DCPTextDecoder::pass ()
{
if (_next == _subtitles.end ()) {
return true;
@@ -64,7 +64,7 @@ DCPSubtitleDecoder::pass ()
/* Gather all subtitles with the same time period that are next
on the list. We must emit all subtitles for the same time
period with the same text_subtitle() call otherwise the
- SubtitleDecoder will assume there is nothing else at the
+ TextDecoder will assume there is nothing else at the
time of emit the first.
*/
@@ -86,7 +86,7 @@ DCPSubtitleDecoder::pass ()
}
ContentTimePeriod
-DCPSubtitleDecoder::content_time_period (shared_ptr<dcp::Subtitle> s) const
+DCPTextDecoder::content_time_period (shared_ptr<dcp::SubtitleString> s) const
{
return ContentTimePeriod (
ContentTime::from_seconds (s->in().as_seconds ()),
diff --git a/src/lib/dcp_subtitle_decoder.h b/src/lib/dcp_text_decoder.h
index 0756a278f..f1b51b823 100644
--- a/src/lib/dcp_subtitle_decoder.h
+++ b/src/lib/dcp_text_decoder.h
@@ -18,15 +18,15 @@
*/
-#include "subtitle_decoder.h"
+#include "text_decoder.h"
#include "dcp_subtitle.h"
-class DCPSubtitleContent;
+class DCPTextContent;
-class DCPSubtitleDecoder : public DCPSubtitle, public Decoder
+class DCPTextDecoder : public DCPSubtitle, public Decoder
{
public:
- DCPSubtitleDecoder (boost::shared_ptr<const DCPSubtitleContent>, boost::shared_ptr<Log> log);
+ DCPTextDecoder (boost::shared_ptr<const DCPTextContent>, boost::shared_ptr<Log> log);
bool pass ();
void seek (ContentTime time, bool accurate);
diff --git a/src/lib/decoder.cc b/src/lib/decoder.cc
index 502273de1..e7e6b8620 100644
--- a/src/lib/decoder.cc
+++ b/src/lib/decoder.cc
@@ -21,7 +21,7 @@
#include "decoder.h"
#include "video_decoder.h"
#include "audio_decoder.h"
-#include "subtitle_decoder.h"
+#include "text_decoder.h"
#include <boost/optional.hpp>
#include <iostream>
diff --git a/src/lib/decoder.h b/src/lib/decoder.h
index d87ff610a..27f0b1141 100644
--- a/src/lib/decoder.h
+++ b/src/lib/decoder.h
@@ -32,7 +32,7 @@
class Decoded;
class VideoDecoder;
class AudioDecoder;
-class SubtitleDecoder;
+class TextDecoder;
class DecoderPart;
/** @class Decoder.
@@ -45,7 +45,7 @@ public:
boost::shared_ptr<VideoDecoder> video;
boost::shared_ptr<AudioDecoder> audio;
- boost::shared_ptr<SubtitleDecoder> subtitle;
+ boost::shared_ptr<TextDecoder> subtitle;
/** Do some decoding and perhaps emit video, audio or subtitle data.
* @return true if this decoder will emit no more data unless a seek() happens.
diff --git a/src/lib/decoder_factory.cc b/src/lib/decoder_factory.cc
index b675f9473..1a0af1b2c 100644
--- a/src/lib/decoder_factory.cc
+++ b/src/lib/decoder_factory.cc
@@ -24,10 +24,10 @@
#include "dcp_decoder.h"
#include "image_content.h"
#include "image_decoder.h"
-#include "text_subtitle_content.h"
-#include "text_subtitle_decoder.h"
-#include "dcp_subtitle_content.h"
-#include "dcp_subtitle_decoder.h"
+#include "text_text_content.h"
+#include "text_text_decoder.h"
+#include "dcp_text_content.h"
+#include "dcp_text_decoder.h"
#include "video_mxf_content.h"
#include "video_mxf_decoder.h"
#include <boost/foreach.hpp>
@@ -54,14 +54,14 @@ decoder_factory (shared_ptr<const Content> content, shared_ptr<Log> log, bool fa
return shared_ptr<Decoder> (new ImageDecoder (ic, log));
}
- shared_ptr<const TextSubtitleContent> rc = dynamic_pointer_cast<const TextSubtitleContent> (content);
+ shared_ptr<const TextTextContent> rc = dynamic_pointer_cast<const TextTextContent> (content);
if (rc) {
- return shared_ptr<Decoder> (new TextSubtitleDecoder (rc, log));
+ return shared_ptr<Decoder> (new TextTextDecoder (rc, log));
}
- shared_ptr<const DCPSubtitleContent> dsc = dynamic_pointer_cast<const DCPSubtitleContent> (content);
+ shared_ptr<const DCPTextContent> dsc = dynamic_pointer_cast<const DCPTextContent> (content);
if (dsc) {
- return shared_ptr<Decoder> (new DCPSubtitleDecoder (dsc, log));
+ return shared_ptr<Decoder> (new DCPTextDecoder (dsc, log));
}
shared_ptr<const VideoMXFContent> vmc = dynamic_pointer_cast<const VideoMXFContent> (content);
diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc
index cbeebd817..e18977944 100644
--- a/src/lib/ffmpeg_content.cc
+++ b/src/lib/ffmpeg_content.cc
@@ -32,7 +32,7 @@
#include "log.h"
#include "exceptions.h"
#include "frame_rate_change.h"
-#include "subtitle_content.h"
+#include "text_content.h"
#include <dcp/raw_convert.h>
#include <libcxml/cxml.h>
extern "C" {
@@ -85,7 +85,7 @@ FFmpegContent::FFmpegContent (shared_ptr<const Film> film, cxml::ConstNodePtr no
{
video = VideoContent::from_xml (this, node, version);
audio = AudioContent::from_xml (this, node, version);
- subtitle = SubtitleContent::from_xml (this, node, version);
+ subtitle = TextContent::from_xml (this, node, version);
list<cxml::NodePtr> c = node->node_children ("SubtitleStream");
for (list<cxml::NodePtr>::const_iterator i = c.begin(); i != c.end(); ++i) {
@@ -163,7 +163,7 @@ FFmpegContent::FFmpegContent (shared_ptr<const Film> film, vector<shared_ptr<Con
audio.reset (new AudioContent (this, c));
}
if (need_subtitle) {
- subtitle.reset (new SubtitleContent (this, c));
+ subtitle.reset (new TextContent (this, c));
}
shared_ptr<FFmpegContent> ref = dynamic_pointer_cast<FFmpegContent> (c[0]);
@@ -303,7 +303,7 @@ FFmpegContent::examine (shared_ptr<Job> job)
_subtitle_streams = examiner->subtitle_streams ();
if (!_subtitle_streams.empty ()) {
- subtitle.reset (new SubtitleContent (this));
+ subtitle.reset (new TextContent (this));
_subtitle_stream = _subtitle_streams.front ();
}
diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc
index 0746458e5..4d10f8ef7 100644
--- a/src/lib/ffmpeg_decoder.cc
+++ b/src/lib/ffmpeg_decoder.cc
@@ -28,7 +28,7 @@
#include "util.h"
#include "log.h"
#include "ffmpeg_decoder.h"
-#include "subtitle_decoder.h"
+#include "text_decoder.h"
#include "ffmpeg_audio_stream.h"
#include "ffmpeg_subtitle_stream.h"
#include "video_filter_graph.h"
@@ -39,7 +39,7 @@
#include "film.h"
#include "audio_decoder.h"
#include "compose.hpp"
-#include "subtitle_content.h"
+#include "text_content.h"
#include "audio_content.h"
#include <dcp/subtitle_string.h>
#include <sub/ssa_reader.h>
@@ -99,7 +99,7 @@ FFmpegDecoder::FFmpegDecoder (shared_ptr<const FFmpegContent> c, shared_ptr<Log>
if (c->subtitle) {
/* XXX: this time here should be the time of the first subtitle, not 0 */
- subtitle.reset (new SubtitleDecoder (this, c->subtitle, log, ContentTime()));
+ subtitle.reset (new TextDecoder (this, c->subtitle, log, ContentTime()));
}
_next_time.resize (_format_context->nb_streams);
diff --git a/src/lib/film.cc b/src/lib/film.cc
index 98ae2e59b..0be1ddd7b 100644
--- a/src/lib/film.cc
+++ b/src/lib/film.cc
@@ -46,7 +46,7 @@
#include "screen.h"
#include "audio_content.h"
#include "video_content.h"
-#include "subtitle_content.h"
+#include "text_content.h"
#include "ffmpeg_content.h"
#include "dcp_content.h"
#include "screen_kdm.h"
diff --git a/src/lib/hints.cc b/src/lib/hints.cc
index 91aabdd56..d29002ad5 100644
--- a/src/lib/hints.cc
+++ b/src/lib/hints.cc
@@ -23,7 +23,7 @@
#include "film.h"
#include "content.h"
#include "video_content.h"
-#include "subtitle_content.h"
+#include "text_content.h"
#include "audio_processor.h"
#include "font.h"
#include "ratio.h"
diff --git a/src/lib/image_subtitle.h b/src/lib/image_subtitle.h
index f82c5b194..e0687e581 100644
--- a/src/lib/image_subtitle.h
+++ b/src/lib/image_subtitle.h
@@ -39,7 +39,7 @@ public:
* proportions of the image size; e.g. rectangle.x = 0.5 would mean that
* the rectangle starts half-way across the video.
*
- * This rectangle may or may not have had a SubtitleContent's offsets and
+ * This rectangle may or may not have had a TextContent's offsets and
* scale applied to it, depending on context.
*/
dcpomatic::Rect<double> rectangle;
diff --git a/src/lib/player.cc b/src/lib/player.cc
index df58ed223..b701deb5e 100644
--- a/src/lib/player.cc
+++ b/src/lib/player.cc
@@ -40,8 +40,8 @@
#include "decoder.h"
#include "video_decoder.h"
#include "audio_decoder.h"
-#include "subtitle_content.h"
-#include "subtitle_decoder.h"
+#include "text_content.h"
+#include "text_decoder.h"
#include "ffmpeg_content.h"
#include "audio_content.h"
#include "content_subtitle.h"
@@ -210,9 +210,9 @@ Player::playlist_content_changed (weak_ptr<Content> w, int property, bool freque
property == AudioContentProperty::STREAMS ||
property == DCPContentProperty::NEEDS_ASSETS ||
property == DCPContentProperty::NEEDS_KDM ||
- property == SubtitleContentProperty::COLOUR ||
- property == SubtitleContentProperty::EFFECT ||
- property == SubtitleContentProperty::EFFECT_COLOUR ||
+ property == TextContentProperty::COLOUR ||
+ property == TextContentProperty::EFFECT ||
+ property == TextContentProperty::EFFECT_COLOUR ||
property == FFmpegContentProperty::SUBTITLE_STREAM ||
property == FFmpegContentProperty::FILTERS
) {
@@ -221,17 +221,17 @@ Player::playlist_content_changed (weak_ptr<Content> w, int property, bool freque
Changed (property, frequent);
} else if (
- property == SubtitleContentProperty::LINE_SPACING ||
- property == SubtitleContentProperty::OUTLINE_WIDTH ||
- property == SubtitleContentProperty::Y_SCALE ||
- property == SubtitleContentProperty::FADE_IN ||
- property == SubtitleContentProperty::FADE_OUT ||
+ property == TextContentProperty::LINE_SPACING ||
+ property == TextContentProperty::OUTLINE_WIDTH ||
+ property == TextContentProperty::Y_SCALE ||
+ property == TextContentProperty::FADE_IN ||
+ property == TextContentProperty::FADE_OUT ||
property == ContentProperty::VIDEO_FRAME_RATE ||
- property == SubtitleContentProperty::USE ||
- property == SubtitleContentProperty::X_OFFSET ||
- property == SubtitleContentProperty::Y_OFFSET ||
- property == SubtitleContentProperty::X_SCALE ||
- property == SubtitleContentProperty::FONTS ||
+ property == TextContentProperty::USE ||
+ property == TextContentProperty::X_OFFSET ||
+ property == TextContentProperty::Y_OFFSET ||
+ property == TextContentProperty::X_SCALE ||
+ property == TextContentProperty::FONTS ||
property == VideoContentProperty::CROP ||
property == VideoContentProperty::SCALE ||
property == VideoContentProperty::FADE_IN ||
diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc
index 3376a55ea..13b4d7337 100644
--- a/src/lib/playlist.cc
+++ b/src/lib/playlist.cc
@@ -20,7 +20,7 @@
#include "playlist.h"
#include "video_content.h"
-#include "subtitle_content.h"
+#include "text_content.h"
#include "ffmpeg_decoder.h"
#include "ffmpeg_content.h"
#include "image_decoder.h"
diff --git a/src/lib/subtitle_content.cc b/src/lib/text_content.cc
index cd9363839..9eae63519 100644
--- a/src/lib/subtitle_content.cc
+++ b/src/lib/text_content.cc
@@ -18,7 +18,7 @@
*/
-#include "subtitle_content.h"
+#include "text_content.h"
#include "util.h"
#include "exceptions.h"
#include "font.h"
@@ -40,23 +40,23 @@ using boost::dynamic_pointer_cast;
using boost::optional;
using dcp::raw_convert;
-int const SubtitleContentProperty::X_OFFSET = 500;
-int const SubtitleContentProperty::Y_OFFSET = 501;
-int const SubtitleContentProperty::X_SCALE = 502;
-int const SubtitleContentProperty::Y_SCALE = 503;
-int const SubtitleContentProperty::USE = 504;
-int const SubtitleContentProperty::BURN = 505;
-int const SubtitleContentProperty::LANGUAGE = 506;
-int const SubtitleContentProperty::FONTS = 507;
-int const SubtitleContentProperty::COLOUR = 508;
-int const SubtitleContentProperty::EFFECT = 509;
-int const SubtitleContentProperty::EFFECT_COLOUR = 510;
-int const SubtitleContentProperty::LINE_SPACING = 511;
-int const SubtitleContentProperty::FADE_IN = 512;
-int const SubtitleContentProperty::FADE_OUT = 513;
-int const SubtitleContentProperty::OUTLINE_WIDTH = 514;
-
-SubtitleContent::SubtitleContent (Content* parent)
+int const TextContentProperty::X_OFFSET = 500;
+int const TextContentProperty::Y_OFFSET = 501;
+int const TextContentProperty::X_SCALE = 502;
+int const TextContentProperty::Y_SCALE = 503;
+int const TextContentProperty::USE = 504;
+int const TextContentProperty::BURN = 505;
+int const TextContentProperty::LANGUAGE = 506;
+int const TextContentProperty::FONTS = 507;
+int const TextContentProperty::COLOUR = 508;
+int const TextContentProperty::EFFECT = 509;
+int const TextContentProperty::EFFECT_COLOUR = 510;
+int const TextContentProperty::LINE_SPACING = 511;
+int const TextContentProperty::FADE_IN = 512;
+int const TextContentProperty::FADE_OUT = 513;
+int const TextContentProperty::OUTLINE_WIDTH = 514;
+
+TextContent::TextContent (Content* parent)
: ContentPart (parent)
, _use (false)
, _burn (false)
@@ -70,28 +70,28 @@ SubtitleContent::SubtitleContent (Content* parent)
}
-shared_ptr<SubtitleContent>
-SubtitleContent::from_xml (Content* parent, cxml::ConstNodePtr node, int version)
+shared_ptr<TextContent>
+TextContent::from_xml (Content* parent, cxml::ConstNodePtr node, int version)
{
if (version < 34) {
/* With old metadata FFmpeg content has the subtitle-related tags even with no
subtitle streams, so check for that.
*/
if (node->string_child("Type") == "FFmpeg" && node->node_children("SubtitleStream").empty()) {
- return shared_ptr<SubtitleContent> ();
+ return shared_ptr<TextContent> ();
}
/* Otherwise we can drop through to the newer logic */
}
if (!node->optional_number_child<double>("SubtitleXOffset") && !node->optional_number_child<double>("SubtitleOffset")) {
- return shared_ptr<SubtitleContent> ();
+ return shared_ptr<TextContent> ();
}
- return shared_ptr<SubtitleContent> (new SubtitleContent (parent, node, version));
+ return shared_ptr<TextContent> (new TextContent (parent, node, version));
}
-SubtitleContent::SubtitleContent (Content* parent, cxml::ConstNodePtr node, int version)
+TextContent::TextContent (Content* parent, cxml::ConstNodePtr node, int version)
: ContentPart (parent)
, _use (false)
, _burn (false)
@@ -181,10 +181,10 @@ SubtitleContent::SubtitleContent (Content* parent, cxml::ConstNodePtr node, int
connect_to_fonts ();
}
-SubtitleContent::SubtitleContent (Content* parent, vector<shared_ptr<Content> > c)
+TextContent::TextContent (Content* parent, vector<shared_ptr<Content> > c)
: ContentPart (parent)
{
- shared_ptr<SubtitleContent> ref = c[0]->subtitle;
+ shared_ptr<TextContent> ref = c[0]->subtitle;
DCPOMATIC_ASSERT (ref);
list<shared_ptr<Font> > ref_fonts = ref->fonts ();
@@ -261,7 +261,7 @@ SubtitleContent::SubtitleContent (Content* parent, vector<shared_ptr<Content> >
/** _mutex must not be held on entry */
void
-SubtitleContent::as_xml (xmlpp::Node* root) const
+TextContent::as_xml (xmlpp::Node* root) const
{
boost::mutex::scoped_lock lm (_mutex);
@@ -310,7 +310,7 @@ SubtitleContent::as_xml (xmlpp::Node* root) const
}
string
-SubtitleContent::identifier () const
+TextContent::identifier () const
{
string s = raw_convert<string> (x_scale())
+ "_" + raw_convert<string> (y_scale())
@@ -341,14 +341,14 @@ SubtitleContent::identifier () const
}
void
-SubtitleContent::add_font (shared_ptr<Font> font)
+TextContent::add_font (shared_ptr<Font> font)
{
_fonts.push_back (font);
connect_to_fonts ();
}
void
-SubtitleContent::connect_to_fonts ()
+TextContent::connect_to_fonts ()
{
BOOST_FOREACH (boost::signals2::connection& i, _font_connections) {
i.disconnect ();
@@ -357,132 +357,132 @@ SubtitleContent::connect_to_fonts ()
_font_connections.clear ();
BOOST_FOREACH (shared_ptr<Font> i, _fonts) {
- _font_connections.push_back (i->Changed.connect (boost::bind (&SubtitleContent::font_changed, this)));
+ _font_connections.push_back (i->Changed.connect (boost::bind (&TextContent::font_changed, this)));
}
}
void
-SubtitleContent::font_changed ()
+TextContent::font_changed ()
{
- _parent->signal_changed (SubtitleContentProperty::FONTS);
+ _parent->signal_changed (TextContentProperty::FONTS);
}
void
-SubtitleContent::set_colour (dcp::Colour colour)
+TextContent::set_colour (dcp::Colour colour)
{
- maybe_set (_colour, colour, SubtitleContentProperty::COLOUR);
+ maybe_set (_colour, colour, TextContentProperty::COLOUR);
}
void
-SubtitleContent::unset_colour ()
+TextContent::unset_colour ()
{
- maybe_set (_colour, optional<dcp::Colour>(), SubtitleContentProperty::COLOUR);
+ maybe_set (_colour, optional<dcp::Colour>(), TextContentProperty::COLOUR);
}
void
-SubtitleContent::set_effect (dcp::Effect e)
+TextContent::set_effect (dcp::Effect e)
{
- maybe_set (_effect, e, SubtitleContentProperty::EFFECT);
+ maybe_set (_effect, e, TextContentProperty::EFFECT);
}
void
-SubtitleContent::unset_effect ()
+TextContent::unset_effect ()
{
- maybe_set (_effect, optional<dcp::Effect>(), SubtitleContentProperty::EFFECT);
+ maybe_set (_effect, optional<dcp::Effect>(), TextContentProperty::EFFECT);
}
void
-SubtitleContent::set_effect_colour (dcp::Colour colour)
+TextContent::set_effect_colour (dcp::Colour colour)
{
- maybe_set (_effect_colour, colour, SubtitleContentProperty::EFFECT_COLOUR);
+ maybe_set (_effect_colour, colour, TextContentProperty::EFFECT_COLOUR);
}
void
-SubtitleContent::unset_effect_colour ()
+TextContent::unset_effect_colour ()
{
- maybe_set (_effect_colour, optional<dcp::Colour>(), SubtitleContentProperty::EFFECT_COLOUR);
+ maybe_set (_effect_colour, optional<dcp::Colour>(), TextContentProperty::EFFECT_COLOUR);
}
void
-SubtitleContent::set_use (bool u)
+TextContent::set_use (bool u)
{
- maybe_set (_use, u, SubtitleContentProperty::USE);
+ maybe_set (_use, u, TextContentProperty::USE);
}
void
-SubtitleContent::set_burn (bool b)
+TextContent::set_burn (bool b)
{
- maybe_set (_burn, b, SubtitleContentProperty::BURN);
+ maybe_set (_burn, b, TextContentProperty::BURN);
}
void
-SubtitleContent::set_x_offset (double o)
+TextContent::set_x_offset (double o)
{
- maybe_set (_x_offset, o, SubtitleContentProperty::X_OFFSET);
+ maybe_set (_x_offset, o, TextContentProperty::X_OFFSET);
}
void
-SubtitleContent::set_y_offset (double o)
+TextContent::set_y_offset (double o)
{
- maybe_set (_y_offset, o, SubtitleContentProperty::Y_OFFSET);
+ maybe_set (_y_offset, o, TextContentProperty::Y_OFFSET);
}
void
-SubtitleContent::set_x_scale (double s)
+TextContent::set_x_scale (double s)
{
- maybe_set (_x_scale, s, SubtitleContentProperty::X_SCALE);
+ maybe_set (_x_scale, s, TextContentProperty::X_SCALE);
}
void
-SubtitleContent::set_y_scale (double s)
+TextContent::set_y_scale (double s)
{
- maybe_set (_y_scale, s, SubtitleContentProperty::Y_SCALE);
+ maybe_set (_y_scale, s, TextContentProperty::Y_SCALE);
}
void
-SubtitleContent::set_language (string language)
+TextContent::set_language (string language)
{
- maybe_set (_language, language, SubtitleContentProperty::LANGUAGE);
+ maybe_set (_language, language, TextContentProperty::LANGUAGE);
}
void
-SubtitleContent::set_line_spacing (double s)
+TextContent::set_line_spacing (double s)
{
- maybe_set (_line_spacing, s, SubtitleContentProperty::LINE_SPACING);
+ maybe_set (_line_spacing, s, TextContentProperty::LINE_SPACING);
}
void
-SubtitleContent::set_fade_in (ContentTime t)
+TextContent::set_fade_in (ContentTime t)
{
- maybe_set (_fade_in, t, SubtitleContentProperty::FADE_IN);
+ maybe_set (_fade_in, t, TextContentProperty::FADE_IN);
}
void
-SubtitleContent::unset_fade_in ()
+TextContent::unset_fade_in ()
{
- maybe_set (_fade_in, optional<ContentTime>(), SubtitleContentProperty::FADE_IN);
+ maybe_set (_fade_in, optional<ContentTime>(), TextContentProperty::FADE_IN);
}
void
-SubtitleContent::set_fade_out (ContentTime t)
+TextContent::set_fade_out (ContentTime t)
{
- maybe_set (_fade_out, t, SubtitleContentProperty::FADE_OUT);
+ maybe_set (_fade_out, t, TextContentProperty::FADE_OUT);
}
void
-SubtitleContent::unset_fade_out ()
+TextContent::unset_fade_out ()
{
- maybe_set (_fade_out, optional<ContentTime>(), SubtitleContentProperty::FADE_OUT);
+ maybe_set (_fade_out, optional<ContentTime>(), TextContentProperty::FADE_OUT);
}
void
-SubtitleContent::set_outline_width (int w)
+TextContent::set_outline_width (int w)
{
- maybe_set (_outline_width, w, SubtitleContentProperty::OUTLINE_WIDTH);
+ maybe_set (_outline_width, w, TextContentProperty::OUTLINE_WIDTH);
}
void
-SubtitleContent::take_settings_from (shared_ptr<const SubtitleContent> c)
+TextContent::take_settings_from (shared_ptr<const TextContent> c)
{
set_use (c->_use);
set_burn (c->_burn);
@@ -490,7 +490,7 @@ SubtitleContent::take_settings_from (shared_ptr<const SubtitleContent> c)
set_y_offset (c->_y_offset);
set_x_scale (c->_x_scale);
set_y_scale (c->_y_scale);
- maybe_set (_fonts, c->_fonts, SubtitleContentProperty::FONTS);
+ maybe_set (_fonts, c->_fonts, TextContentProperty::FONTS);
if (c->_colour) {
set_colour (*c->_colour);
} else {
diff --git a/src/lib/subtitle_content.h b/src/lib/text_content.h
index b64e4787b..941184388 100644
--- a/src/lib/subtitle_content.h
+++ b/src/lib/text_content.h
@@ -28,7 +28,7 @@
class Font;
-class SubtitleContentProperty
+class TextContentProperty
{
public:
static int const X_OFFSET;
@@ -48,21 +48,21 @@ public:
static int const OUTLINE_WIDTH;
};
-/** @class SubtitleContent
+/** @class TextContent
* @brief Description of how some subtitle content should be presented.
*
* There are `image' subtitles (bitmaps) and `text' subtitles (plain text),
* and not all of the settings in this class correspond to both types.
*/
-class SubtitleContent : public ContentPart
+class TextContent : public ContentPart
{
public:
- explicit SubtitleContent (Content* parent);
- SubtitleContent (Content* parent, std::vector<boost::shared_ptr<Content> >);
+ explicit TextContent (Content* parent);
+ TextContent (Content* parent, std::vector<boost::shared_ptr<Content> >);
void as_xml (xmlpp::Node *) const;
std::string identifier () const;
- void take_settings_from (boost::shared_ptr<const SubtitleContent> c);
+ void take_settings_from (boost::shared_ptr<const TextContent> c);
void add_font (boost::shared_ptr<Font> font);
@@ -161,7 +161,7 @@ public:
return _outline_width;
}
- static boost::shared_ptr<SubtitleContent> from_xml (Content* parent, cxml::ConstNodePtr, int version);
+ static boost::shared_ptr<TextContent> from_xml (Content* parent, cxml::ConstNodePtr, int version);
protected:
/** subtitle language (e.g. "German") or empty if it is not known */
@@ -170,7 +170,7 @@ protected:
private:
friend struct ffmpeg_pts_offset_test;
- SubtitleContent (Content* parent, cxml::ConstNodePtr, int version);
+ TextContent (Content* parent, cxml::ConstNodePtr, int version);
void font_changed ();
void connect_to_fonts ();
diff --git a/src/lib/subtitle_decoder.cc b/src/lib/text_decoder.cc
index 32cae6acc..56a7e1e15 100644
--- a/src/lib/subtitle_decoder.cc
+++ b/src/lib/text_decoder.cc
@@ -18,8 +18,8 @@
*/
-#include "subtitle_decoder.h"
-#include "subtitle_content.h"
+#include "text_decoder.h"
+#include "text_content.h"
#include "util.h"
#include "log.h"
#include "compose.hpp"
@@ -37,9 +37,9 @@ using boost::shared_ptr;
using boost::optional;
using boost::function;
-SubtitleDecoder::SubtitleDecoder (
+TextDecoder::TextDecoder (
Decoder* parent,
- shared_ptr<const SubtitleContent> c,
+ shared_ptr<const TextContent> c,
shared_ptr<Log> log,
ContentTime first
)
@@ -58,14 +58,14 @@ SubtitleDecoder::SubtitleDecoder (
* of the video frame)
*/
void
-SubtitleDecoder::emit_image_start (ContentTime from, shared_ptr<Image> image, dcpomatic::Rect<double> rect)
+TextDecoder::emit_image_start (ContentTime from, shared_ptr<Image> image, dcpomatic::Rect<double> rect)
{
ImageStart (ContentImageSubtitle (from, image, rect));
_position = from;
}
void
-SubtitleDecoder::emit_text_start (ContentTime from, list<dcp::SubtitleString> s)
+TextDecoder::emit_text_start (ContentTime from, list<dcp::SubtitleString> s)
{
BOOST_FOREACH (dcp::SubtitleString& i, s) {
/* We must escape < and > in strings, otherwise they might confuse our subtitle
@@ -99,7 +99,7 @@ SubtitleDecoder::emit_text_start (ContentTime from, list<dcp::SubtitleString> s)
}
void
-SubtitleDecoder::emit_text_start (ContentTime from, sub::Subtitle const & subtitle)
+TextDecoder::emit_text_start (ContentTime from, sub::Subtitle const & subtitle)
{
/* See if our next subtitle needs to be vertically placed on screen by us */
bool needs_placement = false;
@@ -231,27 +231,27 @@ SubtitleDecoder::emit_text_start (ContentTime from, sub::Subtitle const & subtit
}
void
-SubtitleDecoder::emit_stop (ContentTime to)
+TextDecoder::emit_stop (ContentTime to)
{
Stop (to);
}
void
-SubtitleDecoder::emit_text (ContentTimePeriod period, list<dcp::SubtitleString> s)
+TextDecoder::emit_text (ContentTimePeriod period, list<dcp::SubtitleString> s)
{
emit_text_start (period.from, s);
emit_stop (period.to);
}
void
-SubtitleDecoder::emit_text (ContentTimePeriod period, sub::Subtitle const & s)
+TextDecoder::emit_text (ContentTimePeriod period, sub::Subtitle const & s)
{
emit_text_start (period.from, s);
emit_stop (period.to);
}
void
-SubtitleDecoder::seek ()
+TextDecoder::seek ()
{
_position = ContentTime ();
}
diff --git a/src/lib/subtitle_decoder.h b/src/lib/text_decoder.h
index c1f171b1f..d9d351d92 100644
--- a/src/lib/subtitle_decoder.h
+++ b/src/lib/text_decoder.h
@@ -35,12 +35,12 @@ namespace sub {
class Image;
-class SubtitleDecoder : public DecoderPart
+class TextDecoder : public DecoderPart
{
public:
- SubtitleDecoder (
+ TextDecoder (
Decoder* parent,
- boost::shared_ptr<const SubtitleContent>,
+ boost::shared_ptr<const TextContent>,
boost::shared_ptr<Log> log,
ContentTime first
);
@@ -58,7 +58,7 @@ public:
void seek ();
- boost::shared_ptr<const SubtitleContent> content () const {
+ boost::shared_ptr<const TextContent> content () const {
return _content;
}
@@ -67,7 +67,7 @@ public:
boost::signals2::signal<void (ContentTime)> Stop;
private:
- boost::shared_ptr<const SubtitleContent> _content;
+ boost::shared_ptr<const TextContent> _content;
ContentTime _position;
};
diff --git a/src/lib/text_file.cc b/src/lib/text_file.cc
new file mode 100644
index 000000000..b6a07574b
--- /dev/null
+++ b/src/lib/text_file.cc
@@ -0,0 +1,96 @@
+/*
+ Copyright (C) 2014-2016 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/>.
+
+*/
+
+#include "text_file.h"
+#include "cross.h"
+#include "exceptions.h"
+#include "text_file_content.h"
+#include <sub/subrip_reader.h>
+#include <sub/ssa_reader.h>
+#include <sub/collect.h>
+#include <unicode/ucsdet.h>
+#include <unicode/ucnv.h>
+#include <iostream>
+
+#include "i18n.h"
+
+using std::vector;
+using std::cout;
+using std::string;
+using boost::shared_ptr;
+using boost::scoped_array;
+using dcp::Data;
+
+TextFile::TextFile (shared_ptr<const TextFileContent> content)
+{
+ Data in (content->path (0));
+
+ UErrorCode status = U_ZERO_ERROR;
+ UCharsetDetector* detector = ucsdet_open (&status);
+ ucsdet_setText (detector, reinterpret_cast<const char *> (in.data().get()), in.size(), &status);
+
+ UCharsetMatch const * match = ucsdet_detect (detector, &status);
+ char const * in_charset = ucsdet_getName (match, &status);
+
+ UConverter* to_utf16 = ucnv_open (in_charset, &status);
+ /* This is a guess; I think we should be able to encode any input in 4 times its input size */
+ scoped_array<uint16_t> utf16 (new uint16_t[in.size() * 2]);
+ int const utf16_len = ucnv_toUChars (
+ to_utf16, reinterpret_cast<UChar*>(utf16.get()), in.size() * 2,
+ reinterpret_cast<const char *> (in.data().get()), in.size(),
+ &status
+ );
+
+ UConverter* to_utf8 = ucnv_open ("UTF-8", &status);
+ /* Another guess */
+ scoped_array<char> utf8 (new char[utf16_len * 2]);
+ ucnv_fromUChars (to_utf8, utf8.get(), utf16_len * 2, reinterpret_cast<UChar*>(utf16.get()), utf16_len, &status);
+
+ ucsdet_close (detector);
+ ucnv_close (to_utf16);
+ ucnv_close (to_utf8);
+
+ sub::Reader* reader = 0;
+
+ string ext = content->path(0).extension().string();
+ transform (ext.begin(), ext.end(), ext.begin(), ::tolower);
+
+ if (ext == ".srt") {
+ reader = new sub::SubripReader (utf8.get());
+ } else if (ext == ".ssa" || ext == ".ass") {
+ reader = new sub::SSAReader (utf8.get());
+ }
+
+ if (reader) {
+ _subtitles = sub::collect<vector<sub::Subtitle> > (reader->subtitles ());
+ }
+
+ delete reader;
+}
+
+ContentTime
+TextFile::length () const
+{
+ if (_subtitles.empty ()) {
+ return ContentTime ();
+ }
+
+ return ContentTime::from_seconds (_subtitles.back().to.all_as_seconds ());
+}
diff --git a/src/lib/text_file.h b/src/lib/text_file.h
new file mode 100644
index 000000000..346571fc1
--- /dev/null
+++ b/src/lib/text_file.h
@@ -0,0 +1,46 @@
+/*
+ Copyright (C) 2014-2016 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_TEXT_SUBTITLE_H
+#define DCPOMATIC_TEXT_SUBTITLE_H
+
+#include "dcpomatic_time.h"
+#include <sub/subtitle.h>
+#include <boost/shared_ptr.hpp>
+#include <vector>
+
+class TextFileContent;
+class text_file_time_test;
+class text_file_coordinate_test;
+class text_text_content_test;
+class text_file_parse_test;
+
+class TextFile
+{
+public:
+ explicit TextFile (boost::shared_ptr<const TextFileContent>);
+
+ ContentTime length () const;
+
+protected:
+ std::vector<sub::Subtitle> _subtitles;
+};
+
+#endif
diff --git a/src/lib/text_file_decoder.cc b/src/lib/text_file_decoder.cc
new file mode 100644
index 000000000..1dba3acd0
--- /dev/null
+++ b/src/lib/text_file_decoder.cc
@@ -0,0 +1,84 @@
+/*
+ Copyright (C) 2014-2016 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/>.
+
+*/
+
+#include "text_file_decoder.h"
+#include "text_file_content.h"
+#include "text_content.h"
+#include <dcp/subtitle_string.h>
+#include <boost/foreach.hpp>
+#include <iostream>
+
+using std::list;
+using std::vector;
+using std::string;
+using std::cout;
+using std::max;
+using boost::shared_ptr;
+using boost::optional;
+using boost::dynamic_pointer_cast;
+
+TextTextDecoder::TextTextDecoder (shared_ptr<const TextFileContent> content, shared_ptr<Log> log)
+ : TextFile (content)
+ , _next (0)
+{
+ subtitle.reset (new TextDecoder (this, content->subtitle, log));
+}
+
+void
+TextTextDecoder::seek (ContentTime time, bool accurate)
+{
+ /* It's worth back-tracking a little here as decoding is cheap and it's nice if we don't miss
+ too many subtitles when seeking.
+ */
+ time -= ContentTime::from_seconds (5);
+ if (time < ContentTime()) {
+ time = ContentTime();
+ }
+
+ Decoder::seek (time, accurate);
+
+ _next = 0;
+ while (_next < _subtitles.size() && ContentTime::from_seconds (_subtitles[_next].from.all_as_seconds ()) < time) {
+ ++_next;
+ }
+}
+
+bool
+TextTextDecoder::pass ()
+{
+ if (_next >= _subtitles.size ()) {
+ return true;
+ }
+
+ ContentTimePeriod const p = content_time_period (_subtitles[_next]);
+ subtitle->emit_text (p, _subtitles[_next]);
+
+ ++_next;
+ return false;
+}
+
+ContentTimePeriod
+TextTextDecoder::content_time_period (sub::Subtitle s) const
+{
+ return ContentTimePeriod (
+ ContentTime::from_seconds (s.from.all_as_seconds()),
+ ContentTime::from_seconds (s.to.all_as_seconds())
+ );
+}
diff --git a/src/lib/text_file_decoder.h b/src/lib/text_file_decoder.h
new file mode 100644
index 000000000..cd279ba92
--- /dev/null
+++ b/src/lib/text_file_decoder.h
@@ -0,0 +1,43 @@
+/*
+ Copyright (C) 2014-2016 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_TEXT_SUBTITLE_DECODER_H
+#define DCPOMATIC_TEXT_SUBTITLE_DECODER_H
+
+#include "text_decoder.h"
+#include "text_file.h"
+
+class TextFileContent;
+
+class TextTextDecoder : public Decoder, public TextFile
+{
+public:
+ TextTextDecoder (boost::shared_ptr<const TextFileContent>, boost::shared_ptr<Log> log);
+
+ void seek (ContentTime time, bool accurate);
+ bool pass ();
+
+private:
+ ContentTimePeriod content_time_period (sub::Subtitle s) const;
+
+ size_t _next;
+};
+
+#endif
diff --git a/src/lib/text_subtitle.cc b/src/lib/text_subtitle.cc
index 972e74b66..35acb9022 100644
--- a/src/lib/text_subtitle.cc
+++ b/src/lib/text_subtitle.cc
@@ -21,7 +21,7 @@
#include "text_subtitle.h"
#include "cross.h"
#include "exceptions.h"
-#include "text_subtitle_content.h"
+#include "text_text_content.h"
#include <sub/subrip_reader.h>
#include <sub/ssa_reader.h>
#include <sub/collect.h>
@@ -39,7 +39,7 @@ using boost::scoped_array;
using boost::optional;
using dcp::Data;
-TextSubtitle::TextSubtitle (shared_ptr<const TextSubtitleContent> content)
+TextSubtitle::TextSubtitle (shared_ptr<const TextTextContent> content)
{
Data in (content->path (0));
diff --git a/src/lib/text_subtitle.h b/src/lib/text_subtitle.h
index c72486ca0..0cd33c9fb 100644
--- a/src/lib/text_subtitle.h
+++ b/src/lib/text_subtitle.h
@@ -26,16 +26,16 @@
#include <boost/shared_ptr.hpp>
#include <vector>
-class TextSubtitleContent;
+class TextTextContent;
class text_subtitle_time_test;
class text_subtitle_coordinate_test;
-class text_subtitle_content_test;
+class text_text_content_test;
class text_subtitle_parse_test;
class TextSubtitle
{
public:
- explicit TextSubtitle (boost::shared_ptr<const TextSubtitleContent>);
+ explicit TextSubtitle (boost::shared_ptr<const TextTextContent>);
boost::optional<ContentTime> first () const;
ContentTime length () const;
diff --git a/src/lib/text_subtitle_content.cc b/src/lib/text_text_content.cc
index 08722a065..1ff66c490 100644
--- a/src/lib/text_subtitle_content.cc
+++ b/src/lib/text_text_content.cc
@@ -18,12 +18,12 @@
*/
-#include "text_subtitle_content.h"
+#include "text_text_content.h"
#include "util.h"
#include "text_subtitle.h"
#include "film.h"
#include "font.h"
-#include "subtitle_content.h"
+#include "text_content.h"
#include <dcp/raw_convert.h>
#include <libxml++/libxml++.h>
#include <iostream>
@@ -35,21 +35,21 @@ using std::cout;
using boost::shared_ptr;
using dcp::raw_convert;
-TextSubtitleContent::TextSubtitleContent (shared_ptr<const Film> film, boost::filesystem::path path)
+TextTextContent::TextTextContent (shared_ptr<const Film> film, boost::filesystem::path path)
: Content (film, path)
{
- subtitle.reset (new SubtitleContent (this));
+ subtitle.reset (new TextContent (this));
}
-TextSubtitleContent::TextSubtitleContent (shared_ptr<const Film> film, cxml::ConstNodePtr node, int version)
+TextTextContent::TextTextContent (shared_ptr<const Film> film, cxml::ConstNodePtr node, int version)
: Content (film, node)
, _length (node->number_child<ContentTime::Type> ("Length"))
{
- subtitle = SubtitleContent::from_xml (this, node, version);
+ subtitle = TextContent::from_xml (this, node, version);
}
void
-TextSubtitleContent::examine (boost::shared_ptr<Job> job)
+TextTextContent::examine (boost::shared_ptr<Job> job)
{
Content::examine (job);
TextSubtitle s (shared_from_this ());
@@ -63,19 +63,19 @@ TextSubtitleContent::examine (boost::shared_ptr<Job> job)
}
string
-TextSubtitleContent::summary () const
+TextTextContent::summary () const
{
return path_summary() + " " + _("[subtitles]");
}
string
-TextSubtitleContent::technical_summary () const
+TextTextContent::technical_summary () const
{
return Content::technical_summary() + " - " + _("Text subtitles");
}
void
-TextSubtitleContent::as_xml (xmlpp::Node* node, bool with_paths) const
+TextTextContent::as_xml (xmlpp::Node* node, bool with_paths) const
{
node->add_child("Type")->add_child_text ("TextSubtitle");
Content::as_xml (node, with_paths);
@@ -88,7 +88,7 @@ TextSubtitleContent::as_xml (xmlpp::Node* node, bool with_paths) const
}
DCPTime
-TextSubtitleContent::full_length () const
+TextTextContent::full_length () const
{
FrameRateChange const frc (active_video_frame_rate(), film()->video_frame_rate ());
return DCPTime (_length, frc);
diff --git a/src/lib/text_subtitle_content.h b/src/lib/text_text_content.h
index fd0bad12a..ccc86fbbf 100644
--- a/src/lib/text_subtitle_content.h
+++ b/src/lib/text_text_content.h
@@ -22,17 +22,17 @@
class Job;
-/** @class TextSubtitleContent
+/** @class TextTextContent
* @brief SubRip or SSA subtitles.
*/
-class TextSubtitleContent : public Content
+class TextTextContent : public Content
{
public:
- TextSubtitleContent (boost::shared_ptr<const Film>, boost::filesystem::path);
- TextSubtitleContent (boost::shared_ptr<const Film>, cxml::ConstNodePtr, int);
+ TextTextContent (boost::shared_ptr<const Film>, boost::filesystem::path);
+ TextTextContent (boost::shared_ptr<const Film>, cxml::ConstNodePtr, int);
- boost::shared_ptr<TextSubtitleContent> shared_from_this () {
- return boost::dynamic_pointer_cast<TextSubtitleContent> (Content::shared_from_this ());
+ boost::shared_ptr<TextTextContent> shared_from_this () {
+ return boost::dynamic_pointer_cast<TextTextContent> (Content::shared_from_this ());
}
void examine (boost::shared_ptr<Job>);
diff --git a/src/lib/text_subtitle_decoder.cc b/src/lib/text_text_decoder.cc
index 6188d524f..2ae5cd38e 100644
--- a/src/lib/text_subtitle_decoder.cc
+++ b/src/lib/text_text_decoder.cc
@@ -18,9 +18,9 @@
*/
-#include "text_subtitle_decoder.h"
-#include "text_subtitle_content.h"
-#include "subtitle_content.h"
+#include "text_text_decoder.h"
+#include "text_text_content.h"
+#include "text_content.h"
#include <dcp/subtitle_string.h>
#include <boost/foreach.hpp>
#include <iostream>
@@ -34,7 +34,7 @@ using boost::shared_ptr;
using boost::optional;
using boost::dynamic_pointer_cast;
-TextSubtitleDecoder::TextSubtitleDecoder (shared_ptr<const TextSubtitleContent> content, shared_ptr<Log> log)
+TextTextDecoder::TextTextDecoder (shared_ptr<const TextTextContent> content, shared_ptr<Log> log)
: TextSubtitle (content)
, _next (0)
{
@@ -42,11 +42,11 @@ TextSubtitleDecoder::TextSubtitleDecoder (shared_ptr<const TextSubtitleContent>
if (!_subtitles.empty()) {
first = content_time_period(_subtitles[0]).from;
}
- subtitle.reset (new SubtitleDecoder (this, content->subtitle, log, first));
+ subtitle.reset (new TextDecoder (this, content->subtitle, log, first));
}
void
-TextSubtitleDecoder::seek (ContentTime time, bool accurate)
+TextTextDecoder::seek (ContentTime time, bool accurate)
{
/* It's worth back-tracking a little here as decoding is cheap and it's nice if we don't miss
too many subtitles when seeking.
@@ -65,7 +65,7 @@ TextSubtitleDecoder::seek (ContentTime time, bool accurate)
}
bool
-TextSubtitleDecoder::pass ()
+TextTextDecoder::pass ()
{
if (_next >= _subtitles.size ()) {
return true;
@@ -79,7 +79,7 @@ TextSubtitleDecoder::pass ()
}
ContentTimePeriod
-TextSubtitleDecoder::content_time_period (sub::Subtitle s) const
+TextTextDecoder::content_time_period (sub::Subtitle s) const
{
return ContentTimePeriod (
ContentTime::from_seconds (s.from.all_as_seconds()),
diff --git a/src/lib/text_subtitle_decoder.h b/src/lib/text_text_decoder.h
index 72bb89b77..daaf2fcfe 100644
--- a/src/lib/text_subtitle_decoder.h
+++ b/src/lib/text_text_decoder.h
@@ -21,15 +21,15 @@
#ifndef DCPOMATIC_TEXT_SUBTITLE_DECODER_H
#define DCPOMATIC_TEXT_SUBTITLE_DECODER_H
-#include "subtitle_decoder.h"
+#include "text_decoder.h"
#include "text_subtitle.h"
-class TextSubtitleContent;
+class TextTextContent;
-class TextSubtitleDecoder : public Decoder, public TextSubtitle
+class TextTextDecoder : public Decoder, public TextSubtitle
{
public:
- TextSubtitleDecoder (boost::shared_ptr<const TextSubtitleContent>, boost::shared_ptr<Log> log);
+ TextTextDecoder (boost::shared_ptr<const TextTextContent>, boost::shared_ptr<Log> log);
void seek (ContentTime time, bool accurate);
bool pass ();
diff --git a/src/lib/types.h b/src/lib/types.h
index dfce6aec5..af2171718 100644
--- a/src/lib/types.h
+++ b/src/lib/types.h
@@ -31,7 +31,7 @@
class Content;
class VideoContent;
class AudioContent;
-class SubtitleContent;
+class TextContent;
class FFmpegContent;
namespace cxml {
diff --git a/src/lib/wscript b/src/lib/wscript
index b6784dbaa..4a7132e48 100644
--- a/src/lib/wscript
+++ b/src/lib/wscript
@@ -55,8 +55,8 @@ sources = """
dcp_encoder.cc
dcp_examiner.cc
dcp_subtitle.cc
- dcp_subtitle_content.cc
- dcp_subtitle_decoder.cc
+ dcp_text_content.cc
+ dcp_text_decoder.cc
dcp_video.cc
dcpomatic_socket.cc
dcpomatic_time.cc
@@ -132,11 +132,11 @@ sources = """
server.cc
shuffler.cc
string_log_entry.cc
- subtitle_content.cc
- subtitle_decoder.cc
+ text_content.cc
+ text_decoder.cc
text_subtitle.cc
- text_subtitle_content.cc
- text_subtitle_decoder.cc
+ text_text_content.cc
+ text_text_decoder.cc
timer.cc
transcode_job.cc
types.cc