From: Carl Hetherington Date: Thu, 19 Jul 2018 20:48:27 +0000 (+0100) Subject: Reword again: Text -> Caption and Plain -> Text. X-Git-Tag: v2.13.36~8 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=9cb73fbc0fa4643612f01665bc6d9fc430656f32 Reword again: Text -> Caption and Plain -> Text. sed -i "s/ActiveText/ActiveCaptions/g" src/lib/*.{cc,h} sed -i "s/active_text.h/active_captions.h/g" src/lib/*.{cc,h} sed -i "s/active_text.cc/active_captions.cc/g" src/lib/wscript mv src/lib/active_text.cc src/lib/active_captions.cc mv src/lib/active_text.h src/lib/active_captions.h sed -i "s/PlainTextFileContent/TextCaptionFileContent/g" src/lib/*.{cc,h} src/wx/*.cc sed -i "s/PlainTextFile/TextCaptionFile/g" src/lib/*.{cc,h} src/wx/*.cc sed -i "s/plain_text_file_content/text_caption_file_content/g" src/lib/*.{cc,h} src/lib/wscript src/wx/*.{cc,h} test/*.cc mv src/lib/plain_text_file_content.cc src/lib/text_caption_file_content.cc mv src/lib/plain_text_file_content.h src/lib/text_caption_file_content.h sed -i "s/PlainTextFileDecoder/TextCaptionFileDecoder/g" src/lib/*.{cc,h} sed -i "s/plain_text_file_decoder/text_caption_file_decoder/g" src/lib/*.{cc,h} src/lib/wscript src/wx/*.{cc,h} mv src/lib/plain_text_file_decoder.cc src/lib/text_caption_file_decoder.cc mv src/lib/plain_text_file_decoder.h src/lib/text_caption_file_decoder.h sed -i "s/PlayerText/PlayerCaption/g" src/lib/*.{cc,h} sed -i "s/player_text.cc/player_caption.cc/g" src/lib/wscript sed -i "s/player_text.h/player_caption.h/g" src/lib/*.{cc,h} mv src/lib/player_text.cc src/lib/player_caption.cc mv src/lib/player_text.h src/lib/player_caption.h sed -i "s/ContentPlainText/ContentTextCaption/g" src/lib/*.{cc,h} src/wx/*.{cc,h} sed -i "s/ContentBitmapText/ContentBitmapCaption/g" src/lib/*.{cc,h} src/wx/*.{cc,h} sed -i "s/PlainText/TextCaption/g" src/lib/*.{cc,h} test/*.cc sed -i "s/plain_text.h/text_caption.h/g" src/lib/*.{cc,h} mv src/lib/plain_text.h src/lib/text_caption.h --- diff --git a/src/lib/active_captions.cc b/src/lib/active_captions.cc new file mode 100644 index 000000000..972095e37 --- /dev/null +++ b/src/lib/active_captions.cc @@ -0,0 +1,139 @@ +/* + Copyright (C) 2017-2018 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 "active_captions.h" +#include "piece.h" +#include "text_content.h" +#include +#include + +using std::list; +using std::pair; +using std::make_pair; +using boost::weak_ptr; +using boost::shared_ptr; +using boost::optional; + +/** Get the subtitles that should be burnt into a given period. + * @param period Period of interest. + * @param always_burn_subtitles Always burn subtitles even if their content is not set to burn. + */ +list +ActiveCaptions::get_burnt (DCPTimePeriod period, bool always_burn_subtitles) const +{ + list ps; + + for (Map::const_iterator i = _data.begin(); i != _data.end(); ++i) { + + shared_ptr piece = i->first.lock (); + if (!piece) { + continue; + } + + if (!piece->content->subtitle->use() || (!always_burn_subtitles && !piece->content->subtitle->burn())) { + /* Not burning this piece */ + continue; + } + + BOOST_FOREACH (Period j, i->second) { + DCPTimePeriod test (j.from, j.to.get_value_or(DCPTime::max())); + optional overlap = period.overlap (test); + if (overlap && overlap->duration() > DCPTime(period.duration().get() / 2)) { + ps.push_back (j.subs); + } + } + } + + return ps; +} + +/** Remove subtitles that finish before a given time from our list. + * @param time Time to remove before. + */ +void +ActiveCaptions::clear_before (DCPTime time) +{ + Map updated; + for (Map::const_iterator i = _data.begin(); i != _data.end(); ++i) { + list as; + BOOST_FOREACH (Period j, i->second) { + if (!j.to || j.to.get() >= time) { + as.push_back (j); + } + } + if (!as.empty ()) { + updated[i->first] = as; + } + } + _data = updated; +} + +/** Add a new subtitle with a from time. + * @param piece Piece that the subtitle is from. + * @param ps Subtitles. + * @param from From time for these subtitles. + */ +void +ActiveCaptions::add_from (weak_ptr piece, PlayerCaption ps, DCPTime from) +{ + if (_data.find(piece) == _data.end()) { + _data[piece] = list(); + } + _data[piece].push_back (Period (ps, from)); +} + +/** Add the to time for the last subtitle added from a piece. + * @param piece Piece that the subtitle is from. + * @param to To time for the last subtitle submitted to add_from for this piece. + * @return Return the corresponding subtitles and their from time. + */ +pair +ActiveCaptions::add_to (weak_ptr piece, DCPTime to) +{ + DCPOMATIC_ASSERT (_data.find(piece) != _data.end()); + + _data[piece].back().to = to; + + BOOST_FOREACH (TextCaption& i, _data[piece].back().subs.text) { + i.set_out (dcp::Time(to.seconds(), 1000)); + } + + return make_pair (_data[piece].back().subs, _data[piece].back().from); +} + +/** @param piece A piece. + * @return true if we have any active subtitles from this piece. + */ +bool +ActiveCaptions::have (weak_ptr piece) const +{ + Map::const_iterator i = _data.find(piece); + if (i == _data.end()) { + return false; + } + + return !i->second.empty(); +} + +void +ActiveCaptions::clear () +{ + _data.clear (); +} diff --git a/src/lib/active_captions.h b/src/lib/active_captions.h new file mode 100644 index 000000000..718ba393e --- /dev/null +++ b/src/lib/active_captions.h @@ -0,0 +1,65 @@ +/* + Copyright (C) 2017-2018 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 . + +*/ + +/** @file src/lib/active_captions.h + * @brief ActiveCaptions class. + */ + +#include "dcpomatic_time.h" +#include "player_caption.h" +#include +#include +#include + +class Piece; + +/** @class ActiveCaptions + * @brief A class to maintain information on active subtitles for Player. + */ +class ActiveCaptions : public boost::noncopyable +{ +public: + std::list get_burnt (DCPTimePeriod period, bool always_burn_subtitles) const; + void clear_before (DCPTime time); + void clear (); + void add_from (boost::weak_ptr piece, PlayerCaption ps, DCPTime from); + std::pair add_to (boost::weak_ptr piece, DCPTime to); + bool have (boost::weak_ptr piece) const; + +private: + class Period + { + public: + Period () {} + + Period (PlayerCaption s, DCPTime f) + : subs (s) + , from (f) + {} + + PlayerCaption subs; + DCPTime from; + boost::optional to; + }; + + typedef std::map, std::list > Map; + + Map _data; +}; diff --git a/src/lib/active_text.cc b/src/lib/active_text.cc deleted file mode 100644 index 885aa034c..000000000 --- a/src/lib/active_text.cc +++ /dev/null @@ -1,139 +0,0 @@ -/* - Copyright (C) 2017-2018 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 "active_text.h" -#include "piece.h" -#include "text_content.h" -#include -#include - -using std::list; -using std::pair; -using std::make_pair; -using boost::weak_ptr; -using boost::shared_ptr; -using boost::optional; - -/** Get the subtitles that should be burnt into a given period. - * @param period Period of interest. - * @param always_burn_subtitles Always burn subtitles even if their content is not set to burn. - */ -list -ActiveText::get_burnt (DCPTimePeriod period, bool always_burn_subtitles) const -{ - list ps; - - for (Map::const_iterator i = _data.begin(); i != _data.end(); ++i) { - - shared_ptr piece = i->first.lock (); - if (!piece) { - continue; - } - - if (!piece->content->subtitle->use() || (!always_burn_subtitles && !piece->content->subtitle->burn())) { - /* Not burning this piece */ - continue; - } - - BOOST_FOREACH (Period j, i->second) { - DCPTimePeriod test (j.from, j.to.get_value_or(DCPTime::max())); - optional overlap = period.overlap (test); - if (overlap && overlap->duration() > DCPTime(period.duration().get() / 2)) { - ps.push_back (j.subs); - } - } - } - - return ps; -} - -/** Remove subtitles that finish before a given time from our list. - * @param time Time to remove before. - */ -void -ActiveText::clear_before (DCPTime time) -{ - Map updated; - for (Map::const_iterator i = _data.begin(); i != _data.end(); ++i) { - list as; - BOOST_FOREACH (Period j, i->second) { - if (!j.to || j.to.get() >= time) { - as.push_back (j); - } - } - if (!as.empty ()) { - updated[i->first] = as; - } - } - _data = updated; -} - -/** Add a new subtitle with a from time. - * @param piece Piece that the subtitle is from. - * @param ps Subtitles. - * @param from From time for these subtitles. - */ -void -ActiveText::add_from (weak_ptr piece, PlayerText ps, DCPTime from) -{ - if (_data.find(piece) == _data.end()) { - _data[piece] = list(); - } - _data[piece].push_back (Period (ps, from)); -} - -/** Add the to time for the last subtitle added from a piece. - * @param piece Piece that the subtitle is from. - * @param to To time for the last subtitle submitted to add_from for this piece. - * @return Return the corresponding subtitles and their from time. - */ -pair -ActiveText::add_to (weak_ptr piece, DCPTime to) -{ - DCPOMATIC_ASSERT (_data.find(piece) != _data.end()); - - _data[piece].back().to = to; - - BOOST_FOREACH (PlainText& i, _data[piece].back().subs.text) { - i.set_out (dcp::Time(to.seconds(), 1000)); - } - - return make_pair (_data[piece].back().subs, _data[piece].back().from); -} - -/** @param piece A piece. - * @return true if we have any active subtitles from this piece. - */ -bool -ActiveText::have (weak_ptr piece) const -{ - Map::const_iterator i = _data.find(piece); - if (i == _data.end()) { - return false; - } - - return !i->second.empty(); -} - -void -ActiveText::clear () -{ - _data.clear (); -} diff --git a/src/lib/active_text.h b/src/lib/active_text.h deleted file mode 100644 index 09ef1cdaf..000000000 --- a/src/lib/active_text.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - Copyright (C) 2017-2018 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 . - -*/ - -/** @file src/lib/active_text.h - * @brief ActiveText class. - */ - -#include "dcpomatic_time.h" -#include "player_text.h" -#include -#include -#include - -class Piece; - -/** @class ActiveText - * @brief A class to maintain information on active subtitles for Player. - */ -class ActiveText : public boost::noncopyable -{ -public: - std::list get_burnt (DCPTimePeriod period, bool always_burn_subtitles) const; - void clear_before (DCPTime time); - void clear (); - void add_from (boost::weak_ptr piece, PlayerText ps, DCPTime from); - std::pair add_to (boost::weak_ptr piece, DCPTime to); - bool have (boost::weak_ptr piece) const; - -private: - class Period - { - public: - Period () {} - - Period (PlayerText s, DCPTime f) - : subs (s) - , from (f) - {} - - PlayerText subs; - DCPTime from; - boost::optional to; - }; - - typedef std::map, std::list > Map; - - Map _data; -}; diff --git a/src/lib/content_factory.cc b/src/lib/content_factory.cc index 167b3f4e9..9429f1c46 100644 --- a/src/lib/content_factory.cc +++ b/src/lib/content_factory.cc @@ -26,7 +26,7 @@ #include "audio_content.h" #include "image_content.h" #include "atmos_mxf_content.h" -#include "plain_text_file_content.h" +#include "text_caption_file_content.h" #include "dcp_content.h" #include "dcp_text_content.h" #include "util.h" @@ -88,7 +88,7 @@ content_factory (shared_ptr film, cxml::NodePtr node, int version, l ); } else if (type == "SubRip" || type == "TextSubtitle") { - content.reset (new PlainTextFileContent (film, node, version)); + content.reset (new TextCaptionFileContent (film, node, version)); } else if (type == "DCP") { content.reset (new DCPContent (film, node, version)); } else if (type == "DCPSubtitle") { @@ -210,7 +210,7 @@ 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 PlainTextFileContent (film, path)); + single.reset (new TextCaptionFileContent (film, path)); } else if (ext == ".xml") { cxml::Document doc; doc.read_file (path); diff --git a/src/lib/content_text.h b/src/lib/content_text.h index eaba64ecf..1b550c96d 100644 --- a/src/lib/content_text.h +++ b/src/lib/content_text.h @@ -51,10 +51,10 @@ private: TextType _type; }; -class ContentBitmapText : public ContentText +class ContentBitmapCaption : public ContentText { public: - ContentBitmapText (ContentTime f, TextType type, boost::shared_ptr im, dcpomatic::Rect r) + ContentBitmapCaption (ContentTime f, TextType type, boost::shared_ptr im, dcpomatic::Rect r) : ContentText (f, type) , sub (im, r) {} @@ -67,10 +67,10 @@ public: * as the dcp::SubtitleString timings are sometimes quite heavily quantised and this causes problems * when we want to compare the quantised periods to the unquantised ones. */ -class ContentPlainText : public ContentText +class ContentTextCaption : public ContentText { public: - ContentPlainText (ContentTime f, TextType type, std::list s) + ContentTextCaption (ContentTime f, TextType type, std::list s) : ContentText (f, type) , subs (s) {} diff --git a/src/lib/dcp_encoder.cc b/src/lib/dcp_encoder.cc index cfc7da903..9766aad33 100644 --- a/src/lib/dcp_encoder.cc +++ b/src/lib/dcp_encoder.cc @@ -141,7 +141,7 @@ DCPEncoder::audio (shared_ptr data, DCPTime time) } void -DCPEncoder::text (PlayerText data, TextType type, DCPTimePeriod period) +DCPEncoder::text (PlayerCaption data, TextType type, DCPTimePeriod period) { if (type == TEXT_CLOSED_CAPTION || _non_burnt_subtitles) { _writer->write (data, type, period); diff --git a/src/lib/dcp_encoder.h b/src/lib/dcp_encoder.h index 8a2ad947d..850ead656 100644 --- a/src/lib/dcp_encoder.h +++ b/src/lib/dcp_encoder.h @@ -19,7 +19,7 @@ */ #include "types.h" -#include "player_text.h" +#include "player_caption.h" #include "encoder.h" #include @@ -52,7 +52,7 @@ private: void video (boost::shared_ptr, DCPTime); void audio (boost::shared_ptr, DCPTime); - void text (PlayerText, TextType, DCPTimePeriod); + void text (PlayerCaption, TextType, DCPTimePeriod); boost::shared_ptr _writer; boost::shared_ptr _j2k_encoder; diff --git a/src/lib/decoder_factory.cc b/src/lib/decoder_factory.cc index a7367dd24..3d4ce8a7b 100644 --- a/src/lib/decoder_factory.cc +++ b/src/lib/decoder_factory.cc @@ -24,8 +24,8 @@ #include "dcp_decoder.h" #include "image_content.h" #include "image_decoder.h" -#include "plain_text_file_content.h" -#include "plain_text_file_decoder.h" +#include "text_caption_file_content.h" +#include "text_caption_file_decoder.h" #include "dcp_text_content.h" #include "dcp_text_decoder.h" #include "video_mxf_content.h" @@ -54,9 +54,9 @@ 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 PlainTextFileDecoder (rc, log)); + return shared_ptr (new TextCaptionFileDecoder (rc, log)); } shared_ptr dsc = dynamic_pointer_cast (content); diff --git a/src/lib/encoder.h b/src/lib/encoder.h index f4116c50c..27fa0745f 100644 --- a/src/lib/encoder.h +++ b/src/lib/encoder.h @@ -22,7 +22,7 @@ #define DCPOMATIC_ENCODER_H #include "types.h" -#include "player_text.h" +#include "player_caption.h" #include #include diff --git a/src/lib/ffmpeg_encoder.cc b/src/lib/ffmpeg_encoder.cc index e9d872c8f..cc2591498 100644 --- a/src/lib/ffmpeg_encoder.cc +++ b/src/lib/ffmpeg_encoder.cc @@ -411,7 +411,7 @@ FFmpegEncoder::audio_frame (int size) } void -FFmpegEncoder::subtitle (PlayerText, DCPTimePeriod) +FFmpegEncoder::subtitle (PlayerCaption, DCPTimePeriod) { } diff --git a/src/lib/ffmpeg_encoder.h b/src/lib/ffmpeg_encoder.h index b1d07eb7f..35fd85064 100644 --- a/src/lib/ffmpeg_encoder.h +++ b/src/lib/ffmpeg_encoder.h @@ -54,7 +54,7 @@ public: private: void video (boost::shared_ptr, DCPTime); void audio (boost::shared_ptr); - void subtitle (PlayerText, DCPTimePeriod); + void subtitle (PlayerCaption, DCPTimePeriod); void setup_video (); void setup_audio (); diff --git a/src/lib/plain_text.h b/src/lib/plain_text.h deleted file mode 100644 index 05a95aef2..000000000 --- a/src/lib/plain_text.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - Copyright (C) 2016-2018 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_PLAIN_TEXT_H -#define DCPOMATIC_PLAIN_TEXT_H - -#include - -/** A wrapper for SubtitleString which allows us to include settings that are not - * applicable to true DCP subtitles. For example, we can set outline width for burn-in - * but this cannot be specified in DCP XML. - */ -class PlainText : public dcp::SubtitleString -{ -public: - explicit PlainText (dcp::SubtitleString dcp_) - : dcp::SubtitleString (dcp_) - , outline_width (2) - {} - - PlainText (dcp::SubtitleString dcp_, int outline_width_) - : dcp::SubtitleString (dcp_) - , outline_width (outline_width_) - {} - - int outline_width; -}; - -#endif diff --git a/src/lib/plain_text_file.cc b/src/lib/plain_text_file.cc index 4ed13491c..666953c40 100644 --- a/src/lib/plain_text_file.cc +++ b/src/lib/plain_text_file.cc @@ -21,7 +21,7 @@ #include "plain_text_file.h" #include "cross.h" #include "exceptions.h" -#include "plain_text_file_content.h" +#include "text_caption_file_content.h" #include #include #include @@ -39,7 +39,7 @@ using boost::scoped_array; using boost::optional; using dcp::Data; -PlainTextFile::PlainTextFile (shared_ptr content) +TextCaptionFile::TextCaptionFile (shared_ptr content) { Data in (content->path (0)); @@ -96,7 +96,7 @@ PlainTextFile::PlainTextFile (shared_ptr content) /** @return time of first subtitle, if there is one */ optional -PlainTextFile::first () const +TextCaptionFile::first () const { if (_subtitles.empty()) { return optional(); @@ -106,7 +106,7 @@ PlainTextFile::first () const } ContentTime -PlainTextFile::length () const +TextCaptionFile::length () const { if (_subtitles.empty ()) { return ContentTime (); diff --git a/src/lib/plain_text_file.h b/src/lib/plain_text_file.h index 34dc08465..8c74d9e59 100644 --- a/src/lib/plain_text_file.h +++ b/src/lib/plain_text_file.h @@ -26,22 +26,22 @@ #include #include -class PlainTextFileContent; +class TextCaptionFileContent; class plain_text_time_test; class plain_text_coordinate_test; class plain_text_content_test; class plain_text_parse_test; -/** @class PlainTextFile - * @brief Base for PlainTextFile decoder and examiner. +/** @class TextCaptionFile + * @brief Base for TextCaptionFile decoder and examiner. * * In fact this is sufficient for the examiner, so it's used as-is rather than deriving - * a pointless PlainTextFileExaminer. + * a pointless TextCaptionFileExaminer. */ -class PlainTextFile +class TextCaptionFile { public: - explicit PlainTextFile (boost::shared_ptr); + explicit TextCaptionFile (boost::shared_ptr); boost::optional first () const; ContentTime length () const; diff --git a/src/lib/plain_text_file_content.cc b/src/lib/plain_text_file_content.cc deleted file mode 100644 index 2b52cee96..000000000 --- a/src/lib/plain_text_file_content.cc +++ /dev/null @@ -1,95 +0,0 @@ -/* - Copyright (C) 2014-2018 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 "plain_text_file_content.h" -#include "util.h" -#include "plain_text_file.h" -#include "film.h" -#include "font.h" -#include "text_content.h" -#include -#include -#include - -#include "i18n.h" - -using std::string; -using std::cout; -using boost::shared_ptr; -using dcp::raw_convert; - -PlainTextFileContent::PlainTextFileContent (shared_ptr film, boost::filesystem::path path) - : Content (film, path) -{ - subtitle.reset (new TextContent (this)); -} - -PlainTextFileContent::PlainTextFileContent (shared_ptr film, cxml::ConstNodePtr node, int version) - : Content (film, node) - , _length (node->number_child ("Length")) -{ - subtitle = TextContent::from_xml (this, node, version); -} - -void -PlainTextFileContent::examine (boost::shared_ptr job) -{ - Content::examine (job); - PlainTextFile s (shared_from_this ()); - - /* Default to turning these subtitles on */ - subtitle->set_use (true); - - boost::mutex::scoped_lock lm (_mutex); - _length = s.length (); - subtitle->add_font (shared_ptr (new Font (TEXT_FONT_ID))); -} - -string -PlainTextFileContent::summary () const -{ - return path_summary() + " " + _("[subtitles]"); -} - -string -PlainTextFileContent::technical_summary () const -{ - return Content::technical_summary() + " - " + _("Text subtitles"); -} - -void -PlainTextFileContent::as_xml (xmlpp::Node* node, bool with_paths) const -{ - node->add_child("Type")->add_child_text ("TextSubtitle"); - Content::as_xml (node, with_paths); - - if (subtitle) { - subtitle->as_xml (node); - } - - node->add_child("Length")->add_child_text (raw_convert (_length.get ())); -} - -DCPTime -PlainTextFileContent::full_length () const -{ - FrameRateChange const frc (active_video_frame_rate(), film()->video_frame_rate ()); - return DCPTime (_length, frc); -} diff --git a/src/lib/plain_text_file_content.h b/src/lib/plain_text_file_content.h deleted file mode 100644 index 603931e4c..000000000 --- a/src/lib/plain_text_file_content.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - Copyright (C) 2014-2018 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 "content.h" - -class Job; - -/** @class PlainTextFileContent - * @brief A SubRip, SSA or ASS file. - */ -class PlainTextFileContent : public Content -{ -public: - PlainTextFileContent (boost::shared_ptr, boost::filesystem::path); - PlainTextFileContent (boost::shared_ptr, cxml::ConstNodePtr, int); - - boost::shared_ptr shared_from_this () { - return boost::dynamic_pointer_cast (Content::shared_from_this ()); - } - - void examine (boost::shared_ptr); - std::string summary () const; - std::string technical_summary () const; - void as_xml (xmlpp::Node *, bool with_paths) const; - DCPTime full_length () const; - -private: - ContentTime _length; -}; diff --git a/src/lib/plain_text_file_decoder.cc b/src/lib/plain_text_file_decoder.cc deleted file mode 100644 index 40a605963..000000000 --- a/src/lib/plain_text_file_decoder.cc +++ /dev/null @@ -1,89 +0,0 @@ -/* - Copyright (C) 2014-2018 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 "plain_text_file_decoder.h" -#include "plain_text_file_content.h" -#include "text_content.h" -#include "text_decoder.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; - -PlainTextFileDecoder::PlainTextFileDecoder (shared_ptr content, shared_ptr log) - : PlainTextFile (content) - , _next (0) -{ - ContentTime first; - if (!_subtitles.empty()) { - first = content_time_period(_subtitles[0]).from; - } - subtitle.reset (new TextDecoder (this, content->subtitle, log, first)); -} - -void -PlainTextFileDecoder::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 -PlainTextFileDecoder::pass () -{ - if (_next >= _subtitles.size ()) { - return true; - } - - ContentTimePeriod const p = content_time_period (_subtitles[_next]); - subtitle->emit_plain (p, _subtitles[_next]); - - ++_next; - return false; -} - -ContentTimePeriod -PlainTextFileDecoder::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/plain_text_file_decoder.h b/src/lib/plain_text_file_decoder.h deleted file mode 100644 index ea64a294b..000000000 --- a/src/lib/plain_text_file_decoder.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - Copyright (C) 2014-2018 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_PLAIN_TEXT_FILE_DECODER_H -#define DCPOMATIC_PLAIN_TEXT_FILE_DECODER_H - -#include "plain_text_file.h" -#include "decoder.h" - -class PlainTextFileContent; -class Log; - -class PlainTextFileDecoder : public Decoder, public PlainTextFile -{ -public: - PlainTextFileDecoder (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/player.cc b/src/lib/player.cc index e300b5448..a7cd0fd94 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -663,7 +663,7 @@ Player::subtitles_for_frame (DCPTime time) const int const vfr = _film->video_frame_rate(); - BOOST_FOREACH (PlayerText i, _active_text[TEXT_SUBTITLE].get_burnt (DCPTimePeriod(time, time + DCPTime::from_frames(1, vfr)), _always_burn_subtitles)) { + BOOST_FOREACH (PlayerCaption i, _active_text[TEXT_SUBTITLE].get_burnt (DCPTimePeriod(time, time + DCPTime::from_frames(1, vfr)), _always_burn_subtitles)) { /* Image subtitles */ list c = transform_bitmap_texts (i.image); @@ -839,7 +839,7 @@ Player::audio (weak_ptr wp, AudioStreamPtr stream, ContentAudio content_a } void -Player::bitmap_text_start (weak_ptr wp, ContentBitmapText subtitle) +Player::bitmap_text_start (weak_ptr wp, ContentBitmapCaption subtitle) { shared_ptr piece = wp.lock (); if (!piece) { @@ -858,7 +858,7 @@ Player::bitmap_text_start (weak_ptr wp, ContentBitmapText subtitle) subtitle.sub.rectangle.width *= piece->content->subtitle->x_scale (); subtitle.sub.rectangle.height *= piece->content->subtitle->y_scale (); - PlayerText ps; + PlayerCaption ps; ps.image.push_back (subtitle.sub); DCPTime from (content_time_to_dcp (piece, subtitle.from())); @@ -866,14 +866,14 @@ Player::bitmap_text_start (weak_ptr wp, ContentBitmapText subtitle) } void -Player::plain_text_start (weak_ptr wp, ContentPlainText subtitle) +Player::plain_text_start (weak_ptr wp, ContentTextCaption subtitle) { shared_ptr piece = wp.lock (); if (!piece) { return; } - PlayerText ps; + PlayerCaption ps; DCPTime const from (content_time_to_dcp (piece, subtitle.from())); if (from > piece->content->end()) { @@ -901,7 +901,7 @@ Player::plain_text_start (weak_ptr wp, ContentPlainText subtitle) } s.set_in (dcp::Time(from.seconds(), 1000)); - ps.text.push_back (PlainText (s, piece->content->subtitle->outline_width())); + ps.text.push_back (TextCaption (s, piece->content->subtitle->outline_width())); ps.add_fonts (piece->content->subtitle->fonts ()); } @@ -926,7 +926,7 @@ Player::subtitle_stop (weak_ptr wp, ContentTime to, TextType type) return; } - pair from = _active_text[type].add_to (wp, dcp_to); + pair from = _active_text[type].add_to (wp, dcp_to); if (piece->content->subtitle->use() && !_always_burn_subtitles && !piece->content->subtitle->burn()) { Text (from.first, type, DCPTimePeriod (from.second, dcp_to)); diff --git a/src/lib/player.h b/src/lib/player.h index c936524a2..16e9d57a5 100644 --- a/src/lib/player.h +++ b/src/lib/player.h @@ -21,8 +21,8 @@ #ifndef DCPOMATIC_PLAYER_H #define DCPOMATIC_PLAYER_H -#include "player_text.h" -#include "active_text.h" +#include "player_caption.h" +#include "active_captions.h" #include "content_text.h" #include "film.h" #include "content.h" @@ -101,7 +101,7 @@ public: /** Emitted when a caption is ready. This signal may be emitted considerably * after the corresponding Video. */ - boost::signals2::signal Text; + boost::signals2::signal Text; private: friend class PlayerWrapper; @@ -126,8 +126,8 @@ private: boost::shared_ptr black_player_video_frame (Eyes eyes) const; void video (boost::weak_ptr, ContentVideo); void audio (boost::weak_ptr, AudioStreamPtr, ContentAudio); - void bitmap_text_start (boost::weak_ptr, ContentBitmapText); - void plain_text_start (boost::weak_ptr, ContentPlainText); + void bitmap_text_start (boost::weak_ptr, ContentBitmapCaption); + void plain_text_start (boost::weak_ptr, ContentTextCaption); void subtitle_stop (boost::weak_ptr, ContentTime, TextType); DCPTime one_video_frame () const; void fill_audio (DCPTimePeriod period); @@ -196,7 +196,7 @@ private: Empty _black; Empty _silent; - ActiveText _active_text[TEXT_COUNT]; + ActiveCaptions _active_text[TEXT_COUNT]; boost::shared_ptr _audio_processor; boost::signals2::scoped_connection _film_changed_connection; diff --git a/src/lib/player_caption.cc b/src/lib/player_caption.cc new file mode 100644 index 000000000..74c847aae --- /dev/null +++ b/src/lib/player_caption.cc @@ -0,0 +1,42 @@ +/* + Copyright (C) 2014-2018 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 "player_caption.h" +#include "font.h" +#include + +using std::list; +using boost::shared_ptr; + +void +PlayerCaption::add_fonts (list > fonts_) +{ + BOOST_FOREACH (shared_ptr i, fonts_) { + bool got = false; + BOOST_FOREACH (shared_ptr j, fonts) { + if (*i == *j) { + got = true; + } + } + if (!got) { + fonts.push_back (i); + } + } +} diff --git a/src/lib/player_caption.h b/src/lib/player_caption.h new file mode 100644 index 000000000..2875790df --- /dev/null +++ b/src/lib/player_caption.h @@ -0,0 +1,42 @@ +/* + Copyright (C) 2014-2018 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_PLAYER_TEXT_H +#define DCPOMATIC_PLAYER_TEXT_H + +#include "bitmap_text.h" +#include "dcpomatic_time.h" +#include "text_caption.h" + +class Font; + +/** A set of text (subtitle/CCAP) which span the same time period */ +class PlayerCaption +{ +public: + void add_fonts (std::list > fonts_); + std::list > fonts; + + /** BitmapTexts, with their rectangles transformed as specified by their content */ + std::list image; + std::list text; +}; + +#endif diff --git a/src/lib/player_text.cc b/src/lib/player_text.cc deleted file mode 100644 index 16e89b0f1..000000000 --- a/src/lib/player_text.cc +++ /dev/null @@ -1,42 +0,0 @@ -/* - Copyright (C) 2014-2018 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 "player_text.h" -#include "font.h" -#include - -using std::list; -using boost::shared_ptr; - -void -PlayerText::add_fonts (list > fonts_) -{ - BOOST_FOREACH (shared_ptr i, fonts_) { - bool got = false; - BOOST_FOREACH (shared_ptr j, fonts) { - if (*i == *j) { - got = true; - } - } - if (!got) { - fonts.push_back (i); - } - } -} diff --git a/src/lib/player_text.h b/src/lib/player_text.h deleted file mode 100644 index 93b6cd970..000000000 --- a/src/lib/player_text.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - Copyright (C) 2014-2018 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_PLAYER_TEXT_H -#define DCPOMATIC_PLAYER_TEXT_H - -#include "bitmap_text.h" -#include "dcpomatic_time.h" -#include "plain_text.h" - -class Font; - -/** A set of text (subtitle/CCAP) which span the same time period */ -class PlayerText -{ -public: - void add_fonts (std::list > fonts_); - std::list > fonts; - - /** BitmapTexts, with their rectangles transformed as specified by their content */ - std::list image; - std::list text; -}; - -#endif diff --git a/src/lib/reel_writer.cc b/src/lib/reel_writer.cc index 8eb0461bc..77d583353 100644 --- a/src/lib/reel_writer.cc +++ b/src/lib/reel_writer.cc @@ -528,7 +528,7 @@ ReelWriter::write (shared_ptr<const AudioBuffers> audio) } void -ReelWriter::write (PlayerText subs, TextType type, DCPTimePeriod period) +ReelWriter::write (PlayerCaption subs, TextType type, DCPTimePeriod period) { /* XXX: we need separate libdcp asset types here and to know how different they are */ @@ -558,7 +558,7 @@ ReelWriter::write (PlayerText subs, TextType type, DCPTimePeriod period) } } - BOOST_FOREACH (PlainText i, subs.text) { + BOOST_FOREACH (TextCaption i, subs.text) { /* XXX: couldn't / shouldn't we use period here rather than getting time from the subtitle? */ i.set_in (i.in() - dcp::Time (_period.from.seconds(), i.in().tcr)); i.set_out (i.out() - dcp::Time (_period.from.seconds(), i.out().tcr)); diff --git a/src/lib/reel_writer.h b/src/lib/reel_writer.h index 6de1de68d..cd22fa775 100644 --- a/src/lib/reel_writer.h +++ b/src/lib/reel_writer.h @@ -21,7 +21,7 @@ #include "types.h" #include "dcpomatic_time.h" #include "referenced_reel_asset.h" -#include "player_text.h" +#include "player_caption.h" #include <dcp/picture_asset_writer.h> #include <boost/shared_ptr.hpp> @@ -60,7 +60,7 @@ public: void fake_write (Frame frame, Eyes eyes, int size); void repeat_write (Frame frame, Eyes eyes); void write (boost::shared_ptr<const AudioBuffers> audio); - void write (PlayerText text, TextType type, DCPTimePeriod period); + void write (PlayerCaption text, TextType type, DCPTimePeriod period); void finish (); boost::shared_ptr<dcp::Reel> create_reel (std::list<ReferencedReelAsset> const & refs, std::list<boost::shared_ptr<Font> > const & fonts); diff --git a/src/lib/render_text.cc b/src/lib/render_text.cc index 77a8036e8..63ff2b74c 100644 --- a/src/lib/render_text.cc +++ b/src/lib/render_text.cc @@ -51,11 +51,11 @@ static FcConfig* fc_config = 0; static list<pair<FontFiles, string> > fc_config_fonts; string -marked_up (list<PlainText> subtitles, int target_height, float fade_factor) +marked_up (list<TextCaption> subtitles, int target_height, float fade_factor) { string out; - BOOST_FOREACH (PlainText const & i, subtitles) { + BOOST_FOREACH (TextCaption const & i, subtitles) { out += "<span "; if (i.italic()) { out += "style=\"italic\" "; @@ -91,7 +91,7 @@ set_source_rgba (Cairo::RefPtr<Cairo::Context> context, dcp::Colour colour, floa * at the same time and with the same fade in/out. */ static PositionImage -render_line (list<PlainText> subtitles, list<shared_ptr<Font> > fonts, dcp::Size target, DCPTime time, int frame_rate) +render_line (list<TextCaption> subtitles, list<shared_ptr<Font> > fonts, dcp::Size target, DCPTime time, int frame_rate) { /* XXX: this method can only handle italic / bold changes mid-line, nothing else yet. @@ -365,12 +365,12 @@ render_line (list<PlainText> subtitles, list<shared_ptr<Font> > fonts, dcp::Size * @param frame_rate DCP frame rate. */ list<PositionImage> -render_text (list<PlainText> subtitles, list<shared_ptr<Font> > fonts, dcp::Size target, DCPTime time, int frame_rate) +render_text (list<TextCaption> subtitles, list<shared_ptr<Font> > fonts, dcp::Size target, DCPTime time, int frame_rate) { - list<PlainText> pending; + list<TextCaption> pending; list<PositionImage> images; - BOOST_FOREACH (PlainText const & i, subtitles) { + BOOST_FOREACH (TextCaption const & i, subtitles) { if (!pending.empty() && fabs (i.v_position() - pending.back().v_position()) > 1e-4) { images.push_back (render_line (pending, fonts, target, time, frame_rate)); pending.clear (); diff --git a/src/lib/render_text.h b/src/lib/render_text.h index f9c35005e..0a8e97bc9 100644 --- a/src/lib/render_text.h +++ b/src/lib/render_text.h @@ -20,12 +20,12 @@ #include "position_image.h" #include "dcpomatic_time.h" -#include "plain_text.h" +#include "text_caption.h" #include <dcp/util.h> class Font; -std::string marked_up (std::list<PlainText> subtitles, int target_height, float fade_factor); +std::string marked_up (std::list<TextCaption> subtitles, int target_height, float fade_factor); std::list<PositionImage> render_text ( - std::list<PlainText>, std::list<boost::shared_ptr<Font> > fonts, dcp::Size, DCPTime, int + std::list<TextCaption>, std::list<boost::shared_ptr<Font> > fonts, dcp::Size, DCPTime, int ); diff --git a/src/lib/text_caption.h b/src/lib/text_caption.h new file mode 100644 index 000000000..b4400f5bb --- /dev/null +++ b/src/lib/text_caption.h @@ -0,0 +1,46 @@ +/* + Copyright (C) 2016-2018 Carl Hetherington <cth@carlh.net> + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>. + +*/ + +#ifndef DCPOMATIC_PLAIN_TEXT_H +#define DCPOMATIC_PLAIN_TEXT_H + +#include <dcp/subtitle_string.h> + +/** A wrapper for SubtitleString which allows us to include settings that are not + * applicable to true DCP subtitles. For example, we can set outline width for burn-in + * but this cannot be specified in DCP XML. + */ +class TextCaption : public dcp::SubtitleString +{ +public: + explicit TextCaption (dcp::SubtitleString dcp_) + : dcp::SubtitleString (dcp_) + , outline_width (2) + {} + + TextCaption (dcp::SubtitleString dcp_, int outline_width_) + : dcp::SubtitleString (dcp_) + , outline_width (outline_width_) + {} + + int outline_width; +}; + +#endif diff --git a/src/lib/text_caption_file_content.cc b/src/lib/text_caption_file_content.cc new file mode 100644 index 000000000..df5de93ef --- /dev/null +++ b/src/lib/text_caption_file_content.cc @@ -0,0 +1,95 @@ +/* + Copyright (C) 2014-2018 Carl Hetherington <cth@carlh.net> + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>. + +*/ + +#include "text_caption_file_content.h" +#include "util.h" +#include "plain_text_file.h" +#include "film.h" +#include "font.h" +#include "text_content.h" +#include <dcp/raw_convert.h> +#include <libxml++/libxml++.h> +#include <iostream> + +#include "i18n.h" + +using std::string; +using std::cout; +using boost::shared_ptr; +using dcp::raw_convert; + +TextCaptionFileContent::TextCaptionFileContent (shared_ptr<const Film> film, boost::filesystem::path path) + : Content (film, path) +{ + subtitle.reset (new TextContent (this)); +} + +TextCaptionFileContent::TextCaptionFileContent (shared_ptr<const Film> film, cxml::ConstNodePtr node, int version) + : Content (film, node) + , _length (node->number_child<ContentTime::Type> ("Length")) +{ + subtitle = TextContent::from_xml (this, node, version); +} + +void +TextCaptionFileContent::examine (boost::shared_ptr<Job> job) +{ + Content::examine (job); + TextCaptionFile s (shared_from_this ()); + + /* Default to turning these subtitles on */ + subtitle->set_use (true); + + boost::mutex::scoped_lock lm (_mutex); + _length = s.length (); + subtitle->add_font (shared_ptr<Font> (new Font (TEXT_FONT_ID))); +} + +string +TextCaptionFileContent::summary () const +{ + return path_summary() + " " + _("[subtitles]"); +} + +string +TextCaptionFileContent::technical_summary () const +{ + return Content::technical_summary() + " - " + _("Text subtitles"); +} + +void +TextCaptionFileContent::as_xml (xmlpp::Node* node, bool with_paths) const +{ + node->add_child("Type")->add_child_text ("TextSubtitle"); + Content::as_xml (node, with_paths); + + if (subtitle) { + subtitle->as_xml (node); + } + + node->add_child("Length")->add_child_text (raw_convert<string> (_length.get ())); +} + +DCPTime +TextCaptionFileContent::full_length () const +{ + FrameRateChange const frc (active_video_frame_rate(), film()->video_frame_rate ()); + return DCPTime (_length, frc); +} diff --git a/src/lib/text_caption_file_content.h b/src/lib/text_caption_file_content.h new file mode 100644 index 000000000..f8f4a9851 --- /dev/null +++ b/src/lib/text_caption_file_content.h @@ -0,0 +1,46 @@ +/* + Copyright (C) 2014-2018 Carl Hetherington <cth@carlh.net> + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>. + +*/ + +#include "content.h" + +class Job; + +/** @class TextCaptionFileContent + * @brief A SubRip, SSA or ASS file. + */ +class TextCaptionFileContent : public Content +{ +public: + TextCaptionFileContent (boost::shared_ptr<const Film>, boost::filesystem::path); + TextCaptionFileContent (boost::shared_ptr<const Film>, cxml::ConstNodePtr, int); + + boost::shared_ptr<TextCaptionFileContent> shared_from_this () { + return boost::dynamic_pointer_cast<TextCaptionFileContent> (Content::shared_from_this ()); + } + + void examine (boost::shared_ptr<Job>); + std::string summary () const; + std::string technical_summary () const; + void as_xml (xmlpp::Node *, bool with_paths) const; + DCPTime full_length () const; + +private: + ContentTime _length; +}; diff --git a/src/lib/text_caption_file_decoder.cc b/src/lib/text_caption_file_decoder.cc new file mode 100644 index 000000000..d1a72faeb --- /dev/null +++ b/src/lib/text_caption_file_decoder.cc @@ -0,0 +1,89 @@ +/* + Copyright (C) 2014-2018 Carl Hetherington <cth@carlh.net> + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>. + +*/ + +#include "text_caption_file_decoder.h" +#include "text_caption_file_content.h" +#include "text_content.h" +#include "text_decoder.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; + +TextCaptionFileDecoder::TextCaptionFileDecoder (shared_ptr<const TextCaptionFileContent> content, shared_ptr<Log> log) + : TextCaptionFile (content) + , _next (0) +{ + ContentTime first; + if (!_subtitles.empty()) { + first = content_time_period(_subtitles[0]).from; + } + subtitle.reset (new TextDecoder (this, content->subtitle, log, first)); +} + +void +TextCaptionFileDecoder::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 +TextCaptionFileDecoder::pass () +{ + if (_next >= _subtitles.size ()) { + return true; + } + + ContentTimePeriod const p = content_time_period (_subtitles[_next]); + subtitle->emit_plain (p, _subtitles[_next]); + + ++_next; + return false; +} + +ContentTimePeriod +TextCaptionFileDecoder::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_caption_file_decoder.h b/src/lib/text_caption_file_decoder.h new file mode 100644 index 000000000..7f889e72d --- /dev/null +++ b/src/lib/text_caption_file_decoder.h @@ -0,0 +1,44 @@ +/* + Copyright (C) 2014-2018 Carl Hetherington <cth@carlh.net> + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>. + +*/ + +#ifndef DCPOMATIC_PLAIN_TEXT_FILE_DECODER_H +#define DCPOMATIC_PLAIN_TEXT_FILE_DECODER_H + +#include "plain_text_file.h" +#include "decoder.h" + +class TextCaptionFileContent; +class Log; + +class TextCaptionFileDecoder : public Decoder, public TextCaptionFile +{ +public: + TextCaptionFileDecoder (boost::shared_ptr<const TextCaptionFileContent>, 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_decoder.cc b/src/lib/text_decoder.cc index 2423fc738..932a57564 100644 --- a/src/lib/text_decoder.cc +++ b/src/lib/text_decoder.cc @@ -60,7 +60,7 @@ TextDecoder::TextDecoder ( void TextDecoder::emit_bitmap_start (ContentTime from, shared_ptr<Image> image, dcpomatic::Rect<double> rect) { - BitmapStart (ContentBitmapText (from, _content->type(), image, rect)); + BitmapStart (ContentBitmapCaption (from, _content->type(), image, rect)); _position = from; } @@ -94,7 +94,7 @@ TextDecoder::emit_plain_start (ContentTime from, list<dcp::SubtitleString> s) } } - PlainStart (ContentPlainText (from, _content->type(), s)); + PlainStart (ContentTextCaption (from, _content->type(), s)); _position = from; } diff --git a/src/lib/text_decoder.h b/src/lib/text_decoder.h index 96eba80e2..ed2763916 100644 --- a/src/lib/text_decoder.h +++ b/src/lib/text_decoder.h @@ -62,8 +62,8 @@ public: return _content; } - boost::signals2::signal<void (ContentBitmapText)> BitmapStart; - boost::signals2::signal<void (ContentPlainText)> PlainStart; + boost::signals2::signal<void (ContentBitmapCaption)> BitmapStart; + boost::signals2::signal<void (ContentTextCaption)> PlainStart; boost::signals2::signal<void (ContentTime, TextType)> Stop; private: diff --git a/src/lib/writer.cc b/src/lib/writer.cc index 7b2944d32..ea4a6d29b 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -665,7 +665,7 @@ Writer::can_fake_write (Frame frame) const } void -Writer::write (PlayerText text, TextType type, DCPTimePeriod period) +Writer::write (PlayerCaption text, TextType type, DCPTimePeriod period) { while (_text_reel[type]->period().to <= period.from) { ++_text_reel[type]; diff --git a/src/lib/writer.h b/src/lib/writer.h index 484ca1285..a776e54c3 100644 --- a/src/lib/writer.h +++ b/src/lib/writer.h @@ -23,7 +23,7 @@ */ #include "types.h" -#include "player_text.h" +#include "player_caption.h" #include "exception_store.h" #include <boost/shared_ptr.hpp> #include <boost/weak_ptr.hpp> @@ -104,7 +104,7 @@ public: bool can_repeat (Frame) const; void repeat (Frame, Eyes); void write (boost::shared_ptr<const AudioBuffers>, DCPTime time); - void write (PlayerText text, TextType type, DCPTimePeriod period); + void write (PlayerCaption text, TextType type, DCPTimePeriod period); void write (std::list<boost::shared_ptr<Font> > fonts); void write (ReferencedReelAsset asset); void finish (); diff --git a/src/lib/wscript b/src/lib/wscript index ddbc1d4ff..71c94c28b 100644 --- a/src/lib/wscript +++ b/src/lib/wscript @@ -21,7 +21,7 @@ import os import i18n sources = """ - active_text.cc + active_captions.cc analyse_audio_job.cc atmos_mxf_content.cc audio_analysis.cc @@ -112,7 +112,7 @@ sources = """ mid_side_decoder.cc overlaps.cc player.cc - player_text.cc + player_caption.cc player_video.cc playlist.cc position_image.cc @@ -135,8 +135,8 @@ sources = """ text_content.cc text_decoder.cc plain_text_file.cc - plain_text_file_content.cc - plain_text_file_decoder.cc + text_caption_file_content.cc + text_caption_file_decoder.cc timer.cc transcode_job.cc types.cc diff --git a/src/wx/caption_panel.cc b/src/wx/caption_panel.cc index c4a71677b..20a0ad143 100644 --- a/src/wx/caption_panel.cc +++ b/src/wx/caption_panel.cc @@ -26,10 +26,10 @@ #include "fonts_dialog.h" #include "subtitle_appearance_dialog.h" #include "lib/ffmpeg_content.h" -#include "lib/plain_text_file_content.h" +#include "lib/text_caption_file_content.h" #include "lib/ffmpeg_subtitle_stream.h" #include "lib/dcp_text_content.h" -#include "lib/plain_text_file_decoder.h" +#include "lib/text_caption_file_decoder.h" #include "lib/dcp_text_decoder.h" #include "lib/dcp_content.h" #include "lib/text_content.h" @@ -303,7 +303,7 @@ CaptionPanel::setup_sensitivity () BOOST_FOREACH (shared_ptr<Content> i, sel) { /* These are the content types that could include subtitles */ shared_ptr<const FFmpegContent> fc = boost::dynamic_pointer_cast<const FFmpegContent> (i); - shared_ptr<const PlainTextFileContent> sc = boost::dynamic_pointer_cast<const PlainTextFileContent> (i); + shared_ptr<const TextCaptionFileContent> sc = boost::dynamic_pointer_cast<const TextCaptionFileContent> (i); shared_ptr<const DCPContent> dc = boost::dynamic_pointer_cast<const DCPContent> (i); shared_ptr<const DCPTextContent> dsc = boost::dynamic_pointer_cast<const DCPTextContent> (i); if (fc) { diff --git a/src/wx/content_panel.cc b/src/wx/content_panel.cc index 770015292..3dc0e2b63 100644 --- a/src/wx/content_panel.cc +++ b/src/wx/content_panel.cc @@ -39,7 +39,7 @@ #include "lib/config.h" #include "lib/log.h" #include "lib/compose.hpp" -#include "lib/plain_text_file_content.h" +#include "lib/text_caption_file_content.h" #include "lib/plain_text_file.h" #include <wx/wx.h> #include <wx/notebook.h> @@ -258,11 +258,11 @@ ContentPanel::selection_changed () BOOST_FOREACH (shared_ptr<Content> i, selected ()) { DCPTime p; p = i->position(); - if (dynamic_pointer_cast<PlainTextFileContent>(i) && i->paths_valid()) { + if (dynamic_pointer_cast<TextCaptionFileContent>(i) && i->paths_valid()) { /* Rather special case; if we select a text subtitle file jump to its first subtitle. */ - PlainTextFile ts (dynamic_pointer_cast<PlainTextFileContent>(i)); + TextCaptionFile ts (dynamic_pointer_cast<TextCaptionFileContent>(i)); if (ts.first()) { p += DCPTime(ts.first().get(), _film->active_frame_rate_change(i->position())); } diff --git a/src/wx/subtitle_appearance_dialog.cc b/src/wx/subtitle_appearance_dialog.cc index 77109909f..de6f1c8e8 100644 --- a/src/wx/subtitle_appearance_dialog.cc +++ b/src/wx/subtitle_appearance_dialog.cc @@ -20,7 +20,7 @@ #include "subtitle_appearance_dialog.h" #include "rgba_colour_picker.h" -#include "lib/plain_text_file_content.h" +#include "lib/text_caption_file_content.h" #include "lib/text_content.h" #include "lib/ffmpeg_subtitle_stream.h" #include "lib/ffmpeg_content.h" diff --git a/src/wx/subtitle_view.cc b/src/wx/subtitle_view.cc index b2e74eb88..f33d6eddf 100644 --- a/src/wx/subtitle_view.cc +++ b/src/wx/subtitle_view.cc @@ -18,13 +18,13 @@ */ -#include "lib/plain_text_file_decoder.h" +#include "lib/text_caption_file_decoder.h" #include "lib/content_text.h" #include "lib/video_decoder.h" #include "lib/audio_decoder.h" #include "lib/film.h" #include "lib/config.h" -#include "lib/plain_text_file_content.h" +#include "lib/text_caption_file_content.h" #include "lib/text_decoder.h" #include "subtitle_view.h" #include "film_viewer.h" @@ -92,7 +92,7 @@ SubtitleView::SubtitleView (wxWindow* parent, shared_ptr<Film> film, shared_ptr< } void -SubtitleView::data_start (ContentPlainText cts) +SubtitleView::data_start (ContentTextCaption cts) { BOOST_FOREACH (dcp::SubtitleString const & i, cts.subs) { wxListItem list_item; diff --git a/src/wx/subtitle_view.h b/src/wx/subtitle_view.h index 7272c608c..222fc3890 100644 --- a/src/wx/subtitle_view.h +++ b/src/wx/subtitle_view.h @@ -32,7 +32,7 @@ public: SubtitleView (wxWindow *, boost::shared_ptr<Film>, boost::shared_ptr<Content> content, boost::shared_ptr<Decoder>, FilmViewer* viewer); private: - void data_start (ContentPlainText cts); + void data_start (ContentTextCaption cts); void data_stop (ContentTime time); void subtitle_selected (wxListEvent &); diff --git a/src/wx/timing_panel.cc b/src/wx/timing_panel.cc index 93ac02784..2a97f405f 100644 --- a/src/wx/timing_panel.cc +++ b/src/wx/timing_panel.cc @@ -29,7 +29,7 @@ #include "lib/text_content.h" #include "lib/dcp_text_content.h" #include "lib/audio_content.h" -#include "lib/plain_text_file_content.h" +#include "lib/text_caption_file_content.h" #include "lib/video_content.h" #include <dcp/locale_convert.h> #include <boost/foreach.hpp> diff --git a/test/burnt_subtitle_test.cc b/test/burnt_subtitle_test.cc index e01e1e3d1..8ca436207 100644 --- a/test/burnt_subtitle_test.cc +++ b/test/burnt_subtitle_test.cc @@ -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<PlainText> content (new PlainText (film, "test/data/subrip2.srt")); + shared_ptr<TextCaption> content (new TextCaption (film, "test/data/subrip2.srt")); content->subtitle->set_use (true); content->subtitle->set_burn (true); film->examine_and_add_content (content); @@ -106,7 +106,7 @@ BOOST_AUTO_TEST_CASE (burnt_subtitle_test_onto_dcp) film2->set_name ("frobozz"); shared_ptr<DCPContent> background_dcp (new DCPContent(film2, film->dir(film->dcp_name()))); film2->examine_and_add_content (background_dcp); - shared_ptr<PlainText> sub = dynamic_pointer_cast<PlainText> ( + shared_ptr<TextCaption> sub = dynamic_pointer_cast<TextCaption> ( 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 9ea708ed5..e5d0408bb 100644 --- a/test/dcp_subtitle_test.cc +++ b/test/dcp_subtitle_test.cc @@ -43,10 +43,10 @@ using std::list; using boost::shared_ptr; using boost::optional; -optional<ContentPlainText> stored; +optional<ContentTextCaption> stored; static void -store (ContentPlainText sub) +store (ContentTextCaption sub) { if (!stored) { stored = sub; @@ -93,7 +93,7 @@ BOOST_AUTO_TEST_CASE (dcp_subtitle_within_dcp_test) shared_ptr<DCPDecoder> decoder (new DCPDecoder (content, film->log(), false)); decoder->subtitle->PlainStart.connect (bind (store, _1)); - stored = optional<ContentPlainText> (); + stored = optional<ContentTextCaption> (); while (!decoder->pass() && !stored) {} BOOST_REQUIRE (stored); @@ -116,7 +116,7 @@ BOOST_AUTO_TEST_CASE (dcp_subtitle_test2) shared_ptr<DCPTextDecoder> decoder (new DCPTextDecoder (content, film->log())); decoder->subtitle->PlainStart.connect (bind (store, _1)); - stored = optional<ContentPlainText> (); + stored = optional<ContentTextCaption> (); while (!decoder->pass ()) { if (stored && stored->from() == ContentTime(0)) { BOOST_CHECK_EQUAL (stored->subs.front().text(), "&lt;b&gt;Hello world!&lt;/b&gt;"); @@ -140,7 +140,7 @@ BOOST_AUTO_TEST_CASE (dcp_subtitle_test3) BOOST_REQUIRE (!wait_for_jobs ()); shared_ptr<DCPTextDecoder> decoder (new DCPTextDecoder (content, film->log())); - stored = optional<ContentPlainText> (); + stored = optional<ContentTextCaption> (); while (!decoder->pass ()) { decoder->subtitle->PlainStart.connect (bind (store, _1)); if (stored && stored->from() == ContentTime::from_seconds(0.08)) { diff --git a/test/ffmpeg_encoder_test.cc b/test/ffmpeg_encoder_test.cc index 00ca976e0..65ca59d34 100644 --- a/test/ffmpeg_encoder_test.cc +++ b/test/ffmpeg_encoder_test.cc @@ -24,7 +24,7 @@ #include "lib/image_content.h" #include "lib/video_content.h" #include "lib/audio_content.h" -#include "lib/plain_text_file_content.h" +#include "lib/text_caption_file_content.h" #include "lib/ratio.h" #include "lib/transcode_job.h" #include "lib/dcp_content.h" @@ -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<PlainTextFileContent> s (new PlainTextFileContent (film, "test/data/subrip2.srt")); + shared_ptr<TextCaptionFileContent> s (new TextCaptionFileContent (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<PlainTextFileContent> s (new PlainTextFileContent (film, "test/data/subrip.srt")); + shared_ptr<TextCaptionFileContent> s (new TextCaptionFileContent (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<PlainTextFileContent> s (new PlainTextFileContent (film, "test/data/subrip2.srt")); + shared_ptr<TextCaptionFileContent> s (new TextCaptionFileContent (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<PlainTextFileContent> s (new PlainTextFileContent (film, "test/data/subrip.srt")); + shared_ptr<TextCaptionFileContent> s (new TextCaptionFileContent (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/player_test.cc b/test/player_test.cc index a66860911..d3b6df6da 100644 --- a/test/player_test.cc +++ b/test/player_test.cc @@ -31,7 +31,7 @@ #include "lib/player.h" #include "lib/video_content.h" #include "lib/image_content.h" -#include "lib/plain_text_file_content.h" +#include "lib/text_caption_file_content.h" #include "lib/content_factory.h" #include "lib/dcp_content.h" #include "lib/text_content.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<PlainTextFileContent> s (new PlainTextFileContent (film, "test/data/subrip.srt")); + shared_ptr<TextCaptionFileContent> s (new TextCaptionFileContent (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 9a915ab2b..a408402c9 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/plain_text_file_content.h" +#include "lib/text_caption_file_content.h" #include "lib/content_factory.h" #include "test.h" #include <boost/test/unit_test.hpp> @@ -165,7 +165,7 @@ BOOST_AUTO_TEST_CASE (reels_test3) shared_ptr<Content> dcp (new DCPContent (film, "test/data/reels_test2")); film->examine_and_add_content (dcp); - shared_ptr<Content> sub (new PlainTextFileContent (film, "test/data/subrip.srt")); + shared_ptr<Content> sub (new TextCaptionFileContent (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<PlainTextFileContent> subs (new PlainTextFileContent (film, "test/data/subrip3.srt")); + shared_ptr<TextCaptionFileContent> subs (new TextCaptionFileContent (film, "test/data/subrip3.srt")); film->examine_and_add_content (subs); wait_for_jobs (); diff --git a/test/render_subtitles_test.cc b/test/render_subtitles_test.cc index a8db80c8b..5b3136497 100644 --- a/test/render_subtitles_test.cc +++ b/test/render_subtitles_test.cc @@ -28,10 +28,10 @@ #include <boost/test/unit_test.hpp> static void -add (std::list<PlainText>& s, std::string text, bool italic, bool bold, bool underline) +add (std::list<TextCaption>& s, std::string text, bool italic, bool bold, bool underline) { s.push_back ( - PlainText ( + TextCaption ( dcp::SubtitleString ( boost::optional<std::string> (), italic, @@ -60,7 +60,7 @@ add (std::list<PlainText>& s, std::string text, bool italic, bool bold, bool und /** Test marked_up() in render_text.cc */ BOOST_AUTO_TEST_CASE (render_markup_test1) { - std::list<PlainText> s; + std::list<TextCaption> s; add (s, "Hello", false, false, false); BOOST_CHECK_EQUAL (marked_up (s, 1024, 1), "<span size=\"41472\" alpha=\"65535\" color=\"#FFFFFF\">Hello</span>"); } @@ -68,7 +68,7 @@ BOOST_AUTO_TEST_CASE (render_markup_test1) /** Test marked_up() in render_text.cc */ BOOST_AUTO_TEST_CASE (render_markup_test2) { - std::list<PlainText> s; + std::list<TextCaption> s; add (s, "Hello", false, true, false); BOOST_CHECK_EQUAL (marked_up (s, 1024, 1), "<span weight=\"bold\" size=\"41472\" alpha=\"65535\" color=\"#FFFFFF\">Hello</span>"); } @@ -77,7 +77,7 @@ BOOST_AUTO_TEST_CASE (render_markup_test2) /** Test marked_up() in render_text.cc */ BOOST_AUTO_TEST_CASE (render_markup_test3) { - std::list<PlainText> s; + std::list<TextCaption> s; add (s, "Hello", true, true, false); BOOST_CHECK_EQUAL (marked_up (s, 1024, 1), "<span style=\"italic\" weight=\"bold\" size=\"41472\" alpha=\"65535\" color=\"#FFFFFF\">Hello</span>"); } @@ -85,7 +85,7 @@ BOOST_AUTO_TEST_CASE (render_markup_test3) /** Test marked_up() in render_text.cc */ BOOST_AUTO_TEST_CASE (render_markup_test4) { - std::list<PlainText> s; + std::list<TextCaption> s; add (s, "Hello", true, true, true); BOOST_CHECK_EQUAL (marked_up (s, 1024, 1), "<span style=\"italic\" weight=\"bold\" underline=\"single\" size=\"41472\" alpha=\"65535\" color=\"#FFFFFF\">Hello</span>"); } @@ -93,7 +93,7 @@ BOOST_AUTO_TEST_CASE (render_markup_test4) /** Test marked_up() in render_text.cc */ BOOST_AUTO_TEST_CASE (render_markup_test5) { - std::list<PlainText> s; + std::list<TextCaption> s; add (s, "Hello", false, true, false); add (s, " world.", false, false, false); BOOST_CHECK_EQUAL (marked_up (s, 1024, 1), "<span weight=\"bold\" size=\"41472\" alpha=\"65535\" color=\"#FFFFFF\">Hello</span><span size=\"41472\" alpha=\"65535\" color=\"#FFFFFF\"> world.</span>"); @@ -102,7 +102,7 @@ BOOST_AUTO_TEST_CASE (render_markup_test5) /** Test marked_up() in render_text.cc */ BOOST_AUTO_TEST_CASE (render_markup_test6) { - std::list<PlainText> s; + std::list<TextCaption> s; add (s, "Hello", true, false, false); add (s, " world ", false, false, false); add (s, "we are bold.", false, true, false); diff --git a/test/srt_subtitle_test.cc b/test/srt_subtitle_test.cc index 268da3472..6fe430d77 100644 --- a/test/srt_subtitle_test.cc +++ b/test/srt_subtitle_test.cc @@ -24,7 +24,7 @@ */ #include "lib/film.h" -#include "lib/plain_text_file_content.h" +#include "lib/text_caption_file_content.h" #include "lib/dcp_content_type.h" #include "lib/font.h" #include "lib/ratio.h" @@ -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<PlainTextFileContent> content (new PlainTextFileContent (film, "test/data/subrip2.srt")); + shared_ptr<TextCaptionFileContent> content (new TextCaptionFileContent (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<PlainTextFileContent> content (new PlainTextFileContent (film, "test/data/subrip2.srt")); + shared_ptr<TextCaptionFileContent> content (new TextCaptionFileContent (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<PlainTextFileContent> content (new PlainTextFileContent (film, private_data / "Ankoemmling_short.srt")); + shared_ptr<TextCaptionFileContent> content (new TextCaptionFileContent (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<PlainTextFileContent> content (new PlainTextFileContent (film, "test/data/subrip2.srt")); + shared_ptr<TextCaptionFileContent> content (new TextCaptionFileContent (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<PlainTextFileContent> content (new PlainTextFileContent (film, "test/data/subrip2.srt")); + shared_ptr<TextCaptionFileContent> content (new TextCaptionFileContent (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> film = new_test_film2 ("srt_subtitle_test6"); film->set_interop (false); - shared_ptr<PlainTextFileContent> content (new PlainTextFileContent (film, "test/data/frames.srt")); + shared_ptr<TextCaptionFileContent> content (new TextCaptionFileContent (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> film = new_test_film ("subrip_render_test"); - shared_ptr<PlainTextFile> content (new PlainTextFile (film, "test/data/subrip.srt")); + shared_ptr<TextCaptionFile> content (new TextCaptionFile (film, "test/data/subrip.srt")); content->examine (shared_ptr<Job> (), 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 536a3ce6a..b3e4f9d33 100644 --- a/test/ssa_subtitle_test.cc +++ b/test/ssa_subtitle_test.cc @@ -24,7 +24,7 @@ */ #include "lib/film.h" -#include "lib/plain_text_file_content.h" +#include "lib/text_caption_file_content.h" #include "lib/dcp_content_type.h" #include "lib/font.h" #include "lib/ratio.h" @@ -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<PlainTextFileContent> content (new PlainTextFileContent (film, private_data / "DKH_UT_EN20160601def.ssa")); + shared_ptr<TextCaptionFileContent> content (new TextCaptionFileContent (film, private_data / "DKH_UT_EN20160601def.ssa")); film->examine_and_add_content (content); wait_for_jobs (); diff --git a/test/subtitle_charset_test.cc b/test/subtitle_charset_test.cc index 892ea76f5..3e7df0a61 100644 --- a/test/subtitle_charset_test.cc +++ b/test/subtitle_charset_test.cc @@ -23,7 +23,7 @@ #include "lib/film.h" #include "lib/content_factory.h" #include "lib/plain_text_file.h" -#include "lib/plain_text_file_content.h" +#include "lib/text_caption_file_content.h" #include <boost/test/unit_test.hpp> using boost::shared_ptr; @@ -45,7 +45,7 @@ BOOST_AUTO_TEST_CASE (subtitle_charset_test2) shared_ptr<Content> content = content_factory (film, "test/data/osx.srt").front (); film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs ()); - shared_ptr<PlainTextFile> ts = dynamic_pointer_cast<PlainTextFile> (content); + shared_ptr<TextCaptionFile> ts = dynamic_pointer_cast<TextCaptionFile> (content); BOOST_REQUIRE (ts); /* Make sure we got the subtitle data from the file */ BOOST_REQUIRE_EQUAL (content->full_length().get(), 6052032); diff --git a/test/subtitle_reel_number_test.cc b/test/subtitle_reel_number_test.cc index ee9c8ecc7..27c6e2d0e 100644 --- a/test/subtitle_reel_number_test.cc +++ b/test/subtitle_reel_number_test.cc @@ -18,7 +18,7 @@ */ -#include "lib/plain_text_file_content.h" +#include "lib/text_caption_file_content.h" #include "lib/film.h" #include "lib/ratio.h" #include "lib/text_content.h" @@ -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<PlainTextFileContent> content (new PlainTextFileContent (film, "test/data/subrip5.srt")); + shared_ptr<TextCaptionFileContent> content (new TextCaptionFileContent (film, "test/data/subrip5.srt")); film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs ()); content->subtitle->set_use (true);