/** * Adds a listener for the <code>need-data</code> signal * * @param listener Listener to be called when appsrc needs data. */ public void connect(final NEED_DATA listener) { connect(NEED_DATA.class, listener, new GstCallback() { @SuppressWarnings("unused") public void callback(AppSrc elem, int size) { listener.needData(elem, size); } }); } /**
/** * Adds a listener for the <code>push-buffer</code> signal * * @param listener Listener to be called when appsrc push buffer. */ public void connect(final PUSH_BUFFER listener) { connect(PUSH_BUFFER.class, listener, new GstCallback() { @SuppressWarnings("unused") public FlowReturn callback(AppSrc elem, Buffer buffer) { return listener.pushBuffer(elem, buffer); } }); } /**
/** * Adds a listener for the <code>enough-data</code> signal * * @param listener Listener to be called this when appsrc fills its queue. */ public void connect(final ENOUGH_DATA listener) { connect(ENOUGH_DATA.class, listener, new GstCallback() { @SuppressWarnings("unused") public void callback(AppSrc elem) { listener.enoughData(elem); } }); } /**
/** * Adds a listener for the <code>end-of-stream</code> signal * * @param listener Listener to be called this when appsrc has no more buffer are available. */ public void connect(final END_OF_STREAM listener) { connect(END_OF_STREAM.class, listener, new GstCallback() { @SuppressWarnings("unused") public FlowReturn callback(AppSrc elem) { return listener.endOfStream(elem); } }); } /**
/** * Adds a listener for the <code>seek-data</code> signal * * @param listener Listener to be called when appsrc when its "stream-mode" * property is set to "seekable" or "random-access". The signal argument * will contain the new desired position in the stream expressed in the unit * set with the "format" property. After receiving the seek-data signal, * the application should push-buffers from the new position. */ public void connect(final SEEK_DATA listener) { connect(SEEK_DATA.class, listener, new GstCallback() { @SuppressWarnings("unused") public boolean callback(AppSrc elem, long position) { return listener.seekData(elem, position); } }); } /**
public void enoughData(AppSrc elem) { if (sendingData) { sendingData = false; source.connect(needDataListener); source.disconnect(enoughDataListener); } } }
public void needData(AppSrc elem, int size) { if (!sendingData) { sendingData = true; // If needDataListener is not disconnected, then it keeps triggering // "need-data" signals... This shouldn't happen. Bug in the signal // handling in Gstreamer-java? // Same thing in stopSendingData below. source.disconnect(needDataListener); source.connect(enoughDataListener); } } }
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]; appsrc.connect(new AppSrc.ENOUGH_DATA() { public void enoughData(AppSrc elem) { System.out.println("NEED_DATA: Element=" + elem.getNativeAddress());