From: Carl Hetherington Date: Fri, 12 Feb 2016 00:13:14 +0000 (+0000) Subject: Rename SubRip -> TextSubtitle. X-Git-Tag: v2.6.21~11 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=80400212e939dc2f3b987cb6df57709929aa5178 Rename SubRip -> TextSubtitle. --- diff --git a/src/lib/content_factory.cc b/src/lib/content_factory.cc index 3aa8ca9d3..2b17d69e4 100644 --- a/src/lib/content_factory.cc +++ b/src/lib/content_factory.cc @@ -24,7 +24,7 @@ #include "ffmpeg_content.h" #include "image_content.h" #include "sndfile_content.h" -#include "subrip_content.h" +#include "text_subtitle_content.h" #include "dcp_content.h" #include "dcp_subtitle_content.h" #include "util.h" @@ -56,8 +56,8 @@ content_factory (shared_ptr film, cxml::NodePtr node, int version, l content.reset (new ImageContent (film, node, version)); } else if (type == "Sndfile") { content.reset (new SndfileContent (film, node, version)); - } else if (type == "SubRip") { - content.reset (new SubRipContent (film, node, version)); + } else if (type == "SubRip" || type == "TextSubtitle") { + content.reset (new TextSubtitleContent (film, node, version)); } else if (type == "DCP") { content.reset (new DCPContent (film, node, version)); } else if (type == "DCPSubtitle") { @@ -118,8 +118,8 @@ content_factory (shared_ptr film, boost::filesystem::path path) content.reset (new ImageContent (film, path)); } else if (SndfileContent::valid_file (path)) { content.reset (new SndfileContent (film, path)); - } else if (ext == ".srt") { - content.reset (new SubRipContent (film, path)); + } else if (ext == ".srt" || ext == ".ssa") { + content.reset (new TextSubtitleContent (film, path)); } else if (ext == ".xml") { content.reset (new DCPSubtitleContent (film, path)); } else if (ext == ".mxf" && dcp::SMPTESubtitleAsset::valid_mxf (path)) { diff --git a/src/lib/exceptions.cc b/src/lib/exceptions.cc index c15e134ee..968e81439 100644 --- a/src/lib/exceptions.cc +++ b/src/lib/exceptions.cc @@ -63,8 +63,8 @@ PixelFormatError::PixelFormatError (string o, AVPixelFormat f) } -SubRipError::SubRipError (string saw, string expecting, boost::filesystem::path f) - : FileError (String::compose (_("Error in SubRip file: saw %1 while expecting %2"), saw.empty() ? "[nothing]" : saw, expecting), f) +TextSubtitleError::TextSubtitleError (string saw, string expecting, boost::filesystem::path f) + : FileError (String::compose (_("Error in subtitle file: saw %1 while expecting %2"), saw.empty() ? "[nothing]" : saw, expecting), f) { } diff --git a/src/lib/exceptions.h b/src/lib/exceptions.h index da8761304..3e7289a50 100644 --- a/src/lib/exceptions.h +++ b/src/lib/exceptions.h @@ -211,13 +211,13 @@ public: PixelFormatError (std::string o, AVPixelFormat f); }; -/** @class SubRipError - * @brief An error that occurs while parsing a SubRip file. +/** @class TextSubtitleError + * @brief An error that occurs while parsing a TextSubtitleError file. */ -class SubRipError : public FileError +class TextSubtitleError : public FileError { public: - SubRipError (std::string, std::string, boost::filesystem::path); + TextSubtitleError (std::string, std::string, boost::filesystem::path); }; class DCPError : public std::runtime_error diff --git a/src/lib/player.cc b/src/lib/player.cc index ecf37b576..fc1332573 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -27,8 +27,8 @@ #include "sndfile_decoder.h" #include "sndfile_content.h" #include "subtitle_content.h" -#include "subrip_decoder.h" -#include "subrip_content.h" +#include "text_subtitle_decoder.h" +#include "text_subtitle_content.h" #include "dcp_content.h" #include "job.h" #include "image.h" @@ -174,10 +174,10 @@ Player::setup_pieces () as simultaneous video content (like we do with audio). */ - /* SubRipContent */ - shared_ptr rc = dynamic_pointer_cast (i); + /* TextSubtitleContent */ + shared_ptr rc = dynamic_pointer_cast (i); if (rc) { - decoder.reset (new SubRipDecoder (rc)); + decoder.reset (new TextSubtitleDecoder (rc)); frc = FrameRateChange (rc->subtitle_video_frame_rate(), _film->video_frame_rate()); } @@ -220,9 +220,9 @@ Player::playlist_content_changed (weak_ptr w, int property, bool freque property == ContentProperty::PATH || property == VideoContentProperty::VIDEO_FRAME_TYPE || property == DCPContentProperty::CAN_BE_PLAYED || - property == SubRipContentProperty::SUBTITLE_COLOUR || - property == SubRipContentProperty::SUBTITLE_OUTLINE || - property == SubRipContentProperty::SUBTITLE_OUTLINE_COLOUR + property == TextSubtitleContentProperty::TEXT_SUBTITLE_COLOUR || + property == TextSubtitleContentProperty::TEXT_SUBTITLE_OUTLINE || + property == TextSubtitleContentProperty::TEXT_SUBTITLE_OUTLINE_COLOUR ) { _have_valid_pieces = false; diff --git a/src/lib/subrip.cc b/src/lib/subrip.cc deleted file mode 100644 index c4166cb28..000000000 --- a/src/lib/subrip.cc +++ /dev/null @@ -1,80 +0,0 @@ -/* - Copyright (C) 2014 Carl Hetherington - - This program 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. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -#include "subrip.h" -#include "cross.h" -#include "exceptions.h" -#include "subrip_content.h" -#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; - -SubRip::SubRip (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::SubripReader reader (utf8.get()); - _subtitles = sub::collect > (reader.subtitles ()); -} - -ContentTime -SubRip::length () const -{ - if (_subtitles.empty ()) { - return ContentTime (); - } - - return ContentTime::from_seconds (_subtitles.back().to.all_as_seconds ()); -} diff --git a/src/lib/subrip.h b/src/lib/subrip.h deleted file mode 100644 index 35687eb00..000000000 --- a/src/lib/subrip.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - Copyright (C) 2014 Carl Hetherington - - This program 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. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -#ifndef DCPOMATIC_SUBRIP_H -#define DCPOMATIC_SUBRIP_H - -#include "dcpomatic_time.h" -#include -#include -#include - -class SubRipContent; -class subrip_time_test; -class subrip_coordinate_test; -class subrip_content_test; -class subrip_parse_test; - -class SubRip -{ -public: - SubRip (boost::shared_ptr); - - ContentTime length () const; - -protected: - std::vector _subtitles; -}; - -#endif diff --git a/src/lib/subrip_content.cc b/src/lib/subrip_content.cc deleted file mode 100644 index a6eb07629..000000000 --- a/src/lib/subrip_content.cc +++ /dev/null @@ -1,191 +0,0 @@ -/* - Copyright (C) 2014-2015 Carl Hetherington - - This program 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. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -#include "subrip_content.h" -#include "util.h" -#include "subrip.h" -#include "film.h" -#include "font.h" -#include "raw_convert.h" -#include -#include - -#include "i18n.h" - -using std::string; -using std::cout; -using boost::shared_ptr; -using boost::lexical_cast; - -std::string const SubRipContent::font_id = "font"; - -int const SubRipContentProperty::SUBTITLE_COLOUR = 300; -int const SubRipContentProperty::SUBTITLE_OUTLINE = 301; -int const SubRipContentProperty::SUBTITLE_OUTLINE_COLOUR = 302; - -SubRipContent::SubRipContent (shared_ptr film, boost::filesystem::path path) - : Content (film, path) - , SubtitleContent (film, path) - , _colour (255, 255, 255) - , _outline (false) - , _outline_colour (0, 0, 0) -{ - -} - -SubRipContent::SubRipContent (shared_ptr film, cxml::ConstNodePtr node, int version) - : Content (film, node) - , SubtitleContent (film, node, version) - , _length (node->number_child ("Length")) - , _frame_rate (node->optional_number_child("SubtitleFrameRate")) - , _colour ( - node->optional_number_child("Red").get_value_or(255), - node->optional_number_child("Green").get_value_or(255), - node->optional_number_child("Blue").get_value_or(255) - ) - , _outline (node->optional_bool_child("Outline").get_value_or(false)) - , _outline_colour ( - node->optional_number_child("OutlineRed").get_value_or(255), - node->optional_number_child("OutlineGreen").get_value_or(255), - node->optional_number_child("OutlineBlue").get_value_or(255) - ) -{ - -} - -void -SubRipContent::examine (boost::shared_ptr job) -{ - Content::examine (job); - SubRip s (shared_from_this ()); - - /* Default to turning these subtitles on */ - set_use_subtitles (true); - - boost::mutex::scoped_lock lm (_mutex); - _length = s.length (); - add_font (shared_ptr (new Font (font_id))); -} - -string -SubRipContent::summary () const -{ - return path_summary() + " " + _("[subtitles]"); -} - -string -SubRipContent::technical_summary () const -{ - return Content::technical_summary() + " - " + _("SubRip subtitles"); -} - -void -SubRipContent::as_xml (xmlpp::Node* node) const -{ - node->add_child("Type")->add_child_text ("SubRip"); - Content::as_xml (node); - SubtitleContent::as_xml (node); - node->add_child("Length")->add_child_text (raw_convert (_length.get ())); - node->add_child("Red")->add_child_text (raw_convert (_colour.r)); - node->add_child("Green")->add_child_text (raw_convert (_colour.g)); - node->add_child("Blue")->add_child_text (raw_convert (_colour.b)); - node->add_child("Outline")->add_child_text (raw_convert (_outline)); - node->add_child("OutlineRed")->add_child_text (raw_convert (_outline_colour.r)); - node->add_child("OutlineGreen")->add_child_text (raw_convert (_outline_colour.g)); - node->add_child("OutlineBlue")->add_child_text (raw_convert (_outline_colour.b)); -} - -DCPTime -SubRipContent::full_length () const -{ - FrameRateChange const frc (subtitle_video_frame_rate(), film()->video_frame_rate ()); - return DCPTime (_length, frc); -} - -void -SubRipContent::set_subtitle_video_frame_rate (int r) -{ - { - boost::mutex::scoped_lock lm (_mutex); - _frame_rate = r; - } - - signal_changed (SubtitleContentProperty::SUBTITLE_VIDEO_FRAME_RATE); -} - -double -SubRipContent::subtitle_video_frame_rate () const -{ - { - boost::mutex::scoped_lock lm (_mutex); - if (_frame_rate) { - return _frame_rate.get (); - } - } - - /* No frame rate specified, so assume this content has been - prepared for any concurrent video content. - */ - return film()->active_frame_rate_change(position()).source; -} - -void -SubRipContent::set_colour (dcp::Colour colour) -{ - { - boost::mutex::scoped_lock lm (_mutex); - if (_colour == colour) { - return; - } - - _colour = colour; - } - - signal_changed (SubRipContentProperty::SUBTITLE_COLOUR); -} - -void -SubRipContent::set_outline (bool o) -{ - { - boost::mutex::scoped_lock lm (_mutex); - if (_outline == o) { - return; - } - - _outline = o; - } - - signal_changed (SubRipContentProperty::SUBTITLE_OUTLINE); -} - -void -SubRipContent::set_outline_colour (dcp::Colour colour) -{ - { - boost::mutex::scoped_lock lm (_mutex); - if (_outline_colour == colour) { - return; - } - - _outline_colour = colour; - } - - signal_changed (SubRipContentProperty::SUBTITLE_OUTLINE_COLOUR); -} diff --git a/src/lib/subrip_content.h b/src/lib/subrip_content.h deleted file mode 100644 index 68864f58c..000000000 --- a/src/lib/subrip_content.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - Copyright (C) 2014-2015 Carl Hetherington - - This program 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. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -#include "subtitle_content.h" - -class SubRipContentProperty -{ -public: - static int const SUBTITLE_COLOUR; - static int const SUBTITLE_OUTLINE; - static int const SUBTITLE_OUTLINE_COLOUR; -}; - - -class SubRipContent : public SubtitleContent -{ -public: - SubRipContent (boost::shared_ptr, boost::filesystem::path); - SubRipContent (boost::shared_ptr, cxml::ConstNodePtr, int); - - boost::shared_ptr shared_from_this () { - return boost::dynamic_pointer_cast (Content::shared_from_this ()); - } - - /* Content */ - void examine (boost::shared_ptr); - std::string summary () const; - std::string technical_summary () const; - void as_xml (xmlpp::Node *) const; - DCPTime full_length () const; - - /* SubtitleContent */ - - bool has_text_subtitles () const { - return true; - } - - bool has_image_subtitles () const { - return false; - } - - double subtitle_video_frame_rate () const; - void set_subtitle_video_frame_rate (int r); - - void set_colour (dcp::Colour); - - dcp::Colour colour () const { - boost::mutex::scoped_lock lm (_mutex); - return _colour; - } - - void set_outline (bool); - - bool outline () const { - boost::mutex::scoped_lock lm (_mutex); - return _outline; - } - - void set_outline_colour (dcp::Colour); - - dcp::Colour outline_colour () const { - boost::mutex::scoped_lock lm (_mutex); - return _outline_colour; - } - - static std::string const font_id; - -private: - ContentTime _length; - /** Video frame rate that this content has been prepared for, if known */ - boost::optional _frame_rate; - dcp::Colour _colour; - bool _outline; - dcp::Colour _outline_colour; -}; diff --git a/src/lib/subrip_decoder.cc b/src/lib/subrip_decoder.cc deleted file mode 100644 index 2f8b8a5f3..000000000 --- a/src/lib/subrip_decoder.cc +++ /dev/null @@ -1,141 +0,0 @@ -/* - Copyright (C) 2014-2015 Carl Hetherington - - This program 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. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -#include "subrip_decoder.h" -#include "subrip_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; - -SubRipDecoder::SubRipDecoder (shared_ptr content) - : SubtitleDecoder (content) - , SubRip (content) - , _next (0) -{ - -} - -void -SubRipDecoder::seek (ContentTime time, bool accurate) -{ - SubtitleDecoder::seek (time, accurate); - - _next = 0; - while (_next < _subtitles.size() && ContentTime::from_seconds (_subtitles[_next].from.all_as_seconds ()) < time) { - ++_next; - } -} - -bool -SubRipDecoder::pass (PassReason, bool) -{ - if (_next >= _subtitles.size ()) { - return true; - } - - /* XXX: we are ignoring positioning specified in the file */ - - shared_ptr content = dynamic_pointer_cast (_subtitle_content); - DCPOMATIC_ASSERT (content); - - list out; - - /* Highest line index in this subtitle */ - int highest = 0; - BOOST_FOREACH (sub::Line i, _subtitles[_next].lines) { - DCPOMATIC_ASSERT (i.vertical_position.reference && i.vertical_position.reference.get() == sub::TOP_OF_SUBTITLE); - DCPOMATIC_ASSERT (i.vertical_position.line); - highest = max (highest, i.vertical_position.line.get()); - } - - BOOST_FOREACH (sub::Line i, _subtitles[_next].lines) { - BOOST_FOREACH (sub::Block j, i.blocks) { - out.push_back ( - dcp::SubtitleString ( - SubRipContent::font_id, - j.italic, - /* force the colour to whatever is configured */ - content->colour(), - j.font_size.points (72 * 11), - 1.0, - dcp::Time (_subtitles[_next].from.all_as_seconds(), 1000), - dcp::Time (_subtitles[_next].to.all_as_seconds(), 1000), - 0, - dcp::HALIGN_CENTER, - /* This 1.015 is an arbitrary value to lift the bottom sub off the bottom - of the screen a bit to a pleasing degree. - */ - 1.015 - ((1 + highest - i.vertical_position.line.get()) * 1.5 / 22), - dcp::VALIGN_TOP, - j.text, - content->outline() ? dcp::BORDER : dcp::NONE, - content->outline_colour(), - dcp::Time (0, 1000), - dcp::Time (0, 1000) - ) - ); - } - } - - text_subtitle (content_time_period (_subtitles[_next]), out); - - ++_next; - return false; -} - -list -SubRipDecoder::image_subtitles_during (ContentTimePeriod, bool) const -{ - return list (); -} - -list -SubRipDecoder::text_subtitles_during (ContentTimePeriod p, bool starting) const -{ - /* XXX: inefficient */ - - list d; - - for (vector::const_iterator i = _subtitles.begin(); i != _subtitles.end(); ++i) { - ContentTimePeriod t = content_time_period (*i); - if ((starting && p.contains (t.from)) || (!starting && p.overlaps (t))) { - d.push_back (t); - } - } - - return d; -} - -ContentTimePeriod -SubRipDecoder::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/subrip_decoder.h b/src/lib/subrip_decoder.h deleted file mode 100644 index f76d04aeb..000000000 --- a/src/lib/subrip_decoder.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - Copyright (C) 2014 Carl Hetherington - - This program 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. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -#ifndef DCPOMATIC_SUBRIP_DECODER_H -#define DCPOMATIC_SUBRIP_DECODER_H - -#include "subtitle_decoder.h" -#include "subrip.h" - -class SubRipContent; - -class SubRipDecoder : public SubtitleDecoder, public SubRip -{ -public: - SubRipDecoder (boost::shared_ptr); - -protected: - void seek (ContentTime time, bool accurate); - bool pass (PassReason, bool accurate); - -private: - std::list image_subtitles_during (ContentTimePeriod, bool starting) const; - std::list text_subtitles_during (ContentTimePeriod, bool starting) const; - 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 new file mode 100644 index 000000000..d55ff68d7 --- /dev/null +++ b/src/lib/text_subtitle.cc @@ -0,0 +1,80 @@ +/* + Copyright (C) 2014-2016 Carl Hetherington + + This program 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. + + This program 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 this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include "text_subtitle.h" +#include "cross.h" +#include "exceptions.h" +#include "text_subtitle_content.h" +#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; + +TextSubtitle::TextSubtitle (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::SubripReader reader (utf8.get()); + _subtitles = sub::collect > (reader.subtitles ()); +} + +ContentTime +TextSubtitle::length () const +{ + if (_subtitles.empty ()) { + return ContentTime (); + } + + return ContentTime::from_seconds (_subtitles.back().to.all_as_seconds ()); +} diff --git a/src/lib/text_subtitle.h b/src/lib/text_subtitle.h new file mode 100644 index 000000000..4614f6bd0 --- /dev/null +++ b/src/lib/text_subtitle.h @@ -0,0 +1,45 @@ +/* + Copyright (C) 2014-2016 Carl Hetherington + + This program 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. + + This program 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 this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef DCPOMATIC_TEXT_SUBTITLE_H +#define DCPOMATIC_TEXT_SUBTITLE_H + +#include "dcpomatic_time.h" +#include +#include +#include + +class TextSubtitleContent; +class text_subtitle_time_test; +class text_subtitle_coordinate_test; +class text_subtitle_content_test; +class text_subtitle_parse_test; + +class TextSubtitle +{ +public: + TextSubtitle (boost::shared_ptr); + + ContentTime length () const; + +protected: + std::vector _subtitles; +}; + +#endif diff --git a/src/lib/text_subtitle_content.cc b/src/lib/text_subtitle_content.cc new file mode 100644 index 000000000..93ac1d091 --- /dev/null +++ b/src/lib/text_subtitle_content.cc @@ -0,0 +1,191 @@ +/* + Copyright (C) 2014-2016 Carl Hetherington + + This program 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. + + This program 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 this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include "text_subtitle_content.h" +#include "util.h" +#include "text_subtitle.h" +#include "film.h" +#include "font.h" +#include "raw_convert.h" +#include +#include + +#include "i18n.h" + +using std::string; +using std::cout; +using boost::shared_ptr; +using boost::lexical_cast; + +std::string const TextSubtitleContent::font_id = "font"; + +int const TextSubtitleContentProperty::TEXT_SUBTITLE_COLOUR = 300; +int const TextSubtitleContentProperty::TEXT_SUBTITLE_OUTLINE = 301; +int const TextSubtitleContentProperty::TEXT_SUBTITLE_OUTLINE_COLOUR = 302; + +TextSubtitleContent::TextSubtitleContent (shared_ptr film, boost::filesystem::path path) + : Content (film, path) + , SubtitleContent (film, path) + , _colour (255, 255, 255) + , _outline (false) + , _outline_colour (0, 0, 0) +{ + +} + +TextSubtitleContent::TextSubtitleContent (shared_ptr film, cxml::ConstNodePtr node, int version) + : Content (film, node) + , SubtitleContent (film, node, version) + , _length (node->number_child ("Length")) + , _frame_rate (node->optional_number_child("SubtitleFrameRate")) + , _colour ( + node->optional_number_child("Red").get_value_or(255), + node->optional_number_child("Green").get_value_or(255), + node->optional_number_child("Blue").get_value_or(255) + ) + , _outline (node->optional_bool_child("Outline").get_value_or(false)) + , _outline_colour ( + node->optional_number_child("OutlineRed").get_value_or(255), + node->optional_number_child("OutlineGreen").get_value_or(255), + node->optional_number_child("OutlineBlue").get_value_or(255) + ) +{ + +} + +void +TextSubtitleContent::examine (boost::shared_ptr job) +{ + Content::examine (job); + TextSubtitle s (shared_from_this ()); + + /* Default to turning these subtitles on */ + set_use_subtitles (true); + + boost::mutex::scoped_lock lm (_mutex); + _length = s.length (); + add_font (shared_ptr (new Font (font_id))); +} + +string +TextSubtitleContent::summary () const +{ + return path_summary() + " " + _("[subtitles]"); +} + +string +TextSubtitleContent::technical_summary () const +{ + return Content::technical_summary() + " - " + _("Text subtitles"); +} + +void +TextSubtitleContent::as_xml (xmlpp::Node* node) const +{ + node->add_child("Type")->add_child_text ("TextSubtitle"); + Content::as_xml (node); + SubtitleContent::as_xml (node); + node->add_child("Length")->add_child_text (raw_convert (_length.get ())); + node->add_child("Red")->add_child_text (raw_convert (_colour.r)); + node->add_child("Green")->add_child_text (raw_convert (_colour.g)); + node->add_child("Blue")->add_child_text (raw_convert (_colour.b)); + node->add_child("Outline")->add_child_text (raw_convert (_outline)); + node->add_child("OutlineRed")->add_child_text (raw_convert (_outline_colour.r)); + node->add_child("OutlineGreen")->add_child_text (raw_convert (_outline_colour.g)); + node->add_child("OutlineBlue")->add_child_text (raw_convert (_outline_colour.b)); +} + +DCPTime +TextSubtitleContent::full_length () const +{ + FrameRateChange const frc (subtitle_video_frame_rate(), film()->video_frame_rate ()); + return DCPTime (_length, frc); +} + +void +TextSubtitleContent::set_subtitle_video_frame_rate (int r) +{ + { + boost::mutex::scoped_lock lm (_mutex); + _frame_rate = r; + } + + signal_changed (SubtitleContentProperty::SUBTITLE_VIDEO_FRAME_RATE); +} + +double +TextSubtitleContent::subtitle_video_frame_rate () const +{ + { + boost::mutex::scoped_lock lm (_mutex); + if (_frame_rate) { + return _frame_rate.get (); + } + } + + /* No frame rate specified, so assume this content has been + prepared for any concurrent video content. + */ + return film()->active_frame_rate_change(position()).source; +} + +void +TextSubtitleContent::set_colour (dcp::Colour colour) +{ + { + boost::mutex::scoped_lock lm (_mutex); + if (_colour == colour) { + return; + } + + _colour = colour; + } + + signal_changed (TextSubtitleContentProperty::TEXT_SUBTITLE_COLOUR); +} + +void +TextSubtitleContent::set_outline (bool o) +{ + { + boost::mutex::scoped_lock lm (_mutex); + if (_outline == o) { + return; + } + + _outline = o; + } + + signal_changed (TextSubtitleContentProperty::TEXT_SUBTITLE_OUTLINE); +} + +void +TextSubtitleContent::set_outline_colour (dcp::Colour colour) +{ + { + boost::mutex::scoped_lock lm (_mutex); + if (_outline_colour == colour) { + return; + } + + _outline_colour = colour; + } + + signal_changed (TextSubtitleContentProperty::TEXT_SUBTITLE_OUTLINE_COLOUR); +} diff --git a/src/lib/text_subtitle_content.h b/src/lib/text_subtitle_content.h new file mode 100644 index 000000000..52d44ae54 --- /dev/null +++ b/src/lib/text_subtitle_content.h @@ -0,0 +1,91 @@ +/* + Copyright (C) 2014-2015 Carl Hetherington + + This program 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. + + This program 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 this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include "subtitle_content.h" + +class TextSubtitleContentProperty +{ +public: + static int const TEXT_SUBTITLE_COLOUR; + static int const TEXT_SUBTITLE_OUTLINE; + static int const TEXT_SUBTITLE_OUTLINE_COLOUR; +}; + + +class TextSubtitleContent : public SubtitleContent +{ +public: + TextSubtitleContent (boost::shared_ptr, boost::filesystem::path); + TextSubtitleContent (boost::shared_ptr, cxml::ConstNodePtr, int); + + boost::shared_ptr shared_from_this () { + return boost::dynamic_pointer_cast (Content::shared_from_this ()); + } + + /* Content */ + void examine (boost::shared_ptr); + std::string summary () const; + std::string technical_summary () const; + void as_xml (xmlpp::Node *) const; + DCPTime full_length () const; + + /* SubtitleContent */ + + bool has_text_subtitles () const { + return true; + } + + bool has_image_subtitles () const { + return false; + } + + double subtitle_video_frame_rate () const; + void set_subtitle_video_frame_rate (int r); + + void set_colour (dcp::Colour); + + dcp::Colour colour () const { + boost::mutex::scoped_lock lm (_mutex); + return _colour; + } + + void set_outline (bool); + + bool outline () const { + boost::mutex::scoped_lock lm (_mutex); + return _outline; + } + + void set_outline_colour (dcp::Colour); + + dcp::Colour outline_colour () const { + boost::mutex::scoped_lock lm (_mutex); + return _outline_colour; + } + + static std::string const font_id; + +private: + ContentTime _length; + /** Video frame rate that this content has been prepared for, if known */ + boost::optional _frame_rate; + dcp::Colour _colour; + bool _outline; + dcp::Colour _outline_colour; +}; diff --git a/src/lib/text_subtitle_decoder.cc b/src/lib/text_subtitle_decoder.cc new file mode 100644 index 000000000..893fd5d3c --- /dev/null +++ b/src/lib/text_subtitle_decoder.cc @@ -0,0 +1,141 @@ +/* + Copyright (C) 2014-2016 Carl Hetherington + + This program 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. + + This program 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 this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include "text_subtitle_decoder.h" +#include "text_subtitle_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; + +TextSubtitleDecoder::TextSubtitleDecoder (shared_ptr content) + : SubtitleDecoder (content) + , TextSubtitle (content) + , _next (0) +{ + +} + +void +TextSubtitleDecoder::seek (ContentTime time, bool accurate) +{ + SubtitleDecoder::seek (time, accurate); + + _next = 0; + while (_next < _subtitles.size() && ContentTime::from_seconds (_subtitles[_next].from.all_as_seconds ()) < time) { + ++_next; + } +} + +bool +TextSubtitleDecoder::pass (PassReason, bool) +{ + if (_next >= _subtitles.size ()) { + return true; + } + + /* XXX: we are ignoring positioning specified in the file */ + + shared_ptr content = dynamic_pointer_cast (_subtitle_content); + DCPOMATIC_ASSERT (content); + + list out; + + /* Highest line index in this subtitle */ + int highest = 0; + BOOST_FOREACH (sub::Line i, _subtitles[_next].lines) { + DCPOMATIC_ASSERT (i.vertical_position.reference && i.vertical_position.reference.get() == sub::TOP_OF_SUBTITLE); + DCPOMATIC_ASSERT (i.vertical_position.line); + highest = max (highest, i.vertical_position.line.get()); + } + + BOOST_FOREACH (sub::Line i, _subtitles[_next].lines) { + BOOST_FOREACH (sub::Block j, i.blocks) { + out.push_back ( + dcp::SubtitleString ( + TextSubtitleContent::font_id, + j.italic, + /* force the colour to whatever is configured */ + content->colour(), + j.font_size.points (72 * 11), + 1.0, + dcp::Time (_subtitles[_next].from.all_as_seconds(), 1000), + dcp::Time (_subtitles[_next].to.all_as_seconds(), 1000), + 0, + dcp::HALIGN_CENTER, + /* This 1.015 is an arbitrary value to lift the bottom sub off the bottom + of the screen a bit to a pleasing degree. + */ + 1.015 - ((1 + highest - i.vertical_position.line.get()) * 1.5 / 22), + dcp::VALIGN_TOP, + j.text, + content->outline() ? dcp::BORDER : dcp::NONE, + content->outline_colour(), + dcp::Time (0, 1000), + dcp::Time (0, 1000) + ) + ); + } + } + + text_subtitle (content_time_period (_subtitles[_next]), out); + + ++_next; + return false; +} + +list +TextSubtitleDecoder::image_subtitles_during (ContentTimePeriod, bool) const +{ + return list (); +} + +list +TextSubtitleDecoder::text_subtitles_during (ContentTimePeriod p, bool starting) const +{ + /* XXX: inefficient */ + + list d; + + for (vector::const_iterator i = _subtitles.begin(); i != _subtitles.end(); ++i) { + ContentTimePeriod t = content_time_period (*i); + if ((starting && p.contains (t.from)) || (!starting && p.overlaps (t))) { + d.push_back (t); + } + } + + return d; +} + +ContentTimePeriod +TextSubtitleDecoder::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_subtitle_decoder.h b/src/lib/text_subtitle_decoder.h new file mode 100644 index 000000000..67d2caca8 --- /dev/null +++ b/src/lib/text_subtitle_decoder.h @@ -0,0 +1,45 @@ +/* + Copyright (C) 2014-2016 Carl Hetherington + + This program 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. + + This program 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 this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef DCPOMATIC_TEXT_SUBTITLE_DECODER_H +#define DCPOMATIC_TEXT_SUBTITLE_DECODER_H + +#include "subtitle_decoder.h" +#include "text_subtitle.h" + +class TextSubtitleContent; + +class TextSubtitleDecoder : public SubtitleDecoder, public TextSubtitle +{ +public: + TextSubtitleDecoder (boost::shared_ptr); + +protected: + void seek (ContentTime time, bool accurate); + bool pass (PassReason, bool accurate); + +private: + std::list image_subtitles_during (ContentTimePeriod, bool starting) const; + std::list text_subtitles_during (ContentTimePeriod, bool starting) const; + ContentTimePeriod content_time_period (sub::Subtitle s) const; + + size_t _next; +}; + +#endif diff --git a/src/lib/wscript b/src/lib/wscript index 88cb9d4dc..f6ca52fb7 100644 --- a/src/lib/wscript +++ b/src/lib/wscript @@ -118,9 +118,9 @@ sources = """ sndfile_decoder.cc sndfile_examiner.cc string_log_entry.cc - subrip.cc - subrip_content.cc - subrip_decoder.cc + text_subtitle.cc + text_subtitle_content.cc + text_subtitle_decoder.cc subtitle_content.cc subtitle_decoder.cc timer.cc diff --git a/src/wx/subtitle_appearance_dialog.cc b/src/wx/subtitle_appearance_dialog.cc index 0db55edfe..8e158bbac 100644 --- a/src/wx/subtitle_appearance_dialog.cc +++ b/src/wx/subtitle_appearance_dialog.cc @@ -18,13 +18,13 @@ */ #include "subtitle_appearance_dialog.h" -#include "lib/subrip_content.h" +#include "lib/text_subtitle_content.h" #include #include using boost::shared_ptr; -SubtitleAppearanceDialog::SubtitleAppearanceDialog (wxWindow* parent, shared_ptr content) +SubtitleAppearanceDialog::SubtitleAppearanceDialog (wxWindow* parent, shared_ptr content) : TableDialog (parent, _("Subtitle appearance"), 2, 1, true) , _content (content) { diff --git a/src/wx/subtitle_appearance_dialog.h b/src/wx/subtitle_appearance_dialog.h index f4fe307d2..fddb902ac 100644 --- a/src/wx/subtitle_appearance_dialog.h +++ b/src/wx/subtitle_appearance_dialog.h @@ -22,12 +22,12 @@ class wxCheckBox; class wxColourPickerCtrl; -class SubRipContent; +class TextSubtitleContent; class SubtitleAppearanceDialog : public TableDialog { public: - SubtitleAppearanceDialog (wxWindow* parent, boost::shared_ptr content); + SubtitleAppearanceDialog (wxWindow* parent, boost::shared_ptr content); void apply (); @@ -36,5 +36,5 @@ private: wxCheckBox* _outline; wxColourPickerCtrl* _outline_colour; - boost::shared_ptr _content; + boost::shared_ptr _content; }; diff --git a/src/wx/subtitle_panel.cc b/src/wx/subtitle_panel.cc index 591166a9e..3024617e5 100644 --- a/src/wx/subtitle_panel.cc +++ b/src/wx/subtitle_panel.cc @@ -25,10 +25,10 @@ #include "fonts_dialog.h" #include "subtitle_appearance_dialog.h" #include "lib/ffmpeg_content.h" -#include "lib/subrip_content.h" +#include "lib/text_subtitle_content.h" #include "lib/ffmpeg_subtitle_stream.h" #include "lib/dcp_subtitle_content.h" -#include "lib/subrip_decoder.h" +#include "lib/text_subtitle_decoder.h" #include "lib/dcp_subtitle_decoder.h" #include "lib/dcp_content.h" #include @@ -233,13 +233,13 @@ SubtitlePanel::setup_sensitivity () { int any_subs = 0; int ffmpeg_subs = 0; - int subrip_subs = 0; + int text_subs = 0; int dcp_subs = 0; int image_subs = 0; SubtitleContentList sel = _parent->selected_subtitle (); BOOST_FOREACH (shared_ptr i, sel) { 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 dsc = boost::dynamic_pointer_cast (i); if (fc) { if (fc->has_subtitles ()) { @@ -247,7 +247,7 @@ SubtitlePanel::setup_sensitivity () ++any_subs; } } else if (sc) { - ++subrip_subs; + ++text_subs; ++any_subs; } else if (dsc) { ++dcp_subs; @@ -283,9 +283,9 @@ SubtitlePanel::setup_sensitivity () _y_scale->Enable (!reference && any_subs > 0 && use); _language->Enable (!reference && any_subs > 0 && use); _stream->Enable (!reference && ffmpeg_subs == 1); - _subtitle_view_button->Enable (!reference && (subrip_subs == 1 || dcp_subs == 1)); - _fonts_dialog_button->Enable (!reference && (subrip_subs == 1 || dcp_subs == 1)); - _appearance_dialog_button->Enable (!reference && subrip_subs == 1); + _subtitle_view_button->Enable (!reference && (text_subs == 1 || dcp_subs == 1)); + _fonts_dialog_button->Enable (!reference && (text_subs == 1 || dcp_subs == 1)); + _appearance_dialog_button->Enable (!reference && text_subs == 1); } void @@ -379,9 +379,9 @@ SubtitlePanel::subtitle_view_clicked () shared_ptr decoder; - shared_ptr sr = dynamic_pointer_cast (c.front ()); + shared_ptr sr = dynamic_pointer_cast (c.front ()); if (sr) { - decoder.reset (new SubRipDecoder (sr)); + decoder.reset (new TextSubtitleDecoder (sr)); } shared_ptr dc = dynamic_pointer_cast (c.front ()); @@ -432,7 +432,7 @@ SubtitlePanel::appearance_dialog_clicked () SubtitleContentList c = _parent->selected_subtitle (); DCPOMATIC_ASSERT (c.size() == 1); - shared_ptr sr = dynamic_pointer_cast (c.front ()); + shared_ptr sr = dynamic_pointer_cast (c.front ()); DCPOMATIC_ASSERT (sr); SubtitleAppearanceDialog* d = new SubtitleAppearanceDialog (this, sr); diff --git a/src/wx/subtitle_view.cc b/src/wx/subtitle_view.cc index f54b19680..916f1eedc 100644 --- a/src/wx/subtitle_view.cc +++ b/src/wx/subtitle_view.cc @@ -17,10 +17,10 @@ */ -#include "lib/subrip_decoder.h" +#include "lib/text_subtitle_decoder.h" #include "lib/content_subtitle.h" #include "lib/film.h" -#include "lib/subrip_content.h" +#include "lib/text_subtitle_content.h" #include "subtitle_view.h" #include "wx_util.h" diff --git a/src/wx/timing_panel.cc b/src/wx/timing_panel.cc index c7567455b..a29240f8d 100644 --- a/src/wx/timing_panel.cc +++ b/src/wx/timing_panel.cc @@ -27,7 +27,7 @@ #include "lib/raw_convert.h" #include "lib/subtitle_content.h" #include "lib/dcp_subtitle_content.h" -#include "lib/subrip_content.h" +#include "lib/text_subtitle_content.h" #include #include #include @@ -393,13 +393,13 @@ TimingPanel::set_video_frame_rate () BOOST_FOREACH (shared_ptr i, _parent->selected ()) { shared_ptr vc = dynamic_pointer_cast (i); shared_ptr dsc = dynamic_pointer_cast (i); - shared_ptr ssc = dynamic_pointer_cast (i); + shared_ptr tsc = dynamic_pointer_cast (i); if (vc) { vc->set_video_frame_rate (raw_convert (wx_to_std (_video_frame_rate->GetValue ()))); } else if (dsc) { dsc->set_subtitle_video_frame_rate (raw_convert (wx_to_std (_video_frame_rate->GetValue ()))); - } else if (ssc) { - ssc->set_subtitle_video_frame_rate (raw_convert (wx_to_std (_video_frame_rate->GetValue ()))); + } else if (tsc) { + tsc->set_subtitle_video_frame_rate (raw_convert (wx_to_std (_video_frame_rate->GetValue ()))); } _set_video_frame_rate->Enable (false); } diff --git a/test/burnt_subtitle_test.cc b/test/burnt_subtitle_test.cc index e2f7272be..fc5b88578 100644 --- a/test/burnt_subtitle_test.cc +++ b/test/burnt_subtitle_test.cc @@ -22,7 +22,7 @@ */ #include -#include "lib/subrip_content.h" +#include "lib/text_subtitle_content.h" #include "lib/dcp_subtitle_content.h" #include "lib/film.h" #include "lib/ratio.h" @@ -40,7 +40,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 SubRipContent (film, "test/data/subrip2.srt")); + shared_ptr content (new TextSubtitleContent (film, "test/data/subrip2.srt")); content->set_use_subtitles (true); content->set_burn_subtitles (true); film->examine_and_add_content (content, true); diff --git a/test/reels_test.cc b/test/reels_test.cc index 12a311fe8..b5a24f7fc 100644 --- a/test/reels_test.cc +++ b/test/reels_test.cc @@ -23,7 +23,7 @@ #include "lib/image_content.h" #include "lib/dcp_content_type.h" #include "lib/dcp_content.h" -#include "lib/subrip_content.h" +#include "lib/text_subtitle_content.h" #include "test.h" #include #include @@ -155,7 +155,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 SubRipContent (film, "test/data/subrip.srt")); + shared_ptr sub (new TextSubtitleContent (film, "test/data/subrip.srt")); film->examine_and_add_content (sub); wait_for_jobs (); @@ -198,7 +198,7 @@ BOOST_AUTO_TEST_CASE (reels_test4) content[i]->set_video_length (24); } - shared_ptr subs (new SubRipContent (film, "test/data/subrip3.srt")); + shared_ptr subs (new TextSubtitleContent (film, "test/data/subrip3.srt")); film->examine_and_add_content (subs); wait_for_jobs (); diff --git a/test/srt_subtitle_test.cc b/test/srt_subtitle_test.cc index 759c2720c..c2d3e27bd 100644 --- a/test/srt_subtitle_test.cc +++ b/test/srt_subtitle_test.cc @@ -22,7 +22,7 @@ */ #include "lib/film.h" -#include "lib/subrip_content.h" +#include "lib/text_subtitle_content.h" #include "lib/dcp_content_type.h" #include "lib/font.h" #include "lib/ratio.h" @@ -42,7 +42,7 @@ BOOST_AUTO_TEST_CASE (srt_subtitle_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 SubRipContent (film, "test/data/subrip2.srt")); + shared_ptr content (new TextSubtitleContent (film, "test/data/subrip2.srt")); film->examine_and_add_content (content); wait_for_jobs (); @@ -62,7 +62,7 @@ BOOST_AUTO_TEST_CASE (srt_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 SubRipContent (film, "test/data/subrip2.srt")); + shared_ptr content (new TextSubtitleContent (film, "test/data/subrip2.srt")); film->examine_and_add_content (content); wait_for_jobs (); @@ -87,7 +87,7 @@ BOOST_AUTO_TEST_CASE (srt_subtitle_test3) film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR")); film->set_name ("frobozz"); film->set_interop (true); - shared_ptr content (new SubRipContent (film, private_data / "Ankoemmling.srt")); + shared_ptr content (new TextSubtitleContent (film, private_data / "Ankoemmling.srt")); film->examine_and_add_content (content); wait_for_jobs (); diff --git a/test/subrip_test.cc b/test/subrip_test.cc index cd517cfe9..d443a416d 100644 --- a/test/subrip_test.cc +++ b/test/subrip_test.cc @@ -39,7 +39,7 @@ using boost::dynamic_pointer_cast; BOOST_AUTO_TEST_CASE (subrip_render_test) { shared_ptr film = new_test_film ("subrip_render_test"); - shared_ptr content (new SubRipContent (film, "test/data/subrip.srt")); + shared_ptr content (new TextSubtitleContent (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/xml_subtitle_test.cc b/test/xml_subtitle_test.cc index 837c73c58..554591b92 100644 --- a/test/xml_subtitle_test.cc +++ b/test/xml_subtitle_test.cc @@ -22,7 +22,7 @@ */ #include -#include "lib/subrip_content.h" +#include "lib/text_subtitle_content.h" #include "lib/film.h" #include "lib/ratio.h" #include "lib/dcp_content_type.h" @@ -39,7 +39,7 @@ BOOST_AUTO_TEST_CASE (xml_subtitle_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 SubRipContent (film, "test/data/subrip2.srt")); + shared_ptr content (new TextSubtitleContent (film, "test/data/subrip2.srt")); content->set_use_subtitles (true); content->set_burn_subtitles (false); film->examine_and_add_content (content);