[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
diff --git a/java/src/com/tightvnc/decoder/CoRREDecoder.java b/java/src/com/tightvnc/decoder/CoRREDecoder.java
index 3947d15..bc08668 100644
--- a/java/src/com/tightvnc/decoder/CoRREDecoder.java
+++ b/java/src/com/tightvnc/decoder/CoRREDecoder.java
@@ -28,6 +28,15 @@
//
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 9c05309..da7e778 100644
--- a/java/src/com/tightvnc/decoder/HextileDecoder.java
+++ b/java/src/com/tightvnc/decoder/HextileDecoder.java
@@ -46,6 +46,15 @@
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 @@
// 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 e2b5feb..02eb513 100644
--- a/java/src/com/tightvnc/decoder/RREDecoder.java
+++ b/java/src/com/tightvnc/decoder/RREDecoder.java
@@ -30,6 +30,15 @@
//
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 9025e9e..affdc67 100644
--- a/java/src/com/tightvnc/decoder/RawDecoder.java
+++ b/java/src/com/tightvnc/decoder/RawDecoder.java
@@ -85,6 +85,15 @@
//
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 @@
}
//
+ // 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 @@
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 c4ce226..a1d28d7 100644
--- a/java/src/com/tightvnc/decoder/TightDecoder.java
+++ b/java/src/com/tightvnc/decoder/TightDecoder.java
@@ -71,6 +71,14 @@
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 91f7c16..fbbb3a6 100644
--- a/java/src/com/tightvnc/decoder/ZRLEDecoder.java
+++ b/java/src/com/tightvnc/decoder/ZRLEDecoder.java
@@ -34,6 +34,15 @@
//
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 9a167b1..1370da1 100644
--- a/java/src/com/tightvnc/decoder/ZlibDecoder.java
+++ b/java/src/com/tightvnc/decoder/ZlibDecoder.java
@@ -29,6 +29,17 @@
//
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 @@
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 @@
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 @@
}
//
- // 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) {