Search in sources :

Example 1 with BitmapOrder

use of common.BitmapOrder in project cloudstack by apache.

the class ServerBitmapUpdate method handleData.

@Override
public void handleData(ByteBuffer buf, Link link) {
    if (verbose)
        System.out.println("[" + this + "] INFO: Data received: " + buf + ".");
    // * DEBUG */System.out.println(buf.toHexString(buf.length));
    BitmapOrder order = new BitmapOrder();
    // (2 bytes): A 16-bit, unsigned integer. The update type. This field MUST
    // be set to UPDATETYPE_BITMAP (0x0001).
    int updateType = buf.readSignedShortLE();
    if (updateType != UPDATETYPE_BITMAP)
        throw new RuntimeException("Unknown update type. Expected update type: UPDATETYPE_BITMAP (0x1). Actual update type: " + updateType + ", buf: " + buf + ".");
    // (2 bytes): A 16-bit, unsigned integer. The number of screen rectangles
    // present in the rectangles field.
    int numberRectangles = buf.readSignedShortLE();
    // (variable): Variable-length array of TS_BITMAP_DATA structures, each of
    // which contains a rectangular clipping taken from the server-side screen
    // frame buffer. The number of screen clippings in the array is specified by
    // the numberRectangles field.
    BitmapRectangle[] rectangles = new BitmapRectangle[numberRectangles];
    for (int i = 0; i < numberRectangles; i++) {
        rectangles[i] = readRectangle(buf);
    }
    order.rectangles = rectangles;
    buf.assertThatBufferIsFullyRead();
    ByteBuffer data = new ByteBuffer(order);
    pushDataToAllOuts(data);
    buf.unref();
}
Also used : BitmapRectangle(common.BitmapRectangle) ByteBuffer(streamer.ByteBuffer) BitmapOrder(common.BitmapOrder)

Example 2 with BitmapOrder

use of common.BitmapOrder in project cloudstack by apache.

the class AwtCanvasAdapter method handleData.

@Override
public void handleData(ByteBuffer buf, Link link) {
    if (verbose)
        System.out.println("[" + this + "] INFO: Data received: " + buf + ".");
    Order order = buf.getOrder();
    switch((OrderType) order.type) {
        case BITMAP_UPDATE:
            handleBitmap((BitmapOrder) order, buf);
            break;
        case COPY_RECT:
            handleCopyRect((CopyRectOrder) order, buf);
            break;
        default:
            throw new RuntimeException("Order is not implemented: " + buf + ".");
    }
    buf.unref();
}
Also used : BitmapOrder(common.BitmapOrder) Order(streamer.Order) CopyRectOrder(common.CopyRectOrder) OrderType(common.OrderType)

Example 3 with BitmapOrder

use of common.BitmapOrder in project cloudstack by apache.

the class VncMessageHandler method handleRawRectangle.

private boolean handleRawRectangle(ByteBuffer buf, Link link, int x, int y, int width, int height) {
    // Raw rectangle is just array of pixels to draw on screen.
    int rectDataLength = width * height * screen.getBytesPerPixel();
    // rectangles.
    if (!cap(buf, rectDataLength, UNLIMITED, link, true))
        return false;
    if (verbose)
        System.out.println("[" + this + "] INFO: Raw rect. X: " + x + ", y: " + y + ", width: " + width + ", height: " + height + ", data length: " + rectDataLength + ".");
    BitmapRectangle rectangle = new BitmapRectangle();
    rectangle.x = x;
    rectangle.y = y;
    rectangle.width = width;
    rectangle.height = height;
    rectangle.bufferWidth = width;
    rectangle.bufferHeight = height;
    rectangle.bitmapDataStream = buf.readBytes(rectDataLength);
    rectangle.colorDepth = screen.getColorDeph();
    BitmapOrder order = new BitmapOrder();
    order.rectangles = new BitmapRectangle[] { rectangle };
    pushDataToPad(PIXEL_ADAPTER_PAD, new ByteBuffer(order));
    return true;
}
Also used : BitmapRectangle(common.BitmapRectangle) ByteBuffer(streamer.ByteBuffer) BitmapOrder(common.BitmapOrder)

Aggregations

BitmapOrder (common.BitmapOrder)3 BitmapRectangle (common.BitmapRectangle)2 ByteBuffer (streamer.ByteBuffer)2 CopyRectOrder (common.CopyRectOrder)1 OrderType (common.OrderType)1 Order (streamer.Order)1