org.gstreamer.example.SWTVideoTest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gstreamer-java Show documentation
Show all versions of gstreamer-java Show documentation
Java binding for the Gstreamer framework
/*
* Copyright (C) 2009 Tamas Korodi
*
* This code is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* version 3 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with this work. If not, see .
*/
package org.gstreamer.example;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.gstreamer.Element;
import org.gstreamer.ElementFactory;
import org.gstreamer.Gst;
import org.gstreamer.Pipeline;
import org.gstreamer.swt.overlay.VideoComponent;
public class SWTVideoTest {
public static void main(String[] args) {
args = Gst.init("SWTVideoTest", args);
try {
Display display = new Display();
Shell shell = new Shell(display);
shell.setSize(640, 480);
shell.setLayout(new GridLayout(1, false));
shell.setText("SWT Video Test");
Pipeline pipe = new Pipeline("SWT Overlay Test");
Element src = ElementFactory.make("videotestsrc", "videotest");
VideoComponent component = new VideoComponent(shell, SWT.NONE, true);
component.getElement().setName("video");
component.setKeepAspect(true);
component.setLayoutData(new GridData(GridData.FILL_BOTH));
Element sink = component.getElement();
pipe.addMany(src, sink);
Element.linkMany(src, sink);
pipe.play();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
pipe.stop();
display.dispose();
} catch (Exception e) {
e.printStackTrace();
}
}
}