Mercurial > hg > Applications > TreeVNC
changeset 63:84f1c39ba3bf
temp commit
author | Taninari YU <you@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 17 Jan 2014 12:43:25 +0900 |
parents | a5b831d5b542 |
children | e73e2c30c9a6 |
files | src/main/java/com/glavsoft/rfb/encoding/decoder/FramebufferUpdateRectangle.java src/main/java/com/glavsoft/rfb/encoding/decoder/ZRLEDecoder.java src/main/java/com/glavsoft/rfb/encoding/decoder/ZRLEESender.java src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java src/main/java/jp/ac/u_ryukyu/treevnc/server/MyRfbProtoProxy.java |
diffstat | 6 files changed, 91 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/com/glavsoft/rfb/encoding/decoder/FramebufferUpdateRectangle.java Thu Jan 02 07:56:30 2014 +0900 +++ b/src/main/java/com/glavsoft/rfb/encoding/decoder/FramebufferUpdateRectangle.java Fri Jan 17 12:43:25 2014 +0900 @@ -60,6 +60,7 @@ height = reader.readUInt16(); int encoding = reader.readInt32(); encodingType = EncodingType.byId(encoding); + } public EncodingType getEncodingType() {
--- a/src/main/java/com/glavsoft/rfb/encoding/decoder/ZRLEDecoder.java Thu Jan 02 07:56:30 2014 +0900 +++ b/src/main/java/com/glavsoft/rfb/encoding/decoder/ZRLEDecoder.java Fri Jan 17 12:43:25 2014 +0900 @@ -55,6 +55,8 @@ for (int tileX = rect.x; tileX < maxX; tileX += MAX_TILE_SIZE) { int tileWidth = Math.min(maxX - tileX, MAX_TILE_SIZE); int subencoding = bytes[offset++] & 0x0ff; + if(subencoding!=0) + System.out.println("----------------"+subencoding); // 128 -plain RLE, 130-255 - Palette RLE boolean isRle = (subencoding & 128) != 0; // 2 to 16 for raw packed palette data, 130 to 255 for Palette RLE (subencoding - 128) @@ -73,6 +75,7 @@ } else { if (0 == paletteSize) { // subencoding == 0 (or paletteSize == 0) - raw CPIXEL data offset += decodeRaw(bytes, offset, renderer, tileX, tileY, tileWidth, tileHeight); +// System.out.println("offset:"+offset); } else { offset += decodePacked(bytes, offset, renderer, paletteSize, tileX, tileY, tileWidth, tileHeight); }
--- a/src/main/java/com/glavsoft/rfb/encoding/decoder/ZRLEESender.java Thu Jan 02 07:56:30 2014 +0900 +++ b/src/main/java/com/glavsoft/rfb/encoding/decoder/ZRLEESender.java Fri Jan 17 12:43:25 2014 +0900 @@ -25,6 +25,7 @@ int dataLen = getZrleLength(rect,reader); reader.reset(); rfb.readSendData(dataLen, reader); + if(rfb instanceof MyRfbProtoClient) { reader.readByte();// message reader.readByte();// padding @@ -45,6 +46,4 @@ } return zrleLength + 20; } - - }
--- a/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java Thu Jan 02 07:56:30 2014 +0900 +++ b/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java Fri Jan 17 12:43:25 2014 +0900 @@ -91,7 +91,7 @@ this.decoders = decoders; renderer = repaintController.createRenderer(reader, context.getFbWidth(), context.getFbHeight(), context.getPixelFormat()); - fullscreenFbUpdateIncrementalRequest = + fullscreenFbUpdateIncrementalRequest = new FramebufferUpdateRequestMessage(0, 0, context.getFbWidth(), context.getFbHeight(), true); } @@ -189,6 +189,7 @@ reader.readByte(); // padding int numberOfRectangles = reader.readUInt16(); while (numberOfRectangles-- > 0) { + //FramebufferUpdateRectangle rect = new FramebufferUpdateRectangle(); FramebufferUpdateRectangle rect = new FramebufferUpdateRectangle(); rect.fill(reader);
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java Thu Jan 02 07:56:30 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java Fri Jan 17 12:43:25 2014 +0900 @@ -153,7 +153,7 @@ writeToClient(os, bufs, inputIndex); continue; } else if (header.get(0) == FramebufferUpdate) { - // System.out.println("client "+ myId); + //System.out.println("client "+ myId); } /* * if(i%20==0){ sendDataCheckDelay(); } i++;
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/server/MyRfbProtoProxy.java Thu Jan 02 07:56:30 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/server/MyRfbProtoProxy.java Fri Jan 17 12:43:25 2014 +0900 @@ -9,6 +9,7 @@ import java.net.Socket; import java.nio.ByteBuffer; import java.util.LinkedList; + import com.glavsoft.exceptions.TransportException; import com.glavsoft.rfb.encoding.EncodingType; import com.glavsoft.transport.Reader; @@ -51,7 +52,6 @@ ExecutorService executor; byte[] pngBytes; - // private MulticastQueue<LinkedList<ByteBuffer>> multicastqueue = new // MostRecentMultiCast<LinkedList<ByteBuffer>>(10); // private MulticastQueue<LinkedList<ByteBuffer>> multicastqueue = new @@ -61,7 +61,11 @@ // private Thread requestThread; private RequestScreenThread rThread; private Thread requestThread; - + private int rangeX = 256; // screenRange XPosition + private int rangeY = 256; // screenRange YPosition + private int rangeWidth = 512; // screenRange Width + private int rangeHeight = 256; // screenRange Height + public MyRfbProtoProxy() { rThread = new RequestScreenThread(this); requestThread = new Thread(rThread); @@ -293,6 +297,7 @@ // protocol, clients have to be modified. Deflater nDeflater = deflater; // new Deflater(); LinkedList<ByteBuffer> out = new LinkedList<ByteBuffer>(); + //List<ByteBuffer> out = java.util.Collections.synchronizedList(new LinkedList<ByteBuffer>()); int len2 = 0; try { unzip(inflater, inputs, 0, out, INFLATE_BUFSIZE); @@ -302,26 +307,15 @@ } catch (IOException e) { throw new TransportException(e); } - + //if(dataLen<=64000) ByteBuffer blen = ByteBuffer.allocate(4); blen.putInt(len2); blen.flip(); - bufs.addFirst(blen); - + bufs.addFirst(blen); bufs.addFirst(header); - // if(dataLen<=64000) - multicastqueue.put(bufs); - - + if(header.getShort(4)<1920) + multicastqueue.put(bufs); // is.reset(); - - /* - * System.out.println("ZRLE = "+dataLen); - * System.out.println("ZRLEE = "+(len2+20)); float mag = - * (float)dataLen / (float)(len2 + 20); - * System.out.println("ZRLE / ZRLEE = "+ mag); if(mag > maxMag) - * maxMag = mag; System.out.println("maxMag = "+maxMag); - */ return; } bufs.add(header); @@ -344,6 +338,27 @@ // But we have do inflation for all input data, so we have to do it // here. } + + /** + * + * @param header image position. + * @return 0 notsend. + * 1 Send image as it is. + * 2 Transmission by processing the image + */ + private int checkScreenRange(ByteBuffer header) { + if(rangeWidth==0) // if image width set, rangeWidth not 0; + return 1; + if(header.getShort(4) > rangeX +rangeWidth) + return 0; + if(header.getShort(6) > rangeY + rangeHeight) + return 0; + if(header.getShort(4) >= rangeX && header.getShort(4)+header.getShort(8) < rangeX+rangeWidth) + return 1; + if(header.getShort(6) >= rangeX && header.getShort(6)+header.getShort(10) < rangeX+rangeWidth) + return 1; + return 2; + } public void dump32(LinkedList<ByteBuffer> bufs) { int len = 0; @@ -534,5 +549,56 @@ public void setReadyReconnect(boolean ready) { readyReconnect = ready; } + + /* + int a = list.size(); + for(int i = 0; i < a -1; i++ ) { + if(i>6) { + if(i==7){ + list.get(7).limit(20540); + } + list.remove(8); + } + } + */ + + private void testScreenSize(LinkedList<ByteBuffer> list, ByteBuffer header) { + int block = (64*64*3)+1; // size of one-block. + int skip; // skip-byte + int xBlock = (header.getShort(8)-header.getShort(4))/64; //xBlockNum + int yBlock = (header.getShort(10)-header.getShort(6))/64; // yBlockNum; + int outOfRangeT = (rangeY - header.getShort(6))/64 > 0 ? (rangeY - header.getShort(6))/64 : 0; + int outOfRangeB = (header.getShort(6) + header.getShort(10))-(rangeY + rangeHeight)/64 > 0 ? + (header.getShort(6) + header.getShort(10))-(rangeY + rangeHeight)/64 : 0; + int outOfRangeL = (rangeX - header.getShort(4))/64 > 0 ? (rangeY - header.getShort(4))/64 : 0; + int outOfRangeR = (header.getShort(4) + header.getShort(8))-(rangeY + rangeHeight)/64 > 0 ? + (header.getShort(4) + header.getShort(8))-(rangeY + rangeHeight)/64 : 0; + ByteBuffer input = list.getFirst(); + if((header.getShort(8)-header.getShort(4)%64)!=0) + ++xBlock; + if((header.getShort(10)-header.getShort(6)%64)!=0) + ++yBlock; + + for(int i=0; i<yBlock; i++) { + for(int g=0; g<xBlock; g++) { + if(outOfRangeT < i && i < yBlock - outOfRangeB) { + input.get(block); + } + } + } + if((rangeX-header.getShort(4))%64==0) + skip = 4*block*(header.getShort(8)/64); + else + skip = (4*block*(header.getShort(8)/64))+1; + + } + + private void createHeader(ByteBuffer buf) { + buf.putShort(4, (short)256); + buf.putShort(6, (short)256); + buf.putShort(8, (short)512); + buf.putShort(10, (short)256); + } } +