Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.neomedia.protocol
Class BufferStreamAdapter<T extends javax.media.protocol.SourceStream>

java.lang.Object
  extended by net.java.sip.communicator.impl.neomedia.protocol.BufferStreamAdapter<T>
Type Parameters:
T - the very type of SourceStream to be adapted by a BufferStreamAdapter
All Implemented Interfaces:
javax.media.Controls, javax.media.protocol.SourceStream
Direct Known Subclasses:
PullBufferStreamAdapter, PushBufferStreamAdapter

public abstract class BufferStreamAdapter<T extends javax.media.protocol.SourceStream>
extends Object
implements javax.media.protocol.SourceStream

Represents a base class for adapters of SourceStreams, usually ones reading data in arrays of bytes and not in Buffers, to SourceStreams reading data in Buffers. An example use is creating a PushBufferStream representation of a PushSourceStream.

Author:
Lubomir Marinov

Field Summary
protected  T stream
          The SourceStream being adapted by this instance.
 
Fields inherited from interface javax.media.protocol.SourceStream
LENGTH_UNKNOWN
 
Constructor Summary
BufferStreamAdapter(T stream, javax.media.Format format)
          Initializes a new BufferStreamAdapter which is to adapt a specific SourceStream into a SourceStream with a specific Format.
 
Method Summary
 boolean endOfStream()
          Implements SourceStream#endOfStream().
 javax.media.protocol.ContentDescriptor getContentDescriptor()
          Implements SourceStream#getContentDescriptor().
 long getContentLength()
          Implements SourceStream#getContentLength().
 Object getControl(String controlType)
          Implements Controls#getControl(String).
 Object[] getControls()
          Implements Controls#getControls().
 javax.media.Format getFormat()
          Gets the Format of the data this stream provides.
 T getStream()
          Gets the SourceStream wrapped by this instance.
protected  void read(javax.media.Buffer buffer, byte[] bytes)
          Reads byte data from this stream into a specific Buffer which is to use a specific array of bytes for its data.
protected abstract  int read(byte[] buffer, int offset, int length)
          Reads byte data from this stream into a specific array of bytes starting the storing at a specific offset and reading at most a specific number of bytes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stream

protected final T extends javax.media.protocol.SourceStream stream
The SourceStream being adapted by this instance.

Constructor Detail

BufferStreamAdapter

public BufferStreamAdapter(T stream,
                           javax.media.Format format)
Initializes a new BufferStreamAdapter which is to adapt a specific SourceStream into a SourceStream with a specific Format.

Parameters:
stream - the SourceStream to be adapted
format - the specific Format of the SourceStream
Method Detail

endOfStream

public boolean endOfStream()
Implements SourceStream#endOfStream(). Delegates to the wrapped SourceStream.

Specified by:
endOfStream in interface javax.media.protocol.SourceStream
Returns:
true if the stream is finished, false otherwise

getContentDescriptor

public javax.media.protocol.ContentDescriptor getContentDescriptor()
Implements SourceStream#getContentDescriptor(). Delegates to the wrapped SourceStream.

Specified by:
getContentDescriptor in interface javax.media.protocol.SourceStream
Returns:
the ContentDescriptor of the stream

getContentLength

public long getContentLength()
Implements SourceStream#getContentLength(). Delegates to the wrapped SourceStream.

Specified by:
getContentLength in interface javax.media.protocol.SourceStream
Returns:
content length

getControl

public Object getControl(String controlType)
Implements Controls#getControl(String). Delegates to the wrapped SourceStream.

Specified by:
getControl in interface javax.media.Controls
Parameters:
controlType - a String value naming the type of the control of this instance to be retrieved
Returns:
an Object which represents the control of this instance with the specified type

getControls

public Object[] getControls()
Implements Controls#getControls(). Delegates to the wrapped SourceStream.

Specified by:
getControls in interface javax.media.Controls
Returns:
array of JMF Control objects

getFormat

public javax.media.Format getFormat()
Gets the Format of the data this stream provides.

Returns:
the Format of the data this stream provides

getStream

public T getStream()
Gets the SourceStream wrapped by this instance.

Returns:
the SourceStream wrapped by this instance

read

protected void read(javax.media.Buffer buffer,
                    byte[] bytes)
             throws IOException
Reads byte data from this stream into a specific Buffer which is to use a specific array of bytes for its data.

Parameters:
buffer - the Buffer to read byte data into from this instance
bytes - the array of bytes to read data into from this instance and to be set as the data of the specified buffer
Throws:
IOException - if I/O related errors occurred during read operation

read

protected abstract int read(byte[] buffer,
                            int offset,
                            int length)
                     throws IOException
Reads byte data from this stream into a specific array of bytes starting the storing at a specific offset and reading at most a specific number of bytes.

Parameters:
buffer - the array of bytes into which the data read from this stream is to be written
offset - the offset in the specified buffer at which writing data read from this stream should start
length - the maximum number of bytes to be written into the specified buffer
Returns:
the number of bytes read from this stream and written into the specified buffer
Throws:
IOException - if I/O related errors occurred during read operation

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.