
org.jfxvnc.net.rfb.codec.decoder.FramebufferUpdateRectDecoder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jfxvnc-net Show documentation
Show all versions of jfxvnc-net Show documentation
RFB/VNC protocol codec and handler based on netty
The newest version!
/*******************************************************************************
* Copyright (c) 2016 comtel inc.
*
* Licensed under the Apache License, version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*******************************************************************************/
package org.jfxvnc.net.rfb.codec.decoder;
import java.util.EnumMap;
import java.util.List;
import org.jfxvnc.net.rfb.codec.Encoding;
import org.jfxvnc.net.rfb.codec.PixelFormat;
import org.jfxvnc.net.rfb.codec.ProtocolState;
import org.jfxvnc.net.rfb.codec.ServerEvent;
import org.jfxvnc.net.rfb.codec.decoder.rect.CopyRectDecoder;
import org.jfxvnc.net.rfb.codec.decoder.rect.CursorRectDecoder;
import org.jfxvnc.net.rfb.codec.decoder.rect.DesktopSizeRectDecoder;
import org.jfxvnc.net.rfb.codec.decoder.rect.FrameRect;
import org.jfxvnc.net.rfb.codec.decoder.rect.FrameRectDecoder;
import org.jfxvnc.net.rfb.codec.decoder.rect.HextileDecoder;
import org.jfxvnc.net.rfb.codec.decoder.rect.RawRectDecoder;
import org.jfxvnc.net.rfb.codec.decoder.rect.UnknownRectDecoder;
import org.jfxvnc.net.rfb.codec.decoder.rect.ZlibRectDecoder;
import org.jfxvnc.net.rfb.exception.ProtocolException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
class FramebufferUpdateRectDecoder implements FrameDecoder {
private static Logger logger = LoggerFactory.getLogger(FramebufferUpdateRectDecoder.class);
private PixelFormat pixelFormat;
private int numberRects, currentRect;
private final EnumMap frameRectDecoder = new EnumMap<>(Encoding.class);
private State state;
private FrameRect rect;
enum State {
INIT, NEW_RECT, READ_RECT
}
public FramebufferUpdateRectDecoder(PixelFormat pixelFormat) {
this.pixelFormat = pixelFormat;
state = State.INIT;
registerFrameRectDecoder();
}
private void registerFrameRectDecoder() {
frameRectDecoder.put(Encoding.ZLIB, new ZlibRectDecoder(pixelFormat));
frameRectDecoder.put(Encoding.COPY_RECT, new CopyRectDecoder(pixelFormat));
frameRectDecoder.put(Encoding.HEXTILE, new HextileDecoder(pixelFormat));
frameRectDecoder.put(Encoding.RAW, new RawRectDecoder(pixelFormat));
frameRectDecoder.put(Encoding.CURSOR, new CursorRectDecoder(pixelFormat));
frameRectDecoder.put(Encoding.DESKTOP_SIZE, new DesktopSizeRectDecoder(pixelFormat));
frameRectDecoder.put(Encoding.UNKNOWN, new UnknownRectDecoder(pixelFormat));
}
public Encoding[] getSupportedEncodings() {
return new Encoding[] {Encoding.ZLIB, Encoding.COPY_RECT, Encoding.HEXTILE, Encoding.RAW, Encoding.CURSOR, Encoding.DESKTOP_SIZE};
}
public boolean isPixelFormatSupported() {
logger.debug("is pixelformat supported: {}", pixelFormat);
return true;// PixelFormat.RGB_888.equals(pixelFormat);
}
@Override
public boolean decode(ChannelHandlerContext ctx, ByteBuf m, List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy