protected InputStream in;
protected long startTime;
protected long timeOffset;
+ protected long seekOffset;
protected boolean paused;
protected byte[] buffer;
this.in = in;
startTime = System.currentTimeMillis();
timeOffset = 0;
+ seekOffset = -1;
paused = false;
byte[] b = new byte[12];
in = null;
startTime = -1;
timeOffset = 0;
+ seekOffset = -1;
paused = false;
buffer = null;
return timeOffset;
}
- public void setTimeOffset(int pos)
+ public synchronized void setTimeOffset(int pos)
{
+ // FIXME: Seeking works only in paused mode.
+ paused = true;
+ seekOffset = pos;
+ notify();
}
public boolean isSeeking()
{
- return false;
+ return (seekOffset >= 0);
}
public synchronized void pausePlayback()
return false;
}
+ if (seekOffset >= 0) {
+ if (timeOffset >= seekOffset) {
+ seekOffset = -1;
+ }
+ return true;
+ }
+
while (true) {
long timeDiff = startTime + timeOffset - System.currentTimeMillis();
if (timeDiff <= 0) {
private void waitWhilePaused()
{
- while (paused) {
+ while (paused && !isSeeking()) {
synchronized(this) {
try {
wait();
// which decodes and loads JPEG images.
Rectangle jpegRect;
+ // When we're in the seeking mode, we should not update the desktop.
+ // This variable helps us to remember that repainting the desktop at
+ // once is necessary when the seek operation is finished.
+ boolean seekMode;
+
//
// The constructor.
//
VncCanvas(RfbPlayer player) throws IOException {
this.player = player;
rfb = player.rfb;
+ seekMode = false;
cm24 = new DirectColorModel(24, 0xFF0000, 0x00FF00, 0x0000FF);
//
void scheduleRepaint(int x, int y, int w, int h) {
- // Request repaint if not in the seeking mode.
- if (!player.fbsStream.isSeeking())
- repaint(player.deferScreenUpdates, x, y, w, h);
+ if (player.fbsStream.isSeeking()) {
+ // Do nothing, and remember we are seeking.
+ seekMode = true;
+ } else {
+ if (seekMode) {
+ // Full-screen immediate repaint after seeking.
+ repaint();
+ } else {
+ // Usual incremental repaint in playback mode.
+ repaint(player.deferScreenUpdates, x, y, w, h);
+ }
+ seekMode = false;
+ }
}
}