Package org.gstreamer.elements

Examples of org.gstreamer.elements.AppSrc


        args = Gst.init("AppSrcTest", args);
        final int width = 320, height = 200;
        /* setup pipeline */
        pipeline = new Pipeline("pipeline");
        final AppSrc appsrc = (AppSrc) ElementFactory.make("appsrc", "source");
        final Element srcfilter = ElementFactory.make("capsfilter", "srcfilter");
        Caps fltcaps = new Caps("video/x-raw-rgb, framerate=2/1"
                + ", width=" + width + ", height=" + height
                + ", bpp=16, depth=16");
        srcfilter.setCaps(fltcaps);
        final Element videorate = ElementFactory.make("videorate", "videorate");
        final Element ratefilter = ElementFactory.make("capsfilter", "RateFilter");
        ratefilter.setCaps(Caps.fromString("video/x-raw-rgb, framerate=2/1"));
        SwingUtilities.invokeLater(new Runnable() {

            public void run() {
                JFrame frame = new JFrame("FakeSrcTest");
                VideoComponent panel = new VideoComponent();
                panel.setPreferredSize(new Dimension(width, height));
                frame.add(panel, BorderLayout.CENTER);
                Element videosink = panel.getElement();
                pipeline.addMany(appsrc, srcfilter, videorate, ratefilter, videosink);
                Element.linkMany(appsrc, srcfilter, videorate, ratefilter, videosink);
                appsrc.set("emit-signals", true);
                appsrc.connect(new AppSrc.NEED_DATA() {
                    byte color = 0;
                    byte[] data = new byte[width * height * 2];
                    public void needData(AppSrc elem, int size) {
                        System.out.println("NEED_DATA: Element=" + elem.getNativeAddress()
                                + " size=" + size);
                        Arrays.fill(data, color++);
                        Buffer buffer = new Buffer(data.length);
                        buffer.getByteBuffer().put(data);
                appsrc.pushBuffer(buffer);
                    }
                });
                appsrc.connect(new AppSrc.ENOUGH_DATA() {
          public void enoughData(AppSrc elem) {
            System.out.println("NEED_DATA: Element=" + elem.getNativeAddress());
          }
        });
                frame.setSize(640, 480);
View Full Code Here

TOP

Related Classes of org.gstreamer.elements.AppSrc

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.