Search in sources :

Example 1 with Element

use of streamer.Element in project cloudstack by apache.

the class AwtBellAdapter method main.

/**
     * Example.
     */
public static void main(String[] args) {
    System.setProperty("streamer.Element.debug", "true");
    Element source = new FakeSource("source") {

        {
            incommingBufLength = 0;
            delay = 1000;
            numBuffers = 3;
        }
    };
    Element sink = new AwtBellAdapter("sink");
    Pipeline pipeline = new PipelineImpl("test");
    pipeline.addAndLink(source, sink);
    pipeline.runMainLoop("source", STDOUT, false, false);
}
Also used : PipelineImpl(streamer.PipelineImpl) Element(streamer.Element) BaseElement(streamer.BaseElement) FakeSource(streamer.debug.FakeSource) Pipeline(streamer.Pipeline)

Example 2 with Element

use of streamer.Element in project cloudstack by apache.

the class BufferedImageCopyRectAdapter method main.

public static void main(String[] args) {
    System.setProperty("streamer.Element.debug", "true");
    BufferedImageCanvas canvas = new BufferedImageCanvas(4, 4);
    Element renderer = new BufferedImageCopyRectAdapter("renderer", canvas);
    int[] pixelsBeforeCopy = new int[] { // 0
    1, 2, 3, 4, // 1
    5, 6, 7, 8, // 2
    9, 10, 11, 12, // 3
    13, 14, 15, 16 };
    int[] pixelsAfterCopy = new int[] { // 0
    11, 12, 3, 4, // 1
    15, 16, 7, 8, // 2
    9, 10, 11, 12, // 3
    13, 14, 15, 16 };
    // Initalize image
    int[] data = ((DataBufferInt) canvas.getOfflineImage().getRaster().getDataBuffer()).getData();
    System.arraycopy(pixelsBeforeCopy, 0, data, 0, pixelsBeforeCopy.length);
    ByteBuffer buf = new ByteBuffer(new byte[0]);
    buf.putMetadata(TARGET_X, 0);
    buf.putMetadata(TARGET_Y, 0);
    buf.putMetadata(WIDTH, 2);
    buf.putMetadata(HEIGHT, 2);
    buf.putMetadata(SRC_X, 2);
    buf.putMetadata(SRC_Y, 2);
    renderer.handleData(buf, null);
    data = ((DataBufferInt) canvas.getOfflineImage().getRaster().getDataBuffer()).getData();
    String actualData = Arrays.toString(data);
    String expectedData = Arrays.toString(pixelsAfterCopy);
    if (!actualData.equals(expectedData))
        System.err.println("Actual image:   " + actualData + "\nExpected image: " + expectedData + ".");
}
Also used : Element(streamer.Element) BaseElement(streamer.BaseElement) DataBufferInt(java.awt.image.DataBufferInt) ByteBuffer(streamer.ByteBuffer)

Example 3 with Element

use of streamer.Element in project cloudstack by apache.

the class ServerBitmapUpdate method main.

/**
     * Example.
     */
public static void main(String[] args) {
    ByteBuffer packet = new ByteBuffer(new byte[] { 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x10, 0x00, 0x01, 0x00, 0x10, 0x00, 0x01, 0x04, 0x0a, 0x00, 0x0c, (byte) 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
    Element bitmap = new ServerBitmapUpdate("bitmap") {

        {
            verbose = true;
        }
    };
    FakeSink fakeSink = new FakeSink("sink") {

        {
            verbose = true;
        }
    };
    Pipeline pipeline = new PipelineImpl("test");
    // BufferedImageCanvas canvas = new BufferedImageCanvas(1024, 768);
    // Element adapter = new AwtRdpAdapter("test",canvas );
    // pipeline.addAndLink(bitmap, adapter);
    pipeline.addAndLink(bitmap, fakeSink);
    bitmap.handleData(packet, null);
}
Also used : FakeSink(streamer.debug.FakeSink) PipelineImpl(streamer.PipelineImpl) Element(streamer.Element) BaseElement(streamer.BaseElement) ByteBuffer(streamer.ByteBuffer) Pipeline(streamer.Pipeline)

Example 4 with Element

use of streamer.Element in project cloudstack by apache.

the class ServerIOChannelRouter 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");
    byte[] packet = new byte[] { // TPKT Header: TPKT version = 3
    (byte) 0x03, // TPKT Header: TPKT version = 3
    (byte) 0x00, // TPKT length: 27 bytes
    (byte) 0x00, // TPKT length: 27 bytes
    (byte) 0x1B, // X224 Length: 2 bytes
    (byte) 0x02, // X224 Type: Data
    (byte) 0xF0, // X224 EOT
    (byte) 0x80, // ??
    (byte) 0x68, // User ID: 1002 (1001+1)
    (byte) 0x00, // User ID: 1002 (1001+1)
    (byte) 0x01, // Channel ID: 1003
    (byte) 0x03, // Channel ID: 1003
    (byte) 0xEB, // Data priority: high, segmentation: begin|end
    (byte) 0x70, // Payload length: 13 bytes
    (byte) 0x0D, // Length: 13 bytes (LE)
    (byte) 0x0D, // Length: 13 bytes (LE)
    (byte) 0x00, // ProtocolVersion: (000000000001....) 1
    (byte) 0x16, (byte) 0x00, // PDU source: 1002 (LE)
    (byte) 0xEA, // PDU source: 1002 (LE)
    (byte) 0x03, // ShareID = 66538
    (byte) 0xEA, // ShareID = 66538
    (byte) 0x03, // ShareID = 66538
    (byte) 0x01, // ShareID = 66538
    (byte) 0x00, // Length if source descriptor: 1 (LE)
    (byte) 0x01, // Length if source descriptor: 1 (LE)
    (byte) 0x00, // Source descriptor (should be set to 0): 0
    (byte) 0x00 };
    MockSource source = new MockSource("source", ByteBuffer.convertByteArraysToByteBuffers(packet));
    RdpState rdpState = new RdpState() {

        {
            serverShareId = 66538;
        }
    };
    Element channel1003 = new ServerIOChannelRouter("channel_1003", rdpState);
    Element mcs = new ServerMCSPDU("mcs");
    Element tpkt = new ServerTpkt("tpkt");
    Element x224 = new ServerX224DataPdu("x224");
    Element sink = new MockSink("sink", ByteBuffer.convertByteArraysToByteBuffers(new byte[] { // Length: 13 bytes (LE)
    (byte) 0x0D, // Length: 13 bytes (LE)
    (byte) 0x00, // ProtocolVersion: (000000000001....) 1
    (byte) 0x16, (byte) 0x00, // PDU source: 1002 (LE)
    (byte) 0xEA, // PDU source: 1002 (LE)
    (byte) 0x03, // ShareID = 66538
    (byte) 0xEA, // ShareID = 66538
    (byte) 0x03, // ShareID = 66538
    (byte) 0x01, // ShareID = 66538
    (byte) 0x00, // Length if source descriptor: 1 (LE)
    (byte) 0x01, // Length if source descriptor: 1 (LE)
    (byte) 0x00, // Source descriptor (should be set to 0): 0
    (byte) 0x00 }));
    Pipeline pipeline = new PipelineImpl("test");
    pipeline.add(source, tpkt, x224, mcs, channel1003, sink);
    pipeline.link("source", "tpkt", "x224", "mcs >channel_1003", "channel_1003 >deactivate_all", "sink");
    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) Pipeline(streamer.Pipeline)

Example 5 with Element

use of streamer.Element in project cloudstack by apache.

the class ServerMCSAttachUserConfirmPDU method main.

/**
     * Example.
     */
/**
     * Example.
     *
     * @see http://msdn.microsoft.com/en-us/library/cc240842.aspx
     * @see http://msdn.microsoft.com/en-us/library/cc240500.aspx
     */
public static void main(String[] args) {
    // System.setProperty("streamer.Link.debug", "true");
    System.setProperty("streamer.Element.debug", "true");
    // System.setProperty("streamer.Pipeline.debug", "true");
    byte[] packet = new byte[] { // MCS user confirm (001011..,
    (byte) 0x2E, // RT successfull (0000...., 0x0)
    (byte) 0x00, // Initiator: 1001+3 = 1004
    (byte) 0x00, (byte) 0x03 };
    RdpState rdpState = new RdpState();
    MockSource source = new MockSource("source", ByteBuffer.convertByteArraysToByteBuffers(packet, new byte[] { 1, 2, 3 }));
    Element atachUserConfirm = new ServerMCSAttachUserConfirmPDU("attach_user_confirm", rdpState);
    Element sink = new MockSink("sink");
    Element mainSink = new MockSink("mainSink", ByteBuffer.convertByteArraysToByteBuffers(new byte[] { 1, 2, 3 }));
    Pipeline pipeline = new PipelineImpl("test");
    pipeline.add(source, atachUserConfirm, sink, mainSink);
    pipeline.link("source", "attach_user_confirm", "mainSink");
    pipeline.link("attach_user_confirm >" + OTOUT, "sink");
    pipeline.runMainLoop("source", STDOUT, false, false);
    if (rdpState.serverUserChannelId != 1004)
        System.err.println("Incorrect user channel ID. Expected value: 1004, actual value: " + rdpState.serverUserChannelId + ".");
}
Also used : MockSource(streamer.debug.MockSource) MockSink(streamer.debug.MockSink) PipelineImpl(streamer.PipelineImpl) Element(streamer.Element) Pipeline(streamer.Pipeline)

Aggregations

Element (streamer.Element)36 Pipeline (streamer.Pipeline)28 PipelineImpl (streamer.PipelineImpl)28 MockSource (streamer.debug.MockSource)25 MockSink (streamer.debug.MockSink)24 BaseElement (streamer.BaseElement)18 ByteBuffer (streamer.ByteBuffer)12 ScreenDescription (common.ScreenDescription)5 SyncLink (streamer.SyncLink)4 Link (streamer.Link)3 FakeSink (streamer.debug.FakeSink)3 BufferedImageCanvas (common.BufferedImageCanvas)1 DataBufferInt (java.awt.image.DataBufferInt)1 InetSocketAddress (java.net.InetSocketAddress)1 Test (org.junit.Test)1 RdpClient (rdpclient.RdpClient)1 ServerBitmapUpdate (rdpclient.rdp.ServerBitmapUpdate)1 SocketWrapper (streamer.SocketWrapper)1 FakeSource (streamer.debug.FakeSource)1 SSLState (streamer.ssl.SSLState)1