Package org.mp4parser.support
Class AbstractBox
- java.lang.Object
-
- org.mp4parser.support.AbstractBox
-
- All Implemented Interfaces:
Box,ParsableBox
- Direct Known Subclasses:
AbstractFullBox,AC3SpecificBox,AmrSpecificBox,AppleDataBox,AppleGPSCoordinatesBox,AvcConfigurationBox,AvcNalUnitStorageBox,BitRateBox,DoViConfigurationBox,DTSSpecificBox,EC3SpecificBox,FileTypeBox,FontTableBox,FreeSpaceBox,GenericMediaHeaderTextAtom,HevcConfigurationBox,ItemDataBox,MLPSpecificBox,OriginalFormatBox,PixelAspectRationAtom,PriotityRangeBox,SegmentTypeBox,TierBitRateBox,TierInfoBox,TimeCodeBox,TrackLoadSettingsAtom,TrackReferenceTypeBox,UnknownBox,UserBox,WebVTTConfigurationBox,WebVTTSourceLabelBox,XtraBox
public abstract class AbstractBox extends Object implements ParsableBox
A basic on-demand parsing box. Requires the implementation of three methods to become a fully working box: additionally this new box has to be put into theisoparser2-default.propertiesfile so that it is accessible by thePropertyBoxParserImpl
-
-
Field Summary
Fields Modifier and Type Field Description protected ByteBuffercontentprotected Stringtype
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractBox(String type)protectedAbstractBox(String type, byte[] userType)
-
Method Summary
Modifier and Type Method Description protected abstract void_parseDetails(ByteBuffer content)Parse the box's fields and child boxes if any.voidgetBox(WritableByteChannel os)Writes the complete box - size | 4-cc | content - to the givenwritableByteChannel.protected abstract voidgetContent(ByteBuffer byteBuffer)Write the box's content into the givenByteBuffer.protected abstract longgetContentSize()Get the box's content size without its header.longgetSize()Gets the full size of the box including header and content.StringgetType()The box's 4-cc type.byte[]getUserType()booleanisParsed()Check if details are parsed.voidparse(ReadableByteChannel dataSource, ByteBuffer header, long contentSize, BoxParser boxParser)Parses the box excluding the already parsed header (size, 4cc, [long-size], [user-type]).voidparseDetails()Parses the raw content of the box.
-
-
-
Field Detail
-
type
protected String type
-
content
protected ByteBuffer content
-
-
Method Detail
-
getContentSize
protected abstract long getContentSize()
Get the box's content size without its header. This must be the exact number of bytes thatgetContent(ByteBuffer)writes.- Returns:
- Gets the box's content size in bytes
- See Also:
getContent(java.nio.ByteBuffer)
-
getContent
protected abstract void getContent(ByteBuffer byteBuffer)
Write the box's content into the givenByteBuffer. This must include flags and version in case of a full box.byteBufferhas been initialized withgetSize()bytes.- Parameters:
byteBuffer- the sink for the box's content
-
_parseDetails
protected abstract void _parseDetails(ByteBuffer content)
Parse the box's fields and child boxes if any.- Parameters:
content- the box's raw content beginning after the 4-cc field.
-
parse
@DoNotParseDetail public void parse(ReadableByteChannel dataSource, ByteBuffer header, long contentSize, BoxParser boxParser) throws IOException
Parses the box excluding the already parsed header (size, 4cc, [long-size], [user-type]). The remaining size of the box is thecontentSize,contentSizenumber of bytes should be read from the box source (readableByteChannel). If you need theheaderbuffer at a later stage you have to create a copy.- Specified by:
parsein interfaceParsableBox- Parameters:
dataSource- the source for this boxheader- the box' already parsed header (create copy if you need it later as it will be overwritten)contentSize- remaining bytes of this boxboxParser- use it to parse sub-boxes.- Throws:
IOException- in case of an error during a read operation
-
getBox
public void getBox(WritableByteChannel os) throws IOException
Description copied from interface:BoxWrites the complete box - size | 4-cc | content - to the givenwritableByteChannel.- Specified by:
getBoxin interfaceBox- Parameters:
os- the box's sink- Throws:
IOException- in case of problems with theChannel
-
parseDetails
public final void parseDetails()
Parses the raw content of the box. It surrounds the actual parsing which is done
-
getSize
public long getSize()
Gets the full size of the box including header and content.
-
getType
@DoNotParseDetail public String getType()
Description copied from interface:BoxThe box's 4-cc type.
-
getUserType
@DoNotParseDetail public byte[] getUserType()
-
isParsed
public boolean isParsed()
Check if details are parsed.- Returns:
truewhenever the contentByteBufferis notnull
-
-