@Override public BufferedImage getImage() { if (!open) { throw new RuntimeException("Webcam has to be open to get image"); } Buffer buffer = grabber.grabFrame(); Image image = converter.createImage(buffer); if (image == null) { throw new RuntimeException("Cannot get image"); } int width = image.getWidth(null); int height = image.getHeight(null); int type = BufferedImage.TYPE_INT_RGB; BufferedImage buffered = new BufferedImage(width, height, type); Graphics2D g2 = buffered.createGraphics(); g2.drawImage(image, null, null); g2.dispose(); buffered.flush(); return buffered; }
if (tracks[i].isEnabled()) { supported = tracks[i].getSupportedFormats(); tracks[i].setFormat(chosen); LOGGER.severe("Track " + i + " is set to transmit as: " + chosen); if (tracks[i].getFormat() instanceof AudioFormat) { int packetRate = 20; PacketSizeControl pktCtrl = (PacketSizeControl) processor.getControl(PacketSizeControl.class.getName()); if (pktCtrl != null) { try { pktCtrl.setPacketSize(getPacketSize(tracks[i].getFormat(), packetRate)); pktCtrl.setPacketSize(80); if (tracks[i].getFormat().getEncoding().equals(AudioFormat.ULAW_RTP)) { Codec[] codec = new Codec[3]; tracks[i].setCodecChain(codec); tracks[i].setEnabled(false); tracks[i].setEnabled(false);
grabber = (FrameGrabbingControl) getControl(GRABBING_CTRL); if (control.setFormat(format) == null) { throw new RuntimeException("Cannot change video format");
if (bc != null) { int bl = 160; bc.setBufferLength(bl);
/** * Gets the <tt>Format</tt> of the media data made available by this * <tt>AbstractBufferStream</tt>. * * @return the <tt>Format</tt> of the media data made available by this * <tt>AbstractBufferStream</tt> */ public Format getFormat() { return (formatControl == null) ? null : formatControl.getFormat(); }
/** * Implements {@link BufferControl#getBufferLength()}. Gets the length in * milliseconds of the buffering performed by the owner of the wrapped * <tt>BufferControl</tt>. * * @return the length in milliseconds of the buffering performed by the * owner of the wrapped <tt>BufferControl</tt> */ public long getBufferLength() { return bufferControl.getBufferLength(); }
/** * Implements {@link BufferControl#getMinimumThreshold()}. Gets the minimum * threshold in milliseconds for the buffering performed by the owner of the * wrapped <tt>BufferControl</tt>. * * @return the minimum threshold in milliseconds for the buffering performed * by the owner of the wrapped <tt>BufferControl</tt> */ public long getMinimumThreshold() { return bufferControl.getMinimumThreshold(); }
/** * Implements {@link Control#getControlComponent()}. * * @return a <tt>Component</tt> which represents UI associated with this * instance if any; otherwise, <tt>null</tt> */ public Component getControlComponent() { return formatControl.getControlComponent(); }
/** * Implements {@link BufferControl#getEnabledThreshold()}. Gets the * indicator of the wrapped <tt>BufferControl</tt> which determines whether * threshold calculations are enabled. * * @return <tt>true</tt> if threshold calculations are enabled in the * wrapped <tt>BufferControl</tt>; otherwise, <tt>false</tt> */ public boolean getEnabledThreshold() { return bufferControl.getEnabledThreshold(); }
/** * Gets the <tt>Format</tt>s supported by the owner of this * <tt>FormatControl</tt>. Delegates to the wrapped <tt>FormatControl</tt>. * * @return an array of <tt>Format</tt>s supported by the owner of this * <tt>FormatControl</tt> */ public Format[] getSupportedFormats() { return formatControl.getSupportedFormats(); }
/** * Implements {@link FormatControl#isEnabled()}. * * @return <tt>true</tt> if this track is enabled; otherwise, <tt>false</tt> */ public boolean isEnabled() { return formatControl.isEnabled(); }
/** * Implements {@link javax.media.Control#getControlComponent()}. Gets the UI * <tt>Component</tt> representing this instance and exported by the owner * of the wrapped <tt>BufferControl</tt>. * * @return the UI <tt>Component</tt> representing the wrapped * <tt>BufferControl</tt> and exported by its owner if such a * <tt>Component</tt> is available; otherwise, <tt>null</tt> */ public java.awt.Component getControlComponent() { return bufferControl.getControlComponent(); }
public boolean isAdaptiveBufferEnabled() { for(JitterBufferControl pcq : getJitterBufferControls()) if(pcq.isAdaptiveBufferEnabled()) return true; return false; }
/** * Returns the number of packets in the first <tt>JitterBufferControl</tt> * found via <tt>getJitterBufferControls</tt>. * * @return the number of packets in the first <tt>JitterBufferControl</tt> * found via <tt>getJitterBufferControls</tt>. */ public int getPacketQueueCountPackets() { for(JitterBufferControl pqc : getJitterBufferControls()) return pqc.getCurrentPacketCount(); return 0; }
/** * Returns the size of the first <tt>JitterBufferControl</tt> found via * <tt>getJitterBufferControls</tt>. * * @return the size of the first <tt>JitterBufferControl</tt> found via * <tt>getJitterBufferControls</tt>. */ public int getPacketQueueSize() { for(JitterBufferControl pqc : getJitterBufferControls()) return pqc.getCurrentSizePackets(); return 0; }
/** * Returns the total number of Protocol Data Units (PDU) discarded by the * FMJ packet queue since the beginning of the session. It's the sum over * all <tt>ReceiveStream</tt>s of the <tt>MediaStream</tt> * * @return the number of discarded packets. */ public long getNbDiscarded() { int nbDiscarded = 0; for(JitterBufferControl pqc : getJitterBufferControls()) nbDiscarded =+ pqc.getDiscarded(); return nbDiscarded; }
/** * Returns the number of Protocol Data Units (PDU) discarded by the * FMJ packet queue since the beginning of the session because it was full. * It's the sum over all <tt>ReceiveStream</tt>s of the <tt>MediaStream</tt> * * @return the number of discarded packets because it was full. */ public int getNbDiscardedFull() { int nbDiscardedFull = 0; for(JitterBufferControl pqc : getJitterBufferControls()) nbDiscardedFull =+ pqc.getDiscardedFull(); return nbDiscardedFull; }
@Override public void run() { // wait for start while (!started) { try { Thread.sleep(10); } catch (InterruptedException e) { e.printStackTrace(); } started = player.getState() == Controller.Started; if (started) { break; } } // try to grab single image (wait 10 seconds) for (int i = 0; i < 100; i++) { Buffer buffer = grabber.grabFrame(); if (buffer.getLength() == 0) { try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } } } semaphore.release(); }
/** * Gets the <tt>Format</tt> of the owner of this <tt>FormatControl</tt>. * Delegates to the wrapped <tt>FormatControl</tt>. * * @return the <tt>Format</tt> of the owner of this <tt>FormatControl</tt> */ public Format getFormat() { return formatControl.getFormat(); }
/** * Gets the length in milliseconds of the buffering performed by this * <tt>PushBufferStream</tt>. * * @return the length in milliseconds of the buffering performed by this * <tt>PushBufferStream</tt> if such a value has been set; otherwise, * {@link BufferControl#DEFAULT_VALUE} */ private long getBufferLength() { synchronized (bufferControlSyncRoot) { return (bufferControl == null) ? BufferControl.DEFAULT_VALUE : bufferControl.getBufferLength(); } }