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:
  1. _parseDetails(java.nio.ByteBuffer)
  2. getContent(java.nio.ByteBuffer)
  3. getContentSize()
additionally this new box has to be put into the isoparser2-default.properties file so that it is accessible by the PropertyBoxParserImpl
  • Field Details

  • Constructor Details

    • AbstractBox

      protected AbstractBox(String type)
    • AbstractBox

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

    • 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

      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 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 the contentSize, contentSize number of bytes should be read from the box source (readableByteChannel). If you need the header buffer at a later stage you have to create a copy.
      Specified by:
      parse in interface ParsableBox
      Parameters:
      dataSource - the source for this box
      header - the box' already parsed header (create copy if you need it later as it will be overwritten)
      contentSize - remaining bytes of this box
      boxParser - 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: 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
    • 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.
      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()
    • isParsed

      public boolean isParsed()
      Check if details are parsed.
      Returns:
      true whenever the content ByteBuffer is not null