SegmentedSeekableStream provides a view of a subset of another SeekableStream consiting of a series of segments with given starting positions in the source stream and lengths. The resulting stream behaves like an ordinary SeekableStream. For example, given a SeekableStream containing data in a format consisting of a number of sub-streams stored in non-contiguous sectors indexed by a directory, it is possible to construct a set of SegmentedSeekableStreams, one for each sub-stream, that each provide a view of the sectors comprising a particular stream by providing the positions and lengths of the stream's sectors as indicated by the directory. The complex multi-stream structure of the original stream may be ignored by users of the SegmentedSeekableStream, who see a separate SeekableStream for each sub-stream and do not need to understand the directory structure at all.
For further efficiency, a directory structure such as in the example described above need not be fully parsed in order to build a SegmentedSeekableStream. Instead, the StreamSegmentMapper interface allows the association between a desired region of the output and an input segment to be provided dynamically. This mapping might be computed by reading from a directory in piecemeal fashion in order to avoid consuming memory resources.
It is the responsibility of the user of this class to determine whether backwards seeking should be enabled. If the source stream supports only forward seeking, backwards seeking must be disabled and the StreamSegmentMapper must be monotone; that is, forward motion in the destination must always result in forward motion within the source. If the source stream supports backwards seeking, there are no restrictions on the StreamSegmentMapper and backwards seeking may always be enabled for the SegmentedSeekableStream.
This class is not a committed part of the JAI API. It may be removed or changed in future releases of JAI.
| |
| |
| |
| |
| |
| |