Basics of subtitle split.
authorCarl Hetherington <cth@carlh.net>
Wed, 13 Apr 2016 13:46:01 +0000 (14:46 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 18 May 2016 10:50:29 +0000 (11:50 +0100)
18 files changed:
src/lib/content.h
src/lib/content_part.h
src/lib/dcp_content.cc
src/lib/dcp_content.h
src/lib/dcp_decoder.cc
src/lib/dcp_subtitle_content.cc
src/lib/dcp_subtitle_content.h
src/lib/dcp_subtitle_decoder.cc
src/lib/ffmpeg_content.cc
src/lib/ffmpeg_content.h
src/lib/ffmpeg_decoder.cc
src/lib/player.cc
src/lib/playlist.cc
src/lib/subtitle_content.cc
src/lib/subtitle_content.h
src/lib/text_subtitle_content.cc
src/lib/text_subtitle_content.h
src/lib/text_subtitle_decoder.cc

index 0ce9d39c146a781d3b5f54d7755e67c33e3c9d9c..f488962b349272d08d428e6a3848c3cc2c4dec2c 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-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
@@ -167,6 +167,7 @@ public:
        boost::signals2::signal<void (boost::weak_ptr<Content>, int, bool)> Changed;
 
        boost::shared_ptr<VideoContent> video;
+       boost::shared_ptr<SubtitleContent> subtitle;
 
        void signal_changed (int);
 
index 2d0f73f7f87096c76e3cb8bf381a7ea3160fca4d..b1282d98d96fb53e5c35d79a3d6b4df78b350e49 100644 (file)
@@ -17,6 +17,9 @@
 
 */
 
+#ifndef DCPOMATIC_CONTENT_PART_H
+#define DCPOMATIC_CONTENT_PART_H
+
 #include <boost/weak_ptr.hpp>
 
 class Content;
@@ -35,3 +38,5 @@ protected:
        boost::weak_ptr<const Film> _film;
        mutable boost::mutex _mutex;
 };
+
+#endif
index 5a9a47fb11bbde028ae56dea2a226c4ab83886df..81068262b9fc87a5e312d12bfe95a9c4348c7ac8 100644 (file)
@@ -26,6 +26,7 @@
 #include "overlaps.h"
 #include "compose.hpp"
 #include "dcp_decoder.h"
+#include "subtitle_content.h"
 #include <dcp/dcp.h>
 #include <dcp/exceptions.h>
 #include <dcp/reel_picture_asset.h>
@@ -54,7 +55,6 @@ int const DCPContentProperty::REFERENCE_SUBTITLE = 603;
 DCPContent::DCPContent (shared_ptr<const Film> film, boost::filesystem::path p)
        : Content (film)
        , SingleStreamAudioContent (film)
-       , SubtitleContent (film)
        , _has_subtitles (false)
        , _encrypted (false)
        , _kdm_valid (false)
@@ -63,6 +63,7 @@ DCPContent::DCPContent (shared_ptr<const Film> film, boost::filesystem::path p)
        , _reference_subtitle (false)
 {
        video.reset (new VideoContent (this, film));
+       subtitle.reset (new SubtitleContent (this, film));
 
        read_directory (p);
        set_default_colour_conversion ();
@@ -71,9 +72,9 @@ DCPContent::DCPContent (shared_ptr<const Film> film, boost::filesystem::path p)
 DCPContent::DCPContent (shared_ptr<const Film> film, cxml::ConstNodePtr node, int version)
        : Content (film, node)
        , SingleStreamAudioContent (film, node, version)
-       , SubtitleContent (film, node, version)
 {
        video.reset (new VideoContent (this, film, node, version));
+       subtitle.reset (new SubtitleContent (this, film, node, version));
 
        _name = node->string_child ("Name");
        _has_subtitles = node->bool_child ("HasSubtitles");
@@ -148,7 +149,7 @@ DCPContent::as_xml (xmlpp::Node* node) const
        Content::as_xml (node);
        video->as_xml (node);
        SingleStreamAudioContent::as_xml (node);
-       SubtitleContent::as_xml (node);
+       subtitle->as_xml (node);
 
        boost::mutex::scoped_lock lm (_mutex);
        node->add_child("Name")->add_child_text (_name);
@@ -174,7 +175,7 @@ string
 DCPContent::identifier () const
 {
        SafeStringStream s;
-       s << Content::identifier() << "_" << video->identifier() << "_" << SubtitleContent::identifier () << " "
+       s << Content::identifier() << "_" << video->identifier() << "_" << subtitle->identifier () << " "
          << (_reference_video ? "1" : "0")
          << (_reference_subtitle ? "1" : "0");
        return s.str ();
@@ -337,15 +338,8 @@ DCPContent::can_reference_audio (list<string>& why_not) const
 bool
 DCPContent::can_reference_subtitle (list<string>& why_not) const
 {
-       DCPDecoder decoder (shared_from_this(), film()->log(), false);
-       BOOST_FOREACH (shared_ptr<dcp::Reel> i, decoder.reels()) {
-               if (!i->main_subtitle()) {
-                       why_not.push_back (_("The DCP does not have subtitles in all reels."));
-                       return false;
-               }
-       }
-
-       return can_reference<SubtitleContent> (_("There is other subtitle content overlapping this DCP; remove it."), why_not);
+       /* XXX: this needs to be fixed */
+       return true;
 }
 
 double
index 1edc3a3aaaac7276a600499f60b7a93d7f4d0100..81432b6d310adc4d62a168e086d6753ce2d4b031 100644 (file)
@@ -25,7 +25,6 @@
  */
 
 #include "single_stream_audio_content.h"
-#include "subtitle_content.h"
 #include <libcxml/cxml.h>
 #include <dcp/encrypted_kdm.h>
 
@@ -41,7 +40,7 @@ public:
 /** @class DCPContent
  *  @brief An existing DCP used as input.
  */
-class DCPContent : public SingleStreamAudioContent, public SubtitleContent
+class DCPContent : public SingleStreamAudioContent
 {
 public:
        DCPContent (boost::shared_ptr<const Film>, boost::filesystem::path p);
index e8c64a086012742e1fe3c4fe3c8bfe3320ece87c..f032ee661781914759afa73baea10c0fbc3e2496 100644 (file)
@@ -45,7 +45,7 @@ using boost::dynamic_pointer_cast;
 DCPDecoder::DCPDecoder (shared_ptr<const DCPContent> c, shared_ptr<Log> log, bool fast)
        : VideoDecoder (c->video, log)
        , AudioDecoder (c, fast)
-       , SubtitleDecoder (c)
+       , SubtitleDecoder (c->subtitle)
        , _dcp_content (c)
 {
        dcp::DCP dcp (c->directory ());
index 39f24b21514c01d1bdb7247ac44366aff4fc2e16..b38c0c6a76e0b27ae56a6dd8b77f8547d01b0405 100644 (file)
@@ -21,6 +21,7 @@
 #include "dcp_subtitle_content.h"
 #include "raw_convert.h"
 #include "film.h"
+#include "subtitle_content.h"
 #include <dcp/interop_subtitle_asset.h>
 #include <dcp/smpte_subtitle_asset.h>
 #include <dcp/interop_load_font_node.h>
@@ -36,18 +37,16 @@ using boost::dynamic_pointer_cast;
 
 DCPSubtitleContent::DCPSubtitleContent (shared_ptr<const Film> film, boost::filesystem::path path)
        : Content (film, path)
-       , SubtitleContent (film, path)
 {
-
+       subtitle.reset (new SubtitleContent (this, film));
 }
 
 DCPSubtitleContent::DCPSubtitleContent (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<int>("SubtitleFrameRate"))
 {
-
+       subtitle.reset (new SubtitleContent (this, film, node, version));
 }
 
 void
@@ -58,24 +57,24 @@ DCPSubtitleContent::examine (shared_ptr<Job> job)
        shared_ptr<dcp::SubtitleAsset> sc = load (path (0));
 
        /* Default to turning these subtitles on */
-       set_use_subtitles (true);
+       subtitle->set_use_subtitles (true);
 
        boost::mutex::scoped_lock lm (_mutex);
 
        shared_ptr<dcp::InteropSubtitleAsset> iop = dynamic_pointer_cast<dcp::InteropSubtitleAsset> (sc);
        if (iop) {
-               _subtitle_language = iop->language ();
+               subtitle->set_subtitle_language (iop->language ());
        }
        shared_ptr<dcp::SMPTESubtitleAsset> smpte = dynamic_pointer_cast<dcp::SMPTESubtitleAsset> (sc);
        if (smpte) {
-               _subtitle_language = smpte->language().get_value_or ("");
+               subtitle->set_subtitle_language (smpte->language().get_value_or (""));
                _frame_rate = smpte->edit_rate().numerator;
        }
 
        _length = ContentTime::from_seconds (sc->latest_subtitle_out().as_seconds ());
 
        BOOST_FOREACH (shared_ptr<dcp::LoadFontNode> i, sc->load_font_nodes ()) {
-               add_font (shared_ptr<Font> (new Font (i->id)));
+               subtitle->add_font (shared_ptr<Font> (new Font (i->id)));
        }
 }
 
@@ -103,7 +102,7 @@ DCPSubtitleContent::as_xml (xmlpp::Node* node) const
 {
        node->add_child("Type")->add_child_text ("DCPSubtitle");
        Content::as_xml (node);
-       SubtitleContent::as_xml (node);
+       subtitle->as_xml (node);
        node->add_child("Length")->add_child_text (raw_convert<string> (_length.get ()));
 }
 
index 8873283931114383a74a1d0411eafc2a78300dc3..de9fa68ec6fa8b57dc545e1a716c10af5c00d50e 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
+    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
 
 */
 
-#include "subtitle_content.h"
 #include "dcp_subtitle.h"
+#include "content.h"
 
-class DCPSubtitleContent : public SubtitleContent, public DCPSubtitle
+class DCPSubtitleContent : public DCPSubtitle, public Content
 {
 public:
        DCPSubtitleContent (boost::shared_ptr<const Film>, boost::filesystem::path);
index 1bcc7fcf17844926eb217095ecc559b7cfab4fbe..964ee6f202cea7e8ef0b5d503dab34ac07b446fb 100644 (file)
@@ -27,7 +27,7 @@ using std::cout;
 using boost::shared_ptr;
 
 DCPSubtitleDecoder::DCPSubtitleDecoder (shared_ptr<const DCPSubtitleContent> content)
-       : SubtitleDecoder (content)
+       : SubtitleDecoder (content->subtitle)
 {
        shared_ptr<dcp::SubtitleAsset> c (load (content->path (0)));
        _subtitles = c->subtitles ();
index a8b7fb716cecf92d39b1b931ddf7d49277f35bee..f276a16a33114c1345990ca488dd58c47d75bc35 100644 (file)
@@ -32,6 +32,7 @@
 #include "frame_rate_change.h"
 #include "safe_stringstream.h"
 #include "raw_convert.h"
+#include "subtitle_content.h"
 #include <libcxml/cxml.h>
 extern "C" {
 #include <libavformat/avformat.h>
@@ -62,9 +63,9 @@ int const FFmpegContentProperty::FILTERS = 102;
 FFmpegContent::FFmpegContent (shared_ptr<const Film> film, boost::filesystem::path p)
        : Content (film, p)
        , AudioContent (film, p)
-       , SubtitleContent (film, p)
 {
        video.reset (new VideoContent (this, film));
+       subtitle.reset (new SubtitleContent (this, film));
 
        set_default_colour_conversion ();
 }
@@ -72,9 +73,9 @@ FFmpegContent::FFmpegContent (shared_ptr<const Film> film, boost::filesystem::pa
 FFmpegContent::FFmpegContent (shared_ptr<const Film> film, cxml::ConstNodePtr node, int version, list<string>& notes)
        : Content (film, node)
        , AudioContent (film, node)
-       , SubtitleContent (film, node, version)
 {
        video.reset (new VideoContent (this, film, node, version));
+       subtitle.reset (new SubtitleContent (this, film, node, version));
 
        list<cxml::NodePtr> c = node->node_children ("SubtitleStream");
        for (list<cxml::NodePtr>::const_iterator i = c.begin(); i != c.end(); ++i) {
@@ -121,16 +122,16 @@ FFmpegContent::FFmpegContent (shared_ptr<const Film> film, cxml::ConstNodePtr no
 FFmpegContent::FFmpegContent (shared_ptr<const Film> film, vector<boost::shared_ptr<Content> > c)
        : Content (film, c)
        , AudioContent (film, c)
-       , SubtitleContent (film, c)
 {
        video.reset (new VideoContent (this, film, c));
+       subtitle.reset (new SubtitleContent (this, film, c));
 
        shared_ptr<FFmpegContent> ref = dynamic_pointer_cast<FFmpegContent> (c[0]);
        DCPOMATIC_ASSERT (ref);
 
        for (size_t i = 0; i < c.size(); ++i) {
                shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (c[i]);
-               if (fc->use_subtitles() && *(fc->_subtitle_stream.get()) != *(ref->_subtitle_stream.get())) {
+               if (fc->subtitle->use_subtitles() && *(fc->_subtitle_stream.get()) != *(ref->_subtitle_stream.get())) {
                        throw JoinError (_("Content to be joined must use the same subtitle stream."));
                }
        }
@@ -156,7 +157,7 @@ FFmpegContent::as_xml (xmlpp::Node* node) const
        Content::as_xml (node);
        video->as_xml (node);
        AudioContent::as_xml (node);
-       SubtitleContent::as_xml (node);
+       subtitle->as_xml (node);
 
        boost::mutex::scoped_lock lm (_mutex);
 
@@ -312,7 +313,7 @@ FFmpegContent::identifier () const
 
        s << Content::identifier() << "_"
          << video->identifier() << "_"
-         << SubtitleContent::identifier();
+         << subtitle->identifier();
 
        boost::mutex::scoped_lock lm (_mutex);
 
index d210d63a8b98e8cb674b6b745d25ee7d901b5986..da0eb48af70ed9c8ca2b61eb2ba7963535532b76 100644 (file)
@@ -21,7 +21,6 @@
 #define DCPOMATIC_FFMPEG_CONTENT_H
 
 #include "audio_content.h"
-#include "subtitle_content.h"
 
 struct AVFormatContext;
 struct AVStream;
@@ -42,7 +41,7 @@ public:
        static int const FILTERS;
 };
 
-class FFmpegContent : public AudioContent, public SubtitleContent
+class FFmpegContent : public AudioContent
 {
 public:
        FFmpegContent (boost::shared_ptr<const Film>, boost::filesystem::path);
index 5240decb24dfd69e74650b31a2de3b13ab8c8f18..15cc9b2560053659cb5ee0437c458c82778dfd7c 100644 (file)
@@ -74,12 +74,11 @@ using dcp::Size;
 FFmpegDecoder::FFmpegDecoder (shared_ptr<const FFmpegContent> c, shared_ptr<Log> log, bool fast)
        : VideoDecoder (c->video, log)
        , AudioDecoder (c, fast)
-       , SubtitleDecoder (c)
+       , SubtitleDecoder (c->subtitle)
        , FFmpeg (c)
        , _log (log)
        , _pts_offset (pts_offset (c->ffmpeg_audio_streams(), c->first_video(), c->video->video_frame_rate()))
 {
-
 }
 
 void
index 2b65fd54e393d5c252fecb67a564115d45bb3630..ca833208cee034b6113f904ed997f73e43aaa882 100644 (file)
@@ -631,12 +631,11 @@ Player::get_subtitles (DCPTime time, DCPTime length, bool starting, bool burnt,
        PlayerSubtitles ps (time, length);
 
        for (list<shared_ptr<Piece> >::const_iterator j = subs.begin(); j != subs.end(); ++j) {
-               shared_ptr<SubtitleContent> subtitle_content = dynamic_pointer_cast<SubtitleContent> ((*j)->content);
-               if (!subtitle_content->use_subtitles () || (!_always_burn_subtitles && (burnt != subtitle_content->burn_subtitles ()))) {
+               if (!(*j)->content->subtitle->use_subtitles () || (!_always_burn_subtitles && (burnt != (*j)->content->subtitle->burn_subtitles ()))) {
                        continue;
                }
 
-               shared_ptr<DCPContent> dcp_content = dynamic_pointer_cast<DCPContent> (subtitle_content);
+               shared_ptr<DCPContent> dcp_content = dynamic_pointer_cast<DCPContent> ((*j)->content);
                if (dcp_content && dcp_content->reference_subtitle () && !_play_referenced) {
                        continue;
                }
@@ -650,16 +649,16 @@ Player::get_subtitles (DCPTime time, DCPTime length, bool starting, bool burnt,
                for (list<ContentImageSubtitle>::iterator i = image.begin(); i != image.end(); ++i) {
 
                        /* Apply content's subtitle offsets */
-                       i->sub.rectangle.x += subtitle_content->subtitle_x_offset ();
-                       i->sub.rectangle.y += subtitle_content->subtitle_y_offset ();
+                       i->sub.rectangle.x += (*j)->content->subtitle->subtitle_x_offset ();
+                       i->sub.rectangle.y += (*j)->content->subtitle->subtitle_y_offset ();
 
                        /* Apply content's subtitle scale */
-                       i->sub.rectangle.width *= subtitle_content->subtitle_x_scale ();
-                       i->sub.rectangle.height *= subtitle_content->subtitle_y_scale ();
+                       i->sub.rectangle.width *= (*j)->content->subtitle->subtitle_x_scale ();
+                       i->sub.rectangle.height *= (*j)->content->subtitle->subtitle_y_scale ();
 
                        /* Apply a corrective translation to keep the subtitle centred after that scale */
-                       i->sub.rectangle.x -= i->sub.rectangle.width * (subtitle_content->subtitle_x_scale() - 1);
-                       i->sub.rectangle.y -= i->sub.rectangle.height * (subtitle_content->subtitle_y_scale() - 1);
+                       i->sub.rectangle.x -= i->sub.rectangle.width * ((*j)->content->subtitle->subtitle_x_scale() - 1);
+                       i->sub.rectangle.y -= i->sub.rectangle.height * ((*j)->content->subtitle->subtitle_y_scale() - 1);
 
                        ps.image.push_back (i->sub);
                }
@@ -667,10 +666,10 @@ Player::get_subtitles (DCPTime time, DCPTime length, bool starting, bool burnt,
                list<ContentTextSubtitle> text = subtitle_decoder->get_text_subtitles (ContentTimePeriod (from, to), starting, accurate);
                BOOST_FOREACH (ContentTextSubtitle& ts, text) {
                        BOOST_FOREACH (dcp::SubtitleString s, ts.subs) {
-                               s.set_h_position (s.h_position() + subtitle_content->subtitle_x_offset ());
-                               s.set_v_position (s.v_position() + subtitle_content->subtitle_y_offset ());
-                               float const xs = subtitle_content->subtitle_x_scale();
-                               float const ys = subtitle_content->subtitle_y_scale();
+                               s.set_h_position (s.h_position() + (*j)->content->subtitle->subtitle_x_offset ());
+                               s.set_v_position (s.v_position() + (*j)->content->subtitle->subtitle_y_offset ());
+                               float const xs = (*j)->content->subtitle->subtitle_x_scale();
+                               float const ys = (*j)->content->subtitle->subtitle_y_scale();
                                float size = s.size();
 
                                /* Adjust size to express the common part of the scaling;
@@ -688,7 +687,7 @@ Player::get_subtitles (DCPTime time, DCPTime length, bool starting, bool burnt,
                                s.set_in (dcp::Time(content_subtitle_to_dcp (*j, ts.period().from).seconds(), 1000));
                                s.set_out (dcp::Time(content_subtitle_to_dcp (*j, ts.period().to).seconds(), 1000));
                                ps.text.push_back (s);
-                               ps.add_fonts (subtitle_content->fonts ());
+                               ps.add_fonts ((*j)->content->subtitle->fonts ());
                        }
                }
        }
index f03f8a9a1747eb7fcd061c2c4f078ce93a598ec5..9df7857b5cda85297ee00cbda307b9c7ef66d4b0 100644 (file)
@@ -21,6 +21,7 @@
 #include "sndfile_content.h"
 #include "sndfile_decoder.h"
 #include "video_content.h"
+#include "subtitle_content.h"
 #include "ffmpeg_decoder.h"
 #include "ffmpeg_content.h"
 #include "image_decoder.h"
@@ -129,13 +130,12 @@ Playlist::maybe_sequence ()
 
        DCPTime next;
        BOOST_FOREACH (shared_ptr<Content> i, _content) {
-               shared_ptr<SubtitleContent> sc = dynamic_pointer_cast<SubtitleContent> (i);
-               if (!sc || !sc->has_subtitles() || find (placed.begin(), placed.end(), i) != placed.end()) {
+               if (!i->subtitle || !i->subtitle->has_subtitles() || find (placed.begin(), placed.end(), i) != placed.end()) {
                        continue;
                }
 
-               sc->set_position (next);
-               next = sc->end();
+               i->set_position (next);
+               next = i->end();
        }
 
 
index 48c9e9cf6c8fb673df9f8b94582be870ba3d896c..bdc2b729cf8786757bc7bd3ce044534a7b8916a2 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-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
@@ -47,8 +47,8 @@ int const SubtitleContentProperty::SUBTITLE_LANGUAGE = 506;
 int const SubtitleContentProperty::FONTS = 507;
 int const SubtitleContentProperty::SUBTITLE_VIDEO_FRAME_RATE = 508;
 
-SubtitleContent::SubtitleContent (shared_ptr<const Film> film)
-       : Content (film)
+SubtitleContent::SubtitleContent (Content* parent, shared_ptr<const Film> film)
+       : ContentPart (parent, film)
        , _use_subtitles (false)
        , _burn_subtitles (false)
        , _subtitle_x_offset (0)
@@ -59,20 +59,8 @@ SubtitleContent::SubtitleContent (shared_ptr<const Film> film)
 
 }
 
-SubtitleContent::SubtitleContent (shared_ptr<const Film> film, boost::filesystem::path p)
-       : Content (film, p)
-       , _use_subtitles (false)
-       , _burn_subtitles (false)
-       , _subtitle_x_offset (0)
-       , _subtitle_y_offset (0)
-       , _subtitle_x_scale (1)
-       , _subtitle_y_scale (1)
-{
-
-}
-
-SubtitleContent::SubtitleContent (shared_ptr<const Film> film, cxml::ConstNodePtr node, int version)
-       : Content (film, node)
+SubtitleContent::SubtitleContent (Content* parent, shared_ptr<const Film> film, cxml::ConstNodePtr node, int version)
+       : ContentParet (parent, film)
        , _use_subtitles (false)
        , _burn_subtitles (false)
        , _subtitle_x_offset (0)
@@ -109,8 +97,8 @@ SubtitleContent::SubtitleContent (shared_ptr<const Film> film, cxml::ConstNodePt
        connect_to_fonts ();
 }
 
-SubtitleContent::SubtitleContent (shared_ptr<const Film> film, vector<shared_ptr<Content> > c)
-       : Content (film, c)
+SubtitleContent::SubtitleContent (Content* parent, shared_ptr<const Film> film, vector<shared_ptr<Content> > c)
+       : ContentPart (parent, film)
 {
        shared_ptr<SubtitleContent> ref = dynamic_pointer_cast<SubtitleContent> (c[0]);
        DCPOMATIC_ASSERT (ref);
index e9017e40da4d51d500a4704235cf160ee6e13b4f..f9d5336f2d6c0fdcfdaee380421307317d424256 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-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
@@ -20,7 +20,9 @@
 #ifndef DCPOMATIC_SUBTITLE_CONTENT_H
 #define DCPOMATIC_SUBTITLE_CONTENT_H
 
-#include "content.h"
+#include "content_part.h"
+#include <libcxml/cxml.h>
+#include <boost/signals2.hpp>
 
 class Font;
 
@@ -38,27 +40,17 @@ public:
        static int const SUBTITLE_VIDEO_FRAME_RATE;
 };
 
-/** @class SubtitleContent
- *  @brief Parent for content which has the potential to include subtitles.
- *
- *  Although inheriting from this class indicates that the content could
- *  have subtitles, it may not.  ::has_subtitles() will tell you.
- */
-class SubtitleContent : public virtual Content
+class SubtitleContent : public ContentPart
 {
 public:
-       SubtitleContent (boost::shared_ptr<const Film>);
-       SubtitleContent (boost::shared_ptr<const Film>, boost::filesystem::path);
-       SubtitleContent (boost::shared_ptr<const Film>, cxml::ConstNodePtr, int version);
-       SubtitleContent (boost::shared_ptr<const Film>, std::vector<boost::shared_ptr<Content> >);
+       SubtitleContent (Content* parent, boost::shared_ptr<const Film>);
+       SubtitleContent (Content* parent, boost::shared_ptr<const Film>, cxml::ConstNodePtr, int version);
+       SubtitleContent (Content* parent, boost::shared_ptr<const Film>, std::vector<boost::shared_ptr<Content> >);
 
        void as_xml (xmlpp::Node *) const;
        std::string identifier () const;
 
        bool has_subtitles () const;
-       virtual bool has_text_subtitles () const = 0;
-       virtual bool has_image_subtitles () const = 0;
-       virtual double subtitle_video_frame_rate () const = 0;
 
        void add_font (boost::shared_ptr<Font> font);
 
index 0de219574332ea8b542a9f00478d15ecfef369bb..88890ebdc455184b40ea8c57ba1278d8b23ef314 100644 (file)
@@ -23,6 +23,7 @@
 #include "film.h"
 #include "font.h"
 #include "raw_convert.h"
+#include "subtitle_content.h"
 #include <libxml++/libxml++.h>
 #include <iostream>
 
@@ -40,17 +41,15 @@ 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)
 {
-
+       subtitle.reset (new SubtitleContent (this, film, path));
 }
 
 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>("SubtitleVideoFrameRate"))
        , _colour (
@@ -65,7 +64,7 @@ TextSubtitleContent::TextSubtitleContent (shared_ptr<const Film> film, cxml::Con
                node->optional_number_child<int>("OutlineBlue").get_value_or(255)
                )
 {
-
+       subtitle.reset (new SubtitleContent (this, film, node, version));
 }
 
 void
@@ -99,7 +98,7 @@ TextSubtitleContent::as_xml (xmlpp::Node* node) const
 {
        node->add_child("Type")->add_child_text ("TextSubtitle");
        Content::as_xml (node);
-       SubtitleContent::as_xml (node);
+       subtitle->as_xml (node);
        node->add_child("Length")->add_child_text (raw_convert<string> (_length.get ()));
        if (_frame_rate) {
                node->add_child("SubtitleVideoFrameRate")->add_child_text (raw_convert<string> (_frame_rate.get()));
index 2c8e3b1b7e77bd203b5f04dfd13f6f73277e4b07..a2ef5d98abed2eb15dd8e720c9a4cb34d7ae9882 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
+    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
@@ -17,7 +17,9 @@
 
 */
 
-#include "subtitle_content.h"
+#include "content.h"
+
+class Job;
 
 class TextSubtitleContentProperty
 {
@@ -30,7 +32,7 @@ public:
 /** @class TextSubtitleContent
  *  @brief SubRip or SSA subtitles.
  */
-class TextSubtitleContent : public SubtitleContent
+class TextSubtitleContent : public Content
 {
 public:
        TextSubtitleContent (boost::shared_ptr<const Film>, boost::filesystem::path);
index c94a002f550bdec8f0cc73ac399261178289c145..36e44cc99012936979cdb84bee26bb65a74bfdf1 100644 (file)
@@ -33,7 +33,7 @@ using boost::optional;
 using boost::dynamic_pointer_cast;
 
 TextSubtitleDecoder::TextSubtitleDecoder (shared_ptr<const TextSubtitleContent> content)
-       : SubtitleDecoder (content)
+       : SubtitleDecoder (content->subtitle)
        , TextSubtitle (content)
        , _next (0)
 {