/*
- Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
*/
-/** @file src/subtitle.h
- * @brief Representations of subtitles.
- */
-
-#include <list>
#include <boost/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
+#include <boost/optional.hpp>
+#include <libdcp/util.h>
+#include "rect.h"
#include "types.h"
-struct AVSubtitle;
+class Film;
+class Piece;
class Image;
-/** A subtitle, consisting of an image and a position */
class Subtitle
{
public:
- Subtitle (Position p, boost::shared_ptr<Image> i);
- void set_position (Position p) {
- _position = p;
+ Subtitle (boost::shared_ptr<const Film>, libdcp::Size, boost::weak_ptr<Piece>, boost::shared_ptr<Image>, dcpomatic::Rect<double>, Time, Time);
+
+ void update (boost::shared_ptr<const Film>, libdcp::Size);
+ void set_stop (Time t) {
+ _stop = t;
+ check_out_to ();
}
- Position position () const {
- return _position;
+ bool covers (Time t) const;
+ bool ends_before (Time t) const {
+ return _out_to < t;
}
-
- boost::shared_ptr<Image> image () const {
- return _image;
+
+ boost::shared_ptr<Image> out_image () const {
+ return _out_image;
}
- Rect area () const;
+ Position<int> out_position () const {
+ return _out_position;
+ }
private:
- Position _position;
- boost::shared_ptr<Image> _image;
-};
-
-Rect
-subtitle_transformed_area (
- float target_x_scale, float target_y_scale,
- Rect sub_area, int subtitle_offset, float subtitle_scale
- );
-
-/** A Subtitle class with details of the time over which it should be shown */
-class TimedSubtitle
-{
-public:
- TimedSubtitle (AVSubtitle const &);
-
- bool displayed_at (double t) const;
+ void check_out_to ();
- boost::shared_ptr<Subtitle> subtitle () const {
- return _subtitle;
- }
+ boost::weak_ptr<Piece> _piece;
+ boost::shared_ptr<Image> _in_image;
+ dcpomatic::Rect<double> _in_rect;
+ Time _in_from;
+ Time _in_to;
-private:
- /** the subtitle */
- boost::shared_ptr<Subtitle> _subtitle;
- /** display from time in seconds from the start of the film */
- double _from;
- /** display to time in seconds from the start of the film */
- double _to;
+ boost::shared_ptr<Image> _out_image;
+ Position<int> _out_position;
+ Time _out_from;
+ Time _out_to;
+
+ /** Time at which this subtitle should stop (overriding _out_to) */
+ boost::optional<Time> _stop;
};