Package org.jitsi.impl.neomedia.protocol
Class BufferStreamAdapter<T extends javax.media.protocol.SourceStream>
- java.lang.Object
-
- org.jitsi.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.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:
- Lyubomir Marinov
-
-
Constructor Summary
Constructors Constructor Description 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
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract intdoRead(javax.media.Buffer buffer, byte[] data, 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.booleanendOfStream()Implements SourceStream#endOfStream().javax.media.protocol.ContentDescriptorgetContentDescriptor()Implements SourceStream#getContentDescriptor().longgetContentLength()Implements SourceStream#getContentLength().ObjectgetControl(String controlType)Implements Controls#getControl(String).Object[]getControls()Implements Controls#getControls().javax.media.FormatgetFormat()Gets the Format of the data this stream provides.TgetStream()Gets the SourceStream wrapped by this instance.protected voidread(javax.media.Buffer buffer, byte[] data, int offset, int length)Reads byte data from this stream into a specific Buffer which is to use a specific array of bytes for its data.
-
-
-
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 adaptedformat- the specific Format of the SourceStream
-
-
Method Detail
-
endOfStream
public boolean endOfStream()
Implements SourceStream#endOfStream(). Delegates to the wrapped SourceStream.- Specified by:
endOfStreamin interfacejavax.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:
getContentDescriptorin interfacejavax.media.protocol.SourceStream- Returns:
- the ContentDescriptor of the stream
-
getContentLength
public long getContentLength()
Implements SourceStream#getContentLength(). Delegates to the wrapped SourceStream.- Specified by:
getContentLengthin interfacejavax.media.protocol.SourceStream- Returns:
- content length
-
getControl
public Object getControl(String controlType)
Implements Controls#getControl(String). Delegates to the wrapped SourceStream.- Specified by:
getControlin interfacejavax.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:
getControlsin interfacejavax.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[] data, int offset, int length) throws IOExceptionReads 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 instancedata- 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
-
doRead
protected abstract int doRead(javax.media.Buffer buffer, byte[] data, int offset, int length) throws IOExceptionReads 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- an optional Buffer instance associated with the specified data, offset and length and provided to the method in case the implementation would like to provide additional Buffer properties such as flagsdata- the array of bytes into which the data read from this stream is to be writtenoffset- the offset in the specified data at which writing data read from this stream should startlength- the maximum number of bytes to be written into the specified data- Returns:
- the number of bytes read from this stream and written into the specified data
- Throws:
IOException- if I/O related errors occurred during read operation
-
-