Mercurial > hg > Applications > TreeVNC
view src/main/java/com/glavsoft/rfb/encoding/decoder/ZRLEESender.java @ 414:3af5f4af2d63
Send data size for checkDelay
author | Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 24 Nov 2015 02:18:51 +0900 |
parents | 47c018aed50e |
children | 5c3635d6ab3c |
line wrap: on
line source
package com.glavsoft.rfb.encoding.decoder; import java.io.UnsupportedEncodingException; import jp.ac.u_ryukyu.treevnc.TreeRFBProto; import com.glavsoft.drawing.Renderer; import com.glavsoft.exceptions.TransportException; import com.glavsoft.rfb.encoding.EncodingType; import com.glavsoft.transport.Reader; public class ZRLEESender extends Decoder { private TreeRFBProto rfb; public ZRLEESender(TreeRFBProto rfb) { this.rfb = rfb; } public ZRLEESender() { } @Override public void decode(Reader reader, Renderer renderer, FramebufferUpdateRectangle rect) throws TransportException, UnsupportedEncodingException { // TreeVNC handling int dataLen = getZrleLength(rect, reader); byte[] bytes = new byte[rect.width * rect.height * renderer.getBytesPerPixel()]; // byte[] bytes = new byte[renderer.getWidth() * renderer.getHeight() * renderer.getBytesPerPixel()]; reader.reset(); if (rfb.hasViewer()) { ZRLEDecoder decoder = new ZRLEDecoder(); if (rect.getEncodingType() == EncodingType.ZRLE) { // ReadSendData convert ZRLE to ZRLEE // unzipped data in the bytes rfb.readSendData(dataLen, reader, bytes, rect); decoder.decode1(renderer, rect, bytes, 0); return; } else { // no reencoding is required // readSend does not peform unzip, do the fullrecoding rfb.readSendData(dataLen, reader, null, rect); reader.reset(); if (rect.getEncodingType() == EncodingType.CHECK_DELAY) { reader.skip(24); } else { reader.skip(16); } decoder.decode(reader, renderer, rect); return; } } rfb.readSendData(dataLen, reader, bytes, rect); } private int getZrleLength(FramebufferUpdateRectangle rect, Reader reader) throws TransportException { int zrleLength = 0; if (rect.getEncodingType() == EncodingType.ZRLE || rect.getEncodingType() == EncodingType.ZRLEE || rect.getEncodingType() == EncodingType.ZLIB || rect.getEncodingType() == EncodingType.CHECK_DELAY) { zrleLength = reader.readInt32(); } if (rect.getEncodingType() == EncodingType.CHECK_DELAY) { return zrleLength + 28; } return zrleLength + 20; } }