Basic support for trusted device lists in KDMs (#750).
[dcpomatic.git] / src / lib / subtitle_decoder.cc
index d20196a63597f41a768e1aa7e1b98ab7c52010f0..454243b524d279b65eeaa7b57eacdc4f43cabab9 100644 (file)
@@ -21,6 +21,7 @@
 #include "subtitle_content.h"
 #include <boost/shared_ptr.hpp>
 #include <boost/foreach.hpp>
+#include <iostream>
 
 using std::list;
 using std::cout;
@@ -55,15 +56,15 @@ SubtitleDecoder::text_subtitle (ContentTimePeriod period, list<dcp::SubtitleStri
 /** @param sp Full periods of subtitles that are showing or starting during the specified period */
 template <class T>
 list<T>
-SubtitleDecoder::get (list<T> const & subs, list<ContentTimePeriod> const & sp, ContentTimePeriod period, bool starting)
+SubtitleDecoder::get (list<T> const & subs, list<ContentTimePeriod> const & sp, ContentTimePeriod period, bool starting, bool accurate)
 {
        if (sp.empty ()) {
                /* Nothing in this period */
                return list<T> ();
        }
 
-       /* Seek if what we want is before what we have, or more than a reasonable amount after */
-       if (subs.empty() || sp.back().to < subs.front().period().from || sp.front().from > (subs.back().period().to + ContentTime::from_seconds (5))) {
+       /* Seek if what we want is before what we have, or a more than a little bit after */
+       if (subs.empty() || sp.back().to < subs.front().period().from || sp.front().from > (subs.back().period().to + ContentTime::from_seconds (1))) {
                seek (sp.front().from, true);
        }
 
@@ -71,7 +72,7 @@ SubtitleDecoder::get (list<T> const & subs, list<ContentTimePeriod> const & sp,
         *  (a) give us what we want, or
         *  (b) hit the end of the decoder.
         */
-       while (!pass () && (subs.empty() || (subs.back().period().to < sp.back().to))) {}
+       while (!pass(PASS_REASON_SUBTITLE, accurate) && (subs.empty() || (subs.back().period().to < sp.back().to))) {}
 
        /* Now look for what we wanted in the data we have collected */
        /* XXX: inefficient */
@@ -104,15 +105,15 @@ SubtitleDecoder::get (list<T> const & subs, list<ContentTimePeriod> const & sp,
 }
 
 list<ContentTextSubtitle>
-SubtitleDecoder::get_text_subtitles (ContentTimePeriod period, bool starting)
+SubtitleDecoder::get_text_subtitles (ContentTimePeriod period, bool starting, bool accurate)
 {
-       return get<ContentTextSubtitle> (_decoded_text_subtitles, text_subtitles_during (period, starting), period, starting);
+       return get<ContentTextSubtitle> (_decoded_text_subtitles, text_subtitles_during (period, starting), period, starting, accurate);
 }
 
 list<ContentImageSubtitle>
-SubtitleDecoder::get_image_subtitles (ContentTimePeriod period, bool starting)
+SubtitleDecoder::get_image_subtitles (ContentTimePeriod period, bool starting, bool accurate)
 {
-       return get<ContentImageSubtitle> (_decoded_image_subtitles, image_subtitles_during (period, starting), period, starting);
+       return get<ContentImageSubtitle> (_decoded_image_subtitles, image_subtitles_during (period, starting), period, starting, accurate);
 }
 
 void