# HG changeset patch # User Shinji KONO # Date 1581907970 -32400 # Node ID 62a86ceb89d58595ecd0ac1c743c4c269fa59348 # Parent fb26a48b440d74579dc0d8f352b42c41d9295f5a Broadcast blocking done diff -r fb26a48b440d -r 62a86ceb89d5 src/main/java/com/glavsoft/rfb/encoding/decoder/ZRLEESender.java --- a/src/main/java/com/glavsoft/rfb/encoding/decoder/ZRLEESender.java Mon Feb 17 01:03:25 2020 +0900 +++ b/src/main/java/com/glavsoft/rfb/encoding/decoder/ZRLEESender.java Mon Feb 17 11:52:50 2020 +0900 @@ -14,14 +14,32 @@ public class ZRLEESender extends Decoder { private TreeRFBProto rfb; + ZRLEDecoder decoder; public ZRLEESender(TreeRFBProto rfb) { this.rfb = rfb; + decoder = new ZRLEDecoder(); } public ZRLEESender() { } + boolean broadcast = false; + boolean muticast = false; + boolean ZREEstream = false; + + public void setBroadcast(boolean broadcast) { + this.broadcast = broadcast; + } + + public void setMuticast(boolean muticast) { + this.muticast = muticast; + } + + public void setZREEstream(boolean ZREEstream) { + this.ZREEstream = ZREEstream; + } + @Override public void decode(Reader reader, Renderer renderer, FramebufferUpdateRectangle rect) throws TransportException, UnsupportedEncodingException { @@ -29,15 +47,19 @@ int dataLen = getZrleLength(rect, reader); reader.reset(); //System.out.println("ZRLEESender: " + rect + " length: " + dataLen); + if (ZREEstream) + decoder = new ZRLEDecoder(); if (rfb.hasViewer()) { - ZRLEDecoder decoder = new ZRLEDecoder(); if (rect.getEncodingType() == EncodingType.ZRLE) { // ReadSendData convert ZRLE to ZRLEE // unzipped data in the bytes ByteBuffer buf = ByteBuffer.allocate(rect.width * rect.height * renderer.getBytesPerPixel()); - if (rfb.multicastBlocking) { + if (broadcast) { + reader.mark(dataLen); decoder.multicastDecode(reader, renderer, rect, rfb); - } else { + reader.reset(); + } + if (muticast) { ByteBuffer header = rfb.readSendData(dataLen, reader, buf.array(), rect); decoder.decode1(renderer, header, rect, buf, 0, rfb); } @@ -45,6 +67,7 @@ } else { // no reencoding is required // readSend does not peform unzip, do the fullrecoding + // no broadcast rfb.readSendData(dataLen, reader, null, rect); reader.reset(); if (rect.getEncodingType() == EncodingType.CHECK_DELAY) { @@ -56,8 +79,15 @@ return; } } - byte[] bytes = new byte[rect.width * rect.height * renderer.getBytesPerPixel()]; - rfb.readSendData(dataLen, reader, bytes, rect); + if (broadcast) { + reader.mark(dataLen); + decoder.multicastDecode(reader, renderer, rect, rfb); + reader.reset(); + } + if (muticast) { + byte[] bytes = new byte[rect.width * rect.height * renderer.getBytesPerPixel()]; + rfb.readSendData(dataLen, reader, bytes, rect); + } } private int getZrleLength(FramebufferUpdateRectangle rect, Reader reader) diff -r fb26a48b440d -r 62a86ceb89d5 src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java --- a/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java Mon Feb 17 01:03:25 2020 +0900 +++ b/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java Mon Feb 17 11:52:50 2020 +0900 @@ -84,10 +84,16 @@ this.context = context; this.decoders = decoders; - Decoder decoder = new ZRLEESender(rfb); + ZRLEESender zdecdoder = new ZRLEESender(rfb); + Decoder decoder = zdecdoder; + + if (rfb.isTreeManager()) zdecdoder.setMuticast(true); + if (rfb.multicastBlocking) zdecdoder.setBroadcast(true); decoders.setDecoderByType(EncodingType.ZLIB, decoder); decoders.setDecoderByType(EncodingType.ZRLE, decoder); - decoders.setDecoderByType(EncodingType.ZRLEE, decoder); + ZRLEESender zdecdoder1 = new ZRLEESender(rfb); + zdecdoder1.setZREEstream(true); + decoders.setDecoderByType(EncodingType.ZRLEE, zdecdoder1); if(rfb.fixingSize) { context.setFbWidth(rfb.fixingSizeWidth); context.setFbHeight(rfb.fixingSizeHeight);