summaryrefslogtreecommitdiffstats
path: root/java/src/com/tightvnc/rfbplayer
diff options
context:
space:
mode:
authorConstantin Kaplinsky <const@tightvnc.com>2008-06-20 18:50:27 +0000
committerConstantin Kaplinsky <const@tightvnc.com>2008-06-20 18:50:27 +0000
commit1c2865f5fbc98f697a7e466f8adfa98b76bb8f0b (patch)
tree41ed6474fd83b54a23842e90d0b7516b4d1603d8 /java/src/com/tightvnc/rfbplayer
parent38f044f11b6bc5fdb068e38ca533000d46ae0cac (diff)
downloadtigervnc-1c2865f5fbc98f697a7e466f8adfa98b76bb8f0b.tar.gz
tigervnc-1c2865f5fbc98f697a7e466f8adfa98b76bb8f0b.zip
[Development] Added two methods to open FBS files, with and without index-driven seeking. The method that uses index data is not functional yet. Improved error handling.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2608 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'java/src/com/tightvnc/rfbplayer')
-rw-r--r--java/src/com/tightvnc/rfbplayer/FbsConnection.java50
1 files changed, 44 insertions, 6 deletions
diff --git a/java/src/com/tightvnc/rfbplayer/FbsConnection.java b/java/src/com/tightvnc/rfbplayer/FbsConnection.java
index 23b07659..f53e5557 100644
--- a/java/src/com/tightvnc/rfbplayer/FbsConnection.java
+++ b/java/src/com/tightvnc/rfbplayer/FbsConnection.java
@@ -63,6 +63,8 @@ public class FbsConnection {
}
FbsInputStream connect(long timeOffset) throws IOException {
+ FbsInputStream fbs = null;
+
// Try efficient seeking first.
if (timeOffset > 0 && indexData != null && numIndexRecords > 0) {
int i = 0;
@@ -72,21 +74,31 @@ public class FbsConnection {
if (i > 0) {
FbsEntryPoint entryPoint = indexData[i - 1];
if (entryPoint.key_size < entryPoint.fbs_fpos) {
- System.err.println(entryPoint);
+ try {
+ fbs = openFbsFile(entryPoint);
+ } catch (IOException e) {
+ System.err.println(e);
+ }
+ if (fbs == null) {
+ System.err.println("Could not open FBS file at entry point " +
+ entryPoint.timestamp + " ms");
+ }
}
}
}
- // Playback/seek from the beginning.
- URLConnection connection = fbsURL.openConnection();
- FbsInputStream fbs = new FbsInputStream(connection.getInputStream());
- fbs.setTimeOffset(timeOffset);
+ // Fallback to the dumb version of openFbsFile().
+ if (fbs == null) {
+ fbs = openFbsFile();
+ }
+ // Seek to the specified position.
+ fbs.setTimeOffset(timeOffset);
return fbs;
}
/**
- * Load index data from .fbi file to {@link #indexData indexData}.
+ * Load index data from .fbi file to {@link #indexData}.
*/
private void loadIndex() {
// Loading .fbi makes sense only if both .fbi and .fbk files are available.
@@ -156,4 +168,30 @@ public class FbsConnection {
}
}
+ /**
+ * Open FBS file identified by {@link #fbsURL}. The file is open at its very
+ * beginning, no seek is performed.
+ *
+ * @return a newly created FBS input stream.
+ * @throws java.io.IOException if an I/O exception occurs.
+ */
+ private FbsInputStream openFbsFile() throws IOException {
+ return new FbsInputStream(fbsURL.openStream());
+ }
+
+ /**
+ * Open FBS file identified by {@link #fbsURL}. The stream is
+ * positioned at the entry point described by <code>entryPoint</code>.
+ *
+ * @param entryPoint entry point information.
+ *
+ * @return a newly created FBS input stream on success, <code>null</code> if
+ * any error occured and the FBS stream is not opened.
+ * @throws java.io.IOException if an I/O exception occurs.
+ */
+ private FbsInputStream openFbsFile(FbsEntryPoint entryPoint)
+ throws IOException {
+ return null;
+ }
+
}