summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-04-13 14:46:01 +0100
committerCarl Hetherington <cth@carlh.net>2016-05-18 11:50:29 +0100
commit334b94526f2c1271718a94fe97cfa843cf6ef7a1 (patch)
tree67fa8769c7fb72ec6bff799c2a3d1b087454734a /src/lib
parent78664f8073256de51355c9162f61a4ae4fa560d7 (diff)
Basics of subtitle split.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/content.h3
-rw-r--r--src/lib/content_part.h5
-rw-r--r--src/lib/dcp_content.cc20
-rw-r--r--src/lib/dcp_content.h3
-rw-r--r--src/lib/dcp_decoder.cc2
-rw-r--r--src/lib/dcp_subtitle_content.cc17
-rw-r--r--src/lib/dcp_subtitle_content.h6
-rw-r--r--src/lib/dcp_subtitle_decoder.cc2
-rw-r--r--src/lib/ffmpeg_content.cc13
-rw-r--r--src/lib/ffmpeg_content.h3
-rw-r--r--src/lib/ffmpeg_decoder.cc3
-rw-r--r--src/lib/player.cc27
-rw-r--r--src/lib/playlist.cc8
-rw-r--r--src/lib/subtitle_content.cc26
-rw-r--r--src/lib/subtitle_content.h24
-rw-r--r--src/lib/text_subtitle_content.cc9
-rw-r--r--src/lib/text_subtitle_content.h8
-rw-r--r--src/lib/text_subtitle_decoder.cc2
18 files changed, 79 insertions, 102 deletions
diff --git a/src/lib/content.h b/src/lib/content.h
index 0ce9d39c1..f488962b3 100644
--- a/src/lib/content.h
+++ b/src/lib/content.h
@@ -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);
diff --git a/src/lib/content_part.h b/src/lib/content_part.h
index 2d0f73f7f..b1282d98d 100644
--- a/src/lib/content_part.h
+++ b/src/lib/content_part.h
@@ -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
diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc
index 5a9a47fb1..81068262b 100644
--- a/src/lib/dcp_content.cc
+++ b/src/lib/dcp_content.cc
@@ -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
diff --git a/src/lib/dcp_content.h b/src/lib/dcp_content.h
index 1edc3a3aa..81432b6d3 100644
--- a/src/lib/dcp_content.h
+++ b/src/lib/dcp_content.h
@@ -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);
diff --git a/src/lib/dcp_decoder.cc b/src/lib/dcp_decoder.cc
index e8c64a086..f032ee661 100644
--- a/src/lib/dcp_decoder.cc
+++ b/src/lib/dcp_decoder.cc
@@ -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 ());
diff --git a/src/lib/dcp_subtitle_content.cc b/src/lib/dcp_subtitle_content.cc
index 39f24b215..b38c0c6a7 100644
--- a/src/lib/dcp_subtitle_content.cc
+++ b/src/lib/dcp_subtitle_content.cc
@@ -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 ()));
}
diff --git a/src/lib/dcp_subtitle_content.h b/src/lib/dcp_subtitle_content.h
index 887328393..de9fa68ec 100644
--- a/src/lib/dcp_subtitle_content.h
+++ b/src/lib/dcp_subtitle_content.h
@@ -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,10 +17,10 @@
*/
-#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);
diff --git a/src/lib/dcp_subtitle_decoder.cc b/src/lib/dcp_subtitle_decoder.cc
index 1bcc7fcf1..964ee6f20 100644
--- a/src/lib/dcp_subtitle_decoder.cc
+++ b/src/lib/dcp_subtitle_decoder.cc
@@ -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 ();
diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc
index a8b7fb716..f276a16a3 100644
--- a/src/lib/ffmpeg_content.cc
+++ b/src/lib/ffmpeg_content.cc
@@ -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);
diff --git a/src/lib/ffmpeg_content.h b/src/lib/ffmpeg_content.h
index d210d63a8..da0eb48af 100644
--- a/src/lib/ffmpeg_content.h
+++ b/src/lib/ffmpeg_content.h
@@ -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);
diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc
index 5240decb2..15cc9b256 100644
--- a/src/lib/ffmpeg_decoder.cc
+++ b/src/lib/ffmpeg_decoder.cc
@@ -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
diff --git a/src/lib/player.cc b/src/lib/player.cc
index 2b65fd54e..ca833208c 100644
--- a/src/lib/player.cc
+++ b/src/lib/player.cc
@@ -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 ());
}
}
}
diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc
index f03f8a9a1..9df7857b5 100644
--- a/src/lib/playlist.cc
+++ b/src/lib/playlist.cc
@@ -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();
}
diff --git a/src/lib/subtitle_content.cc b/src/lib/subtitle_content.cc
index 48c9e9cf6..bdc2b729c 100644
--- a/src/lib/subtitle_content.cc
+++ b/src/lib/subtitle_content.cc
@@ -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);
diff --git a/src/lib/subtitle_content.h b/src/lib/subtitle_content.h
index e9017e40d..f9d5336f2 100644
--- a/src/lib/subtitle_content.h
+++ b/src/lib/subtitle_content.h
@@ -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);
diff --git a/src/lib/text_subtitle_content.cc b/src/lib/text_subtitle_content.cc
index 0de219574..88890ebdc 100644
--- a/src/lib/text_subtitle_content.cc
+++ b/src/lib/text_subtitle_content.cc
@@ -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()));
diff --git a/src/lib/text_subtitle_content.h b/src/lib/text_subtitle_content.h
index 2c8e3b1b7..a2ef5d98a 100644
--- a/src/lib/text_subtitle_content.h
+++ b/src/lib/text_subtitle_content.h
@@ -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);
diff --git a/src/lib/text_subtitle_decoder.cc b/src/lib/text_subtitle_decoder.cc
index c94a002f5..36e44cc99 100644
--- a/src/lib/text_subtitle_decoder.cc
+++ b/src/lib/text_subtitle_decoder.cc
@@ -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)
{