Mercurial > hg > Members > nobuyasu > tightVNCProxy
changeset 103:d1dc2bb0200d
server side recompression.
slightly better...
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 04 Aug 2011 11:06:10 +0900 |
parents | 2ce6077bdb09 |
children | b649584c9712 |
files | src/myVncProxy/MyRfbProto.java |
diffstat | 1 files changed, 27 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/myVncProxy/MyRfbProto.java Thu Aug 04 10:51:29 2011 +0900 +++ b/src/myVncProxy/MyRfbProto.java Thu Aug 04 11:06:10 2011 +0900 @@ -50,6 +50,7 @@ private int rectH; private int encoding; private int zLen; + private boolean clicomp; private ServerSocket servSock; private int acceptPort; @@ -609,7 +610,16 @@ readFully(inputData.array(),0,inputData.capacity()); inputData.limit(dataLen-20); LinkedList<ByteBuffer>inputs = new LinkedList<ByteBuffer>(); inputs.add(inputData); - unzip(inflater, inputs, 0, bufs); + if (clicomp) { + unzip(inflater, inputs, 0, bufs); + } else { + Deflater nDeflater = new Deflater(); + LinkedList<ByteBuffer> out = new LinkedList<ByteBuffer>(); + unzip(inflater, inputs, 0 , out); + int len2 = zip(nDeflater, out, 0, bufs); + ByteBuffer blen = ByteBuffer.allocate(4); blen.putInt(len2); blen.flip(); + bufs.addFirst(blen); + } bufs.addFirst(header); multicastqueue.put(bufs); is.reset(); @@ -657,6 +667,8 @@ } }; Runnable sender = new Runnable() { + + public void run() { Deflater deflater = new Deflater(); @@ -681,13 +693,20 @@ System.out.println("client "+ clients); int encoding = header.getInt(12); if (encoding==RfbProto.EncodingZlib||encoding==RfbProto.EncodingZRLE) { - LinkedList<ByteBuffer> outs = new LinkedList<ByteBuffer>(); - int len2 = zip(deflater, bufs, inputIndex, outs); - ByteBuffer blen = ByteBuffer.allocate(4); blen.putInt(len2); blen.flip(); - outs.addFirst(blen); - outs.addFirst(header); - while(!outs.isEmpty()) { - ByteBuffer out= outs.poll(); + LinkedList<ByteBuffer> outs; + if (clicomp) { + outs = new LinkedList<ByteBuffer>(); + int len2 = zip(deflater, bufs, inputIndex, outs); + ByteBuffer blen = ByteBuffer.allocate(4); blen.putInt(len2); blen.flip(); + outs.addFirst(blen); + outs.addFirst(header); + inputIndex = 0; + } else { + outs = bufs; + inputIndex = 0; + } + while(inputIndex < outs.size()) { + ByteBuffer out= outs.get(inputIndex++); os.write(out.array(),out.position(),out.limit()); } }