|
MMAPI 1.2 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface SourceStream
Abstracts a single stream of media data. It is used in
conjunction with DataSource
to provide the
input interface to a Player
SourceStream may provide type-specific controls. For that
reason, it implements the Controllable
interface
to provide additional controls.
DataSource
Field Summary | |
---|---|
static int |
NOT_SEEKABLE
The value returned by getSeekType indicating that this
SourceStream is not seekable. |
static int |
RANDOM_ACCESSIBLE
The value returned by getSeekType indicating that this
SourceStream can be seeked anywhere within the media. |
static int |
SEEKABLE_TO_START
The value returned by getSeekType indicating that this
SourceStream can be seeked only to the beginning
of the media stream. |
Method Summary | |
---|---|
ContentDescriptor |
getContentDescriptor()
Get the content type for this stream. |
long |
getContentLength()
Get the size in bytes of the content on this stream. |
int |
getSeekType()
Find out if the stream is seekable. |
int |
getTransferSize()
Get the size of a "logical" chunk of media data from the source. |
int |
read(byte[] b,
int off,
int len)
Reads up to len bytes of data from the input stream into
an array of bytes. |
long |
seek(long where)
Seek to the specified point in the stream. |
long |
tell()
Obtain the current position in the stream. |
Methods inherited from interface javax.microedition.media.Controllable |
---|
getControl, getControls |
Field Detail |
---|
static final int NOT_SEEKABLE
getSeekType
indicating that this
SourceStream
is not seekable.
Value 0 is assigned to NOT_SEEKABLE
.
static final int SEEKABLE_TO_START
getSeekType
indicating that this
SourceStream
can be seeked only to the beginning
of the media stream.
Value 1 is assigned to SEEKABLE_TO_START
.
static final int RANDOM_ACCESSIBLE
getSeekType
indicating that this
SourceStream
can be seeked anywhere within the media.
Value 2 is assigned to RANDOM_ACCESSIBLE
.
Method Detail |
---|
ContentDescriptor getContentDescriptor()
ContentDescriptor
for this stream.long getContentLength()
int read(byte[] b, int off, int len) throws java.io.IOException
len
bytes of data from the input stream into
an array of bytes. An attempt is made to read as many as
len
bytes, but a smaller number may be read.
The number of bytes actually read is returned as an integer.
This method blocks until input data is available, end of file is detected, or an exception is thrown.
If b
is null
, a
NullPointerException
is thrown.
If off
is negative, or len
is negative, or
off+len
is greater than the length of the array
b
, then an IndexOutOfBoundsException
is
thrown.
If len
is zero, then no bytes are read and
0
is returned; otherwise, there is an attempt to read at
least one byte. If no byte is available because the stream is at end of
file, the value -1
is returned; otherwise, at least one
byte is read and stored into b
.
The first byte read is stored into element b[off]
, the
next one into b[off+1]
, and so on. The number of bytes read
is, at most, equal to len
. Let k be the number of
bytes actually read; these bytes will be stored in elements
b[off]
through b[off+
k-1]
,
leaving elements b[off+
k]
through
b[off+len-1]
unaffected.
If the first byte cannot be read for any reason other than end of
file, then an IOException
is thrown. In particular, an
IOException
is thrown if the input stream has been closed.
b
- the buffer into which the data is read.off
- the start offset in array b
at which the data is written.len
- the maximum number of bytes to read.
-1
if there is no more data because the end of
the stream has been reached.
java.io.IOException
- if an I/O error occurs.int getTransferSize()
read
method
to read data from the source.
read(byte[], int, int)
long seek(long where) throws java.io.IOException
seek
method may, for a variety of reasons, fail to seek to the specified
position. For example,
it may be asked to seek to a position beyond the size of the stream;
or the stream may only be seekable to the beginning
(getSeekType
returns SEEKABLE_TO_START
).
The return value indicates whether the seeking is successful.
If it is successful, the value returned will be the same as the
given position. Otherwise, the return value will indicate what
the new position is.
If the given position is negative, seek will treat that as 0 and attempt to seek to 0.
An IOException will be thrown if an I/O error occurs, e.g. when the stream comes from a remote connection and the connection is broken.
where
- The position to seek to.
java.io.IOException
- Thrown if an I/O error occurs.long tell()
int getSeekType()
NOT_SEEKABLE
, SEEKABLE_TO_START
and
RANDOM_ACCESSIBLE
.
If the return value is SEEKABLE_TO_START
, it means
that the stream can only be repositioned to the beginning of
the stream. If the return value is RANDOM_ACCESSIBLE
,
the stream can be seeked anywhere within the stream.
|
MMAPI 1.2 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |