+
+int eDVBTSTools::findNextPicture(off_t &offset, size_t &len, int &distance, int frame_types)
+{
+ int nr_frames = 0;
+// eDebug("trying to move %d frames at %llx", distance, offset);
+
+ frame_types = frametypeI; /* TODO: intelligent "allow IP frames when not crossing an I-Frame */
+
+ int direction = distance > 0 ? 0 : -1;
+ distance = abs(distance);
+
+ off_t new_offset = offset;
+ size_t new_len = len;
+ int first = 1;
+
+ while (distance > 0)
+ {
+ int dir = direction;
+ if (findFrame(new_offset, new_len, dir, frame_types))
+ {
+// eDebug("findFrame failed!\n");
+ return -1;
+ }
+
+ distance -= abs(dir);
+
+// eDebug("we moved %d, %d to go frames (now at %llx)", dir, distance, new_offset);
+
+ if (distance >= 0 || first)
+ {
+ first = 0;
+ offset = new_offset;
+ len = new_len;
+ nr_frames += abs(dir);
+ }
+ }
+
+ distance = (direction < 0) ? -nr_frames : nr_frames;
+// eDebug("in total, we moved %d frames", nr_frames);
+
+ return 0;
+}