Rename SubRip -> TextSubtitle.
authorCarl Hetherington <cth@carlh.net>
Fri, 12 Feb 2016 00:13:14 +0000 (00:13 +0000)
committerCarl Hetherington <cth@carlh.net>
Fri, 12 Feb 2016 00:13:14 +0000 (00:13 +0000)
27 files changed:
src/lib/content_factory.cc
src/lib/exceptions.cc
src/lib/exceptions.h
src/lib/player.cc
src/lib/subrip.cc [deleted file]
src/lib/subrip.h [deleted file]
src/lib/subrip_content.cc [deleted file]
src/lib/subrip_content.h [deleted file]
src/lib/subrip_decoder.cc [deleted file]
src/lib/subrip_decoder.h [deleted file]
src/lib/text_subtitle.cc [new file with mode: 0644]
src/lib/text_subtitle.h [new file with mode: 0644]
src/lib/text_subtitle_content.cc [new file with mode: 0644]
src/lib/text_subtitle_content.h [new file with mode: 0644]
src/lib/text_subtitle_decoder.cc [new file with mode: 0644]
src/lib/text_subtitle_decoder.h [new file with mode: 0644]
src/lib/wscript
src/wx/subtitle_appearance_dialog.cc
src/wx/subtitle_appearance_dialog.h
src/wx/subtitle_panel.cc
src/wx/subtitle_view.cc
src/wx/timing_panel.cc
test/burnt_subtitle_test.cc
test/reels_test.cc
test/srt_subtitle_test.cc
test/subrip_test.cc
test/xml_subtitle_test.cc

index 3aa8ca9d31eb16ef16dc34ce776f43b198a50ad8..2b17d69e42bdbd1525035eb479f79934b4d99ebe 100644 (file)
@@ -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<const Film> 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<const Film> 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)) {
index c15e134ee598de24ba4122dbdb30385d49b6a96a..968e81439396881a6152e16951588c79998a7d7b 100644 (file)
@@ -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)
 {
 
 }
index da87613042f18cf91fa04e32f37dea80951c30b4..3e7289a50e13e00c4c04259ff7c63bb65ba5bdce 100644 (file)
@@ -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
index ecf37b57662b6b89c198a15f3035626ba3b5dce7..fc13325730142222a5bbc18185ebe6d019416689 100644 (file)
@@ -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<const SubRipContent> rc = dynamic_pointer_cast<const SubRipContent> (i);
+               /* TextSubtitleContent */
+               shared_ptr<const TextSubtitleContent> rc = dynamic_pointer_cast<const TextSubtitleContent> (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<Content> 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 (file)
index c4166cb..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
-    Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
-
-    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 <sub/subrip_reader.h>
-#include <sub/collect.h>
-#include <unicode/ucsdet.h>
-#include <unicode/ucnv.h>
-#include <iostream>
-
-#include "i18n.h"
-
-using std::vector;
-using std::cout;
-using std::string;
-using boost::shared_ptr;
-using boost::scoped_array;
-using dcp::Data;
-
-SubRip::SubRip (shared_ptr<const SubRipContent> content)
-{
-       Data in (content->path (0));
-
-       UErrorCode status = U_ZERO_ERROR;
-       UCharsetDetector* detector = ucsdet_open (&status);
-       ucsdet_setText (detector, reinterpret_cast<const char *> (in.data().get()), in.size(), &status);
-
-       UCharsetMatch const * match = ucsdet_detect (detector, &status);
-       char const * in_charset = ucsdet_getName (match, &status);
-
-       UConverter* to_utf16 = ucnv_open (in_charset, &status);
-       /* This is a guess; I think we should be able to encode any input in 4 times its input size */
-       scoped_array<uint16_t> utf16 (new uint16_t[in.size() * 2]);
-       int const utf16_len = ucnv_toUChars (
-               to_utf16, reinterpret_cast<UChar*>(utf16.get()), in.size() * 2,
-               reinterpret_cast<const char *> (in.data().get()), in.size(),
-               &status
-               );
-
-       UConverter* to_utf8 = ucnv_open ("UTF-8", &status);
-       /* Another guess */
-       scoped_array<char> utf8 (new char[utf16_len * 2]);
-       ucnv_fromUChars (to_utf8, utf8.get(), utf16_len * 2, reinterpret_cast<UChar*>(utf16.get()), utf16_len, &status);
-
-       ucsdet_close (detector);
-       ucnv_close (to_utf16);
-       ucnv_close (to_utf8);
-
-       sub::SubripReader reader (utf8.get());
-       _subtitles = sub::collect<vector<sub::Subtitle> > (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 (file)
index 35687eb..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
-    Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
-
-    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 <sub/subtitle.h>
-#include <boost/shared_ptr.hpp>
-#include <vector>
-
-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<const SubRipContent>);
-
-       ContentTime length () const;
-
-protected:
-       std::vector<sub::Subtitle> _subtitles;
-};
-
-#endif
diff --git a/src/lib/subrip_content.cc b/src/lib/subrip_content.cc
deleted file mode 100644 (file)
index a6eb076..0000000
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
-    Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
-
-    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 <libxml++/libxml++.h>
-#include <iostream>
-
-#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<const Film> 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<const Film> film, cxml::ConstNodePtr node, int version)
-       : Content (film, node)
-       , SubtitleContent (film, node, version)
-       , _length (node->number_child<ContentTime::Type> ("Length"))
-       , _frame_rate (node->optional_number_child<double>("SubtitleFrameRate"))
-       , _colour (
-               node->optional_number_child<int>("Red").get_value_or(255),
-               node->optional_number_child<int>("Green").get_value_or(255),
-               node->optional_number_child<int>("Blue").get_value_or(255)
-               )
-       , _outline (node->optional_bool_child("Outline").get_value_or(false))
-       , _outline_colour (
-               node->optional_number_child<int>("OutlineRed").get_value_or(255),
-               node->optional_number_child<int>("OutlineGreen").get_value_or(255),
-               node->optional_number_child<int>("OutlineBlue").get_value_or(255)
-               )
-{
-
-}
-
-void
-SubRipContent::examine (boost::shared_ptr<Job> 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<Font> (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<string> (_length.get ()));
-       node->add_child("Red")->add_child_text (raw_convert<string> (_colour.r));
-       node->add_child("Green")->add_child_text (raw_convert<string> (_colour.g));
-       node->add_child("Blue")->add_child_text (raw_convert<string> (_colour.b));
-       node->add_child("Outline")->add_child_text (raw_convert<string> (_outline));
-       node->add_child("OutlineRed")->add_child_text (raw_convert<string> (_outline_colour.r));
-       node->add_child("OutlineGreen")->add_child_text (raw_convert<string> (_outline_colour.g));
-       node->add_child("OutlineBlue")->add_child_text (raw_convert<string> (_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 (file)
index 68864f5..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
-    Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
-
-    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<const Film>, boost::filesystem::path);
-       SubRipContent (boost::shared_ptr<const Film>, cxml::ConstNodePtr, int);
-
-       boost::shared_ptr<SubRipContent> shared_from_this () {
-               return boost::dynamic_pointer_cast<SubRipContent> (Content::shared_from_this ());
-       }
-
-       /* Content */
-       void examine (boost::shared_ptr<Job>);
-       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<double> _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 (file)
index 2f8b8a5..0000000
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
-    Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
-
-    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 <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;
-
-SubRipDecoder::SubRipDecoder (shared_ptr<const SubRipContent> 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<const SubRipContent> content = dynamic_pointer_cast<const SubRipContent> (_subtitle_content);
-       DCPOMATIC_ASSERT (content);
-
-       list<dcp::SubtitleString> 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<ContentTimePeriod>
-SubRipDecoder::image_subtitles_during (ContentTimePeriod, bool) const
-{
-       return list<ContentTimePeriod> ();
-}
-
-list<ContentTimePeriod>
-SubRipDecoder::text_subtitles_during (ContentTimePeriod p, bool starting) const
-{
-       /* XXX: inefficient */
-
-       list<ContentTimePeriod> d;
-
-       for (vector<sub::Subtitle>::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 (file)
index f76d04a..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
-    Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
-
-    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<const SubRipContent>);
-
-protected:
-       void seek (ContentTime time, bool accurate);
-       bool pass (PassReason, bool accurate);
-
-private:
-       std::list<ContentTimePeriod> image_subtitles_during (ContentTimePeriod, bool starting) const;
-       std::list<ContentTimePeriod> 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 (file)
index 0000000..d55ff68
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+    Copyright (C) 2014-2016 Carl Hetherington <cth@carlh.net>
+
+    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 <sub/subrip_reader.h>
+#include <sub/collect.h>
+#include <unicode/ucsdet.h>
+#include <unicode/ucnv.h>
+#include <iostream>
+
+#include "i18n.h"
+
+using std::vector;
+using std::cout;
+using std::string;
+using boost::shared_ptr;
+using boost::scoped_array;
+using dcp::Data;
+
+TextSubtitle::TextSubtitle (shared_ptr<const TextSubtitleContent> content)
+{
+       Data in (content->path (0));
+
+       UErrorCode status = U_ZERO_ERROR;
+       UCharsetDetector* detector = ucsdet_open (&status);
+       ucsdet_setText (detector, reinterpret_cast<const char *> (in.data().get()), in.size(), &status);
+
+       UCharsetMatch const * match = ucsdet_detect (detector, &status);
+       char const * in_charset = ucsdet_getName (match, &status);
+
+       UConverter* to_utf16 = ucnv_open (in_charset, &status);
+       /* This is a guess; I think we should be able to encode any input in 4 times its input size */
+       scoped_array<uint16_t> utf16 (new uint16_t[in.size() * 2]);
+       int const utf16_len = ucnv_toUChars (
+               to_utf16, reinterpret_cast<UChar*>(utf16.get()), in.size() * 2,
+               reinterpret_cast<const char *> (in.data().get()), in.size(),
+               &status
+               );
+
+       UConverter* to_utf8 = ucnv_open ("UTF-8", &status);
+       /* Another guess */
+       scoped_array<char> utf8 (new char[utf16_len * 2]);
+       ucnv_fromUChars (to_utf8, utf8.get(), utf16_len * 2, reinterpret_cast<UChar*>(utf16.get()), utf16_len, &status);
+
+       ucsdet_close (detector);
+       ucnv_close (to_utf16);
+       ucnv_close (to_utf8);
+
+       sub::SubripReader reader (utf8.get());
+       _subtitles = sub::collect<vector<sub::Subtitle> > (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 (file)
index 0000000..4614f6b
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+    Copyright (C) 2014-2016 Carl Hetherington <cth@carlh.net>
+
+    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 <sub/subtitle.h>
+#include <boost/shared_ptr.hpp>
+#include <vector>
+
+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<const TextSubtitleContent>);
+
+       ContentTime length () const;
+
+protected:
+       std::vector<sub::Subtitle> _subtitles;
+};
+
+#endif
diff --git a/src/lib/text_subtitle_content.cc b/src/lib/text_subtitle_content.cc
new file mode 100644 (file)
index 0000000..93ac1d0
--- /dev/null
@@ -0,0 +1,191 @@
+/*
+    Copyright (C) 2014-2016 Carl Hetherington <cth@carlh.net>
+
+    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 <libxml++/libxml++.h>
+#include <iostream>
+
+#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<const Film> 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<const Film> film, cxml::ConstNodePtr node, int version)
+       : Content (film, node)
+       , SubtitleContent (film, node, version)
+       , _length (node->number_child<ContentTime::Type> ("Length"))
+       , _frame_rate (node->optional_number_child<double>("SubtitleFrameRate"))
+       , _colour (
+               node->optional_number_child<int>("Red").get_value_or(255),
+               node->optional_number_child<int>("Green").get_value_or(255),
+               node->optional_number_child<int>("Blue").get_value_or(255)
+               )
+       , _outline (node->optional_bool_child("Outline").get_value_or(false))
+       , _outline_colour (
+               node->optional_number_child<int>("OutlineRed").get_value_or(255),
+               node->optional_number_child<int>("OutlineGreen").get_value_or(255),
+               node->optional_number_child<int>("OutlineBlue").get_value_or(255)
+               )
+{
+
+}
+
+void
+TextSubtitleContent::examine (boost::shared_ptr<Job> 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<Font> (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<string> (_length.get ()));
+       node->add_child("Red")->add_child_text (raw_convert<string> (_colour.r));
+       node->add_child("Green")->add_child_text (raw_convert<string> (_colour.g));
+       node->add_child("Blue")->add_child_text (raw_convert<string> (_colour.b));
+       node->add_child("Outline")->add_child_text (raw_convert<string> (_outline));
+       node->add_child("OutlineRed")->add_child_text (raw_convert<string> (_outline_colour.r));
+       node->add_child("OutlineGreen")->add_child_text (raw_convert<string> (_outline_colour.g));
+       node->add_child("OutlineBlue")->add_child_text (raw_convert<string> (_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 (file)
index 0000000..52d44ae
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+    Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
+
+    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<const Film>, boost::filesystem::path);
+       TextSubtitleContent (boost::shared_ptr<const Film>, cxml::ConstNodePtr, int);
+
+       boost::shared_ptr<TextSubtitleContent> shared_from_this () {
+               return boost::dynamic_pointer_cast<TextSubtitleContent> (Content::shared_from_this ());
+       }
+
+       /* Content */
+       void examine (boost::shared_ptr<Job>);
+       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<double> _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 (file)
index 0000000..893fd5d
--- /dev/null
@@ -0,0 +1,141 @@
+/*
+    Copyright (C) 2014-2016 Carl Hetherington <cth@carlh.net>
+
+    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 <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;
+
+TextSubtitleDecoder::TextSubtitleDecoder (shared_ptr<const TextSubtitleContent> 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<const TextSubtitleContent> content = dynamic_pointer_cast<const TextSubtitleContent> (_subtitle_content);
+       DCPOMATIC_ASSERT (content);
+
+       list<dcp::SubtitleString> 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<ContentTimePeriod>
+TextSubtitleDecoder::image_subtitles_during (ContentTimePeriod, bool) const
+{
+       return list<ContentTimePeriod> ();
+}
+
+list<ContentTimePeriod>
+TextSubtitleDecoder::text_subtitles_during (ContentTimePeriod p, bool starting) const
+{
+       /* XXX: inefficient */
+
+       list<ContentTimePeriod> d;
+
+       for (vector<sub::Subtitle>::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 (file)
index 0000000..67d2cac
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+    Copyright (C) 2014-2016 Carl Hetherington <cth@carlh.net>
+
+    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<const TextSubtitleContent>);
+
+protected:
+       void seek (ContentTime time, bool accurate);
+       bool pass (PassReason, bool accurate);
+
+private:
+       std::list<ContentTimePeriod> image_subtitles_during (ContentTimePeriod, bool starting) const;
+       std::list<ContentTimePeriod> text_subtitles_during (ContentTimePeriod, bool starting) const;
+       ContentTimePeriod content_time_period (sub::Subtitle s) const;
+
+       size_t _next;
+};
+
+#endif
index 88cb9d4dc099fb2db4f1b436aeb546f38828ddf6..f6ca52fb772f9eb625025136c19e43f43581373f 100644 (file)
@@ -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
index 0db55edfe1ce110453c728e12176abfe7e83d60d..8e158bbac0c0cc5be9003424703b6afca0d5aa43 100644 (file)
 */
 
 #include "subtitle_appearance_dialog.h"
-#include "lib/subrip_content.h"
+#include "lib/text_subtitle_content.h"
 #include <wx/wx.h>
 #include <wx/clrpicker.h>
 
 using boost::shared_ptr;
 
-SubtitleAppearanceDialog::SubtitleAppearanceDialog (wxWindow* parent, shared_ptr<SubRipContent> content)
+SubtitleAppearanceDialog::SubtitleAppearanceDialog (wxWindow* parent, shared_ptr<TextSubtitleContent> content)
        : TableDialog (parent, _("Subtitle appearance"), 2, 1, true)
        , _content (content)
 {
index f4fe307d238dcab485583f7bd6a68fbc583bd566..fddb902acdf5afde8585a960c15642662ac304d0 100644 (file)
 
 class wxCheckBox;
 class wxColourPickerCtrl;
-class SubRipContent;
+class TextSubtitleContent;
 
 class SubtitleAppearanceDialog : public TableDialog
 {
 public:
-       SubtitleAppearanceDialog (wxWindow* parent, boost::shared_ptr<SubRipContent> content);
+       SubtitleAppearanceDialog (wxWindow* parent, boost::shared_ptr<TextSubtitleContent> content);
 
        void apply ();
 
@@ -36,5 +36,5 @@ private:
        wxCheckBox* _outline;
        wxColourPickerCtrl* _outline_colour;
 
-       boost::shared_ptr<SubRipContent> _content;
+       boost::shared_ptr<TextSubtitleContent> _content;
 };
index 591166a9e8d08ac20ccaf1d4493681e7a8f07ae4..3024617e56de9ddff76006632a2bf7eb158d25ee 100644 (file)
 #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 <wx/spinctrl.h>
@@ -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<SubtitleContent> i, sel) {
                shared_ptr<const FFmpegContent> fc = boost::dynamic_pointer_cast<const FFmpegContent> (i);
-               shared_ptr<const SubRipContent> sc = boost::dynamic_pointer_cast<const SubRipContent> (i);
+               shared_ptr<const TextSubtitleContent> sc = boost::dynamic_pointer_cast<const TextSubtitleContent> (i);
                shared_ptr<const DCPSubtitleContent> dsc = boost::dynamic_pointer_cast<const DCPSubtitleContent> (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<SubtitleDecoder> decoder;
 
-       shared_ptr<SubRipContent> sr = dynamic_pointer_cast<SubRipContent> (c.front ());
+       shared_ptr<TextSubtitleContent> sr = dynamic_pointer_cast<TextSubtitleContent> (c.front ());
        if (sr) {
-               decoder.reset (new SubRipDecoder (sr));
+               decoder.reset (new TextSubtitleDecoder (sr));
        }
 
        shared_ptr<DCPSubtitleContent> dc = dynamic_pointer_cast<DCPSubtitleContent> (c.front ());
@@ -432,7 +432,7 @@ SubtitlePanel::appearance_dialog_clicked ()
        SubtitleContentList c = _parent->selected_subtitle ();
        DCPOMATIC_ASSERT (c.size() == 1);
 
-       shared_ptr<SubRipContent> sr = dynamic_pointer_cast<SubRipContent> (c.front ());
+       shared_ptr<TextSubtitleContent> sr = dynamic_pointer_cast<TextSubtitleContent> (c.front ());
        DCPOMATIC_ASSERT (sr);
 
        SubtitleAppearanceDialog* d = new SubtitleAppearanceDialog (this, sr);
index f54b1968060f1f78b99cb6b7963abdfbac0e65c5..916f1eedcdf39ea1afedba5b0ceca5a0399e25f9 100644 (file)
 
 */
 
-#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"
 
index c7567455b762c393d86624aca6df8a4fe136d191..a29240f8dbaf3cd2eea395c133dc885ff0cc918b 100644 (file)
@@ -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 <boost/foreach.hpp>
 #include <set>
 #include <iostream>
@@ -393,13 +393,13 @@ TimingPanel::set_video_frame_rate ()
        BOOST_FOREACH (shared_ptr<Content> i, _parent->selected ()) {
                shared_ptr<VideoContent> vc = dynamic_pointer_cast<VideoContent> (i);
                shared_ptr<DCPSubtitleContent> dsc = dynamic_pointer_cast<DCPSubtitleContent> (i);
-               shared_ptr<SubRipContent> ssc = dynamic_pointer_cast<SubRipContent> (i);
+               shared_ptr<TextSubtitleContent> tsc = dynamic_pointer_cast<TextSubtitleContent> (i);
                if (vc) {
                        vc->set_video_frame_rate (raw_convert<double> (wx_to_std (_video_frame_rate->GetValue ())));
                } else if (dsc) {
                        dsc->set_subtitle_video_frame_rate (raw_convert<double> (wx_to_std (_video_frame_rate->GetValue ())));
-               } else if (ssc) {
-                       ssc->set_subtitle_video_frame_rate (raw_convert<double> (wx_to_std (_video_frame_rate->GetValue ())));
+               } else if (tsc) {
+                       tsc->set_subtitle_video_frame_rate (raw_convert<double> (wx_to_std (_video_frame_rate->GetValue ())));
                }
                _set_video_frame_rate->Enable (false);
        }
index e2f7272be87f3cd8a6f22d3db13e8dd857bd1101..fc5b885780d11dc71d9b6b36b0449b3efd8b06fa 100644 (file)
@@ -22,7 +22,7 @@
  */
 
 #include <boost/test/unit_test.hpp>
-#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<SubRipContent> content (new SubRipContent (film, "test/data/subrip2.srt"));
+       shared_ptr<TextSubtitleContent> 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);
index 12a311fe84629b82d696e0864385c7cdc86781f0..b5a24f7fc8969653c0c6ddcf45099585155b9f9e 100644 (file)
@@ -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 <boost/test/unit_test.hpp>
 #include <boost/foreach.hpp>
@@ -155,7 +155,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 SubRipContent (film, "test/data/subrip.srt"));
+       shared_ptr<Content> 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<SubRipContent> subs (new SubRipContent (film, "test/data/subrip3.srt"));
+       shared_ptr<TextSubtitleContent> subs (new TextSubtitleContent (film, "test/data/subrip3.srt"));
        film->examine_and_add_content (subs);
        wait_for_jobs ();
 
index 759c2720c8f02e5293bd5e264cb3b894ae9f54c3..c2d3e27bd085d54dfac1a6d6012ecabe3f7dbd53 100644 (file)
@@ -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<SubRipContent> content (new SubRipContent (film, "test/data/subrip2.srt"));
+       shared_ptr<TextSubtitleContent> 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<SubRipContent> content (new SubRipContent (film, "test/data/subrip2.srt"));
+       shared_ptr<TextSubtitleContent> 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<SubRipContent> content (new SubRipContent (film, private_data / "Ankoemmling.srt"));
+       shared_ptr<TextSubtitleContent> content (new TextSubtitleContent (film, private_data / "Ankoemmling.srt"));
        film->examine_and_add_content (content);
        wait_for_jobs ();
 
index cd517cfe9492026a9d88fe345e21d0ab0d09e8ff..d443a416daa7ae752f18650e1d5a544416ee2445 100644 (file)
@@ -39,7 +39,7 @@ using boost::dynamic_pointer_cast;
 BOOST_AUTO_TEST_CASE (subrip_render_test)
 {
        shared_ptr<Film> film = new_test_film ("subrip_render_test");
-       shared_ptr<SubRipContent> content (new SubRipContent (film, "test/data/subrip.srt"));
+       shared_ptr<TextSubtitleContent> content (new TextSubtitleContent (film, "test/data/subrip.srt"));
        content->examine (shared_ptr<Job> (), true);
        BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds ((3 * 60) + 56.471));
 
index 837c73c5870d1a17e9fddc5697bb0c498e940796..554591b9213b20be703b9050003ef20f8087dcb7 100644 (file)
@@ -22,7 +22,7 @@
  */
 
 #include <boost/test/unit_test.hpp>
-#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<SubRipContent> content (new SubRipContent (film, "test/data/subrip2.srt"));
+       shared_ptr<TextSubtitleContent> content (new TextSubtitleContent (film, "test/data/subrip2.srt"));
        content->set_use_subtitles (true);
        content->set_burn_subtitles (false);
        film->examine_and_add_content (content);