public class AsfHeaderReader extends Object
AsfHeader
object if successful. Modifier and Type | Field and Description |
---|---|
protected boolean |
eachChunkOnce
If
true each chunk type will only be read once. |
protected boolean |
hasFailingReaders
If
true due to a registered
chunk reader, all InputStream objects passed to
read(GUID, InputStream, long) must support mark/reset. |
protected static Logger |
LOGGER
Logger
|
static int |
READ_LIMIT
Within this range, a
ChunkReader should be aware if it fails. |
protected Map<GUID,ChunkReader> |
readerMap
Registers GUIDs to their reader classes.
|
Constructor and Description |
---|
AsfHeaderReader(List<Class<? extends ChunkReader>> toRegister,
boolean readChunkOnce)
Creates an instance of this reader.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canFail()
Tells whether the reader can fail to return a valid chunk.
The current Use would be a modified version of StreamChunkReader ,
which is configured to only manage audio streams. |
protected void |
checkStream(InputStream stream)
Checks for the constraints of this class.
|
protected AsfHeader |
createContainer(long streamPosition,
BigInteger chunkLength,
InputStream stream)
This method is called by
read(GUID, InputStream, long) in order
to create the resulting object. |
GUID[] |
getApplyingIds()
Returns the GUIDs identifying the types of chunk, this reader will parse.
|
protected ChunkReader |
getReader(GUID guid)
Gets a configured reader instance for ASF
objects (chunks) with the specified
guid . |
protected boolean |
isReaderAvailable(GUID guid)
|
ChunkType |
read(GUID guid,
InputStream stream,
long chunkStart)
This Method implements the reading of a chunk container.
|
static AsfHeader |
readHeader(File file)
This method extracts the full ASF-Header from the given file.
If no header could be extracted null is returned. |
static AsfHeader |
readHeader(RandomAccessFile file)
This method tries to extract a full ASF-header out of the given stream.
|
static AsfHeader |
readInfoHeader(RandomAccessFile file)
This method tries to extract an ASF-header out of the given stream, which
only contains information about the audio stream.
If no header could be extracted null is returned. |
static AsfHeader |
readTagHeader(RandomAccessFile file)
This method tries to extract an ASF-header out of the given stream, which
only contains metadata.
If no header could be extracted null is returned. |
void |
setExtendedHeaderReader(AsfExtHeaderReader extReader)
Sets the
AsfExtHeaderReader , which is to be used, when an header
extension object is found. |
protected static final Logger LOGGER
public static final int READ_LIMIT
ChunkReader
should be aware if it fails.protected final boolean eachChunkOnce
true
each chunk type will only be read once.protected boolean hasFailingReaders
true
due to a registered
chunk reader, all InputStream
objects passed to
read(GUID, InputStream, long)
must support mark/reset.protected final Map<GUID,ChunkReader> readerMap
public AsfHeaderReader(List<Class<? extends ChunkReader>> toRegister, boolean readChunkOnce)
toRegister
- The chunk readers to utilize.readChunkOnce
- if true
, each chunk type (identified by chunk
GUID) will handled only once, if a reader is available, other
chunks will be discarded.public static AsfHeader readHeader(File file) throws IOException
null
is returned. file
- the ASF file to read.null
if no supported ASF
header was found.IOException
- on I/O Errors.public static AsfHeader readHeader(RandomAccessFile file) throws IOException
null
is returned. file
- File which contains the ASF header.null
if no supported ASF
header was found.IOException
- Read errorspublic static AsfHeader readInfoHeader(RandomAccessFile file) throws IOException
null
is returned. file
- File which contains the ASF header.null
if no supported ASF
header was found.IOException
- Read errorspublic static AsfHeader readTagHeader(RandomAccessFile file) throws IOException
null
is returned. file
- File which contains the ASF header.null
if no supported ASF
header was found.IOException
- Read errorspublic boolean canFail()
StreamChunkReader
,
which is configured to only manage audio streams. However, the primary
GUID for audio and video streams is the same. So if a stream shows itself
to be a video stream, the reader would return null
.true
, if further analysis of the chunk can show,
that the reader is not applicable, despite the header GUID
identification told it can handle
the chunk.protected AsfHeader createContainer(long streamPosition, BigInteger chunkLength, InputStream stream) throws IOException
read(GUID, InputStream, long)
in order
to create the resulting object. Implementations of this class should now
return a new instance of their implementation specific result AND
all data should be read, until the list of chunks starts. (The
Chunk.getChunkEnd()
must return a sane result, too)streamPosition
- position of the stream, the chunk starts.chunkLength
- the length of the chunk (from chunk header)stream
- to read the implementation specific information.IOException
- On I/O Errors and Invalid data.public GUID[] getApplyingIds()
public void setExtendedHeaderReader(AsfExtHeaderReader extReader)
AsfExtHeaderReader
, which is to be used, when an header
extension object is found.extReader
- header extension object reader.protected void checkStream(InputStream stream) throws IllegalArgumentException
stream
- stream to test.IllegalArgumentException
- If stream does not meet the requirements.protected ChunkReader getReader(GUID guid)
guid
.guid
- GUID which identifies the chunk to be read.null
if not
registered.protected boolean isReaderAvailable(GUID guid)
guid
- GUID which identifies the chunk to be read.true
if a reader is available.public ChunkType read(GUID guid, InputStream stream, long chunkStart) throws IOException, IllegalArgumentException
read
in interface ChunkReader
guid
- GUID of the currently read container.stream
- Stream which contains the chunk container.chunkStart
- The start of the chunk container from stream start.0
here.null
if no valid data found, else a Wrapper
containing all supported data.IOException
- Read errors.IllegalArgumentException
- If one used ChunkReader
could
fail and the stream source
doesn't support mark/reset.Copyright © 2005–2020 jthink.net. All rights reserved.