public class AsfExtHeaderReader extends Object
InputStream
and creates an AsfExtendedHeader
object.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 |
---|
AsfExtHeaderReader(List<Class<? extends ChunkReader>> toRegister,
boolean readChunkOnce)
Creates a reader instance, which only utilizes the given list of chunk
readers.
|
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 AsfExtendedHeader |
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.
|
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 AsfExtHeaderReader(List<Class<? extends ChunkReader>> toRegister, boolean readChunkOnce)
toRegister
- List of ChunkReader
class instances, which are to be
utilized by the instance.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 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 AsfExtendedHeader 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()
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.