Mercurial > hg > Members > riono > TreeVNC_ja_comment
diff src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java @ 498:8d95d64c33bf
add multicastPut
author | oshiro |
---|---|
date | Fri, 15 Feb 2019 20:11:47 +0900 |
parents | 62d6e9180a11 |
children | 5455c62a3775 |
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java Tue Feb 12 16:55:23 2019 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java Fri Feb 15 20:11:47 2019 +0900 @@ -12,6 +12,7 @@ import com.glavsoft.viewer.ViewerInterface; import com.glavsoft.viewer.swing.ConnectionParams; +import java.awt.*; import java.io.IOException; import java.io.OutputStream; import java.io.UnsupportedEncodingException; @@ -73,6 +74,7 @@ private boolean childrenMulticast = true; private static int uniqueNodeId = 0; // uniquenodeid in all trees (less than MAX_UNIQUE_NODE_ID) private int deflate_size = 65507; + private ByteBuffer header; public TreeRFBProto(boolean isTreeManager, ViewerInterface viewer) { nets.setMyRfb(this); @@ -621,6 +623,7 @@ return position; } + /** * Multicast framebufferUpdate to children. * read FrameBuffferUpdate. If it is ZLE, make it ZLEE which is self contained compressed packet. @@ -629,12 +632,10 @@ * @param dataLen * @param reader * @throws TransportException - * @throws UnsupportedEncodingException */ public void readSendData(int dataLen, Reader reader, byte[] bytes, FramebufferUpdateRectangle rect) - throws TransportException,UnsupportedEncodingException { + throws TransportException { LinkedList<ByteBuffer> bufs = new LinkedList<ByteBuffer>(); - int BLOCKSIZE = 64 * 1024; int headerLen = rect.getEncodingType() == EncodingType.CHECK_DELAY ? 24 : 16; ByteBuffer header = multicastqueue.allocate(headerLen); ByteBuffer serial = multicastqueue.allocate(4 + 8); @@ -650,7 +651,7 @@ if (encoding == EncodingType.ZRLE.getId() || encoding == EncodingType.ZLIB.getId()) { - if (true) { + if (true) { try { zrleeBlocking(dataLen, reader, bytes, rect, context.getPixelFormat().bitsPerPixel/8, bufs, header); } catch (DataFormatException e) { @@ -755,16 +756,23 @@ int inflate_size = rect.width * rect.height * bytePerPixel; unzip(inflater, inputs, 0, bytes, inflate_size); + this.header = header; // dump32(inputs); - out.add(ByteBuffer.wrap(bytes)); - int inputIndex = 0; + return; + } + + public void multicastPut(Rectangle rect, byte[] bytes, int prevoffset, int offset, int bytePerPixel) { + byte subencoding = bytes[0]; + int inputIndex = 1; ByteBuffer c1 = multicastqueue.allocate(deflate_size); int x = rect.x, y = rect.y, w = 0, h = 0, w0 = 0, h0 = 0; int span = rect.width; - while (inputIndex < inflate_size) { - deflater.setInput(bytes,inputIndex,span * bytePerPixel); - if (c1.remaining() < span * bytePerPixel || inputIndex >= inflate_size - span * bytePerPixel) { - deflater.deflate(c1,Deflater.FULL_FLUSH); + while (inputIndex < INFLATE_BUFSIZE) { + byte save = bytes[inputIndex-1]; + bytes[inputIndex-1] = subencoding; + deflater.setInput(bytes,inputIndex-1,span * bytePerPixel +1); + if (c1.remaining() < span * bytePerPixel || inputIndex >= INFLATE_BUFSIZE - span * bytePerPixel) { + deflater.deflate(c1, Deflater.FULL_FLUSH); c1.flip(); try { writeUpdateRectangleWithHeader(c1,header,c1.remaining(),x+w,y+h,rect.width,h-h0); @@ -777,6 +785,7 @@ } else { deflater.deflate(c1,Deflater.SYNC_FLUSH); } + bytes[inputIndex-1] = save; w += span; if (w >= rect.width ) { h++; @@ -785,7 +794,6 @@ } inputIndex += rect.width * bytePerPixel; } - return; } private void writeUpdateRectangleWithHeader(ByteBuffer c1, ByteBuffer header, int len2, int x, int y, int w, int h) throws InterruptedException {