javax.media.protocol
Interface CachedStream


public interface CachedStream

This interface is implemented by a SourceStream that caches downloaded data for fast delivery to the handler. It provides control over enabling/disabling the buffering and provides a way to query if a certain number of bytes are available to be read from the stream.

Buffering here refers to jitter-buffering. Buffering is normally enabled. It enables smooth playback even if the incoming data rate fluctuates. The amount of buffering is implementation dependant.

When parsing the header of a media file, the parser may want to read a few bytes to check for say a valid magic header; if the magic header is illegal, the parser can throw a BadHeaderException. The parser may build several tables and extract media track information.

The parser typically doen't need to wait for the buffers to be filled. So it is desirable to turn off buffering when parsing the header and turn it on after the header is read. This won't have any effect on playback smoothness since playback cannot start until the header is parsed.

Since:
JMF 2.0
See Also:
PullSourceStream, PushSourceStream

Method Summary
 void abortRead()
          Aborts a read if it is in progress.
 boolean getEnabledBuffering()
          Tells if buffering is currently enabled or not.
 void setEnabledBuffering(boolean b)
          This method is used by the parser to turn off buffering while the header is being read.
 boolean willReadBytesBlock(int numBytes)
          Will read numBytes block? Will return true unless numBytes bytes can be read in one read call.
 boolean willReadBytesBlock(long offset, int numBytes)
          Will seek to offset and read numBytes block? Will return true unless numBytes bytes can be read in one read call.
 

Method Detail

setEnabledBuffering

public void setEnabledBuffering(boolean b)
This method is used by the parser to turn off buffering while the header is being read. Buffering is on by default.

getEnabledBuffering

public boolean getEnabledBuffering()
Tells if buffering is currently enabled or not.

willReadBytesBlock

public boolean willReadBytesBlock(long offset,
                                  int numBytes)
Will seek to offset and read numBytes block? Will return true unless numBytes bytes can be read in one read call.

willReadBytesBlock

public boolean willReadBytesBlock(int numBytes)
Will read numBytes block? Will return true unless numBytes bytes can be read in one read call.

abortRead

public void abortRead()
Aborts a read if it is in progress.


Submit a bug or feature
Copyright 1999-2000 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved. See the Specification License for more details.
Sun, Sun Microsystems, and Java are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.