diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-06-06 21:00:50 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-06-06 21:00:50 +0200 |
| commit | 59953282b9f9da1164f39181347a01672c4f674c (patch) | |
| tree | 332a13a1280591ce0b9b7ede6fb57edd5462deec /src/lib | |
| parent | f807d3f9751c43bcfa0b260aeb5deca5f00761d2 (diff) | |
Make jump-to-first-subtitle also work with DCP subs.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/dcp_subtitle_decoder.cc | 24 | ||||
| -rw-r--r-- | src/lib/dcp_subtitle_decoder.h | 2 |
2 files changed, 19 insertions, 7 deletions
diff --git a/src/lib/dcp_subtitle_decoder.cc b/src/lib/dcp_subtitle_decoder.cc index 169a41751..d5cbabf1b 100644 --- a/src/lib/dcp_subtitle_decoder.cc +++ b/src/lib/dcp_subtitle_decoder.cc @@ -19,22 +19,21 @@ */ -#include "dcp_subtitle_decoder.h" #include "dcp_subtitle_content.h" +#include "dcp_subtitle_decoder.h" #include "font.h" #include "text_content.h" #include <dcp/interop_subtitle_asset.h> #include <dcp/load_font_node.h> -#include <iostream> -using std::cout; +using std::dynamic_pointer_cast; using std::list; +using std::make_shared; +using std::shared_ptr; using std::string; using std::vector; -using std::shared_ptr; -using std::dynamic_pointer_cast; -using std::make_shared; +using boost::optional; using namespace dcpomatic; @@ -42,7 +41,7 @@ DCPSubtitleDecoder::DCPSubtitleDecoder (shared_ptr<const Film> film, shared_ptr< : Decoder (film) { /* Load the XML or MXF file */ - shared_ptr<dcp::SubtitleAsset> const c = load (content->path(0)); + auto const c = load (content->path(0)); c->fix_empty_font_ids (); _subtitles = c->subtitles (); _next = _subtitles.begin (); @@ -162,3 +161,14 @@ DCPSubtitleDecoder::fonts () const return _fonts; } + +/** @return time of first subtitle, if there is one */ +optional<ContentTime> +DCPSubtitleDecoder::first () const +{ + if (_subtitles.empty()) { + return {}; + } + + return ContentTime::from_seconds(_subtitles[0]->in().as_seconds()); +} diff --git a/src/lib/dcp_subtitle_decoder.h b/src/lib/dcp_subtitle_decoder.h index 4a54aaf2e..d1237b276 100644 --- a/src/lib/dcp_subtitle_decoder.h +++ b/src/lib/dcp_subtitle_decoder.h @@ -37,6 +37,8 @@ public: std::vector<dcpomatic::FontData> fonts () const override; + boost::optional<dcpomatic::ContentTime> first () const; + private: dcpomatic::ContentTimePeriod content_time_period (std::shared_ptr<const dcp::Subtitle> s) const; |
