A DataSource is an abstraction for media protocol-handlers.
It hides the details of how the data is read from source--whether
the data is
coming from a file, streaming server or proprietary delivery mechanism.
It provides the methods for a Player to access
the input data.
An application-defined protocol can be implemented with a custom
DataSource . A Player can then be
created for playing back the media from the custom
DataSource using the
Manager.createPlayer method.
There are a few reasons why one would choose to implement
a DataSource as opposed to an InputStream
for a custom protocol:
-
DataSource/SourceStream provides the random
seeking API that
is not supported by an InputStream . i.e., if
the custom protocol
requires random seeking capabilities, a custom
DataSource can be used.
-
DataSource/SourceStream supports the concept of
transfer size
that is more suited for frame-delimited data, e.g. video.
A DataSource contains a set of SourceStream s.
Each SourceStream represents one elementary data stream
of the source. In the most common case, a DataSource
only provides one SourceStream . A DataSource
may provide multiple SourceStream s if it encapsulates
multiple elementary data streams.
Each of the SourceStream s provides the methods to allow
a Player to read data for processing.
DataSource manages the life-cycle of the media source
by providing a simple connection protocol.
DataSource implements Controllable which
provides extra controls via some type-specific Control
interfaces. getControl and getControls
can only be called when the DataSource is connected.
An IllegalStateException will be thrown otherwise. |