From d7ac100c0eb1b5efdcfbec59be870fd869252840 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 11 Jun 2018 23:50:59 +0100 Subject: [PATCH] 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 --- src/lib/active_subtitles.cc | 2 +- src/lib/content.cc | 2 +- src/lib/content.h | 2 +- src/lib/content_factory.cc | 14 +- src/lib/dcp_content.cc | 6 +- src/lib/dcp_decoder.cc | 4 +- src/lib/dcp_encoder.cc | 2 +- ...ubtitle_content.cc => dcp_text_content.cc} | 22 +-- ..._subtitle_content.h => dcp_text_content.h} | 6 +- ...ubtitle_decoder.cc => dcp_text_decoder.cc} | 16 +- ..._subtitle_decoder.h => dcp_text_decoder.h} | 8 +- src/lib/decoder.cc | 2 +- src/lib/decoder.h | 4 +- src/lib/decoder_factory.cc | 16 +- src/lib/ffmpeg_content.cc | 8 +- src/lib/ffmpeg_decoder.cc | 6 +- src/lib/film.cc | 2 +- src/lib/hints.cc | 2 +- src/lib/image_subtitle.h | 2 +- src/lib/player.cc | 30 ++-- src/lib/playlist.cc | 2 +- .../{subtitle_content.cc => text_content.cc} | 146 +++++++++--------- .../{subtitle_content.h => text_content.h} | 16 +- .../{subtitle_decoder.cc => text_decoder.cc} | 22 +-- .../{subtitle_decoder.h => text_decoder.h} | 10 +- src/lib/text_file.cc | 96 ++++++++++++ src/lib/text_file.h | 46 ++++++ src/lib/text_file_decoder.cc | 84 ++++++++++ src/lib/text_file_decoder.h | 43 ++++++ src/lib/text_subtitle.cc | 4 +- src/lib/text_subtitle.h | 6 +- ...btitle_content.cc => text_text_content.cc} | 22 +-- ...subtitle_content.h => text_text_content.h} | 12 +- ...btitle_decoder.cc => text_text_decoder.cc} | 16 +- ...subtitle_decoder.h => text_text_decoder.h} | 8 +- src/lib/types.h | 2 +- src/lib/wscript | 12 +- src/tools/dcpomatic.cc | 2 +- src/tools/dcpomatic_player.cc | 2 +- src/wx/content_panel.cc | 8 +- src/wx/dcp_panel.cc | 6 +- src/wx/fonts_dialog.cc | 2 +- src/wx/subtitle_appearance_dialog.cc | 4 +- src/wx/subtitle_panel.cc | 48 +++--- src/wx/subtitle_view.cc | 4 +- src/wx/timeline.cc | 8 +- ..._view.cc => timeline_text_content_view.cc} | 12 +- ...nt_view.h => timeline_text_content_view.h} | 10 +- src/wx/timing_panel.cc | 6 +- src/wx/wscript | 2 +- test/burnt_subtitle_test.cc | 12 +- test/dcp_subtitle_test.cc | 18 +-- test/ffmpeg_encoder_test.cc | 12 +- test/import_dcp_test.cc | 2 +- test/player_test.cc | 6 +- test/reels_test.cc | 6 +- test/remake_id_test.cc | 2 +- test/remake_with_subtitle_test.cc | 2 +- test/srt_subtitle_test.cc | 18 +-- test/ssa_subtitle_test.cc | 6 +- test/subtitle_reel_number_test.cc | 6 +- test/subtitle_trim_test.cc | 4 +- test/vf_kdm_test.cc | 2 +- 63 files changed, 591 insertions(+), 322 deletions(-) rename src/lib/{dcp_subtitle_content.cc => dcp_text_content.cc} (80%) rename src/lib/{dcp_subtitle_content.h => dcp_text_content.h} (82%) rename src/lib/{dcp_subtitle_decoder.cc => dcp_text_decoder.cc} (82%) rename src/lib/{dcp_subtitle_decoder.h => dcp_text_decoder.h} (83%) rename src/lib/{subtitle_content.cc => text_content.cc} (74%) rename src/lib/{subtitle_content.h => text_content.h} (91%) rename src/lib/{subtitle_decoder.cc => text_decoder.cc} (91%) rename src/lib/{subtitle_decoder.h => text_decoder.h} (89%) create mode 100644 src/lib/text_file.cc create mode 100644 src/lib/text_file.h create mode 100644 src/lib/text_file_decoder.cc create mode 100644 src/lib/text_file_decoder.h rename src/lib/{text_subtitle_content.cc => text_text_content.cc} (75%) rename src/lib/{text_subtitle_content.h => text_text_content.h} (73%) rename src/lib/{text_subtitle_decoder.cc => text_text_decoder.cc} (81%) rename src/lib/{text_subtitle_decoder.h => text_text_decoder.h} (82%) rename src/wx/{timeline_subtitle_content_view.cc => timeline_text_content_view.cc} (78%) rename src/wx/{timeline_subtitle_content_view.h => timeline_text_content_view.h} (78%) 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 #include 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 video; boost::shared_ptr audio; - boost::shared_ptr subtitle; + boost::shared_ptr 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 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 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 #include #include @@ -81,7 +81,7 @@ DCPContent::DCPContent (shared_ptr 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) 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 @@ -64,7 +64,7 @@ DCPDecoder::DCPDecoder (shared_ptr c, shared_ptr 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 > 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 #include diff --git a/src/lib/dcp_subtitle_content.cc b/src/lib/dcp_text_content.cc similarity index 80% rename from src/lib/dcp_subtitle_content.cc rename to 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 #include #include @@ -37,21 +37,21 @@ using boost::shared_ptr; using boost::dynamic_pointer_cast; using dcp::raw_convert; -DCPSubtitleContent::DCPSubtitleContent (shared_ptr film, boost::filesystem::path path) +DCPTextContent::DCPTextContent (shared_ptr film, boost::filesystem::path path) : Content (film, path) { - subtitle.reset (new SubtitleContent (this)); + subtitle.reset (new TextContent (this)); } -DCPSubtitleContent::DCPSubtitleContent (shared_ptr film, cxml::ConstNodePtr node, int version) +DCPTextContent::DCPTextContent (shared_ptr film, cxml::ConstNodePtr node, int version) : Content (film, node) , _length (node->number_child ("Length")) { - subtitle = SubtitleContent::from_xml (this, node, version); + subtitle = TextContent::from_xml (this, node, version); } void -DCPSubtitleContent::examine (shared_ptr job) +DCPTextContent::examine (shared_ptr job) { Content::examine (job); @@ -82,26 +82,26 @@ DCPSubtitleContent::examine (shared_ptr 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 similarity index 82% rename from src/lib/dcp_subtitle_content.h rename to 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, boost::filesystem::path); - DCPSubtitleContent (boost::shared_ptr, cxml::ConstNodePtr, int); + DCPTextContent (boost::shared_ptr, boost::filesystem::path); + DCPTextContent (boost::shared_ptr, cxml::ConstNodePtr, int); void examine (boost::shared_ptr); std::string summary () const; diff --git a/src/lib/dcp_subtitle_decoder.cc b/src/lib/dcp_text_decoder.cc similarity index 82% rename from src/lib/dcp_subtitle_decoder.cc rename to 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 #include @@ -29,7 +29,7 @@ using boost::shared_ptr; using boost::dynamic_pointer_cast; using boost::bind; -DCPSubtitleDecoder::DCPSubtitleDecoder (shared_ptr content, shared_ptr log) +DCPTextDecoder::DCPTextDecoder (shared_ptr content, shared_ptr log) { shared_ptr c (load (content->path (0))); _subtitles = c->subtitles (); @@ -39,11 +39,11 @@ DCPSubtitleDecoder::DCPSubtitleDecoder (shared_ptr 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 s) const +DCPTextDecoder::content_time_period (shared_ptr 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 similarity index 83% rename from src/lib/dcp_subtitle_decoder.h rename to 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, boost::shared_ptr log); + DCPTextDecoder (boost::shared_ptr, boost::shared_ptr 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 #include 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 video; boost::shared_ptr audio; - boost::shared_ptr subtitle; + boost::shared_ptr 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 @@ -54,14 +54,14 @@ decoder_factory (shared_ptr content, shared_ptr log, bool fa return shared_ptr (new ImageDecoder (ic, log)); } - shared_ptr rc = dynamic_pointer_cast (content); + shared_ptr rc = dynamic_pointer_cast (content); if (rc) { - return shared_ptr (new TextSubtitleDecoder (rc, log)); + return shared_ptr (new TextTextDecoder (rc, log)); } - shared_ptr dsc = dynamic_pointer_cast (content); + shared_ptr dsc = dynamic_pointer_cast (content); if (dsc) { - return shared_ptr (new DCPSubtitleDecoder (dsc, log)); + return shared_ptr (new DCPTextDecoder (dsc, log)); } shared_ptr vmc = dynamic_pointer_cast (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 #include extern "C" { @@ -85,7 +85,7 @@ FFmpegContent::FFmpegContent (shared_ptr 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 c = node->node_children ("SubtitleStream"); for (list::const_iterator i = c.begin(); i != c.end(); ++i) { @@ -163,7 +163,7 @@ FFmpegContent::FFmpegContent (shared_ptr film, vector ref = dynamic_pointer_cast (c[0]); @@ -303,7 +303,7 @@ FFmpegContent::examine (shared_ptr 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 #include @@ -99,7 +99,7 @@ FFmpegDecoder::FFmpegDecoder (shared_ptr c, shared_ptr 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 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 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 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 similarity index 74% rename from src/lib/subtitle_content.cc rename to 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::from_xml (Content* parent, cxml::ConstNodePtr node, int version) +shared_ptr +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 (); + return shared_ptr (); } /* Otherwise we can drop through to the newer logic */ } if (!node->optional_number_child("SubtitleXOffset") && !node->optional_number_child("SubtitleOffset")) { - return shared_ptr (); + return shared_ptr (); } - return shared_ptr (new SubtitleContent (parent, node, version)); + return shared_ptr (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 > c) +TextContent::TextContent (Content* parent, vector > c) : ContentPart (parent) { - shared_ptr ref = c[0]->subtitle; + shared_ptr ref = c[0]->subtitle; DCPOMATIC_ASSERT (ref); list > ref_fonts = ref->fonts (); @@ -261,7 +261,7 @@ SubtitleContent::SubtitleContent (Content* parent, vector > /** _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 (x_scale()) + "_" + raw_convert (y_scale()) @@ -341,14 +341,14 @@ SubtitleContent::identifier () const } void -SubtitleContent::add_font (shared_ptr font) +TextContent::add_font (shared_ptr 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 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(), SubtitleContentProperty::COLOUR); + maybe_set (_colour, optional(), 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(), SubtitleContentProperty::EFFECT); + maybe_set (_effect, optional(), 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(), SubtitleContentProperty::EFFECT_COLOUR); + maybe_set (_effect_colour, optional(), 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(), SubtitleContentProperty::FADE_IN); + maybe_set (_fade_in, optional(), 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(), SubtitleContentProperty::FADE_OUT); + maybe_set (_fade_out, optional(), 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 c) +TextContent::take_settings_from (shared_ptr c) { set_use (c->_use); set_burn (c->_burn); @@ -490,7 +490,7 @@ SubtitleContent::take_settings_from (shared_ptr 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 similarity index 91% rename from src/lib/subtitle_content.h rename to 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 >); + explicit TextContent (Content* parent); + TextContent (Content* parent, std::vector >); void as_xml (xmlpp::Node *) const; std::string identifier () const; - void take_settings_from (boost::shared_ptr c); + void take_settings_from (boost::shared_ptr c); void add_font (boost::shared_ptr font); @@ -161,7 +161,7 @@ public: return _outline_width; } - static boost::shared_ptr from_xml (Content* parent, cxml::ConstNodePtr, int version); + static boost::shared_ptr 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 similarity index 91% rename from src/lib/subtitle_decoder.cc rename to 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 c, + shared_ptr c, shared_ptr log, ContentTime first ) @@ -58,14 +58,14 @@ SubtitleDecoder::SubtitleDecoder ( * of the video frame) */ void -SubtitleDecoder::emit_image_start (ContentTime from, shared_ptr image, dcpomatic::Rect rect) +TextDecoder::emit_image_start (ContentTime from, shared_ptr image, dcpomatic::Rect rect) { ImageStart (ContentImageSubtitle (from, image, rect)); _position = from; } void -SubtitleDecoder::emit_text_start (ContentTime from, list s) +TextDecoder::emit_text_start (ContentTime from, list 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 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 s) +TextDecoder::emit_text (ContentTimePeriod period, list 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 similarity index 89% rename from src/lib/subtitle_decoder.h rename to 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, + boost::shared_ptr, boost::shared_ptr log, ContentTime first ); @@ -58,7 +58,7 @@ public: void seek (); - boost::shared_ptr content () const { + boost::shared_ptr content () const { return _content; } @@ -67,7 +67,7 @@ public: boost::signals2::signal Stop; private: - boost::shared_ptr _content; + boost::shared_ptr _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 + + 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 . + +*/ + +#include "text_file.h" +#include "cross.h" +#include "exceptions.h" +#include "text_file_content.h" +#include +#include +#include +#include +#include +#include + +#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 content) +{ + Data in (content->path (0)); + + UErrorCode status = U_ZERO_ERROR; + UCharsetDetector* detector = ucsdet_open (&status); + ucsdet_setText (detector, reinterpret_cast (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 utf16 (new uint16_t[in.size() * 2]); + int const utf16_len = ucnv_toUChars ( + to_utf16, reinterpret_cast(utf16.get()), in.size() * 2, + reinterpret_cast (in.data().get()), in.size(), + &status + ); + + UConverter* to_utf8 = ucnv_open ("UTF-8", &status); + /* Another guess */ + scoped_array utf8 (new char[utf16_len * 2]); + ucnv_fromUChars (to_utf8, utf8.get(), utf16_len * 2, reinterpret_cast(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 > (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 + + 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 . + +*/ + +#ifndef DCPOMATIC_TEXT_SUBTITLE_H +#define DCPOMATIC_TEXT_SUBTITLE_H + +#include "dcpomatic_time.h" +#include +#include +#include + +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); + + ContentTime length () const; + +protected: + std::vector _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 + + 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 . + +*/ + +#include "text_file_decoder.h" +#include "text_file_content.h" +#include "text_content.h" +#include +#include +#include + +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 content, shared_ptr 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 + + 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 . + +*/ + +#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, boost::shared_ptr 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 #include #include @@ -39,7 +39,7 @@ using boost::scoped_array; using boost::optional; using dcp::Data; -TextSubtitle::TextSubtitle (shared_ptr content) +TextSubtitle::TextSubtitle (shared_ptr 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 #include -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); + explicit TextSubtitle (boost::shared_ptr); boost::optional first () const; ContentTime length () const; diff --git a/src/lib/text_subtitle_content.cc b/src/lib/text_text_content.cc similarity index 75% rename from src/lib/text_subtitle_content.cc rename to 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 #include #include @@ -35,21 +35,21 @@ using std::cout; using boost::shared_ptr; using dcp::raw_convert; -TextSubtitleContent::TextSubtitleContent (shared_ptr film, boost::filesystem::path path) +TextTextContent::TextTextContent (shared_ptr film, boost::filesystem::path path) : Content (film, path) { - subtitle.reset (new SubtitleContent (this)); + subtitle.reset (new TextContent (this)); } -TextSubtitleContent::TextSubtitleContent (shared_ptr film, cxml::ConstNodePtr node, int version) +TextTextContent::TextTextContent (shared_ptr film, cxml::ConstNodePtr node, int version) : Content (film, node) , _length (node->number_child ("Length")) { - subtitle = SubtitleContent::from_xml (this, node, version); + subtitle = TextContent::from_xml (this, node, version); } void -TextSubtitleContent::examine (boost::shared_ptr job) +TextTextContent::examine (boost::shared_ptr job) { Content::examine (job); TextSubtitle s (shared_from_this ()); @@ -63,19 +63,19 @@ TextSubtitleContent::examine (boost::shared_ptr 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 similarity index 73% rename from src/lib/text_subtitle_content.h rename to 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, boost::filesystem::path); - TextSubtitleContent (boost::shared_ptr, cxml::ConstNodePtr, int); + TextTextContent (boost::shared_ptr, boost::filesystem::path); + TextTextContent (boost::shared_ptr, cxml::ConstNodePtr, int); - boost::shared_ptr shared_from_this () { - return boost::dynamic_pointer_cast (Content::shared_from_this ()); + boost::shared_ptr shared_from_this () { + return boost::dynamic_pointer_cast (Content::shared_from_this ()); } void examine (boost::shared_ptr); diff --git a/src/lib/text_subtitle_decoder.cc b/src/lib/text_text_decoder.cc similarity index 81% rename from src/lib/text_subtitle_decoder.cc rename to 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 #include #include @@ -34,7 +34,7 @@ using boost::shared_ptr; using boost::optional; using boost::dynamic_pointer_cast; -TextSubtitleDecoder::TextSubtitleDecoder (shared_ptr content, shared_ptr log) +TextTextDecoder::TextTextDecoder (shared_ptr content, shared_ptr log) : TextSubtitle (content) , _next (0) { @@ -42,11 +42,11 @@ TextSubtitleDecoder::TextSubtitleDecoder (shared_ptr 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 similarity index 82% rename from src/lib/text_subtitle_decoder.h rename to 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, boost::shared_ptr log); + TextTextDecoder (boost::shared_ptr, boost::shared_ptr 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 diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index 64c11281c..934e57505 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -71,7 +71,7 @@ #include "lib/transcode_job.h" #include "lib/dkdm_wrapper.h" #include "lib/audio_content.h" -#include "lib/subtitle_content.h" +#include "lib/text_content.h" #include #include #include diff --git a/src/tools/dcpomatic_player.cc b/src/tools/dcpomatic_player.cc index 29195777e..3f56f4752 100644 --- a/src/tools/dcpomatic_player.cc +++ b/src/tools/dcpomatic_player.cc @@ -27,7 +27,7 @@ #include "lib/job_manager.h" #include "lib/job.h" #include "lib/video_content.h" -#include "lib/subtitle_content.h" +#include "lib/text_content.h" #include "lib/ratio.h" #include "lib/verify_dcp_job.h" #include "lib/dcp_examiner.h" diff --git a/src/wx/content_panel.cc b/src/wx/content_panel.cc index 4adeb90a4..2c0f35f6c 100644 --- a/src/wx/content_panel.cc +++ b/src/wx/content_panel.cc @@ -28,7 +28,7 @@ #include "image_sequence_dialog.h" #include "film_viewer.h" #include "lib/audio_content.h" -#include "lib/subtitle_content.h" +#include "lib/text_content.h" #include "lib/video_content.h" #include "lib/ffmpeg_content.h" #include "lib/content_factory.h" @@ -39,7 +39,7 @@ #include "lib/config.h" #include "lib/log.h" #include "lib/compose.hpp" -#include "lib/text_subtitle_content.h" +#include "lib/text_text_content.h" #include "lib/text_subtitle.h" #include #include @@ -258,11 +258,11 @@ ContentPanel::selection_changed () BOOST_FOREACH (shared_ptr i, selected ()) { DCPTime p; p = i->position(); - if (dynamic_pointer_cast(i) && i->paths_valid()) { + if (dynamic_pointer_cast(i) && i->paths_valid()) { /* Rather special case; if we select a text subtitle file jump to its first subtitle. */ - TextSubtitle ts (dynamic_pointer_cast(i)); + TextSubtitle ts (dynamic_pointer_cast(i)); if (ts.first()) { p += DCPTime(ts.first().get(), _film->active_frame_rate_change(i->position())); } diff --git a/src/wx/dcp_panel.cc b/src/wx/dcp_panel.cc index f2783af6b..5a380ec4e 100644 --- a/src/wx/dcp_panel.cc +++ b/src/wx/dcp_panel.cc @@ -32,7 +32,7 @@ #include "lib/ffmpeg_content.h" #include "lib/audio_processor.h" #include "lib/video_content.h" -#include "lib/subtitle_content.h" +#include "lib/text_content.h" #include "lib/dcp_content.h" #include "lib/audio_content.h" #include @@ -433,8 +433,8 @@ void DCPPanel::film_content_changed (int property) { if (property == AudioContentProperty::STREAMS || - property == SubtitleContentProperty::USE || - property == SubtitleContentProperty::BURN || + property == TextContentProperty::USE || + property == TextContentProperty::BURN || property == VideoContentProperty::SCALE || property == DCPContentProperty::REFERENCE_VIDEO || property == DCPContentProperty::REFERENCE_AUDIO || diff --git a/src/wx/fonts_dialog.cc b/src/wx/fonts_dialog.cc index c85d18e34..c295ec327 100644 --- a/src/wx/fonts_dialog.cc +++ b/src/wx/fonts_dialog.cc @@ -24,7 +24,7 @@ #include "font_files_dialog.h" #include "lib/font.h" #include "lib/content.h" -#include "lib/subtitle_content.h" +#include "lib/text_content.h" #include #include #include diff --git a/src/wx/subtitle_appearance_dialog.cc b/src/wx/subtitle_appearance_dialog.cc index 8ae479746..f78ed9ab5 100644 --- a/src/wx/subtitle_appearance_dialog.cc +++ b/src/wx/subtitle_appearance_dialog.cc @@ -20,8 +20,8 @@ #include "subtitle_appearance_dialog.h" #include "rgba_colour_picker.h" -#include "lib/text_subtitle_content.h" -#include "lib/subtitle_content.h" +#include "lib/text_text_content.h" +#include "lib/text_content.h" #include "lib/ffmpeg_subtitle_stream.h" #include "lib/ffmpeg_content.h" #include diff --git a/src/wx/subtitle_panel.cc b/src/wx/subtitle_panel.cc index 1a42c1f57..da7891ca8 100644 --- a/src/wx/subtitle_panel.cc +++ b/src/wx/subtitle_panel.cc @@ -26,13 +26,13 @@ #include "fonts_dialog.h" #include "subtitle_appearance_dialog.h" #include "lib/ffmpeg_content.h" -#include "lib/text_subtitle_content.h" +#include "lib/text_text_content.h" #include "lib/ffmpeg_subtitle_stream.h" -#include "lib/dcp_subtitle_content.h" -#include "lib/text_subtitle_decoder.h" -#include "lib/dcp_subtitle_decoder.h" +#include "lib/dcp_text_content.h" +#include "lib/text_text_decoder.h" +#include "lib/dcp_text_decoder.h" #include "lib/dcp_content.h" -#include "lib/subtitle_content.h" +#include "lib/text_content.h" #include "lib/decoder_factory.h" #include #include @@ -209,22 +209,22 @@ SubtitlePanel::film_content_changed (int property) } } setup_sensitivity (); - } else if (property == SubtitleContentProperty::USE) { + } else if (property == TextContentProperty::USE) { checked_set (_use, scs ? scs->subtitle->use() : false); setup_sensitivity (); - } else if (property == SubtitleContentProperty::BURN) { + } else if (property == TextContentProperty::BURN) { checked_set (_burn, scs ? scs->subtitle->burn() : false); - } else if (property == SubtitleContentProperty::X_OFFSET) { + } else if (property == TextContentProperty::X_OFFSET) { checked_set (_x_offset, scs ? lrint (scs->subtitle->x_offset() * 100) : 0); - } else if (property == SubtitleContentProperty::Y_OFFSET) { + } else if (property == TextContentProperty::Y_OFFSET) { checked_set (_y_offset, scs ? lrint (scs->subtitle->y_offset() * 100) : 0); - } else if (property == SubtitleContentProperty::X_SCALE) { + } else if (property == TextContentProperty::X_SCALE) { checked_set (_x_scale, scs ? lrint (scs->subtitle->x_scale() * 100) : 100); - } else if (property == SubtitleContentProperty::Y_SCALE) { + } else if (property == TextContentProperty::Y_SCALE) { checked_set (_y_scale, scs ? lrint (scs->subtitle->y_scale() * 100) : 100); - } else if (property == SubtitleContentProperty::LINE_SPACING) { + } else if (property == TextContentProperty::LINE_SPACING) { checked_set (_line_spacing, scs ? lrint (scs->subtitle->line_spacing() * 100) : 100); - } else if (property == SubtitleContentProperty::LANGUAGE) { + } else if (property == TextContentProperty::LANGUAGE) { checked_set (_language, scs ? scs->subtitle->language() : ""); } else if (property == DCPContentProperty::REFERENCE_SUBTITLE) { if (scs) { @@ -265,9 +265,9 @@ SubtitlePanel::setup_sensitivity () BOOST_FOREACH (shared_ptr i, sel) { /* These are the content types that could include subtitles */ shared_ptr fc = boost::dynamic_pointer_cast (i); - shared_ptr sc = boost::dynamic_pointer_cast (i); + shared_ptr sc = boost::dynamic_pointer_cast (i); shared_ptr dc = boost::dynamic_pointer_cast (i); - shared_ptr dsc = boost::dynamic_pointer_cast (i); + shared_ptr dsc = boost::dynamic_pointer_cast (i); if (fc) { if (fc->subtitle) { ++ffmpeg_subs; @@ -383,15 +383,15 @@ void SubtitlePanel::content_selection_changed () { film_content_changed (FFmpegContentProperty::SUBTITLE_STREAMS); - film_content_changed (SubtitleContentProperty::USE); - film_content_changed (SubtitleContentProperty::BURN); - film_content_changed (SubtitleContentProperty::X_OFFSET); - film_content_changed (SubtitleContentProperty::Y_OFFSET); - film_content_changed (SubtitleContentProperty::X_SCALE); - film_content_changed (SubtitleContentProperty::Y_SCALE); - film_content_changed (SubtitleContentProperty::LINE_SPACING); - film_content_changed (SubtitleContentProperty::LANGUAGE); - film_content_changed (SubtitleContentProperty::FONTS); + film_content_changed (TextContentProperty::USE); + film_content_changed (TextContentProperty::BURN); + film_content_changed (TextContentProperty::X_OFFSET); + film_content_changed (TextContentProperty::Y_OFFSET); + film_content_changed (TextContentProperty::X_SCALE); + film_content_changed (TextContentProperty::Y_SCALE); + film_content_changed (TextContentProperty::LINE_SPACING); + film_content_changed (TextContentProperty::LANGUAGE); + film_content_changed (TextContentProperty::FONTS); film_content_changed (DCPContentProperty::REFERENCE_SUBTITLE); } diff --git a/src/wx/subtitle_view.cc b/src/wx/subtitle_view.cc index cedf273d4..7efe10d0c 100644 --- a/src/wx/subtitle_view.cc +++ b/src/wx/subtitle_view.cc @@ -18,13 +18,13 @@ */ -#include "lib/text_subtitle_decoder.h" +#include "lib/text_text_decoder.h" #include "lib/content_subtitle.h" #include "lib/video_decoder.h" #include "lib/audio_decoder.h" #include "lib/film.h" -#include "lib/text_subtitle_content.h" #include "lib/config.h" +#include "lib/text_text_content.h" #include "subtitle_view.h" #include "film_viewer.h" #include "wx_util.h" diff --git a/src/wx/timeline.cc b/src/wx/timeline.cc index e96b474cf..d0a898b18 100644 --- a/src/wx/timeline.cc +++ b/src/wx/timeline.cc @@ -25,7 +25,7 @@ #include "timeline_labels_view.h" #include "timeline_video_content_view.h" #include "timeline_audio_content_view.h" -#include "timeline_subtitle_content_view.h" +#include "timeline_text_content_view.h" #include "timeline_atmos_content_view.h" #include "content_panel.h" #include "wx_util.h" @@ -34,7 +34,7 @@ #include "lib/image_content.h" #include "lib/timer.h" #include "lib/audio_content.h" -#include "lib/subtitle_content.h" +#include "lib/text_content.h" #include "lib/video_content.h" #include "lib/atmos_mxf_content.h" #include @@ -229,7 +229,7 @@ Timeline::recreate_views () } if (i->subtitle) { - _views.push_back (shared_ptr (new TimelineSubtitleContentView (*this, i))); + _views.push_back (shared_ptr (new TimelineTextContentView (*this, i))); } if (dynamic_pointer_cast (i)) { @@ -375,7 +375,7 @@ Timeline::assign_tracks () /* Subtitle */ - int const subtitle_tracks = place (_views, _tracks); + int const subtitle_tracks = place (_views, _tracks); /* Atmos */ diff --git a/src/wx/timeline_subtitle_content_view.cc b/src/wx/timeline_text_content_view.cc similarity index 78% rename from src/wx/timeline_subtitle_content_view.cc rename to src/wx/timeline_text_content_view.cc index f5c78525e..b4820bfea 100644 --- a/src/wx/timeline_subtitle_content_view.cc +++ b/src/wx/timeline_text_content_view.cc @@ -18,20 +18,20 @@ */ -#include "timeline_subtitle_content_view.h" -#include "lib/subtitle_content.h" +#include "timeline_text_content_view.h" +#include "lib/text_content.h" #include "lib/content.h" using boost::shared_ptr; -TimelineSubtitleContentView::TimelineSubtitleContentView (Timeline& tl, shared_ptr c) +TimelineTextContentView::TimelineTextContentView (Timeline& tl, shared_ptr c) : TimelineContentView (tl, c) { } wxColour -TimelineSubtitleContentView::background_colour () const +TimelineTextContentView::background_colour () const { if (!active ()) { return wxColour (210, 210, 210, 128); @@ -41,7 +41,7 @@ TimelineSubtitleContentView::background_colour () const } wxColour -TimelineSubtitleContentView::foreground_colour () const +TimelineTextContentView::foreground_colour () const { if (!active ()) { return wxColour (180, 180, 180, 128); @@ -51,7 +51,7 @@ TimelineSubtitleContentView::foreground_colour () const } bool -TimelineSubtitleContentView::active () const +TimelineTextContentView::active () const { shared_ptr c = _content.lock (); DCPOMATIC_ASSERT (c); diff --git a/src/wx/timeline_subtitle_content_view.h b/src/wx/timeline_text_content_view.h similarity index 78% rename from src/wx/timeline_subtitle_content_view.h rename to src/wx/timeline_text_content_view.h index a7a15f923..540a90607 100644 --- a/src/wx/timeline_subtitle_content_view.h +++ b/src/wx/timeline_text_content_view.h @@ -20,15 +20,15 @@ #include "timeline_content_view.h" -class SubtitleContent; +class TextContent; -/** @class TimelineSubtitleContentView - * @brief Timeline view for SubtitleContent. +/** @class TimelineTextContentView + * @brief Timeline view for TextContent. */ -class TimelineSubtitleContentView : public TimelineContentView +class TimelineTextContentView : public TimelineContentView { public: - TimelineSubtitleContentView (Timeline& tl, boost::shared_ptr c); + TimelineTextContentView (Timeline& tl, boost::shared_ptr c); private: bool active () const; diff --git a/src/wx/timing_panel.cc b/src/wx/timing_panel.cc index 4006c5d3e..315ead524 100644 --- a/src/wx/timing_panel.cc +++ b/src/wx/timing_panel.cc @@ -26,10 +26,10 @@ #include "move_to_dialog.h" #include "lib/content.h" #include "lib/image_content.h" -#include "lib/subtitle_content.h" -#include "lib/dcp_subtitle_content.h" +#include "lib/text_content.h" +#include "lib/dcp_text_content.h" #include "lib/audio_content.h" -#include "lib/text_subtitle_content.h" +#include "lib/text_text_content.h" #include "lib/video_content.h" #include #include diff --git a/src/wx/wscript b/src/wx/wscript index b5210bace..d5adafebe 100644 --- a/src/wx/wscript +++ b/src/wx/wscript @@ -109,7 +109,7 @@ sources = """ timeline_dialog.cc timeline_audio_content_view.cc timeline_labels_view.cc - timeline_subtitle_content_view.cc + timeline_text_content_view.cc timeline_reels_view.cc timeline_time_axis_view.cc timeline_video_content_view.cc diff --git a/test/burnt_subtitle_test.cc b/test/burnt_subtitle_test.cc index 184be5a82..f0e60284b 100644 --- a/test/burnt_subtitle_test.cc +++ b/test/burnt_subtitle_test.cc @@ -23,12 +23,12 @@ * @ingroup specific */ -#include "lib/text_subtitle_content.h" -#include "lib/dcp_subtitle_content.h" +#include "lib/text_text_content.h" +#include "lib/dcp_text_content.h" #include "lib/film.h" #include "lib/ratio.h" #include "lib/dcp_content_type.h" -#include "lib/subtitle_content.h" +#include "lib/text_content.h" #include "lib/dcp_content.h" #include "lib/content_factory.h" #include "lib/config.h" @@ -59,7 +59,7 @@ BOOST_AUTO_TEST_CASE (burnt_subtitle_test_subrip) film->set_container (Ratio::from_id ("185")); film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR")); film->set_name ("frobozz"); - shared_ptr content (new TextSubtitleContent (film, "test/data/subrip2.srt")); + shared_ptr content (new TextTextContent (film, "test/data/subrip2.srt")); content->subtitle->set_use (true); content->subtitle->set_burn (true); film->examine_and_add_content (content); @@ -77,7 +77,7 @@ BOOST_AUTO_TEST_CASE (burnt_subtitle_test_dcp) film->set_container (Ratio::from_id ("185")); film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR")); film->set_name ("frobozz"); - shared_ptr content (new DCPSubtitleContent (film, "test/data/dcp_sub.xml")); + shared_ptr content (new DCPTextContent (film, "test/data/dcp_sub.xml")); content->subtitle->set_use (true); film->examine_and_add_content (content); wait_for_jobs (); @@ -106,7 +106,7 @@ BOOST_AUTO_TEST_CASE (burnt_subtitle_test_onto_dcp) film2->set_name ("frobozz"); shared_ptr background_dcp (new DCPContent(film2, film->dir(film->dcp_name()))); film2->examine_and_add_content (background_dcp); - shared_ptr sub = dynamic_pointer_cast ( + shared_ptr sub = dynamic_pointer_cast ( content_factory(film2, "test/data/subrip2.srt").front() ); sub->subtitle->set_burn (true); diff --git a/test/dcp_subtitle_test.cc b/test/dcp_subtitle_test.cc index 283fe8fcd..c57d694d0 100644 --- a/test/dcp_subtitle_test.cc +++ b/test/dcp_subtitle_test.cc @@ -25,16 +25,16 @@ #include #include "lib/film.h" -#include "lib/dcp_subtitle_content.h" +#include "lib/dcp_text_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_subtitle_decoder.h" -#include "lib/subtitle_content.h" +#include "lib/dcp_text_decoder.h" +#include "lib/text_content.h" #include "lib/content_subtitle.h" -#include "lib/subtitle_decoder.h" #include "lib/font.h" +#include "lib/text_decoder.h" #include "test.h" #include @@ -65,7 +65,7 @@ BOOST_AUTO_TEST_CASE (dcp_subtitle_test) film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR")); film->set_name ("frobozz"); film->set_interop (false); - shared_ptr content (new DCPSubtitleContent (film, "test/data/dcp_sub.xml")); + shared_ptr content (new DCPTextContent (film, "test/data/dcp_sub.xml")); film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs ()); @@ -109,11 +109,11 @@ BOOST_AUTO_TEST_CASE (dcp_subtitle_test2) film->set_container (Ratio::from_id ("185")); film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR")); film->set_name ("frobozz"); - shared_ptr content (new DCPSubtitleContent (film, "test/data/dcp_sub2.xml")); + shared_ptr content (new DCPTextContent (film, "test/data/dcp_sub2.xml")); film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs ()); - shared_ptr decoder (new DCPSubtitleDecoder (content, film->log())); + shared_ptr decoder (new DCPTextDecoder (content, film->log())); decoder->subtitle->TextStart.connect (bind (store, _1)); stored = optional (); @@ -132,14 +132,14 @@ BOOST_AUTO_TEST_CASE (dcp_subtitle_test3) film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR")); film->set_name ("frobozz"); film->set_interop (true); - shared_ptr content (new DCPSubtitleContent (film, "test/data/dcp_sub3.xml")); + shared_ptr content (new DCPTextContent (film, "test/data/dcp_sub3.xml")); film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs ()); film->make_dcp (); BOOST_REQUIRE (!wait_for_jobs ()); - shared_ptr decoder (new DCPSubtitleDecoder (content, film->log())); + shared_ptr decoder (new DCPTextDecoder (content, film->log())); stored = optional (); while (!decoder->pass ()) { decoder->subtitle->TextStart.connect (bind (store, _1)); diff --git a/test/ffmpeg_encoder_test.cc b/test/ffmpeg_encoder_test.cc index fc53ee40c..cfe607b8d 100644 --- a/test/ffmpeg_encoder_test.cc +++ b/test/ffmpeg_encoder_test.cc @@ -24,11 +24,11 @@ #include "lib/image_content.h" #include "lib/video_content.h" #include "lib/audio_content.h" -#include "lib/text_subtitle_content.h" +#include "lib/text_text_content.h" #include "lib/ratio.h" #include "lib/transcode_job.h" #include "lib/dcp_content.h" -#include "lib/subtitle_content.h" +#include "lib/text_content.h" #include "lib/compose.hpp" #include "test.h" #include @@ -121,7 +121,7 @@ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_prores_test6) film->set_container (Ratio::from_id ("185")); film->set_audio_channels (6); - shared_ptr s (new TextSubtitleContent (film, "test/data/subrip2.srt")); + shared_ptr s (new TextTextContent (film, "test/data/subrip2.srt")); film->examine_and_add_content (s); BOOST_REQUIRE (!wait_for_jobs ()); s->subtitle->set_colour (dcp::Colour (255, 255, 0)); @@ -146,7 +146,7 @@ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_prores_test7) film->examine_and_add_content (c); BOOST_REQUIRE (!wait_for_jobs ()); - shared_ptr s (new TextSubtitleContent (film, "test/data/subrip.srt")); + shared_ptr s (new TextTextContent (film, "test/data/subrip.srt")); film->examine_and_add_content (s); BOOST_REQUIRE (!wait_for_jobs ()); s->subtitle->set_colour (dcp::Colour (255, 255, 0)); @@ -172,7 +172,7 @@ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_h264_test2) film->set_container (Ratio::from_id ("185")); film->set_audio_channels (6); - shared_ptr s (new TextSubtitleContent (film, "test/data/subrip2.srt")); + shared_ptr s (new TextTextContent (film, "test/data/subrip2.srt")); film->examine_and_add_content (s); BOOST_REQUIRE (!wait_for_jobs ()); s->subtitle->set_colour (dcp::Colour (255, 255, 0)); @@ -197,7 +197,7 @@ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_h264_test3) film->examine_and_add_content (c); BOOST_REQUIRE (!wait_for_jobs ()); - shared_ptr s (new TextSubtitleContent (film, "test/data/subrip.srt")); + shared_ptr s (new TextTextContent (film, "test/data/subrip.srt")); film->examine_and_add_content (s); BOOST_REQUIRE (!wait_for_jobs ()); s->subtitle->set_colour (dcp::Colour (255, 255, 0)); diff --git a/test/import_dcp_test.cc b/test/import_dcp_test.cc index 1f5247392..c12f15fa1 100644 --- a/test/import_dcp_test.cc +++ b/test/import_dcp_test.cc @@ -25,7 +25,7 @@ #include "test.h" #include "lib/film.h" -#include "lib/dcp_subtitle_content.h" +#include "lib/dcp_text_content.h" #include "lib/ratio.h" #include "lib/dcp_content_type.h" #include "lib/dcp_content.h" diff --git a/test/player_test.cc b/test/player_test.cc index 52f3097cb..f59205e16 100644 --- a/test/player_test.cc +++ b/test/player_test.cc @@ -31,10 +31,10 @@ #include "lib/player.h" #include "lib/video_content.h" #include "lib/image_content.h" -#include "lib/text_subtitle_content.h" +#include "lib/text_text_content.h" #include "lib/content_factory.h" #include "lib/dcp_content.h" -#include "lib/subtitle_content.h" +#include "lib/text_content.h" #include "lib/butler.h" #include "lib/compose.hpp" #include "test.h" @@ -181,7 +181,7 @@ BOOST_AUTO_TEST_CASE (player_interleave_test) film->examine_and_add_content (c); BOOST_REQUIRE (!wait_for_jobs ()); - shared_ptr s (new TextSubtitleContent (film, "test/data/subrip.srt")); + shared_ptr s (new TextTextContent (film, "test/data/subrip.srt")); film->examine_and_add_content (s); BOOST_REQUIRE (!wait_for_jobs ()); diff --git a/test/reels_test.cc b/test/reels_test.cc index d705d8769..f793cef1d 100644 --- a/test/reels_test.cc +++ b/test/reels_test.cc @@ -30,7 +30,7 @@ #include "lib/dcp_content_type.h" #include "lib/dcp_content.h" #include "lib/video_content.h" -#include "lib/text_subtitle_content.h" +#include "lib/text_text_content.h" #include "lib/content_factory.h" #include "test.h" #include @@ -165,7 +165,7 @@ BOOST_AUTO_TEST_CASE (reels_test3) shared_ptr dcp (new DCPContent (film, "test/data/reels_test2")); film->examine_and_add_content (dcp); - shared_ptr sub (new TextSubtitleContent (film, "test/data/subrip.srt")); + shared_ptr sub (new TextTextContent (film, "test/data/subrip.srt")); film->examine_and_add_content (sub); wait_for_jobs (); @@ -206,7 +206,7 @@ BOOST_AUTO_TEST_CASE (reels_test4) content[i]->video->set_length (24); } - shared_ptr subs (new TextSubtitleContent (film, "test/data/subrip3.srt")); + shared_ptr subs (new TextTextContent (film, "test/data/subrip3.srt")); film->examine_and_add_content (subs); wait_for_jobs (); diff --git a/test/remake_id_test.cc b/test/remake_id_test.cc index 43ed16ebb..e7e9c67b2 100644 --- a/test/remake_id_test.cc +++ b/test/remake_id_test.cc @@ -20,7 +20,7 @@ #include "lib/ffmpeg_content.h" #include "lib/content_factory.h" -#include "lib/subtitle_content.h" +#include "lib/text_content.h" #include "lib/job_manager.h" #include "lib/film.h" #include "lib/dcp_content.h" diff --git a/test/remake_with_subtitle_test.cc b/test/remake_with_subtitle_test.cc index bc6d41798..4e286523f 100644 --- a/test/remake_with_subtitle_test.cc +++ b/test/remake_with_subtitle_test.cc @@ -20,7 +20,7 @@ #include "lib/ffmpeg_content.h" #include "lib/content_factory.h" -#include "lib/subtitle_content.h" +#include "lib/text_content.h" #include "lib/film.h" #include "test.h" #include diff --git a/test/srt_subtitle_test.cc b/test/srt_subtitle_test.cc index 7c89749e2..d931cf803 100644 --- a/test/srt_subtitle_test.cc +++ b/test/srt_subtitle_test.cc @@ -24,11 +24,11 @@ */ #include "lib/film.h" -#include "lib/text_subtitle_content.h" +#include "lib/text_text_content.h" #include "lib/dcp_content_type.h" #include "lib/font.h" #include "lib/ratio.h" -#include "lib/subtitle_content.h" +#include "lib/text_content.h" #include "test.h" #include #include @@ -47,7 +47,7 @@ BOOST_AUTO_TEST_CASE (srt_subtitle_test) film->set_name ("frobozz"); film->set_audio_channels (6); film->set_interop (false); - shared_ptr content (new TextSubtitleContent (film, "test/data/subrip2.srt")); + shared_ptr content (new TextTextContent (film, "test/data/subrip2.srt")); film->examine_and_add_content (content); wait_for_jobs (); @@ -69,7 +69,7 @@ BOOST_AUTO_TEST_CASE (srt_subtitle_test2) film->set_name ("frobozz"); film->set_audio_channels (6); film->set_interop (false); - shared_ptr content (new TextSubtitleContent (film, "test/data/subrip2.srt")); + shared_ptr content (new TextTextContent (film, "test/data/subrip2.srt")); film->examine_and_add_content (content); wait_for_jobs (); @@ -104,7 +104,7 @@ BOOST_AUTO_TEST_CASE (srt_subtitle_test3) film->set_name ("frobozz"); film->set_interop (true); film->set_audio_channels (6); - shared_ptr content (new TextSubtitleContent (film, private_data / "Ankoemmling_short.srt")); + shared_ptr content (new TextTextContent (film, private_data / "Ankoemmling_short.srt")); film->examine_and_add_content (content); wait_for_jobs (); @@ -125,7 +125,7 @@ BOOST_AUTO_TEST_CASE (srt_subtitle_test4) film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR")); film->set_name ("frobozz"); film->set_interop (false); - shared_ptr content (new TextSubtitleContent (film, "test/data/subrip2.srt")); + shared_ptr content (new TextTextContent (film, "test/data/subrip2.srt")); content->subtitle->set_use (true); content->subtitle->set_burn (false); film->examine_and_add_content (content); @@ -146,7 +146,7 @@ BOOST_AUTO_TEST_CASE (srt_subtitle_test5) film->set_name ("frobozz"); film->set_interop (true); film->set_sequence (false); - shared_ptr content (new TextSubtitleContent (film, "test/data/subrip2.srt")); + shared_ptr content (new TextTextContent (film, "test/data/subrip2.srt")); content->subtitle->set_use (true); content->subtitle->set_burn (false); film->examine_and_add_content (content); @@ -164,7 +164,7 @@ BOOST_AUTO_TEST_CASE (srt_subtitle_test6) { shared_ptr film = new_test_film2 ("srt_subtitle_test6"); film->set_interop (false); - shared_ptr content (new TextSubtitleContent (film, "test/data/frames.srt")); + shared_ptr content (new TextTextContent (film, "test/data/frames.srt")); content->subtitle->set_use (true); content->subtitle->set_burn (false); film->examine_and_add_content (content); @@ -185,7 +185,7 @@ BOOST_AUTO_TEST_CASE (srt_subtitle_test6) BOOST_AUTO_TEST_CASE (srt_subtitle_test4) { shared_ptr film = new_test_film ("subrip_render_test"); - shared_ptr content (new TextSubtitleContent (film, "test/data/subrip.srt")); + shared_ptr content (new TextTextContent (film, "test/data/subrip.srt")); content->examine (shared_ptr (), true); BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds ((3 * 60) + 56.471)); diff --git a/test/ssa_subtitle_test.cc b/test/ssa_subtitle_test.cc index bf460247c..b8d7a7c91 100644 --- a/test/ssa_subtitle_test.cc +++ b/test/ssa_subtitle_test.cc @@ -24,11 +24,11 @@ */ #include "lib/film.h" -#include "lib/text_subtitle_content.h" +#include "lib/text_text_content.h" #include "lib/dcp_content_type.h" #include "lib/font.h" #include "lib/ratio.h" -#include "lib/subtitle_content.h" +#include "lib/text_content.h" #include "test.h" #include #include @@ -47,7 +47,7 @@ BOOST_AUTO_TEST_CASE (ssa_subtitle_test1) film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR")); film->set_name ("frobozz"); film->set_interop (true); - shared_ptr content (new TextSubtitleContent (film, private_data / "DKH_UT_EN20160601def.ssa")); + shared_ptr content (new TextTextContent (film, private_data / "DKH_UT_EN20160601def.ssa")); film->examine_and_add_content (content); wait_for_jobs (); diff --git a/test/subtitle_reel_number_test.cc b/test/subtitle_reel_number_test.cc index 3eede3a88..749ef9e73 100644 --- a/test/subtitle_reel_number_test.cc +++ b/test/subtitle_reel_number_test.cc @@ -18,10 +18,10 @@ */ -#include "lib/text_subtitle_content.h" +#include "lib/text_text_content.h" #include "lib/film.h" #include "lib/ratio.h" -#include "lib/subtitle_content.h" +#include "lib/text_content.h" #include "lib/dcp_content_type.h" #include "test.h" #include @@ -43,7 +43,7 @@ BOOST_AUTO_TEST_CASE (subtitle_reel_number_test) film->set_container (Ratio::from_id ("185")); film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR")); film->set_name ("frobozz"); - shared_ptr content (new TextSubtitleContent (film, "test/data/subrip5.srt")); + shared_ptr content (new TextTextContent (film, "test/data/subrip5.srt")); film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs ()); content->subtitle->set_use (true); diff --git a/test/subtitle_trim_test.cc b/test/subtitle_trim_test.cc index 33bcf823f..1174eb583 100644 --- a/test/subtitle_trim_test.cc +++ b/test/subtitle_trim_test.cc @@ -19,7 +19,7 @@ */ #include "lib/film.h" -#include "lib/dcp_subtitle_content.h" +#include "lib/dcp_text_content.h" #include "test.h" #include @@ -29,7 +29,7 @@ using boost::shared_ptr; BOOST_AUTO_TEST_CASE (subtitle_trim_test1) { shared_ptr film = new_test_film2 ("subtitle_trim_test1"); - shared_ptr content (new DCPSubtitleContent (film, "test/data/dcp_sub5.xml")); + shared_ptr content (new DCPTextContent (film, "test/data/dcp_sub5.xml")); film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs ()); diff --git a/test/vf_kdm_test.cc b/test/vf_kdm_test.cc index 8b6e215ba..1ed5ac810 100644 --- a/test/vf_kdm_test.cc +++ b/test/vf_kdm_test.cc @@ -25,7 +25,7 @@ #include "test.h" #include "lib/film.h" -#include "lib/dcp_subtitle_content.h" +#include "lib/dcp_text_content.h" #include "lib/ratio.h" #include "lib/dcp_content_type.h" #include "lib/dcp_content.h" -- 2.30.2