summaryrefslogtreecommitdiff
path: root/src/subtitle_asset.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/subtitle_asset.cc')
-rw-r--r--src/subtitle_asset.cc29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/subtitle_asset.cc b/src/subtitle_asset.cc
index ca27d6da..22098213 100644
--- a/src/subtitle_asset.cc
+++ b/src/subtitle_asset.cc
@@ -19,9 +19,11 @@
#include "subtitle_asset.h"
+using namespace std;
+using namespace boost;
using namespace libdcp;
-SubtitleAsset::SubtitleAsset (std::string directory, std::string xml)
+SubtitleAsset::SubtitleAsset (string directory, string xml)
: Asset (directory, xml)
, XMLFile (path().string(), "DCSubtitle")
{
@@ -55,3 +57,28 @@ Text::Text (xmlpp::Node const * node)
_text = content ();
_v_position = float_attribute ("VPosition");
}
+
+list<shared_ptr<Text> >
+SubtitleAsset::subtitles_at (Time t) const
+{
+ for (list<shared_ptr<Font> >::const_iterator i = _fonts.begin(); i != _fonts.end(); ++i) {
+ list<shared_ptr<Text> > s = (*i)->subtitles_at (t);
+ if (!s.empty ()) {
+ return s;
+ }
+ }
+
+ return list<shared_ptr<Text> > ();
+}
+
+list<shared_ptr<Text> >
+Font::subtitles_at (Time t) const
+{
+ for (list<shared_ptr<Subtitle> >::const_iterator i = _subtitles.begin(); i != _subtitles.end(); ++i) {
+ if ((*i)->in() <= t && t <= (*i)->out()) {
+ return (*i)->texts ();
+ }
+ }
+
+ return list<shared_ptr<Text> > ();
+}