# HG changeset patch # User e085711 # Date 1312222042 -32400 # Node ID 762d2b7f1db2223d664b3f674825d960df3b9339 # Parent 5970410efee71717e7dd9816b2124e6cb78d367d modify MyRfbProto diff -r 5970410efee7 -r 762d2b7f1db2 src/myVncProxy/MyRfbProto.java --- a/src/myVncProxy/MyRfbProto.java Fri Jul 29 19:17:31 2011 +0900 +++ b/src/myVncProxy/MyRfbProto.java Tue Aug 02 03:07:22 2011 +0900 @@ -40,6 +40,7 @@ private int rectH; private int encoding; private int zLen; + private int bytesPixel; private ServerSocket servSock; private int acceptPort; @@ -105,7 +106,7 @@ // 5550を開けるが、開いてないなら+1のポートを開ける。 void selectPort() { - int i = 5550; + int i = 5955;// i = 5550; while (true) { try { initServSock(i); @@ -305,7 +306,7 @@ void regiFramebufferUpdate() throws IOException { - is.mark(20); + is.mark(30); messageType = readU8(); skipBytes(1); rectangles = readU16(); @@ -314,9 +315,39 @@ rectW = readU16(); rectH = readU16(); encoding = readU32(); - System.out.println("encoding = "+encoding); - if (encoding == 16) + System.out.println("encoding = "+ encoding); + switch (encoding) { + case RfbProto.EncodingZRLE: zLen = readU32(); + break; + case RfbProto.EncodingTight: + int comp_ctl = readU8(); + zLen = 1; + if (comp_ctl == TightFill) { + if (bytesPixel == 1 ) { +// int idx = readU8(); + zLen++; + }else { +/* + byte[] buf = new byte[3]; + readFully(buf); +*/ + zLen += 3; + } + } + if ( comp_ctl == TightJpeg) { +/* + byte[] jpegData = new byte[readCompactLen()]; + readFully(jpegData); +*/ + zLen += 3; + zLen += readCompactLen(); + } + break; + default: + + } + is.reset(); /* int dataLen; @@ -325,7 +356,7 @@ dataLen = rectW * rectH * 4 + 16; mark(dataLen); break; - case RfbProto.EncodingCopyRect: + case RfbProto.EncodingCopyRect: dataLen = 16 + 4; mark(dataLen); break; @@ -364,6 +395,9 @@ case RfbProto.EncodingHextile: case RfbProto.EncodingZlib: case RfbProto.EncodingTight: + dataLen = zLen + 20; + is.mark(dataLen); + break; case RfbProto.EncodingZRLE: dataLen = zLen + 20; is.mark(dataLen); @@ -410,6 +444,12 @@ readSendData(dataLen); } + void sendDataToClient(int num) throws IOException { + bytesPixel = num; + regiFramebufferUpdate(); + int dataLen = checkAndMark(); + readSendData(dataLen); + } BufferedImage createBufferedImage(Image img) { BufferedImage bimg = new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_RGB); diff -r 5970410efee7 -r 762d2b7f1db2 src/myVncProxy/ProxyVncCanvas.java --- a/src/myVncProxy/ProxyVncCanvas.java Fri Jul 29 19:17:31 2011 +0900 +++ b/src/myVncProxy/ProxyVncCanvas.java Tue Aug 02 03:07:22 2011 +0900 @@ -104,7 +104,7 @@ for (int i = 0; i < 256; i++) colors[i] = new Color(cm8.getRGB(i)); -// setPixelFormat(); + setPixelFormat(); inputEnabled = false; // Keyboard listener is enabled even in view-only mode, to catch @@ -214,7 +214,7 @@ } public void setPixelFormat() throws IOException { -/* + if (viewer.options.eightBitColors) { rfb.writeSetPixelFormat(8, 8, false, true, 7, 7, 3, 0, 3, 6); bytesPixel = 1; @@ -223,7 +223,7 @@ 0); bytesPixel = 4; } -*/ + updateFramebufferSize(); } @@ -362,14 +362,15 @@ long count = 0; while (true) { - System.out.println("\ncount=" + count); +// System.out.println("\ncount=" + count); count++; /** * read Data from parents and send Data to Client. */ - rfb.sendDataToClient(); + //rfb.sendDataToClient(); + //rfb.sendDataToClient(bytesPixel); int bufSize = (int)rfb.getNumBytesRead(); @@ -498,13 +499,13 @@ // Before requesting framebuffer update, check if the pixel // format should be changed. -/* + if (viewer.options.eightBitColors != (bytesPixel == 1)) { // Pixel format should be changed. setPixelFormat(); fullUpdateNeeded = true; } -*/ + // Request framebuffer update if needed. int w = rfb.framebufferWidth; diff -r 5970410efee7 -r 762d2b7f1db2 src/myVncProxy/VncProxyService.java --- a/src/myVncProxy/VncProxyService.java Fri Jul 29 19:17:31 2011 +0900 +++ b/src/myVncProxy/VncProxyService.java Tue Aug 02 03:07:22 2011 +0900 @@ -322,6 +322,7 @@ int preferredEncoding = options.preferredEncoding; if (preferredEncoding == -1) { long kbitsPerSecond = rfb.kbitsPerSecond(); + if (nEncodingsSaved < 1) { // Choose Tight or ZRLE encoding for the very first update. System.out.println("Using Tight/ZRLE encodings"); @@ -353,7 +354,7 @@ int[] encodings = new int[20]; int nEncodings = 0; -/* + encodings[nEncodings++] = preferredEncoding; if (options.useCopyRect) { encodings[nEncodings++] = RfbProto.EncodingCopyRect; @@ -367,7 +368,6 @@ if (preferredEncoding != RfbProto.EncodingHextile) { encodings[nEncodings++] = RfbProto.EncodingHextile; } -*/ if (preferredEncoding != RfbProto.EncodingZlib) { encodings[nEncodings++] = RfbProto.EncodingZlib; }