Search in sources :

Example 81 with ByteBuffer

use of streamer.ByteBuffer in project cloudstack by apache.

the class VncInitializer method main.

/**
     * Example.
     */
public static void main(String[] args) {
    // System.setProperty("streamer.Link.debug", "true");
    System.setProperty("streamer.Element.debug", "true");
    // System.setProperty("streamer.Pipeline.debug", "true");
    final String desktopName = "test";
    Element source = new MockSource("source") {

        {
            bufs = ByteBuffer.convertByteArraysToByteBuffers(// Send screen description
            new byte[] { // Framebuffer width (short)
            0, (byte) 200, // Framebuffer height (short)
            0, 100, // Bits per pixel
            32, // Depth,
            24, // Endianness flag
            RfbConstants.LITTLE_ENDIAN, // Truecolor flag
            RfbConstants.TRUE_COLOR, // Red max (short)
            0, (byte) 255, // Green max (short)
            0, (byte) 255, // Blue max (short)
            0, (byte) 255, // Red shift
            16, // Green shift
            8, // Blue shift
            0, // Padding
            0, 0, 0, // Desktop name length (int)
            0, 0, 0, 4, // Desktop name ("test", 4 bytes)
            't', 'e', 's', 't', // Tail
            1, 2, 3 }, // Tail packet
            new byte[] { 4, 5, 6 });
        }
    };
    ScreenDescription screen = new ScreenDescription();
    final VncInitializer init = new VncInitializer("init", true, screen);
    Element initSink = new MockSink("initSink") {

        {
            // Expect shared flag
            bufs = ByteBuffer.convertByteArraysToByteBuffers(new byte[] { RfbConstants.SHARED_ACCESS });
        }
    };
    Element mainSink = new MockSink("mainSink") {

        {
            // Expect two tail packets
            bufs = ByteBuffer.convertByteArraysToByteBuffers(new byte[] { 1, 2, 3 }, new byte[] { 4, 5, 6 });
        }
    };
    ByteBuffer[] emptyBuf = ByteBuffer.convertByteArraysToByteBuffers(new byte[] {});
    Element encodingsSink = new MockSink("encodings", emptyBuf);
    Element pixelFormatSink = new MockSink("pixel_format", emptyBuf);
    Pipeline pipeline = new PipelineImpl("test");
    pipeline.addAndLink(source, init, mainSink);
    pipeline.add(encodingsSink, pixelFormatSink, initSink);
    pipeline.link("init >otout", "initSink");
    pipeline.link("init >" + CLIENT_SUPPORTED_ENCODINGS_ADAPTER_PAD, "encodings");
    pipeline.link("init >" + CLIENT_PIXEL_FORMAT_ADAPTER_PAD, "pixel_format");
    pipeline.runMainLoop("source", STDOUT, false, false);
    if (!screen.isRGB888_32_LE())
        System.err.println("Screen description was read incorrectly: " + screen + ".");
    if (!desktopName.equals(screen.getDesktopName()))
        System.err.println("Screen desktop name was read incorrectly: \"" + screen.getDesktopName() + "\".");
}
Also used : MockSource(streamer.debug.MockSource) MockSink(streamer.debug.MockSink) PipelineImpl(streamer.PipelineImpl) Element(streamer.Element) ScreenDescription(common.ScreenDescription) ByteBuffer(streamer.ByteBuffer) Pipeline(streamer.Pipeline)

Example 82 with ByteBuffer

use of streamer.ByteBuffer in project cloudstack by apache.

the class FakeSource method initializeData.

/**
     * Initialize data.
     */
public ByteBuffer initializeData() {
    ByteBuffer buf = new ByteBuffer(incommingBufLength);
    // Set first byte of package to it sequance number
    buf.data[buf.offset] = (byte) (packetNumber % 128);
    // corresponding with their position in byte buffer
    for (int i = buf.offset + 1; i < buf.length; i++) buf.data[i] = (byte) (i % 128);
    buf.putMetadata(ByteBuffer.SEQUENCE_NUMBER, packetNumber);
    buf.putMetadata("src", id);
    return buf;
}
Also used : ByteBuffer(streamer.ByteBuffer)

Example 83 with ByteBuffer

use of streamer.ByteBuffer in project cloudstack by apache.

the class AwtVncMouseAdapter method handleData.

@Override
public void handleData(ByteBuffer buf, Link link) {
    if (verbose)
        System.out.println("[" + this + "] INFO: Data received: " + buf + ".");
    // Get mouse event
    MouseOrder order = (MouseOrder) buf.getOrder();
    ByteBuffer outBuf = new ByteBuffer(6);
    outBuf.writeByte(RfbConstants.CLIENT_POINTER_EVENT);
    int buttonMask = mapAwtModifiersToVncButtonMask(order.event.getModifiersEx());
    outBuf.writeByte(buttonMask);
    outBuf.writeShort(order.event.getX());
    outBuf.writeShort(order.event.getY());
    pushDataToAllOuts(outBuf);
}
Also used : MouseOrder(common.MouseOrder) ByteBuffer(streamer.ByteBuffer)

Example 84 with ByteBuffer

use of streamer.ByteBuffer in project cloudstack by apache.

the class EncodingsMessage method handleData.

@Override
public void handleData(ByteBuffer buf, Link link) {
    if (buf == null)
        return;
    if (verbose)
        System.out.println("[" + this + "] INFO: Data received: " + buf + ".");
    buf.unref();
    ByteBuffer outBuf = new ByteBuffer(4 + encodings.length * 4);
    outBuf.writeByte(RfbConstants.CLIENT_SET_ENCODINGS);
    // padding
    outBuf.writeByte(0);
    outBuf.writeShort(encodings.length);
    for (int i = 0; i < encodings.length; i++) {
        outBuf.writeInt(encodings[i]);
    }
    pushDataToAllOuts(outBuf);
}
Also used : ByteBuffer(streamer.ByteBuffer)

Example 85 with ByteBuffer

use of streamer.ByteBuffer in project cloudstack by apache.

the class FrameBufferUpdateRequest method main.

public static void main(String[] args) {
    System.setProperty("streamer.Element.debug", "true");
    ScreenDescription screen = new ScreenDescription();
    screen.setFramebufferSize(120, 80);
    Element adapter = new FrameBufferUpdateRequest("renderer", screen);
    Element sink = new MockSink("sink", ByteBuffer.convertByteArraysToByteBuffers(new byte[] { // Request
    RfbConstants.CLIENT_FRAMEBUFFER_UPDATE_REQUEST, // Full update (redraw area)
    RfbConstants.FRAMEBUFFER_FULL_UPDATE_REQUEST, // X
    0, 1, // Y
    0, 2, // Width
    0, 3, // Height
    0, 4 }));
    ByteBuffer buf = new ByteBuffer(new byte[0]);
    buf.putMetadata(TARGET_X, 1);
    buf.putMetadata(TARGET_Y, 2);
    buf.putMetadata(WIDTH, 3);
    buf.putMetadata(HEIGHT, 4);
    Element source = new MockSource("source", new ByteBuffer[] { buf });
    Pipeline pipeline = new PipelineImpl("test");
    pipeline.addAndLink(source, adapter, sink);
    pipeline.runMainLoop("source", STDOUT, false, false);
}
Also used : MockSource(streamer.debug.MockSource) MockSink(streamer.debug.MockSink) PipelineImpl(streamer.PipelineImpl) ScreenDescription(common.ScreenDescription) Element(streamer.Element) BaseElement(streamer.BaseElement) ByteBuffer(streamer.ByteBuffer) Pipeline(streamer.Pipeline)

Aggregations

ByteBuffer (streamer.ByteBuffer)110 Element (streamer.Element)12 BaseElement (streamer.BaseElement)9 Pipeline (streamer.Pipeline)7 PipelineImpl (streamer.PipelineImpl)7 TSRequest (rdpclient.ntlmssp.asn1.TSRequest)6 MockSink (streamer.debug.MockSink)5 MockSource (streamer.debug.MockSource)5 BitmapRectangle (common.BitmapRectangle)3 ScreenDescription (common.ScreenDescription)3 SyncLink (streamer.SyncLink)3 AssertingByteBuffer (streamer.debug.AssertingByteBuffer)3 BitmapOrder (common.BitmapOrder)2 KeyOrder (common.KeyOrder)2 MouseOrder (common.MouseOrder)2 NegoItem (rdpclient.ntlmssp.asn1.NegoItem)2 Link (streamer.Link)2 FakeSink (streamer.debug.FakeSink)2 BufferedImageCanvas (common.BufferedImageCanvas)1 CopyRectOrder (common.CopyRectOrder)1