public class CachedUrlStream extends java.lang.Object implements PhysicalOggStream
PhysicalOggStream
interface for reading
and caching an Ogg stream from a URL. This class reads the data as fast as
possible from the URL, caches it locally either in memory or on disk, and
supports seeking within the available data.Modifier and Type | Class and Description |
---|---|
class |
CachedUrlStream.LoaderThread |
Constructor and Description |
---|
CachedUrlStream(java.net.URL source)
Creates an instance of this class, using a memory cache.
|
CachedUrlStream(java.net.URL source,
java.io.RandomAccessFile drain)
Creates an instance of this class, using the specified file as cache.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this stream.
|
long |
getCacheLength() |
java.util.Collection |
getLogicalStreams()
Returns a collection of objects implementing
LogicalOggStream
for accessing the separate logical streams within this physical Ogg stream. |
OggPage |
getOggPage(int index)
Return the Ogg page with the absolute index
index ,
independent from the logical structure of this stream or if the
index parameter is -1, the next Ogg page is returned. |
boolean |
isOpen()
Checks if this stream is open for reading.
|
boolean |
isSeekable() |
void |
setTime(long granulePosition)
Sets this stream's (and its logical stream's) position to the granule
position.
|
public CachedUrlStream(java.net.URL source) throws OggFormatException, java.io.IOException
OggFormatException
java.io.IOException
public CachedUrlStream(java.net.URL source, java.io.RandomAccessFile drain) throws OggFormatException, java.io.IOException
OggFormatException
java.io.IOException
public java.util.Collection getLogicalStreams()
PhysicalOggStream
LogicalOggStream
for accessing the separate logical streams within this physical Ogg stream.getLogicalStreams
in interface PhysicalOggStream
LogicalOggStream
which are representing the logical streams contained within this
physical streamLogicalOggStream
public boolean isOpen()
PhysicalOggStream
isOpen
in interface PhysicalOggStream
true
if this stream is open for reading,
false
otherwisepublic void close() throws java.io.IOException
PhysicalOggStream
close
in interface PhysicalOggStream
java.io.IOException
public long getCacheLength()
public OggPage getOggPage(int index) throws java.io.IOException
PhysicalOggStream
index
,
independent from the logical structure of this stream or if the
index parameter is -1, the next Ogg page is returned.
This method should only be used by implementations of LogicalOggStream
to access the raw pages.getOggPage
in interface PhysicalOggStream
index
- the absolute index starting from 0 at the beginning of
the file or stream or -1 to get the next page in a non-seekable
streamindex
OggFormatException
- if the ogg stream is corruptedjava.io.IOException
- if some other IO error occurspublic void setTime(long granulePosition) throws java.io.IOException
PhysicalOggStream
setTime
in interface PhysicalOggStream
OggFormatException
- if the ogg stream is corruptedjava.io.IOException
- if some other IO error occurspublic boolean isSeekable()
isSeekable
in interface PhysicalOggStream
true
if the stream is seekable, false
otherwiseCopyright © 2016 Tor-Einar Jarnbjo. All Rights Reserved.