Search in sources :

Example 6 with ScreenDescription

use of common.ScreenDescription in project cloudstack by apache.

the class VncMessageHandler 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");
    Element source = new MockSource("source") {

        {
            // Split messages at random boundaries to check "pushback" logic
            bufs = ByteBuffer.convertByteArraysToByteBuffers(new byte[] { // Message type: server bell
            RfbConstants.SERVER_BELL, // Message type: clipboard text
            RfbConstants.SERVER_CUT_TEXT, // Padding
            0, 0, 0, // Length (test)
            0, 0, 0, 4 }, new byte[] { // Clipboard text
            't', 'e', 's', 't', // Message type: frame buffer update
            RfbConstants.SERVER_FRAMEBUFFER_UPDATE, // Padding
            0, // Number of rectangles
            0, 3 }, new byte[] { // x, y, width, height: 0x0@4x4
            0, 0, 0, 0, 0, 4, 0, 4, // Encoding: desktop size
            (byte) ((RfbConstants.ENCODING_DESKTOP_SIZE >> 24) & 0xff), (byte) ((RfbConstants.ENCODING_DESKTOP_SIZE >> 16) & 0xff), (byte) ((RfbConstants.ENCODING_DESKTOP_SIZE >> 8) & 0xff), (byte) ((RfbConstants.ENCODING_DESKTOP_SIZE >> 0) & 0xff) }, new byte[] { // x, y, width, height: 0x0@4x4
            0, 0, 0, 0, 0, 4, 0, 4, // Encoding: raw rect
            (byte) ((RfbConstants.ENCODING_RAW >> 24) & 0xff), (byte) ((RfbConstants.ENCODING_RAW >> 16) & 0xff), (byte) ((RfbConstants.ENCODING_RAW >> 8) & 0xff), (byte) ((RfbConstants.ENCODING_RAW >> 0) & 0xff), // Raw pixel data 4x4x1 bpp
            1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, new byte[] { 11, 12, 13, 14, 15, 16, // x, y, width, height: 0x0@2x2
            0, 0, 0, 0, 0, 2, 0, 2, // Encoding: copy rect
            (byte) ((RfbConstants.ENCODING_COPY_RECT >> 24) & 0xff), (byte) ((RfbConstants.ENCODING_COPY_RECT >> 16) & 0xff), (byte) ((RfbConstants.ENCODING_COPY_RECT >> 8) & 0xff), (byte) ((RfbConstants.ENCODING_COPY_RECT >> 0) & 0xff), // srcX, srcY: 2x2
            0, 2, 0, 2 });
        }
    };
    ScreenDescription screen = new ScreenDescription() {

        {
            bytesPerPixel = 1;
        }
    };
    final Element handler = new VncMessageHandler("handler", screen);
    ByteBuffer[] emptyBuf = ByteBuffer.convertByteArraysToByteBuffers(new byte[] {});
    Element fburSink = new MockSink("fbur", ByteBuffer.convertByteArraysToByteBuffers(new byte[] {}, new byte[] {}));
    Element bellSink = new MockSink("bell", emptyBuf);
    Element clipboardSink = new MockSink("clipboard", emptyBuf);
    Element desktopSizeChangeSink = new MockSink("desktop_size", emptyBuf);
    Element pixelsSink = new MockSink("pixels", ByteBuffer.convertByteArraysToByteBuffers(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }));
    Element copyRectSink = new MockSink("copy_rect", emptyBuf);
    Pipeline pipeline = new PipelineImpl("test");
    pipeline.addAndLink(source, handler);
    pipeline.add(fburSink, bellSink, clipboardSink, desktopSizeChangeSink, pixelsSink, copyRectSink);
    pipeline.link("handler >" + FRAME_BUFFER_UPDATE_REQUEST_ADAPTER_PAD, "fbur");
    pipeline.link("handler >" + SERVER_BELL_ADAPTER_PAD, "bell");
    pipeline.link("handler >" + SERVER_CLIPBOARD_ADAPTER_PAD, "clipboard");
    pipeline.link("handler >" + PIXEL_ADAPTER_PAD, "pixels");
    pipeline.runMainLoop("source", STDOUT, false, false);
}
Also used : MockSource(streamer.debug.MockSource) MockSink(streamer.debug.MockSink) PipelineImpl(streamer.PipelineImpl) Element(streamer.Element) BaseElement(streamer.BaseElement) ScreenDescription(common.ScreenDescription) ByteBuffer(streamer.ByteBuffer) Pipeline(streamer.Pipeline)

Aggregations

ScreenDescription (common.ScreenDescription)6 Pipeline (streamer.Pipeline)6 PipelineImpl (streamer.PipelineImpl)6 Element (streamer.Element)5 MockSource (streamer.debug.MockSource)5 BaseElement (streamer.BaseElement)4 MockSink (streamer.debug.MockSink)4 ByteBuffer (streamer.ByteBuffer)3 RdpBufferedImageCanvas (com.cloud.consoleproxy.rdp.RdpBufferedImageCanvas)1 SizeChangeListener (common.SizeChangeListener)1 InetSocketAddress (java.net.InetSocketAddress)1 RdpClient (rdpclient.RdpClient)1 AprSocketWrapperImpl (streamer.apr.AprSocketWrapperImpl)1 FakeSink (streamer.debug.FakeSink)1 SSLState (streamer.ssl.SSLState)1