X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fstring_text_file_decoder.cc;h=d366bedc0fa84ebd578650eed2c18fb94ef012c6;hb=1a721b82d4094c00ee89574e17c58c23c0de8cdd;hp=e67450b8b719efe38527d74f5b908de3c67a9290;hpb=254b3044d72de6b033d7c584f5abd2b9aa70aad5;p=dcpomatic.git diff --git a/src/lib/string_text_file_decoder.cc b/src/lib/string_text_file_decoder.cc index e67450b8b..d366bedc0 100644 --- a/src/lib/string_text_file_decoder.cc +++ b/src/lib/string_text_file_decoder.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2018 Carl Hetherington + Copyright (C) 2014-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,36 +18,38 @@ */ + #include "string_text_file_decoder.h" #include "string_text_file_content.h" #include "text_content.h" #include "text_decoder.h" #include -#include #include -using std::list; -using std::vector; -using std::string; + using std::cout; -using std::max; -using boost::shared_ptr; -using boost::optional; -using boost::dynamic_pointer_cast; +using std::make_shared; +using std::shared_ptr; +using std::string; +using std::vector; +using namespace dcpomatic; -StringTextFileDecoder::StringTextFileDecoder (shared_ptr content) - : StringTextFile (content) + +StringTextFileDecoder::StringTextFileDecoder (shared_ptr film, shared_ptr content) + : Decoder (film) + , StringTextFile (content) , _next (0) { ContentTime first; if (!_subtitles.empty()) { first = content_time_period(_subtitles[0]).from; } - text.push_back (shared_ptr (new TextDecoder (this, content->only_text(), first))); + text.push_back (make_shared(this, content->only_text(), first)); } + void -StringTextFileDecoder::seek (shared_ptr film, ContentTime time, bool accurate) +StringTextFileDecoder::seek (ContentTime time, bool accurate) { /* It's worth back-tracking a little here as decoding is cheap and it's nice if we don't miss too many subtitles when seeking. @@ -57,7 +59,7 @@ StringTextFileDecoder::seek (shared_ptr film, ContentTime time, bool time = ContentTime(); } - Decoder::seek (film, time, accurate); + Decoder::seek (time, accurate); _next = 0; while (_next < _subtitles.size() && ContentTime::from_seconds (_subtitles[_next].from.all_as_seconds ()) < time) { @@ -65,8 +67,9 @@ StringTextFileDecoder::seek (shared_ptr film, ContentTime time, bool } } + bool -StringTextFileDecoder::pass (shared_ptr) +StringTextFileDecoder::pass () { if (_next >= _subtitles.size ()) { return true; @@ -79,6 +82,7 @@ StringTextFileDecoder::pass (shared_ptr) return false; } + ContentTimePeriod StringTextFileDecoder::content_time_period (sub::Subtitle s) const { @@ -87,3 +91,17 @@ StringTextFileDecoder::content_time_period (sub::Subtitle s) const ContentTime::from_seconds (s.to.all_as_seconds()) ); } + + +vector +StringTextFileDecoder::fonts () const +{ + vector data; + for (auto i: text) { + for (auto j: i->content()->fonts()) { + data.push_back (FontData(j)); + } + } + return data; +} +