Code refactoring in preparation to more efficient seeking. Now we handle initial time offset in RfbProto constructor and its newSession() method.

git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2587 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/java/src/com/tightvnc/rfbplayer/RfbPlayer.java b/java/src/com/tightvnc/rfbplayer/RfbPlayer.java
index 4b1f4fa..98b1505 100644
--- a/java/src/com/tightvnc/rfbplayer/RfbPlayer.java
+++ b/java/src/com/tightvnc/rfbplayer/RfbPlayer.java
@@ -134,7 +134,7 @@
       } else {
         url = new URL(sessionURL);
       }
-      rfb = new RfbProto(url);
+      rfb = new RfbProto(url, initialTimeOffset);
 
       vc = new VncCanvas(this);
       gbc.weightx = 1.0;
@@ -179,8 +179,6 @@
         try {
           setPaused(!autoPlay);
           rfb.fbs.setSpeed(playbackSpeed);
-          if (initialTimeOffset > rfb.fbs.getTimeOffset())
-            setPos(initialTimeOffset); // don't seek backwards here
           vc.processNormalProtocol();
         } catch (EOFException e) {
           if (e.getMessage() != null && e.getMessage().equals("[REWIND]")) {
@@ -192,7 +190,7 @@
             initialTimeOffset = 0;
             autoPlay = false;
           }
-          rfb.newSession(url);
+          rfb.newSession(url, initialTimeOffset);
           vc.updateFramebufferSize();
         } catch (NullPointerException e) {
           // catching this causes a hang with 1.4.1 JVM's under Win32 IE
diff --git a/java/src/com/tightvnc/rfbplayer/RfbProto.java b/java/src/com/tightvnc/rfbplayer/RfbProto.java
index a37cd61..080dfad 100644
--- a/java/src/com/tightvnc/rfbplayer/RfbProto.java
+++ b/java/src/com/tightvnc/rfbplayer/RfbProto.java
@@ -73,9 +73,9 @@
   //
   // Constructor.
   //
-  RfbProto(URL url) throws Exception {
+  RfbProto(URL url, long timeOffset) throws Exception {
     fbs = null;
-    newSession(url);
+    newSession(url, timeOffset);
   }
 
   // Force processing to quit
@@ -91,7 +91,7 @@
   //
   // Open new session URL.
   //
-  public void newSession(URL url) throws Exception {
+  public void newSession(URL url, long timeOffset) throws Exception {
     if (fbs != null)
       fbs.close();
 
@@ -107,6 +107,11 @@
       throw new Exception("Wrong authentication type in the session file");
     }
     readServerInit();
+
+    // Go to initial position but make sure not to seek backwards.
+    if (timeOffset > fbs.getTimeOffset()) {
+      fbs.setTimeOffset(timeOffset);
+    }
   }
 
   //