summaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorenikey <enikey@3789f03b-4d11-0410-bbf8-ca57d06f2519>2008-12-24 08:18:54 +0000
committerenikey <enikey@3789f03b-4d11-0410-bbf8-ca57d06f2519>2008-12-24 08:18:54 +0000
commit2f0294e004bc31cc9329e3e701d33de408a177bf (patch)
tree7d4d85e166d59a236a57b32cbc827c65e959d079 /java
parent7b0c8aa7c18c7e03191a537d27f2dcfb96c83be4 (diff)
downloadtigervnc-2f0294e004bc31cc9329e3e701d33de408a177bf.tar.gz
tigervnc-2f0294e004bc31cc9329e3e701d33de408a177bf.zip
[Refactoring, cleanup] Write encoding ID of real decoders in decoders classes. Pseudo encoding ID still writes in RfbProto class. ZlibDecoder recoding enabled. ZRLEDecoder recoding still not working.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@3455 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'java')
-rw-r--r--java/src/com/tightvnc/decoder/CoRREDecoder.java9
-rw-r--r--java/src/com/tightvnc/decoder/HextileDecoder.java18
-rw-r--r--java/src/com/tightvnc/decoder/RREDecoder.java9
-rw-r--r--java/src/com/tightvnc/decoder/RawDecoder.java21
-rw-r--r--java/src/com/tightvnc/decoder/TightDecoder.java8
-rw-r--r--java/src/com/tightvnc/decoder/ZRLEDecoder.java9
-rw-r--r--java/src/com/tightvnc/decoder/ZlibDecoder.java36
-rw-r--r--java/src/com/tightvnc/vncviewer/RfbProto.java54
8 files changed, 132 insertions, 32 deletions
diff --git a/java/src/com/tightvnc/decoder/CoRREDecoder.java b/java/src/com/tightvnc/decoder/CoRREDecoder.java
index 3947d157..bc086686 100644
--- a/java/src/com/tightvnc/decoder/CoRREDecoder.java
+++ b/java/src/com/tightvnc/decoder/CoRREDecoder.java
@@ -28,6 +28,15 @@ public class CoRREDecoder extends RawDecoder {
//
public void handleRect(int x, int y, int w, int h) throws IOException {
+
+ //
+ // Write encoding ID to record output stream
+ //
+
+ if (dos != null) {
+ dos.writeInt(CoRREDecoder.EncodingCoRRE);
+ }
+
int nSubrects = rfbis.readU32();
byte[] bg_buf = new byte[bytesPerPixel];
diff --git a/java/src/com/tightvnc/decoder/HextileDecoder.java b/java/src/com/tightvnc/decoder/HextileDecoder.java
index 9c053095..da7e7781 100644
--- a/java/src/com/tightvnc/decoder/HextileDecoder.java
+++ b/java/src/com/tightvnc/decoder/HextileDecoder.java
@@ -46,6 +46,15 @@ public class HextileDecoder extends RawDecoder {
public void handleRect(int x, int y, int w, int h) throws IOException,
Exception {
+
+ //
+ // Write encoding ID to record output stream
+ //
+
+ if (dos != null) {
+ dos.writeInt(HextileDecoder.EncodingHextile);
+ }
+
hextile_bg = new Color(0);
hextile_fg = new Color(0);
@@ -87,9 +96,16 @@ public class HextileDecoder extends RawDecoder {
// Is it a raw-encoded sub-rectangle?
if ((subencoding & HextileRaw) != 0) {
- //handleRawRect(tx, ty, tw, th, false);
+ //
+ // Disable encoding id writting to record stream
+ // in super (RawDecoder) class, cause we write subencoding ID
+ // in this class (see code above).
+ //
+
+ super.enableEncodingRecordWritting(false);
super.handleRect(tx, ty, tw, th);
super.handleUpdatedPixels(tx, ty, tw, th);
+ super.enableEncodingRecordWritting(true);
return;
}
diff --git a/java/src/com/tightvnc/decoder/RREDecoder.java b/java/src/com/tightvnc/decoder/RREDecoder.java
index e2b5feb2..02eb513f 100644
--- a/java/src/com/tightvnc/decoder/RREDecoder.java
+++ b/java/src/com/tightvnc/decoder/RREDecoder.java
@@ -30,6 +30,15 @@ public class RREDecoder extends RawDecoder {
//
public void handleRect(int x, int y, int w, int h) throws IOException {
+
+ //
+ // Write encoding ID to record output stream
+ //
+
+ if (dos != null) {
+ dos.writeInt(RREDecoder.EncodingRRE);
+ }
+
int nSubrects = rfbis.readU32();
byte[] bg_buf = new byte[bytesPerPixel];
rfbis.readFully(bg_buf);
diff --git a/java/src/com/tightvnc/decoder/RawDecoder.java b/java/src/com/tightvnc/decoder/RawDecoder.java
index 9025e9ef..affdc679 100644
--- a/java/src/com/tightvnc/decoder/RawDecoder.java
+++ b/java/src/com/tightvnc/decoder/RawDecoder.java
@@ -85,6 +85,15 @@ public class RawDecoder {
//
public void handleRect(int x, int y, int w, int h) throws IOException, Exception {
+
+ //
+ // Write encoding ID to record output stream
+ //
+
+ if ((dos != null) && (enableEncodingRecordWritting)) {
+ dos.writeInt(RawDecoder.EncodingRaw);
+ }
+
if (bytesPerPixel == 1) {
for (int dy = y; dy < y + h; dy++) {
if (pixels8 != null) {
@@ -189,6 +198,17 @@ public class RawDecoder {
}
//
+ // This method will be used by HextileDecoder to disable
+ // double writting encoding id to record stream.
+ //
+ // FIXME: Try to find better solution than this.
+ //
+
+ protected void enableEncodingRecordWritting(boolean enable) {
+ enableEncodingRecordWritting = enable;
+ }
+
+ //
// Unique data for every decoder (? maybe not ?)
//
@@ -199,6 +219,7 @@ public class RawDecoder {
protected Graphics graphics = null;
protected RecordInterface rec = null;
protected DataOutput dos = null;
+ protected boolean enableEncodingRecordWritting = true;
//
// This data must be shared between decoders
diff --git a/java/src/com/tightvnc/decoder/TightDecoder.java b/java/src/com/tightvnc/decoder/TightDecoder.java
index c4ce226a..a1d28d70 100644
--- a/java/src/com/tightvnc/decoder/TightDecoder.java
+++ b/java/src/com/tightvnc/decoder/TightDecoder.java
@@ -71,6 +71,14 @@ public class TightDecoder extends RawDecoder implements ImageObserver {
public void handleRect(int x, int y, int w, int h) throws Exception {
+ //
+ // Write encoding ID to record output stream
+ //
+
+ if (dos != null) {
+ dos.writeInt(TightDecoder.EncodingTight);
+ }
+
int comp_ctl = rfbis.readU8();
if (rec.canWrite()) {
if (rec.isRecordFromBeginning() ||
diff --git a/java/src/com/tightvnc/decoder/ZRLEDecoder.java b/java/src/com/tightvnc/decoder/ZRLEDecoder.java
index 91f7c161..fbbb3a68 100644
--- a/java/src/com/tightvnc/decoder/ZRLEDecoder.java
+++ b/java/src/com/tightvnc/decoder/ZRLEDecoder.java
@@ -34,6 +34,15 @@ public class ZRLEDecoder extends RawDecoder {
//
public void handleRect(int x, int y, int w, int h) throws IOException, Exception {
+
+ //
+ // Write encoding ID to record output stream
+ //
+
+ if (dos != null) {
+ dos.writeInt(ZRLEDecoder.EncodingZRLE);
+ }
+
if (zrleInStream == null)
zrleInStream = new ZlibInStream();
diff --git a/java/src/com/tightvnc/decoder/ZlibDecoder.java b/java/src/com/tightvnc/decoder/ZlibDecoder.java
index 9a167b11..1370da15 100644
--- a/java/src/com/tightvnc/decoder/ZlibDecoder.java
+++ b/java/src/com/tightvnc/decoder/ZlibDecoder.java
@@ -29,6 +29,17 @@ public class ZlibDecoder extends RawDecoder {
//
public void handleRect(int x, int y, int w, int h) throws IOException {
+
+ //
+ // Write encoding ID to record output stream.
+ // Remark: we forced changed encoding from zlib to raw
+ // cause at this moment we cannot save data in zlib encoding.
+ //
+
+ if (dos != null) {
+ dos.writeInt(RawDecoder.EncodingRaw);
+ }
+
int nBytes = rfbis.readU32();
if (zlibBuf == null || zlibBufLen < nBytes) {
@@ -38,17 +49,6 @@ public class ZlibDecoder extends RawDecoder {
rfbis.readFully(zlibBuf, 0, nBytes);
- //
- // FIXME: Now we think that isRecordFromBeggining
- // always returns false and this part of code will be never
- // executed.
- //
-
- //if (rec.canWrite() && rec.isRecordFromBeginning()) {
- // rec.writeIntBE(nBytes);
- // rec.write(zlibBuf, 0, nBytes);
- //}
-
if (zlibInflater == null) {
zlibInflater = new Inflater();
}
@@ -60,12 +60,11 @@ public class ZlibDecoder extends RawDecoder {
zlibInflater.inflate(pixels8, dy * framebufferWidth + x, w);
//
- // Save decoded data to data output stream
+ // Save decoded raw data to data output stream
//
- //if (rec.canWrite() && !rec.isRecordFromBeginning())
- //if (dos != null)
- // dos.write(pixels8, dy * framebufferWidth + x, w);
+ if (dos != null)
+ dos.write(pixels8, dy * framebufferWidth + x, w);
}
} else {
byte[] buf = new byte[w * 4];
@@ -81,12 +80,11 @@ public class ZlibDecoder extends RawDecoder {
}
//
- // Save decoded data to data output stream
+ // Save decoded raw data to data output stream
//
- //if (rec.canWrite() && !rec.isRecordFromBeginning())
- //if (dos != null)
- // dos.write(buf);
+ if (dos != null)
+ dos.write(buf);
}
}
} catch (DataFormatException ex) {
diff --git a/java/src/com/tightvnc/vncviewer/RfbProto.java b/java/src/com/tightvnc/vncviewer/RfbProto.java
index fcdbbfa1..65cf909c 100644
--- a/java/src/com/tightvnc/vncviewer/RfbProto.java
+++ b/java/src/com/tightvnc/vncviewer/RfbProto.java
@@ -177,7 +177,7 @@ class RfbProto {
// Java on UNIX does not call keyPressed() on some keys, for example
// swedish keys To prevent our workaround to produce duplicate
// keypresses on JVMs that actually works, keep track of if
- // keyPressed() for a "broken" key was called or not.
+ // keyPressed() for a "broken" key was called or not.
boolean brokenKeyPressed = false;
// This will be set to true on the first framebuffer update
@@ -196,7 +196,7 @@ class RfbProto {
// Before starting to record each saved session, we set this field
// to 0, and increment on each framebuffer update. We don't flush
- // the SessionRecorder data into the file before the second update.
+ // the SessionRecorder data into the file before the second update.
// This allows us to write initial framebuffer update with zero
// timestamp, to let the player show initial desktop before
// playback.
@@ -758,6 +758,19 @@ class RfbProto {
numUpdatesInSession++;
}
+ //
+ // Returns true if encoding is not pseudo
+ //
+ // FIXME: Find better way to differ pseudo and real encodings
+ //
+
+ boolean isRealDecoderEncoding(int encoding) {
+ if ((encoding >= 1) && (encoding <= 16)) {
+ return true;
+ }
+ return false;
+ }
+
// Read a FramebufferUpdate rectangle header
int updateRectX, updateRectY, updateRectW, updateRectH, updateRectEncoding;
@@ -782,7 +795,25 @@ class RfbProto {
rec.writeShortBE(updateRectY);
rec.writeShortBE(updateRectW);
rec.writeShortBE(updateRectH);
- if (updateRectEncoding == EncodingZlib && !recordFromBeginning) {
+
+ //
+ // If this is pseudo encoding or CopyRect that write encoding ID
+ // in this place. All real encoding ID will be written to record stream
+ // in decoder classes.
+ //
+ // TODO: Make CopyRect decoder class.
+ //
+
+ if (((updateRectEncoding == EncodingCopyRect)
+ || (!isRealDecoderEncoding(updateRectEncoding))) && (rec != null)) {
+ rec.writeIntBE(updateRectEncoding);
+ }
+
+ //
+ // Old code
+ //
+
+ /*if (updateRectEncoding == EncodingZlib && !recordFromBeginning) {
// Here we cannot write Zlib-encoded rectangles because the
// decoder won't be able to reproduce zlib stream state.
if (!zlibWarningShown) {
@@ -799,7 +830,7 @@ class RfbProto {
"updates for session recording.");
tightWarningShown = true;
}
- }
+ }*/
}
if (updateRectEncoding < 0 || updateRectEncoding > MaxNormalEncoding)
@@ -954,7 +985,7 @@ class RfbProto {
b[6 + i * 6 + 4] = (byte) ((blue[i] >> 8) & 0xff);
b[6 + i * 6 + 5] = (byte) (blue[i] & 0xff);
}
-
+
os.write(b);
}
@@ -1002,7 +1033,7 @@ class RfbProto {
//
// A buffer for putting pointer and keyboard events before being sent. This
- // is to ensure that multiple RFB events generated from a single Java Event
+ // is to ensure that multiple RFB events generated from a single Java Event
// will all be sent in a single network packet. The maximum possible
// length is 4 modifier down events, a single key event followed by 4
// modifier up events i.e. 9 key events or 72 bytes.
@@ -1197,13 +1228,13 @@ class RfbProto {
(key == 0xa3)) { // XK_sterling
// Make sure we do not send keypress events twice on platforms
// with correct JVMs (those that actually report KeyPress for all
- // keys)
+ // keys)
if (down)
brokenKeyPressed = true;
if (!down && !brokenKeyPressed) {
// We've got a release event for this key, but haven't received
- // a press. Fake it.
+ // a press. Fake it.
eventBufLen = 0;
writeModifierKeyEvents(evt.getModifiers());
writeKeyEvent(key, true);
@@ -1211,7 +1242,7 @@ class RfbProto {
}
if (!down)
- brokenKeyPressed = false;
+ brokenKeyPressed = false;
}
eventBufLen = 0;
@@ -1383,7 +1414,7 @@ class RfbProto {
int y = rect.y;
int w = rect.width;
int h = rect.height;
-
+
byte[] b = new byte[10];
b[0] = (byte) VideoRectangleSelection;
@@ -1456,7 +1487,7 @@ class RfbProto {
}
public void stopTiming() {
- timing = false;
+ timing = false;
if (timeWaitedIn100us < timedKbits/2)
timeWaitedIn100us = timedKbits/2; // upper limit 20Mbit/s
}
@@ -1534,4 +1565,3 @@ class RfbProto {
return r;
}
}
-