com.coremedia.iso.boxes
Class AbstractBox

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

public abstract class AbstractBox
extends Object
implements Box

A basic ISO box. No full box.


Field Summary
protected  ByteBuffer deadBytes
           
protected  String type
           
 
Constructor Summary
protected AbstractBox(String type)
           
 
Method Summary
abstract  void _parseDetails(ByteBuffer content)
          Implement the actual parsing of the box's fields here.
 void getBox(WritableByteChannel os)
           
protected abstract  void getContent(ByteBuffer bb)
          Writes the box's content into the given ByteBuffer.
protected abstract  long getContentSize()
          Gets the box's content size.
 ByteBuffer getDeadBytes()
           
 void getHeader(ByteBuffer byteBuffer)
           
 IsoFile getIsoFile()
           
 ContainerBox getParent()
           
 long getSize()
           
 String getType()
           
 byte[] getUserType()
           
 boolean isParsed()
           
 void parse(ReadableByteChannel in, ByteBuffer header, long contentSize, BoxParser boxParser)
          Pareses the given IsoBufferWrapper and returns the remaining bytes.
 void parseDetails()
          Parses the boxes fields.
 void setDeadBytes(ByteBuffer newDeadBytes)
           
 void setParent(ContainerBox parent)
           
 void setUserType(byte[] userType)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

type

protected String type

deadBytes

protected ByteBuffer deadBytes
Constructor Detail

AbstractBox

protected AbstractBox(String type)
Method Detail

getSize

public long getSize()
Specified by:
getSize in interface Box

isParsed

public boolean isParsed()

getContentSize

protected abstract long getContentSize()
Gets the box's content size. This excludes all header fields:

Flags and version of a full box need to be taken into account.

Returns:
Gets the box's content size in bytes

getType

@DoNotParseDetail
public String getType()
Specified by:
getType in interface Box

getUserType

@DoNotParseDetail
public byte[] getUserType()

setUserType

@DoNotParseDetail
public void setUserType(byte[] userType)

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()

parse

@DoNotParseDetail
public void parse(ReadableByteChannel in,
                                   ByteBuffer header,
                                   long contentSize,
                                   BoxParser boxParser)
           throws IOException
Pareses the given IsoBufferWrapper and returns the remaining bytes.

Specified by:
parse in interface Box
Parameters:
in - 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.

parseDetails

public final void parseDetails()
Parses the boxes fields.


_parseDetails

public abstract void _parseDetails(ByteBuffer content)
Implement the actual parsing of the box's fields here. External classes will always call parseDetails() which encapsulates the call to this method with some safeguards.

Parameters:
content -

getDeadBytes

public ByteBuffer getDeadBytes()

setDeadBytes

public void setDeadBytes(ByteBuffer newDeadBytes)

getHeader

public void getHeader(ByteBuffer byteBuffer)

getBox

public void getBox(WritableByteChannel os)
            throws IOException
Specified by:
getBox in interface Box
Throws:
IOException

getContent

protected abstract void getContent(ByteBuffer bb)
                            throws IOException
Writes the box's content into the given ByteBuffer. This must include flags and version in case of a full box. bb has been initialized with getSize() bytes.

Parameters:
bb - the box's content-sink.
Throws:
IOException - in case of an exception in the underlying OutputStream.


Copyright © 2012. All Rights Reserved.