/** * Initialize webcam device. */ private synchronized void init() { if (!initialized.compareAndSet(false, true)) { return; } LOG.debug("GStreamer webcam device initialization"); pipe = new Pipeline(getName()); source = ElementFactory.make(GStreamerDriver.getSourceBySystem(), "source"); if (Platform.isWindows()) { source.set("device-index", deviceIndex); } else if (Platform.isLinux()) { source.set("device", videoFile.getAbsolutePath()); } else if (Platform.isMacOSX()) { throw new IllegalStateException("not yet implemented"); } sink = new RGBDataSink(getName(), this); sink.setPassDirectBuffer(true); sink.getSinkElement().setMaximumLateness(LATENESS, TimeUnit.MILLISECONDS); sink.getSinkElement().setQOSEnabled(true); filter = ElementFactory.make("capsfilter", "capsfilter"); jpegdec = ElementFactory.make("jpegdec", "jpegdec"); pipelineReady(); resolutions = parseResolutions(source.getPads().get(0)); pipelineStop(); }
@Override public void dispose() { if (!disposed.compareAndSet(false, true)) { return; } LOG.debug("Disposing GStreamer device"); close(); source.dispose(); filter.dispose(); jpegdec.dispose(); caps.dispose(); sink.dispose(); pipe.dispose(); }
/** * Add a listener for the <code>preroll-handoff</code> signal. * * @param listener The listener to be called when a {@link Buffer} is ready. */ public void connect(final PREROLL_HANDOFF listener) { connect(PREROLL_HANDOFF.class, listener, new PrerollHandoffCallback(listener)); } /**
/** * Add a listener for the <code>handoff</code> signal on this sink * * @param listener The listener to be called when a {@link Buffer} is ready. */ public void connect(final HANDOFF listener) { connect(HANDOFF.class, listener, new HandoffCallback(listener)); } /**
/** * Add a listener for the <code>handoff</code> signal on this element * * @param listener The listener to be called when a {@link Buffer} is ready. */ public void connect(final HANDOFF listener) { connect(HANDOFF.class, listener, new HandoffCallback(listener)); }
/** * 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); }
/** * Sets the audio output Element. * <p> To disable audio output, call this method with a <tt>null</tt> argument. * * @param element The element to use for audio output. */ public void setAudioSink(Element element) { setElement("audio-sink", element); }
@SuppressWarnings("unused") public Buffer callback(AppSink elem) { return listener.pullBuffer(elem); } });
@SuppressWarnings("unused") public void callback(AppSrc elem, int size) { listener.needData(elem, size); } });
@SuppressWarnings("unused") public void callback(Identity identity, Buffer buffer) { listener.handoff(identity, buffer); // if (last) // Native.detach(true); } }
/** * Sets the audio output Element. * <p> To disable audio output, call this method with a <tt>null</tt> argument. * * @param element The element to use for audio output. */ public void setAudioSink(Element element) { setElement("audio-sink", element); }
@SuppressWarnings("unused") public void callback(DecodeBin elem, Pad pad, boolean last) { listener.newDecodedPad(elem, pad, last); } });
/** * Removes a listener for the <code>unknown-type</code> signal * * @param listener The listener that was previously added. */ public void disconnect(UNKNOWN_TYPE listener) { disconnect(UNKNOWN_TYPE.class, listener); } }
public FlowReturn callback(BaseSink sink, Buffer buffer) { try { return ((CustomSink) sink).sinkPreRoll(buffer); } catch (Throwable ex) { return FlowReturn.ERROR; } } };
/** * Adds a listener for the <code>video-tags-changed</code> signal */ public void connect(final VIDEO_TAGS_CHANGED listener) { connect(VIDEO_TAGS_CHANGED.class, listener, new GstCallback() { @SuppressWarnings("unused") public void callback(PlayBin2 elem, int stream) { listener.videoTagsChanged(elem, stream); } }); } /**
/** * Removes a listener for the <code>text-tags-changed</code> signal * * @param listener The listener that was previously added. */ public void disconnect(TEXT_TAGS_CHANGED listener) { disconnect(TEXT_TAGS_CHANGED.class, listener); }
/** * Removes a listener for the <code>autoplug-sort</code> signal * * @param listener The listener that was previously added. */ public void disconnect(AUTOPLUG_SORT listener) { disconnect(AUTOPLUG_SORT.class, listener); }
/** * 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); }
/** * Sets the video output Element. * <p> To disable video output, call this method with a <tt>null</tt> argument. * * @param element The element to use for video output. */ public void setVideoSink(Element element) { setElement("video-sink", element); }
/** * 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); }