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);
}
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();
}
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();
}
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);
}
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 + ".");
}
Aggregations