Add Piece::seek().
authorCarl Hetherington <cth@carlh.net>
Sun, 25 Apr 2021 15:33:20 +0000 (17:33 +0200)
committerCarl Hetherington <cth@carlh.net>
Fri, 7 May 2021 07:29:59 +0000 (09:29 +0200)
src/lib/piece.cc
src/lib/piece.h
src/lib/player.cc

index 2a3adcd408ef32acdeacf506d7ebe744450be0ce..2cdc20a5032395a259891a32f20aa733c89166bd 100644 (file)
@@ -224,3 +224,25 @@ Piece::has_text () const
        return !decoder->text.empty();
 }
 
+
+void
+Piece::seek (shared_ptr<const Film> film, DCPTime time, bool accurate)
+{
+       if (time < position()) {
+               /* Before; seek to the start of the content.  Even if this request is for an inaccurate seek
+                  we must seek this (following) content accurately, otherwise when we come to the end of the current
+                  content we may not start right at the beginning of the next, causing a gap (if the next content has
+                  been trimmed to a point between keyframes, or something).
+                  */
+               decoder->seek (dcp_to_content_time(position(), film), true);
+               done = false;
+       } else if (position() <= time && time < end(film)) {
+               /* During; seek to position */
+               decoder->seek (dcp_to_content_time(time, film), accurate);
+               done = false;
+       } else {
+               /* After; this piece is done */
+               done = true;
+       }
+}
+
index 6c0df23c2c831b4443914c5705a509ca2c4582e6..56b16fb282f646b98403b9db74b70cbd12045a81 100644 (file)
@@ -72,6 +72,7 @@ public:
 
        dcpomatic::DCPTime decoder_position () const;
        bool has_text () const;
+       void seek (std::shared_ptr<const Film> film, dcpomatic::DCPTime time, bool accurate);
 
        std::shared_ptr<Decoder> decoder;
        boost::optional<dcpomatic::DCPTimePeriod> ignore_video;
index 23db8433f388181d5a94ae9c107d6f2dd8f53c8e..5951e179db8b9da964762b47efde1d413fce7b5d 100644 (file)
@@ -1090,22 +1090,7 @@ Player::seek (DCPTime time, bool accurate)
        }
 
        for (auto i: _pieces) {
-               if (time < i->position()) {
-                       /* Before; seek to the start of the content.  Even if this request is for an inaccurate seek
-                          we must seek this (following) content accurately, otherwise when we come to the end of the current
-                          content we may not start right at the beginning of the next, causing a gap (if the next content has
-                          been trimmed to a point between keyframes, or something).
-                       */
-                       i->decoder->seek (i->dcp_to_content_time(i->position(), _film), true);
-                       i->done = false;
-               } else if (i->position() <= time && time < i->end(_film)) {
-                       /* During; seek to position */
-                       i->decoder->seek (i->dcp_to_content_time(time, _film), accurate);
-                       i->done = false;
-               } else {
-                       /* After; this piece is done */
-                       i->done = true;
-               }
+               i->seek (_film, time, accurate);
        }
 
        if (accurate) {