public class PushSourceStream2Impl extends Object implements PushSourceStream2
PushSourceStream2 interface identifies a
SourceStream that pushes asynchronous data.
Note that a PushSourceStream2 provides no
guarantees of the length of time that incoming data will be
buffered before being discarded or overwritten with new data.
Because of the time-dependent nature of the stream, clients should
read the pending data immediately upon notification.
This interface is functionally identical to
javax.media.protocol.PushSourceStream, except that it
provides the readStream() method that throws
exceptions. Instances of PushSourceStream2 may be
obtained through the JMF method
javax.media.protocol.PushDataSource.getStreams(). In
Java TV implementations, objects returned by this method will be of
type PushSourceStream2. Instances of
PushDataSource are obtained by means of
javax.media.Manager.createDataSource(). If access to
broadcast asynchronous data is not supported by the system, this
method will throw javax.media.NoDataSourceException.
PushDataSource.getStreams()| Modifier and Type | Field and Description |
|---|---|
protected long |
contentLength |
protected ContentDescriptor |
contentType |
protected boolean |
eos |
protected InputStream |
inputStream |
protected SourceTransferHandler |
sth |
LENGTH_UNKNOWN| Constructor and Description |
|---|
PushSourceStream2Impl(URLConnection urlConnection,
ContentDescriptor contentDesc) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
boolean |
endOfStream()
Find out if the end of the stream has been reached.
|
ContentDescriptor |
getContentDescriptor()
Get the current content type for this stream.
|
long |
getContentLength()
Get the size, in bytes, of the content on this stream.
|
Object |
getControl(String controlType)
Obtain the object that implements the specified
Class or Interface
The full class or interface name must be used. |
Object[] |
getControls()
Obtain the collection of objects that
control the object that implements this interface.
|
int |
getMinimumTransferSize()
Determine the size of the buffer needed for the data transfer.
|
int |
read(byte[] buffer,
int offset,
int length)
Read from the stream without blocking.
|
int |
readStream(byte[] buffer,
int offset,
int length)
Reads pending data from the stream without blocking.
|
static void |
registerServiceProtocol() |
void |
setTransferHandler(SourceTransferHandler transferHandler)
Register an object to service data transfers to this stream.
|
protected boolean eos
protected long contentLength
protected SourceTransferHandler sth
protected ContentDescriptor contentType
protected InputStream inputStream
public PushSourceStream2Impl(URLConnection urlConnection, ContentDescriptor contentDesc) throws IOException
IOExceptionpublic static void registerServiceProtocol()
public int readStream(byte[] buffer,
int offset,
int length)
throws IOException,
DataLostException
readStream in interface PushSourceStream2buffer - The buffer to read bytes into.offset - The offset into the buffer at which to begin writing
data.length - The number of bytes to read.IOException - If an I/O error occurs.DataLostException - If data from the stream has been lost.ArrayIndexOutOfBoundsException - If offset <
0, length < 0, or offset+length >
buffer.length.public int read(byte[] buffer,
int offset,
int length)
read in interface PushSourceStreambuffer - The buffer to read bytes into.offset - The offset into the buffer at which to begin writing data.length - The number of bytes to read.public int getMinimumTransferSize()
getMinimumTransferSize in interface PushSourceStreampublic void setTransferHandler(SourceTransferHandler transferHandler)
If a handler is already registered when
setTransferHandler is called,
the handler is replaced;
there can only be one handler at a time.
setTransferHandler in interface PushSourceStreamtransferHandler - The handler to transfer data to.public ContentDescriptor getContentDescriptor()
getContentDescriptor in interface SourceStreamContentDescriptor for this stream.public long getContentLength()
getContentLength in interface SourceStreampublic boolean endOfStream()
endOfStream in interface SourceStreamtrue if there is no more data.public Object[] getControls()
If no controls are supported, a zero length array is returned.
getControls in interface Controlspublic Object getControl(String controlType)
Class or Interface
The full class or interface name must be used.
If the control is not supported then null
is returned.
getControl in interface Controlsnull.public void close()
Copyright © 2012 code4tv.com. All Rights Reserved.