public class CachingPushBufferStream
extends java.lang.Object
implements javax.media.protocol.PushBufferStream
An example use of this functionality is pacing a PushBufferStream which pushes more data units in a single step than a CaptureDevice. When these two undergo audio mixing, the different numbers of per-push data units will cause the PushBufferStream "play" itself faster than the CaptureDevice.
Modifier and Type | Field and Description |
---|---|
static long |
DEFAULT_BUFFER_LENGTH
The default length in milliseconds of the buffering to be performed by
CachePushBufferStreams.
|
Constructor and Description |
---|
CachingPushBufferStream(javax.media.protocol.PushBufferStream stream)
Initializes a new CachingPushBufferStream instance which is
to pace the number of per-push data units a specific
PushBufferStream provides.
|
Modifier and Type | Method and Description |
---|---|
boolean |
endOfStream()
Implements
SourceStream.endOfStream() . |
javax.media.protocol.ContentDescriptor |
getContentDescriptor()
Implements
SourceStream.getContentDescriptor() . |
long |
getContentLength()
Implements
SourceStream.getContentLength() . |
java.lang.Object |
getControl(java.lang.String controlType)
Implements
Controls.getControl(String) . |
java.lang.Object[] |
getControls()
Implements
Controls.getControls() . |
javax.media.Format |
getFormat()
Implements
PushBufferStream.getFormat() . |
javax.media.protocol.PushBufferStream |
getStream()
Gets the PushBufferStream wrapped by this instance.
|
void |
read(javax.media.Buffer buffer)
Implements
PushBufferStream.read(Buffer) . |
void |
setTransferHandler(javax.media.protocol.BufferTransferHandler transferHandler)
Implements
PushBufferStream.setTransferHandler(BufferTransferHandler) . |
protected void |
transferData(javax.media.protocol.BufferTransferHandler transferHandler)
Reads data from the wrapped/input PushBufferStream into the
cache of this stream if the cache accepts it.
|
public static final long DEFAULT_BUFFER_LENGTH
public CachingPushBufferStream(javax.media.protocol.PushBufferStream stream)
stream
- the PushBufferStream to be paced with respect to
the number of per-push data units it providespublic boolean endOfStream()
SourceStream.endOfStream()
. Delegates to the wrapped
PushBufferStream when the cache of this instance is fully read;
otherwise, returns false.endOfStream
in interface javax.media.protocol.SourceStream
public javax.media.protocol.ContentDescriptor getContentDescriptor()
SourceStream.getContentDescriptor()
. Delegates to the
wrapped PushBufferStream.getContentDescriptor
in interface javax.media.protocol.SourceStream
public long getContentLength()
SourceStream.getContentLength()
. Delegates to the
wrapped PushBufferStream.getContentLength
in interface javax.media.protocol.SourceStream
public java.lang.Object getControl(java.lang.String controlType)
Controls.getControl(String)
. Delegates to
the wrapped PushBufferStream and gives access to the
BufferControl of this instance if such a controlType is
specified and the wrapped PushBufferStream does not have such a
control available.getControl
in interface javax.media.Controls
controlType
- a String value which names the type of the
control of the wrapped PushBufferStream to be retrievedpublic java.lang.Object[] getControls()
Controls.getControls()
. Delegates to the
wrapped PushBufferStream and adds the BufferControl of
this instance if the wrapped PushBufferStream does not have a
control of such type available.getControls
in interface javax.media.Controls
public javax.media.Format getFormat()
PushBufferStream.getFormat()
. Delegates to the wrapped
PushBufferStream.getFormat
in interface javax.media.protocol.PushBufferStream
public javax.media.protocol.PushBufferStream getStream()
public void read(javax.media.Buffer buffer) throws java.io.IOException
PushBufferStream.read(Buffer)
. If an
IOException has been thrown by the wrapped stream when data was
last read from it, re-throws it. If there has been no such exception,
reads from the cache of this instance.read
in interface javax.media.protocol.PushBufferStream
buffer
- the Buffer to receive the read media datajava.io.IOException
- if the wrapped stream has thrown such an exception
when data was last read from itpublic void setTransferHandler(javax.media.protocol.BufferTransferHandler transferHandler)
PushBufferStream.setTransferHandler(BufferTransferHandler)
.
Delegates to the wrapped PushBufferStream but wraps the specified
BufferTransferHandler in order to intercept the calls to
BufferTransferHandler.transferData(PushBufferStream)
and read
data from the wrapped PushBufferStream into the cache during the
calls in question.setTransferHandler
in interface javax.media.protocol.PushBufferStream
transferHandler
- the BufferTransferHandler to be notified
by this PushBufferStream when media data is available for
readingprotected void transferData(javax.media.protocol.BufferTransferHandler transferHandler)
transferHandler
- the BufferTransferHandler which has been
notified
Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under Apache license.