/** * Implements {@link SourceStream#endOfStream()}. Delegates to the wrapped * <tt>PushBufferStream</tt> when the cache of this instance is fully read; * otherwise, returns <tt>false</tt>. * * @return <tt>true</tt> if this <tt>PushBufferStream</tt> has reached the * end of the content it makes available; otherwise, <tt>false</tt> */ public boolean endOfStream() { /* * TODO If the cache is still not exhausted, don't report the end of * this stream even if the wrapped stream has reached its end. */ return stream.endOfStream(); }
/** * Implements {@link SourceStream#getContentDescriptor()}. Delegates to the * wrapped <tt>PushBufferStream</tt>. * * @return a <tt>ContentDescriptor</tt> which describes the type of the * content made available by the wrapped <tt>PushBufferStream</tt> */ public ContentDescriptor getContentDescriptor() { return stream.getContentDescriptor(); }
/** * Implements {@link SourceStream#getContentLength()}. Delegates to the * wrapped <tt>PushBufferStream</tt>. * * @return the length of the content made available by the wrapped * <tt>PushBufferStream</tt> */ public long getContentLength() { return stream.getContentLength(); }
/** * Implements {@link PushBufferStream#getFormat()}. Delegates to the wrapped * <tt>PushBufferStream</tt>. * * @return the <tt>Format</tt> of the media data available for reading in * this <tt>PushBufferStream</tt> */ public Format getFormat() { return stream.getFormat(); }
@Override public void transferData(PushBufferStream stream) { try { stream.read(buffer); } catch (Exception ex) { // The purpose of NullBufferTransferHandler is to read from the // specified PushBufferStream as soon as possible and throw the read // data away. Hence, Exceptions are of no concern. } } }
/** * {@inheritDoc} */ @Override public void open() throws IOException, SecurityException { synchronized (openCloseSyncRoot) { if (dataSource instanceof PushBufferDataSource) { PushBufferDataSource pbds = (PushBufferDataSource) dataSource; PushBufferStream[] streams = pbds.getStreams(); //XXX: should we allow for multiple streams in the data source? for (PushBufferStream stream : streams) { //XXX whats the proper way to check for this? and handle? if (!stream.getFormat().matches(new VideoFormat("VP8"))) throw new IOException("Unsupported stream format"); stream.setTransferHandler(this); } } dataSource.connect(); open = true; } }
stream.setTransferHandler(substituteTransferHandler); this.transferHandler = substituteTransferHandler; cache.notifyAll();
/** * Implements {@link javax.media.Controls#getControl(String)}. Delegates to * the wrapped <tt>PushBufferStream</tt> and gives access to the * <tt>BufferControl</tt> of this instance if such a <tt>controlType</tt> is * specified and the wrapped <tt>PushBufferStream</tt> does not have such a * control available. * * @param controlType a <tt>String</tt> value which names the type of the * control of the wrapped <tt>PushBufferStream</tt> to be retrieved * @return an <tt>Object</tt> which represents the control of the wrapped * <tt>PushBufferStream</tt> with the specified type if such a control is * available; otherwise, <tt>null</tt> */ public Object getControl(String controlType) { Object control = stream.getControl(controlType); if ((control == null) && BufferControl.class.getName().equals(controlType)) { control = getBufferControl(); } return control; }
Object[] controls = stream.getControls();
/** * Implements {@link PushBufferStream#getFormat()}. Delegates to the * wrapped <tt>PushBufferStream</tt>. * * @return the <tt>Format</tt> of the wrapped <tt>PushBufferStream</tt> */ public Format getFormat() { return stream.getFormat(); }
/** * Reads media from a specific <tt>PushBufferStream</tt> which belongs to * a specific <tt>DataSource</tt> into a specific output <tt>Buffer</tt>. * Allows extenders to tap into the reading and monitor and customize it. * * @param stream the <tt>PushBufferStream</tt> to read media from and known * to belong to the specified <tt>DataSOurce</tt> * @param buffer the output <tt>Buffer</tt> in which the media read from the * specified <tt>stream</tt> is to be written so that it gets returned to * the caller * @param dataSource the <tt>DataSource</tt> from which <tt>stream</tt> * originated * @throws IOException if anything wrong happens while reading from the * specified <tt>stream</tt> */ protected void read( PushBufferStream stream, Buffer buffer, DataSource dataSource) throws IOException { stream.read(buffer); }
/** * Implements * {@link PushBufferStream#setTransferHandler(BufferTransferHandler)}. * Sets up the hiding of the wrapped <tt>PushBufferStream</tt> from the * specified <tt>transferHandler</tt> and thus gives this * <tt>MutePushBufferStream</tt> full control when the * <tt>transferHandler</tt> in question starts calling to the stream * given to it in * <tt>BufferTransferHandler#transferData(PushBufferStream)</tt>. * * @param transferHandler a <tt>BufferTransferHandler</tt> to be * notified by this instance when data is available for reading from it */ public void setTransferHandler(BufferTransferHandler transferHandler) { stream.setTransferHandler( (transferHandler == null) ? null : new StreamSubstituteBufferTransferHandler( transferHandler, stream, this)); } }
/** * Gets the <tt>JitterBufferControl</tt> of a <tt>ReceiveStream</tt>. * * @param receiveStream the <tt>ReceiveStream</tt> to get the * <tt>JitterBufferControl</tt> of * @return the <tt>JitterBufferControl</tt> of <tt>receiveStream</tt>. */ public static JitterBufferControl getJitterBufferControl( ReceiveStream receiveStream) { DataSource ds = receiveStream.getDataSource(); if (ds instanceof PushBufferDataSource) { for (PushBufferStream pbs : ((PushBufferDataSource) ds).getStreams()) { JitterBufferControl pqc = (JitterBufferControl) pbs.getControl(JitterBufferControl.class.getName()); if (pqc != null) return pqc; } } return null; }
/** * Gets the <tt>Format</tt> in which a specific <tt>SourceStream</tt> * provides data. * * @param stream the <tt>SourceStream</tt> for which the <tt>Format</tt> in * which it provides data is to be determined * @return the <tt>Format</tt> in which the specified <tt>SourceStream</tt> * provides data if it was determined; otherwise, <tt>null</tt> */ private static Format getFormat(SourceStream stream) { if (stream instanceof PushBufferStream) return ((PushBufferStream) stream).getFormat(); if (stream instanceof PullBufferStream) return ((PullBufferStream) stream).getFormat(); return null; }
/** * Implements {@link PushBufferStream#read(Buffer)}. If this instance is * muted (through its owning <tt>RewritablePushBufferDataSource</tt>), * overwrites the data read from the wrapped <tt>PushBufferStream</tt> * with silence data. * * @param buffer a <tt>Buffer</tt> in which the read data is to be * returned to the caller * @throws IOException if reading from the wrapped * <tt>PushBufferStream</tt> fails */ public void read(Buffer buffer) throws IOException { stream.read(buffer); if (isSendingDTMF()) sendDTMF(buffer, tones.poll()); else if (isMute()) mute(buffer); }
inPushBufferStream.setTransferHandler( inStreamTransferHandler);
AudioFormat inStreamFormat = (AudioFormat) inStream.getFormat();
stream.read(buffer); readException = null;
stream.setTransferHandler( new NullBufferTransferHandler());
for (PushBufferStream pbs : pbds.getStreams()) if ((format = pbs.getFormat()) != null) break;