/** * Adds a listener for the <code>pull-preroll</code> signal. * * @param listener */ public void connect(final PULL_PREROLL listener) { connect(PULL_PREROLL.class, listener, new GstCallback() { @SuppressWarnings("unused") public Buffer callback(AppSink elem) { return listener.pullPreroll(elem); } }); } /**
/** * Removes a listener for the <code>eos</code> signal * * @param listener The listener that was previously added. */ public void disconnect(EOS listener) { disconnect(EOS.class, listener); }
/** * Gets the <tt>Caps</tt> configured on this <tt>data sink</tt> * * @return The caps configured on this <tt>sink</tt> */ public Caps getCaps() { return sink.getCaps(); }
public BufferDataAppSink(String name, Pipeline pipeline, Listener listener) { super(initializer(gst.ptr_gst_bin_new(name))); this.listener = listener; Element element = pipeline.getElementByName(name); if (element != null) { // TODO: Fix. This doesn't work. getElementByName() returns a BaseSink which // cannot be casted to AppSink. sink = (AppSink) element; sink.set("emit-signals", true); sink.set("sync", true); sink.connect(new AppSinkNewBufferListener()); } else { sink = null; throw new RuntimeException("Element with name " + name + " not found in the pipeline"); } }
/** * Checks if this <tt>AppSink</tt> is end-of-stream. * <p> * If an EOS event has been received, no more buffers can be pulled. * * @return <tt>true</tt> if no more buffers can be pulled and this * <tt>AppSink</tt> is EOS. */ public boolean isEOS() { return gst().gst_app_sink_is_eos(this); }
public void newBuffer(AppSink elem) { Buffer buffer = sink.pullBuffer(); Caps caps = buffer.getCaps(); int n = buffer.getSize(); if (n < 1) { return; } ByteBuffer data; if (passDirectBuffer) { data = buffer.getByteBuffer(); } else { data = ByteBuffer.allocate(n); data.put(buffer.getByteBuffer()).flip(); } listener.byteFrame(caps, n, data); // // Dispose of the gstreamer buffer immediately to avoid more being // allocated before the java GC kicks in // buffer.dispose(); } }
public AppSink(String name) { this(makeRawElement(GST_NAME, name)); }
public ByteDataAppSink(String name, Pipeline pipeline, Listener listener) { super(initializer(gst.ptr_gst_bin_new(name))); this.listener = listener; Element element = pipeline.getElementByName(name); if (element != null) { // TODO: Fix. This doesn't work. getElementByName() returns a BaseSink which // cannot be casted to AppSink. sink = (AppSink) element; sink.set("emit-signals", true); sink.set("sync", true); sink.connect(new AppSinkNewBufferListener()); } else { sink = null; throw new RuntimeException("Element with name " + name + " not found in the pipeline"); } }
/** * Gets the <tt>Caps</tt> configured on this <tt>AppSink</tt> * * @return The caps configured on this <tt>AppSink</tt> */ public Caps getCaps() { return gst().gst_app_sink_get_caps(this); }
public void newBuffer(AppSink elem) { Buffer buffer = sink.pullBuffer(); Caps caps = buffer.getCaps(); Structure struct = caps.getStructure(0); int width = struct.getInteger("width"); int height = struct.getInteger("height"); if (width < 1 || height < 1) { return; } IntBuffer rgb; if (passDirectBuffer) { rgb = buffer.getByteBuffer().asIntBuffer(); } else { rgb = IntBuffer.allocate(width * height); rgb.put(buffer.getByteBuffer().asIntBuffer()).flip(); } listener.rgbFrame(width, height, rgb); // // Dispose of the gstreamer buffer immediately to avoid more being // allocated before the java GC kicks in // buffer.dispose(); } }
public RGBDataAppSink(String name, Pipeline pipeline, Listener listener) { super(initializer(gst.ptr_gst_bin_new(name))); this.listener = listener; Element element = pipeline.getElementByName(name); if (element != null) { // TODO: Fix. This doesn't work. getElementByName() returns a BaseSink which // cannot be casted to AppSink. sink = (AppSink) element; sink.set("emit-signals", true); sink.set("sync", true); sink.connect(new AppSinkNewBufferListener()); } else { sink = null; throw new RuntimeException("Element with name " + name + " not found in the pipeline"); } }
/** * Removes a listener for the <code>new-preroll</code> signal * * @param listener The listener that was previously added. */ public void disconnect(NEW_PREROLL listener) { disconnect(NEW_PREROLL.class, listener); }
/** * Adds a listener for the <code>eos</code> signal. * * @param listener */ public void connect(final EOS listener) { connect(EOS.class, listener, new GstCallback() { @SuppressWarnings("unused") public void callback(AppSink elem) { listener.eos(elem); } }); } /**
/** * Sets the capabilities on the appsink element. * <p> * After calling this method, the sink will only accept caps that match <tt>caps</tt>. * If <tt>caps</tt> is non-fixed, you must check the caps on the buffers to * get the actual used caps. * * @param caps The <tt>Caps</tt> to set. */ @Override public void setCaps(Caps caps) { gst().gst_app_sink_set_caps(this, caps); }
/** * Gets the <tt>Caps</tt> configured on this <tt>data sink</tt> * * @return The caps configured on this <tt>sink</tt> */ public Caps getCaps() { return sink.getCaps(); }
public void newBuffer(AppSink elem) { Buffer buffer = sink.pullBuffer(); Caps caps = buffer.getCaps(); Structure struct = caps.getStructure(0); int width = struct.getInteger("width"); int height = struct.getInteger("height"); if (width < 1 || height < 1) { return; } listener.bufferFrame(width, height, buffer); // // Dispose of the gstreamer buffer immediately to avoid more being // allocated before the java GC kicks in if (autoDisposeBuffer) { buffer.dispose(); } } }
private void initSink(String name, String mask) { sink = (AppSink) ElementFactory.make("appsink", name); sink.set("emit-signals", true); sink.set("sync", true); sink.connect(new AppSinkNewBufferListener()); // // Convert the input into 32bit RGB so it can be fed directly to a BufferedImage // Element conv = ElementFactory.make("ffmpegcolorspace", "ColorConverter"); Element videofilter = ElementFactory.make("capsfilter", "ColorFilter"); StringBuilder caps = new StringBuilder("video/x-raw-rgb, bpp=32, depth=24, endianness=(int)4321, "); caps.append(mask); videofilter.setCaps(new Caps(caps.toString())); addMany(conv, videofilter, sink); Element.linkMany(conv, videofilter, sink); // // Link the ghost pads on the bin to the sink pad on the convertor // addPad(new GhostPad("sink", conv.getStaticPad("sink"))); }
/** * Removes a listener for the <code>new-buffer-list</code> signal * * @param listener The listener that was previously added. */ public void disconnect(NEW_BUFFER_LIST listener) { disconnect(NEW_BUFFER_LIST.class, listener); }
/** * Adds a listener for the <code>new-buffer-list</code> signal. * * @param listener */ public void connect(final NEW_BUFFER_LIST listener) { connect(NEW_BUFFER_LIST.class, listener, new GstCallback() { @SuppressWarnings("unused") public void callback(AppSink elem) { listener.newBufferList(elem); } }); } /**
/** * Pulls a {@link org.gstreamer.Buffer} from the <tt>AppSink</tt>. * <p> * This function blocks until a buffer or EOS becomes available or the appsink * element is set to the READY/NULL state. * <p> * This function will only return buffers when the appsink is in the PLAYING * state. All rendered buffers will be put in a queue so that the application * can pull buffers at its own rate. Note that when the application does not * pull buffers fast enough, the queued buffers could consume a lot of memory, * especially when dealing with raw video frames. * <p> * If an EOS event was received before any buffers, this function returns * <tt>null</tt>. Use {@link #isEOS} to check for the EOS condition. * * Returns: a #GstBuffer or NULL when the appsink is stopped or EOS. * @return A {@link org.gstreamer.Buffer} or NULL when the appsink is stopped or EOS. */ public Buffer pullBuffer() { return gst().gst_app_sink_pull_buffer(this); }