Bump version
[dcpomatic.git] / src / lib / subtitle.h
index e3a853695f0fb313f2f20f2f5e6775e359eada92..c74f5c1b9f0c7c6c775dc368aea684eea1048f82 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    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 "util.h"
+#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;
        }
 
-       dvdomatic::Rect area () const;
+       Position<int> out_position () const {
+               return _out_position;
+       }
        
 private:
-       Position _position;
-       boost::shared_ptr<Image> _image;
-};
-
-dvdomatic::Rect
-subtitle_transformed_area (
-       float target_x_scale, float target_y_scale,
-       dvdomatic::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;
 };