com.googlecode.mp4parser
Class AbstractBox

java.lang.Object
  extended by com.googlecode.mp4parser.AbstractBox
All Implemented Interfaces:
Box
Direct Known Subclasses:
AbstractAppleMetaDataBox, AbstractContainerBox, AbstractFullBox, AC3SpecificBox, AmrSpecificBox, AvcConfigurationBox, AvcNalUnitStorageBox, BitRateBox, DTSSpecificBox, EC3SpecificBox, FileTypeBox, FontTableBox, FreeSpaceBox, GenericMediaHeaderTextAtom, ItemDataBox, MLPSpecificBox, OriginalFormatBox, SampleEntry, SegmentTypeBox, TrackReferenceTypeBox, UnknownBox, UserBox

public abstract class AbstractBox
extends Object
implements Box

A basic on-demand parsing box. Requires the implementation of three methods to become a fully working box:

  1. _parseDetails(java.nio.ByteBuffer)
  2. getContent(java.nio.ByteBuffer)
  3. getContentSize()
additionally this new box has to be put into the isoparser-default.properties file so that it is accessible by the PropertyBoxParserImpl


Field Summary
protected  String type
           
 
Constructor Summary
protected AbstractBox(String type)
           
protected AbstractBox(String type, byte[] userType)
           
 
Method Summary
protected abstract  void _parseDetails(ByteBuffer content)
          Parse the box's fields and child boxes if any.
 void getBox(WritableByteChannel os)
          Writes the complete box - size | 4-cc | content - to the given writableByteChannel.
protected abstract  void getContent(ByteBuffer byteBuffer)
          Write the box's content into the given ByteBuffer.
protected abstract  long getContentSize()
          Get the box's content size without its header.
 IsoFile getIsoFile()
           
 ContainerBox getParent()
           
 long getSize()
          Gets the full size of the box including header and content.
 String getType()
          The box's 4-cc type.
 byte[] getUserType()
           
 boolean isParsed()
          Check if details are parsed.
 void parse(ReadableByteChannel readableByteChannel, ByteBuffer header, long contentSize, BoxParser boxParser)
          Read the box's content from a byte channel without parsing it.
protected  void setDeadBytes(ByteBuffer newDeadBytes)
          Sets the 'dead' bytes.
 void setParent(ContainerBox parent)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

type

protected String type
Constructor Detail

AbstractBox

protected AbstractBox(String type)

AbstractBox

protected AbstractBox(String type,
                      byte[] userType)
Method Detail

getContentSize

protected abstract long getContentSize()
Get the box's content size without its header. This must be the exact number of bytes that getContent(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 given ByteBuffer. This must include flags and version in case of a full box. byteBuffer has been initialized with getSize() 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 readableByteChannel,
                                   ByteBuffer header,
                                   long contentSize,
                                   BoxParser boxParser)
           throws IOException
Read the box's content from a byte channel without parsing it. Parsing is done on-demand.

Specified by:
parse in interface Box
Parameters:
readableByteChannel - the (part of the) iso file to parse
contentSize - expected contentSize of the box
boxParser - creates inner boxes
Throws:
IOException - in case of an I/O error.

getBox

public void getBox(WritableByteChannel os)
            throws IOException
Description copied from interface: Box
Writes the complete box - size | 4-cc | content - to the given writableByteChannel.

Specified by:
getBox in interface Box
Parameters:
os - the box's sink
Throws:
IOException - in case of problems with the Channel

setDeadBytes

protected void setDeadBytes(ByteBuffer newDeadBytes)
Sets the 'dead' bytes. These bytes are left if the content of the box has been parsed but not all bytes have been used up.

Parameters:
newDeadBytes - the unused bytes with no meaning but required for bytewise reconstruction

getSize

public long getSize()
Gets the full size of the box including header and content.

Specified by:
getSize in interface Box
Returns:
the box's size

getType

@DoNotParseDetail
public String getType()
Description copied from interface: Box
The box's 4-cc type.

Specified by:
getType in interface Box
Returns:
the 4 character type of the box

getUserType

@DoNotParseDetail
public byte[] getUserType()

getParent

@DoNotParseDetail
public ContainerBox getParent()
Specified by:
getParent in interface Box

setParent

@DoNotParseDetail
public void setParent(ContainerBox parent)
Specified by:
setParent in interface Box

getIsoFile

@DoNotParseDetail
public IsoFile getIsoFile()

isParsed

public boolean isParsed()
Check if details are parsed.

Returns:
true whenever the content ByteBuffer is not null


Copyright © 2012. All Rights Reserved.