From: Constantin Kaplinsky Date: Thu, 30 May 2002 13:26:34 +0000 (+0000) Subject: Implemented seeking to an arbitrary time point in the session file. X-Git-Tag: v0.0.90~510 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=52c48242bd5bbcb058835d0f0207b65486a50cc0;p=tigervnc.git Implemented seeking to an arbitrary time point in the session file. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2511 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- diff --git a/java/src/com/tightvnc/rfbplayer/FbsInputStream.java b/java/src/com/tightvnc/rfbplayer/FbsInputStream.java index f35219db..f5aeb2de 100644 --- a/java/src/com/tightvnc/rfbplayer/FbsInputStream.java +++ b/java/src/com/tightvnc/rfbplayer/FbsInputStream.java @@ -28,6 +28,7 @@ class FbsInputStream extends InputStream { protected InputStream in; protected long startTime; protected long timeOffset; + protected long seekOffset; protected boolean paused; protected byte[] buffer; @@ -51,6 +52,7 @@ class FbsInputStream extends InputStream { this.in = in; startTime = System.currentTimeMillis(); timeOffset = 0; + seekOffset = -1; paused = false; byte[] b = new byte[12]; @@ -97,6 +99,7 @@ class FbsInputStream extends InputStream { in = null; startTime = -1; timeOffset = 0; + seekOffset = -1; paused = false; buffer = null; @@ -113,13 +116,17 @@ class FbsInputStream extends InputStream { 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() @@ -160,6 +167,13 @@ class FbsInputStream extends InputStream { return false; } + if (seekOffset >= 0) { + if (timeOffset >= seekOffset) { + seekOffset = -1; + } + return true; + } + while (true) { long timeDiff = startTime + timeOffset - System.currentTimeMillis(); if (timeDiff <= 0) { @@ -183,7 +197,7 @@ class FbsInputStream extends InputStream { private void waitWhilePaused() { - while (paused) { + while (paused && !isSeeking()) { synchronized(this) { try { wait(); diff --git a/java/src/com/tightvnc/rfbplayer/VncCanvas.java b/java/src/com/tightvnc/rfbplayer/VncCanvas.java index fa4bde72..63325324 100644 --- a/java/src/com/tightvnc/rfbplayer/VncCanvas.java +++ b/java/src/com/tightvnc/rfbplayer/VncCanvas.java @@ -60,6 +60,11 @@ class VncCanvas extends Canvas { // 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. // @@ -67,6 +72,7 @@ class VncCanvas extends Canvas { VncCanvas(RfbPlayer player) throws IOException { this.player = player; rfb = player.rfb; + seekMode = false; cm24 = new DirectColorModel(24, 0xFF0000, 0x00FF00, 0x0000FF); @@ -809,9 +815,19 @@ class VncCanvas extends Canvas { // 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; + } } }