Search in sources :

Example 6 with Element

use of streamer.Element in project cloudstack by apache.

the class FakeSink method main.

/**
     * Example.
     */
public static void main(String[] args) {
    Element sink = new FakeSink("sink") {

        {
            verbose = true;
        }
    };
    byte[] data = new byte[] { 1, 2, 3 };
    ByteBuffer buf = new ByteBuffer(data);
    sink.setLink(STDIN, new SyncLink(), Direction.IN);
    sink.getLink(STDIN).sendData(buf);
}
Also used : Element(streamer.Element) BaseElement(streamer.BaseElement) SyncLink(streamer.SyncLink) ByteBuffer(streamer.ByteBuffer)

Example 7 with Element

use of streamer.Element in project cloudstack by apache.

the class FakeSource method main.

/**
     * Example.
     */
public static void main(String[] args) {
    Element fakeSource = new FakeSource("source 3/10/100") {

        {
            verbose = true;
            incommingBufLength = 3;
            numBuffers = 10;
            delay = 100;
        }
    };
    Element fakeSink = new FakeSink("sink") {

        {
            verbose = true;
        }
    };
    Element fakeSink2 = new FakeSink("sink2") {

        {
            verbose = true;
        }
    };
    Link link = new SyncLink();
    fakeSource.setLink(STDOUT, link, Direction.OUT);
    fakeSink.setLink(STDIN, link, Direction.IN);
    Link link2 = new SyncLink();
    fakeSource.setLink("out2", link2, Direction.OUT);
    fakeSink2.setLink(STDIN, link2, Direction.IN);
    link.sendEvent(Event.STREAM_START, Direction.IN);
    link.run();
}
Also used : Element(streamer.Element) BaseElement(streamer.BaseElement) SyncLink(streamer.SyncLink) SyncLink(streamer.SyncLink) Link(streamer.Link)

Example 8 with Element

use of streamer.Element in project cloudstack by apache.

the class MockSink method main.

/**
     * Example.
     */
public static void main(String[] args) {
    Element mockSource = new MockSource("source") {

        {
            bufs = new ByteBuffer[] { new ByteBuffer(new byte[] { 1, 1, 2, 3, 4, 5 }), new ByteBuffer(new byte[] { 2, 1, 2, 3, 4 }), new ByteBuffer(new byte[] { 3, 1, 2, 3 }), new ByteBuffer(new byte[] { 4, 1, 2 }), new ByteBuffer(new byte[] { 5, 1 }) };
            verbose = true;
            delay = 100;
            numBuffers = bufs.length;
        }
    };
    Element mockSink = new MockSink("sink") {

        {
            bufs = new ByteBuffer[] { new ByteBuffer(new byte[] { 1, 1, 2, 3, 4, 5 }), new ByteBuffer(new byte[] { 2, 1, 2, 3, 4 }), new ByteBuffer(new byte[] { 3, 1, 2, 3 }), new ByteBuffer(new byte[] { 4, 1, 2 }), new ByteBuffer(new byte[] { 5, 1 }) };
            verbose = true;
        }
    };
    Link link = new SyncLink() {

        {
            verbose = true;
        }
    };
    mockSource.setLink(STDOUT, link, Direction.OUT);
    mockSink.setLink(STDIN, link, Direction.IN);
    link.run();
}
Also used : Element(streamer.Element) BaseElement(streamer.BaseElement) SyncLink(streamer.SyncLink) ByteBuffer(streamer.ByteBuffer) SyncLink(streamer.SyncLink) Link(streamer.Link)

Example 9 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 10 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)

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