summaryrefslogtreecommitdiff
path: root/src/lib/subtitle_content.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-04-14 01:01:28 +0100
committerCarl Hetherington <cth@carlh.net>2016-05-18 11:50:29 +0100
commit65b331d32c383f3a9049f29bf03ab3fe3193b31a (patch)
tree3b27e0ca60742021094cee889a1c8d1ef4d75f8c /src/lib/subtitle_content.cc
parent6dd3777a0074f6f97c7f7286621006a1c14376e8 (diff)
Split audio; builds.
Diffstat (limited to 'src/lib/subtitle_content.cc')
-rw-r--r--src/lib/subtitle_content.cc45
1 files changed, 35 insertions, 10 deletions
diff --git a/src/lib/subtitle_content.cc b/src/lib/subtitle_content.cc
index 03c188b89..089e3a3fc 100644
--- a/src/lib/subtitle_content.cc
+++ b/src/lib/subtitle_content.cc
@@ -24,6 +24,7 @@
#include "font.h"
#include "raw_convert.h"
#include "content.h"
+#include "film.h"
#include <libcxml/cxml.h>
#include <libxml++/libxml++.h>
#include <boost/foreach.hpp>
@@ -85,6 +86,7 @@ SubtitleContent::SubtitleContent (Content* parent, shared_ptr<const Film> film,
node->optional_number_child<int>("OutlineGreen").get_value_or(255),
node->optional_number_child<int>("OutlineBlue").get_value_or(255)
)
+ , _frame_rate (node->optional_number_child<double>("SubtitleFrameRate"))
{
if (version >= 32) {
_use_subtitles = node->bool_child ("UseSubtitles");
@@ -118,38 +120,37 @@ SubtitleContent::SubtitleContent (Content* parent, shared_ptr<const Film> film,
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]);
+ shared_ptr<SubtitleContent> ref = c[0]->subtitle;
DCPOMATIC_ASSERT (ref);
list<shared_ptr<Font> > ref_fonts = ref->fonts ();
- for (size_t i = 0; i < c.size(); ++i) {
- shared_ptr<SubtitleContent> sc = dynamic_pointer_cast<SubtitleContent> (c[i]);
+ for (size_t i = 1; i < c.size(); ++i) {
- if (sc->use_subtitles() != ref->use_subtitles()) {
+ if (c[i]->subtitle->use_subtitles() != ref->use_subtitles()) {
throw JoinError (_("Content to be joined must have the same 'use subtitles' setting."));
}
- if (sc->burn_subtitles() != ref->burn_subtitles()) {
+ if (c[i]->subtitle->burn_subtitles() != ref->burn_subtitles()) {
throw JoinError (_("Content to be joined must have the same 'burn subtitles' setting."));
}
- if (sc->subtitle_x_offset() != ref->subtitle_x_offset()) {
+ if (c[i]->subtitle->subtitle_x_offset() != ref->subtitle_x_offset()) {
throw JoinError (_("Content to be joined must have the same subtitle X offset."));
}
- if (sc->subtitle_y_offset() != ref->subtitle_y_offset()) {
+ if (c[i]->subtitle->subtitle_y_offset() != ref->subtitle_y_offset()) {
throw JoinError (_("Content to be joined must have the same subtitle Y offset."));
}
- if (sc->subtitle_x_scale() != ref->subtitle_x_scale()) {
+ if (c[i]->subtitle->subtitle_x_scale() != ref->subtitle_x_scale()) {
throw JoinError (_("Content to be joined must have the same subtitle X scale."));
}
- if (sc->subtitle_y_scale() != ref->subtitle_y_scale()) {
+ if (c[i]->subtitle->subtitle_y_scale() != ref->subtitle_y_scale()) {
throw JoinError (_("Content to be joined must have the same subtitle Y scale."));
}
- list<shared_ptr<Font> > fonts = sc->fonts ();
+ list<shared_ptr<Font> > fonts = c[i]->subtitle->fonts ();
if (fonts.size() != ref_fonts.size()) {
throw JoinError (_("Content to be joined must use the same fonts."));
}
@@ -315,3 +316,27 @@ SubtitleContent::set_subtitle_language (string language)
{
maybe_set (_subtitle_language, language, SubtitleContentProperty::SUBTITLE_LANGUAGE);
}
+
+void
+SubtitleContent::set_subtitle_video_frame_rate (double r)
+{
+ maybe_set (_frame_rate, r, SubtitleContentProperty::SUBTITLE_VIDEO_FRAME_RATE);
+}
+
+double
+SubtitleContent::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.
+ */
+ shared_ptr<const Film> film = _film.lock ();
+ DCPOMATIC_ASSERT (film);
+ return film->active_frame_rate_change(_parent->position()).source;
+}