Mercurial > hg > Members > nobuyasu > tightVNCProxy
comparison src/myVncProxy/MyRfbProto.java @ 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 |
comparison
equal
deleted
inserted
replaced
102:2ce6077bdb09 | 103:d1dc2bb0200d |
---|---|
48 private int rectY; | 48 private int rectY; |
49 private int rectW; | 49 private int rectW; |
50 private int rectH; | 50 private int rectH; |
51 private int encoding; | 51 private int encoding; |
52 private int zLen; | 52 private int zLen; |
53 private boolean clicomp; | |
53 | 54 |
54 private ServerSocket servSock; | 55 private ServerSocket servSock; |
55 private int acceptPort; | 56 private int acceptPort; |
56 private byte initData[]; | 57 private byte initData[]; |
57 private LinkedList<Socket> cliListTmp; | 58 private LinkedList<Socket> cliListTmp; |
607 readFully(len.array(),0,4); len.limit(4); | 608 readFully(len.array(),0,4); len.limit(4); |
608 ByteBuffer inputData = ByteBuffer.allocate(dataLen-20); | 609 ByteBuffer inputData = ByteBuffer.allocate(dataLen-20); |
609 readFully(inputData.array(),0,inputData.capacity()); inputData.limit(dataLen-20); | 610 readFully(inputData.array(),0,inputData.capacity()); inputData.limit(dataLen-20); |
610 LinkedList<ByteBuffer>inputs = new LinkedList<ByteBuffer>(); | 611 LinkedList<ByteBuffer>inputs = new LinkedList<ByteBuffer>(); |
611 inputs.add(inputData); | 612 inputs.add(inputData); |
612 unzip(inflater, inputs, 0, bufs); | 613 if (clicomp) { |
614 unzip(inflater, inputs, 0, bufs); | |
615 } else { | |
616 Deflater nDeflater = new Deflater(); | |
617 LinkedList<ByteBuffer> out = new LinkedList<ByteBuffer>(); | |
618 unzip(inflater, inputs, 0 , out); | |
619 int len2 = zip(nDeflater, out, 0, bufs); | |
620 ByteBuffer blen = ByteBuffer.allocate(4); blen.putInt(len2); blen.flip(); | |
621 bufs.addFirst(blen); | |
622 } | |
613 bufs.addFirst(header); | 623 bufs.addFirst(header); |
614 multicastqueue.put(bufs); | 624 multicastqueue.put(bufs); |
615 is.reset(); | 625 is.reset(); |
616 return ; | 626 return ; |
617 } | 627 } |
655 } | 665 } |
656 } | 666 } |
657 } | 667 } |
658 }; | 668 }; |
659 Runnable sender = new Runnable() { | 669 Runnable sender = new Runnable() { |
670 | |
671 | |
660 public void run() { | 672 public void run() { |
661 | 673 |
662 Deflater deflater = new Deflater(); | 674 Deflater deflater = new Deflater(); |
663 try { | 675 try { |
664 /** | 676 /** |
679 if (header==null) continue; | 691 if (header==null) continue; |
680 if (header.get(0)==RfbProto.FramebufferUpdate) { | 692 if (header.get(0)==RfbProto.FramebufferUpdate) { |
681 System.out.println("client "+ clients); | 693 System.out.println("client "+ clients); |
682 int encoding = header.getInt(12); | 694 int encoding = header.getInt(12); |
683 if (encoding==RfbProto.EncodingZlib||encoding==RfbProto.EncodingZRLE) { | 695 if (encoding==RfbProto.EncodingZlib||encoding==RfbProto.EncodingZRLE) { |
684 LinkedList<ByteBuffer> outs = new LinkedList<ByteBuffer>(); | 696 LinkedList<ByteBuffer> outs; |
685 int len2 = zip(deflater, bufs, inputIndex, outs); | 697 if (clicomp) { |
686 ByteBuffer blen = ByteBuffer.allocate(4); blen.putInt(len2); blen.flip(); | 698 outs = new LinkedList<ByteBuffer>(); |
687 outs.addFirst(blen); | 699 int len2 = zip(deflater, bufs, inputIndex, outs); |
688 outs.addFirst(header); | 700 ByteBuffer blen = ByteBuffer.allocate(4); blen.putInt(len2); blen.flip(); |
689 while(!outs.isEmpty()) { | 701 outs.addFirst(blen); |
690 ByteBuffer out= outs.poll(); | 702 outs.addFirst(header); |
703 inputIndex = 0; | |
704 } else { | |
705 outs = bufs; | |
706 inputIndex = 0; | |
707 } | |
708 while(inputIndex < outs.size()) { | |
709 ByteBuffer out= outs.get(inputIndex++); | |
691 os.write(out.array(),out.position(),out.limit()); | 710 os.write(out.array(),out.position(),out.limit()); |
692 } | 711 } |
693 } | 712 } |
694 os.flush(); | 713 os.flush(); |
695 continue; | 714 continue; |