summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-07-10 22:41:48 +0100
committerCarl Hetherington <cth@carlh.net>2014-07-10 22:41:48 +0100
commita8af9a0b57b853b8a8cd8fa35adb3fc967d59ee7 (patch)
tree9493b374153de99bc220138361420c5abe85b16e /src/lib
parent8d58a7c5f4320ad5c111e336c45e44d6b51ab509 (diff)
Add has_subtitles method to SubtitleContent; tidy up timeline display a bit.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/dcp_content.cc13
-rw-r--r--src/lib/dcp_content.h4
-rw-r--r--src/lib/dcp_examiner.cc4
-rw-r--r--src/lib/dcp_examiner.h5
-rw-r--r--src/lib/dcp_subtitle_content.h6
-rw-r--r--src/lib/ffmpeg_content.cc6
-rw-r--r--src/lib/ffmpeg_content.h3
-rw-r--r--src/lib/subrip_content.h6
-rw-r--r--src/lib/subtitle_content.h8
9 files changed, 55 insertions, 0 deletions
diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc
index b1d0d9a37..0eef075d7 100644
--- a/src/lib/dcp_content.cc
+++ b/src/lib/dcp_content.cc
@@ -34,6 +34,7 @@ DCPContent::DCPContent (shared_ptr<const Film> f, boost::filesystem::path p)
, VideoContent (f)
, SingleStreamAudioContent (f)
, SubtitleContent (f)
+ , _has_subtitles (false)
, _directory (p)
{
read_directory (p);
@@ -46,6 +47,7 @@ DCPContent::DCPContent (shared_ptr<const Film> f, cxml::ConstNodePtr node, int v
, SubtitleContent (f, node, version)
{
_name = node->string_child ("Name");
+ _has_subtitles = node->bool_child ("HasSubtitles");
_directory = node->string_child ("Directory");
}
@@ -66,12 +68,14 @@ DCPContent::examine (shared_ptr<Job> job)
{
job->set_progress_unknown ();
Content::examine (job);
+
shared_ptr<DCPExaminer> examiner (new DCPExaminer (shared_from_this ()));
take_from_video_examiner (examiner);
take_from_audio_examiner (examiner);
boost::mutex::scoped_lock lm (_mutex);
_name = examiner->name ();
+ _has_subtitles = examiner->has_subtitles ();
}
string
@@ -99,7 +103,9 @@ DCPContent::as_xml (xmlpp::Node* node) const
SingleStreamAudioContent::as_xml (node);
SubtitleContent::as_xml (node);
+ boost::mutex::scoped_lock lm (_mutex);
node->add_child("Name")->add_child_text (_name);
+ node->add_child("HasSubtitles")->add_child_text (_has_subtitles ? "1" : "0");
node->add_child("Directory")->add_child_text (_directory.string ());
}
@@ -116,3 +122,10 @@ DCPContent::identifier () const
{
return SubtitleContent::identifier ();
}
+
+bool
+DCPContent::has_subtitles () const
+{
+ boost::mutex::scoped_lock lm (_mutex);
+ return _has_subtitles;
+}
diff --git a/src/lib/dcp_content.h b/src/lib/dcp_content.h
index 7b7e85d9d..60b7142de 100644
--- a/src/lib/dcp_content.h
+++ b/src/lib/dcp_content.h
@@ -47,6 +47,9 @@ public:
void as_xml (xmlpp::Node *) const;
std::string identifier () const;
+ /* SubtitleContent */
+ bool has_subtitles () const;
+
boost::filesystem::path directory () const {
boost::mutex::scoped_lock lm (_mutex);
return _directory;
@@ -56,5 +59,6 @@ private:
void read_directory (boost::filesystem::path);
std::string _name;
+ bool _has_subtitles;
boost::filesystem::path _directory;
};
diff --git a/src/lib/dcp_examiner.cc b/src/lib/dcp_examiner.cc
index 39bf2d098..625276e18 100644
--- a/src/lib/dcp_examiner.cc
+++ b/src/lib/dcp_examiner.cc
@@ -84,5 +84,9 @@ DCPExaminer::DCPExaminer (shared_ptr<const DCPContent> content)
_audio_length += ContentTime::from_frames ((*i)->main_sound()->duration(), _video_frame_rate.get ());
}
+
+ if ((*i)->main_subtitle ()) {
+ _has_subtitles = true;
+ }
}
}
diff --git a/src/lib/dcp_examiner.h b/src/lib/dcp_examiner.h
index 24a59dd34..5b510743b 100644
--- a/src/lib/dcp_examiner.h
+++ b/src/lib/dcp_examiner.h
@@ -43,6 +43,10 @@ public:
return _name;
}
+ bool has_subtitles () const {
+ return _has_subtitles;
+ }
+
int audio_channels () const {
return _audio_channels.get_value_or (0);
}
@@ -63,4 +67,5 @@ private:
boost::optional<int> _audio_frame_rate;
ContentTime _audio_length;
std::string _name;
+ bool _has_subtitles;
};
diff --git a/src/lib/dcp_subtitle_content.h b/src/lib/dcp_subtitle_content.h
index 79338c1af..5794b5951 100644
--- a/src/lib/dcp_subtitle_content.h
+++ b/src/lib/dcp_subtitle_content.h
@@ -25,6 +25,7 @@ public:
DCPSubtitleContent (boost::shared_ptr<const Film>, boost::filesystem::path);
DCPSubtitleContent (boost::shared_ptr<const Film>, cxml::ConstNodePtr, int);
+ /* Content */
void examine (boost::shared_ptr<Job>);
std::string summary () const;
std::string technical_summary () const;
@@ -32,6 +33,11 @@ public:
void as_xml (xmlpp::Node *) const;
DCPTime full_length () const;
+ /* SubtitleContent */
+ bool has_subtitles () const {
+ return true;
+ }
+
private:
DCPTime _length;
};
diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc
index d2bb329db..9b2bfc606 100644
--- a/src/lib/ffmpeg_content.cc
+++ b/src/lib/ffmpeg_content.cc
@@ -409,3 +409,9 @@ FFmpegContent::subtitles_during (ContentTimePeriod period, bool starting) const
return d;
}
+
+bool
+FFmpegContent::has_subtitles () const
+{
+ return !subtitle_streams().empty ();
+}
diff --git a/src/lib/ffmpeg_content.h b/src/lib/ffmpeg_content.h
index 6bf6c0f50..67839794b 100644
--- a/src/lib/ffmpeg_content.h
+++ b/src/lib/ffmpeg_content.h
@@ -73,6 +73,9 @@ public:
void set_audio_mapping (AudioMapping);
boost::filesystem::path audio_analysis_path () const;
+ /* SubtitleContent */
+ bool has_subtitles () const;
+
void set_filters (std::vector<Filter const *> const &);
std::vector<boost::shared_ptr<FFmpegSubtitleStream> > subtitle_streams () const {
diff --git a/src/lib/subrip_content.h b/src/lib/subrip_content.h
index 7da6e71f7..d2dcdee00 100644
--- a/src/lib/subrip_content.h
+++ b/src/lib/subrip_content.h
@@ -29,6 +29,7 @@ public:
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;
@@ -36,6 +37,11 @@ public:
void as_xml (xmlpp::Node *) const;
DCPTime full_length () const;
+ /* SubtitleContent */
+ bool has_subtitles () const {
+ return true;
+ }
+
private:
DCPTime _length;
};
diff --git a/src/lib/subtitle_content.h b/src/lib/subtitle_content.h
index 1425c33cd..29634f95a 100644
--- a/src/lib/subtitle_content.h
+++ b/src/lib/subtitle_content.h
@@ -31,6 +31,12 @@ public:
static int const SUBTITLE_USE;
};
+/** @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
{
public:
@@ -42,6 +48,8 @@ public:
void as_xml (xmlpp::Node *) const;
std::string identifier () const;
+ virtual bool has_subtitles () const = 0;
+
void set_subtitle_use (bool);
void set_subtitle_x_offset (double);
void set_subtitle_y_offset (double);