The Stream
interface comprises the following methods:
importChunk()
. The StreamExporter
object associated with the origin of a
stream invokes the importChunk()
method to feed a new Chunk
object into the
Stream
's queue of media element objects. The StreamExporter
can determine by
means of a Stream
object's getCopy()
method if the Stream
object requires exclusive copies of
the imported Chunk
objects or if a shared reference is sufficient.
get()
. The Stream
interface defines four different get()
methods:
getChunk()
. The simple getChunk()
method extracts the first
Chunk
object from the Stream
's media element queue without any conversions or playout
synchronisation delays.
getData()
. The getData()
method returns without any synchronisation
delay, too. However, the retrieved
object is not a mere Chunk
object. Instead, the method constructs objects of a more complex type
from the basic Chunk
objects by decoding and interpreting the Chunks
' byte
array object.
The processing steps and the type of the returned object depend on the class of the Stream
object. The returned object is intended to be more suitable for the attached Consumer
object than the basic Chunk
, from which the complex object was built; for example, the
getData()
method could return objects of the type used by a player device object.
getTimedChunk()
. This method returns TimedObject
which contains
a reference to the Chunk
element extracted from the Stream
's queue. The
invocation of the TimedObject
's sync()
method blocks the caller until the point of time
is reached that corresponds to the local playout time mapping of the Chunk
's timestamp.
getTimedData()
. The getTimedData()
method behaves like a combination of the
getData()
and getTimedChunk()
methods. Actually, it returns a TimedObject
initialised with the timing information computed from the Chunk
that was extracted from the
Stream's
queue. The included object reference however denominates a complex object, which
was constructed from the extracted Chunk
in the same way as the getData()
method does.
setMasterStream()
. An invocation of this method synchronises the playout delay of
the invoked Stream
object to the playout delay of the Stream
object given as
argument to the method.
The current mmstream.stream
package includes two implementations of the Stream
interface. First, the simple Chunk_Stream
class, whose
getData()
and getTimedData()
methods behave exactly like the getChunk()
and getChunk()
methods.
Next, the MemoryImageSource_Stream
class' getData()
method returns objects
belonging to the java.awt.image.MemoryImageSource class;
similarly, the getTimedData()
method returns TimedObject
s, which reference
MemoryImageSource
objects.
Both Stream
implementations contain a Clock
object, which is generated by a
Stream
objects' StreamExporter
. The Clock
maps the timestamp contained in
Chunk
objects to local playout time instances; the playout offset necessary for this
computation is set on behalf of user interactions or by the Stream
's
setMasterStream()
method.