Merge 1.0-seek and subtitle-content.
[dcpomatic.git] / src / lib / decoded.h
index ff32e43f2b67a115673a53268b229618e0815750..f4ebe0dbd18a5ed7236372c352861bf5cca28888 100644 (file)
@@ -20,6 +20,7 @@
 #ifndef DCPOMATIC_LIB_DECODED_H
 #define DCPOMATIC_LIB_DECODED_H
 
+#include <libdcp/subtitle_asset.h>
 #include "types.h"
 #include "rect.h"
 #include "util.h"
@@ -85,16 +86,16 @@ public:
        AudioFrame frame;
 };
 
-class DecodedSubtitle : public Decoded
+class DecodedImageSubtitle : public Decoded
 {
 public:
-       DecodedSubtitle ()
+       DecodedImageSubtitle ()
                : content_time (0)
                , content_time_to (0)
                , dcp_time_to (0)
        {}
 
-       DecodedSubtitle (boost::shared_ptr<Image> im, dcpomatic::Rect<double> r, ContentTime f, ContentTime t)
+       DecodedImageSubtitle (boost::shared_ptr<Image> im, dcpomatic::Rect<double> r, ContentTime f, ContentTime t)
                : image (im)
                , rect (r)
                , content_time (f)
@@ -115,4 +116,30 @@ public:
        DCPTime dcp_time_to;
 };
 
+class DecodedTextSubtitle : public Decoded
+{
+public:
+       DecodedTextSubtitle ()
+               : dcp_time_to (0)
+       {}
+
+       DecodedTextSubtitle (std::list<libdcp::Subtitle> s)
+               : subs (s)
+       {}
+
+       void set_dcp_times (VideoFrame, AudioFrame, FrameRateChange frc, DCPTime offset)
+       {
+               if (subs.empty ()) {
+                       return;
+               }
+
+               /* Assuming that all subs are at the same time */
+               dcp_time = rint (subs.front().in().to_ticks() * 4 * TIME_HZ / frc.speed_up) + offset;
+               dcp_time_to = rint (subs.front().out().to_ticks() * 4 * TIME_HZ / frc.speed_up) + offset;
+       }
+
+       std::list<libdcp::Subtitle> subs;
+       DCPTime dcp_time_to;
+};
+
 #endif