X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Flib%2Fsubtitle_decoder.h;h=73d447b9a9480990cee298e5da13758e56f81efb;hp=82662d192fbd1295d8574d7001b44d413984c353;hb=3828baf56467224f5d44049bf1e7a7ed11f43a05;hpb=b299c1873bf23414061d551843275c77a9256a05 diff --git a/src/lib/subtitle_decoder.h b/src/lib/subtitle_decoder.h index 82662d192..73d447b9a 100644 --- a/src/lib/subtitle_decoder.h +++ b/src/lib/subtitle_decoder.h @@ -1,44 +1,71 @@ /* - Copyright (C) 2013 Carl Hetherington + Copyright (C) 2013-2016 Carl Hetherington - This program is free software; you can redistribute it and/or modify + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - This program is distributed in the hope that it will be useful, + DCP-o-matic is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with DCP-o-matic. If not, see . */ #ifndef DCPOMATIC_SUBTITLE_DECODER_H #define DCPOMATIC_SUBTITLE_DECODER_H -#include -#include #include "decoder.h" #include "rect.h" #include "types.h" -#include "decoded.h" +#include "content_subtitle.h" +#include -class Film; -class DCPTimedSubtitle; class Image; -class SubtitleDecoder : public virtual Decoder +class SubtitleDecoder { public: - SubtitleDecoder (boost::shared_ptr); + /** Second parameter to the _during functions is true if we + * want only subtitles that start during the period, + * otherwise we want subtitles that overlap the period. + */ + SubtitleDecoder ( + Decoder* parent, + boost::shared_ptr, + boost::function (ContentTimePeriod, bool)> image_during, + boost::function (ContentTimePeriod, bool)> text_during + ); + + std::list get_image (ContentTimePeriod period, bool starting, bool accurate); + std::list get_text (ContentTimePeriod period, bool starting, bool accurate); + + void seek (ContentTime, bool); + + void give_image (ContentTimePeriod period, boost::shared_ptr, dcpomatic::Rect); + void give_text (ContentTimePeriod period, std::list); + + boost::shared_ptr content () const { + return _content; + } + +private: + Decoder* _parent; + std::list _decoded_image; + std::list _decoded_text; + boost::shared_ptr _content; + + template + std::list get (std::list const & subs, std::list const & sp, ContentTimePeriod period, bool starting, bool accurate); -protected: - void image_subtitle (boost::shared_ptr, dcpomatic::Rect, ContentTime, ContentTime); - void text_subtitle (std::list); + boost::function (ContentTimePeriod, bool)> _image_during; + boost::function (ContentTimePeriod, bool)> _text_during; }; #endif