IndexEntryImpl (Media Authoring with Java API)
Date: 2016-02-05

tv.amwa.maj.io.mxf.impl

## Class IndexEntryImpl

- java.lang.Object
- - tv.amwa.maj.io.mxf.impl.IndexEntryImpl

- All Implemented Interfaces:
    Serializable, Cloneable, IndexEntry, XMLSerializable

      public class IndexEntryImpl
      extends Object
      implements IndexEntry, Cloneable, Serializable, XMLSerializable

  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `FLAGS_TAG`
    `static String` | `INDEXENTRY_TAG`
    `static String` | `KEYFRANEOFFST_TAG`
    `static String` | `POSTABLE_TAG`
    `static String` | `SLICEOFFSET_TAG`
    `static String` | `STREAMOFFSET_TAG`
    `static String` | `TEMPORALOFFSET_TAG`

    - ### Fields inherited from interface tv.amwa.maj.io.mxf.IndexEntry

      `EDITFLAG_BACKWARD_PREDICTION, EDITFLAG_FORWARD_PREDICTION, EDITFLAG_RANDOM_ACCESS, EDITFLAG_SEQUENCE_HEADER, FLAGS_DEFAULT, KEYFRAMEOFFSET_DEFAULT, TEMPORALOFFSET_DEFAULT`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `IndexEntryImpl()`
    `IndexEntryImpl(byte temporalOffset, byte keyFrameOffset, byte flags, long streamOffset)`
    `IndexEntryImpl(long streamOffset)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `appendXMLChildren(Node parent)` Append extra child elements to the given parent node to serialize the value of an object to an XML fragment.
    `IndexEntry` | `clone()` Create a cloned copy of this IndexEntryImpl.
    `static IndexEntry` | `createFromBuffer(ByteBuffer buffer)`
    `boolean` | `equals(Object o)`
    `String` | `getComment()` Include a comment when serializing a value to XML.
    `byte` | `getFlags()` Returns the edit flags that indicate the coding of the edit unit associated with the index entry.
    `byte` | `getKeyFrameOffset()` Returns the offset measured in edit units to the previous key frame for this index entry, which may be the preceding I-frame for an MPEG stream.
    `Rational[]` | `getPosTable()` Returns the array of fractional position offsets from the start of the content package to the synchronized sample in the content package.
    `int[]` | `getSliceOffset()` Returns the array of byte offsets from the stream offset of the edit unit to each slice.
    `long` | `getStreamOffset()` Returns the offset of the edit unit within the container stream relative to the start of that container stream, measured in bytes.
    `byte` | `getTemporalOffset()` Returns the offset measured in edit units from the display order to the coded order for this index entry.
    `int` | `hashCode()`
    `void` | `resolveBytes(IndexTableSegment parentSegment)` Resolves any bytes that could not be parsed initially without the context of an index table segment in the context of the given index table segment.
    `void` | `setFlags(byte flags)` Sets the edit flags that indicate the coding of the edit unit associated with the index entry.
    `void` | `setKeyFrameOffset(byte keyFrameOffset)` Sets the offset measured in edit units to the previous key frame for this index entry, which may be the preceding I-frame for an MPEG stream.
    `void` | `setPosTable(Rational[] posTable)` Sets the array of fractional position offsets from the start of the content package to the synchronized sample in the content package.
    `void` | `setSliceOffset(int[] sliceOffset)` Sets the array of byte offsets from the stream offset of the edit unit to each slice.
    `void` | `setStreamOffset(long streamOffset)` Sets the offset of the edit unit within the container stream relative to the start of that container stream, measured in bytes.
    `void` | `setTemporalOffset(byte temporalOffset)` Sets the offset measured in edit units from the display order to the coded order for this index entry.
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### INDEXENTRY_TAG

          public static final String INDEXENTRY_TAG

      See Also:
        Constant Field Values

    - #### TEMPORALOFFSET_TAG

          public static final String TEMPORALOFFSET_TAG

      See Also:
        Constant Field Values

    - #### KEYFRANEOFFST_TAG

          public static final String KEYFRANEOFFST_TAG

      See Also:
        Constant Field Values

    - #### FLAGS_TAG

          public static final String FLAGS_TAG

      See Also:
        Constant Field Values

    - #### STREAMOFFSET_TAG

          public static final String STREAMOFFSET_TAG

      See Also:
        Constant Field Values

    - #### SLICEOFFSET_TAG

          public static final String SLICEOFFSET_TAG

      See Also:
        Constant Field Values

    - #### POSTABLE_TAG

          public static final String POSTABLE_TAG

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### IndexEntryImpl

          public IndexEntryImpl()

    - #### IndexEntryImpl

          public IndexEntryImpl(@UInt64
                                long streamOffset)
                         throws IllegalArgumentException

      Throws:
        `IllegalArgumentException`

    - #### IndexEntryImpl

          public IndexEntryImpl(@Int8
                                byte temporalOffset,
                                @Int8
                                byte keyFrameOffset,
                                @EditUnitFlag
                                byte flags,
                                @UInt64
                                long streamOffset)
                         throws IllegalArgumentException

      Throws:
        `IllegalArgumentException`

  - ### Method Detail

    - #### getTemporalOffset

          @Int8
          public byte getTemporalOffset()

      Description copied from interface: `IndexEntry`

      Returns the offset measured in edit units from the display order to the coded order for this index entry.

      Specified by:
        `getTemporalOffset` in interface `IndexEntry`
      Returns:
        Offset measured in edit units from the display order to the coded order.
      See Also:
        `IndexEntry.TEMPORALOFFSET_DEFAULT`, `DeltaEntry.getPosTableIndex()`

    - #### setTemporalOffset

          public void setTemporalOffset(@Int8
                                        byte temporalOffset)

      Description copied from interface: `IndexEntry`

      Sets the offset measured in edit units from the display order to the coded order for this index entry.

      Specified by:
        `setTemporalOffset` in interface `IndexEntry`
      Parameters:
        `temporalOffset` - Offset measured in edit units from the display order to the coded order.
      See Also:
        `IndexEntry.TEMPORALOFFSET_DEFAULT`, `DeltaEntry.setPosTableIndex(byte)`

    - #### getKeyFrameOffset

          @Int8
          public byte getKeyFrameOffset()

      Description copied from interface: `IndexEntry`

      Returns the offset measured in edit units to the previous key frame for this index entry, which may be the preceding I-frame for an MPEG stream. The value is zero if this is a key frame.

      Specified by:
        `getKeyFrameOffset` in interface `IndexEntry`
      Returns:
        Offset measured in edit units to the previous key frame.
      See Also:
        `IndexEntry.KEYFRAMEOFFSET_DEFAULT`

    - #### setKeyFrameOffset

          public void setKeyFrameOffset(@Int8
                                        byte keyFrameOffset)

      Description copied from interface: `IndexEntry`

      Sets the offset measured in edit units to the previous key frame for this index entry, which may be the preceding I-frame for an MPEG stream. The value is zero if this is a key frame.

      Specified by:
        `setKeyFrameOffset` in interface `IndexEntry`
      Parameters:
        `keyFrameOffset` - Offset measured in edit units to the previous key frame.
      See Also:
        `IndexEntry.KEYFRAMEOFFSET_DEFAULT`

    - #### getFlags

          @EditUnitFlag
          public byte getFlags()

      Description copied from interface: `IndexEntry`

      Returns the edit flags that indicate the coding of the edit unit associated with the index entry.

      Note the following about prediction flags:

      - If no forward or backward prediction is set, either this is not an MPEG stream or if it is an MPEG stream, the edit unit is an I-frame.
      - If only the forward prediction flag is set, the edit unit is a P-frame.
      - If the backward prediction is set, the edit unit is a B-frame and this may include forward prediction, depending on the state of the forward prediction flag.
      Specified by:
        `getFlags` in interface `IndexEntry`
      Returns:
        Edit flags that indicate the coding of the edit unit.
      See Also:
        `IndexEntry.FLAGS_DEFAULT`, `IndexEntry.EDITFLAG_RANDOM_ACCESS`, `IndexEntry.EDITFLAG_SEQUENCE_HEADER`, `IndexEntry.EDITFLAG_FORWARD_PREDICTION`, `IndexEntry.EDITFLAG_BACKWARD_PREDICTION`

    - #### setFlags

          public void setFlags(@EditUnitFlag
                               byte flags)

      Description copied from interface: `IndexEntry`

      Sets the edit flags that indicate the coding of the edit unit associated with the index entry.

      Note the following about prediction flags:

      - If no forward or backward prediction is set, either this is not an MPEG stream or if it is an MPEG stream, the edit unit is an I-frame.
      - If only the forward prediction flag is set, the edit unit is a P-frame.
      - If the backward prediction is set, the edit unit is a B-frame and this may include forward prediction, depending on the state of the forward prediction flag.
      Specified by:
        `setFlags` in interface `IndexEntry`
      Parameters:
        `flags` - Edit flags that indicate the coding of the edit unit.
      See Also:
        `IndexEntry.FLAGS_DEFAULT`, `IndexEntry.EDITFLAG_RANDOM_ACCESS`, `IndexEntry.EDITFLAG_SEQUENCE_HEADER`, `IndexEntry.EDITFLAG_FORWARD_PREDICTION`, `IndexEntry.EDITFLAG_BACKWARD_PREDICTION`

    - #### getStreamOffset

          @UInt64
          public long getStreamOffset()

      Description copied from interface: `IndexEntry`

      Returns the offset of the edit unit within the container stream relative to the start of that container stream, measured in bytes.

      Specified by:
        `getStreamOffset` in interface `IndexEntry`
      Returns:
        Offset of the edit unit within the container stream relative to the start of that container stream, measured in bytes.

    - #### setStreamOffset

          public void setStreamOffset(@UInt64
                                      long streamOffset)
                               throws IllegalArgumentException

      Description copied from interface: `IndexEntry`

      Sets the offset of the edit unit within the container stream relative to the start of that container stream, measured in bytes.

      Specified by:
        `setStreamOffset` in interface `IndexEntry`
      Parameters:
        `streamOffset` - offset of the edit unit within the container stream relative to the start of that container stream, measured in bytes.
      Throws:
        `IllegalArgumentException` - Stream offset values cannot be negative.

    - #### getSliceOffset

          @UInt32Array
          public int[] getSliceOffset()

      Description copied from interface: `IndexEntry`

      Returns the array of byte offsets from the stream offset of the edit unit to each slice. Other than the first slice always starts at the beginning of the edit unit, a slice offset indicates the start of a group of sections following a variable bitrate encoded item.

      Specified by:
        `getSliceOffset` in interface `IndexEntry`
      Returns:
        Array of byte offsets from the stream offset of the edit unit to each slice.
      See Also:
        `DeltaEntry.getSlice()`

    - #### setSliceOffset

          public void setSliceOffset(@UInt32Array
                                     int[] sliceOffset)
                              throws IllegalArgumentException

      Description copied from interface: `IndexEntry`

      Sets the array of byte offsets from the stream offset of the edit unit to each slice. Other than the first slice always starts at the beginning of the edit unit, a slice offset indicates the start of a group of sections following a variable bitrate encoded item.

      Specified by:
        `setSliceOffset` in interface `IndexEntry`
      Parameters:
        `sliceOffset` - Array of byte offsets from the stream offset of the edit unit to each slice.
      Throws:
        `IllegalArgumentException` - Slice offset values cannot be negative.
      See Also:
        `DeltaEntry.setSlice(byte)`

    - #### getPosTable

          public Rational[] getPosTable()

      Description copied from interface: `IndexEntry`

      Returns the array of fractional position offsets from the start of the content package to the synchronized sample in the content package. Fractional offsets are required when a difference exists between the frame size of content, such as between audio and video.

      For example, the audio may only be synchronized with the video every few frames. In this case the fraction indicates how much of a fraction differece exists between the start of the audio frame and the start of the video frame.

      Specified by:
        `getPosTable` in interface `IndexEntry`
      Returns:
        Array of fractional position offsets from the start of the content package to the synchronized sample in the content package.
      See Also:
        `DeltaEntry.getPosTableIndex()`

    - #### setPosTable

          public void setPosTable(Rational[] posTable)
                           throws NullPointerException

      Description copied from interface: `IndexEntry`

      Sets the array of fractional position offsets from the start of the content package to the synchronized sample in the content package. Fractional offsets are required when a difference exists between the frame size of content, such as between audio and video.

      For example, the audio may only be synchronized with the video every few frames. In this case the fraction indicates how much of a fraction differece exists between the start of the audio frame and the start of the video frame.

      Specified by:
        `setPosTable` in interface `IndexEntry`
      Parameters:
        `posTable` - Array of fractional position offsets from the start of the content package to the synchronized sample in the content package.
      Throws:
        `NullPointerException` - Cannot create a position table with `null` elements.
      See Also:
        `DeltaEntry.setPosTableIndex(byte)`

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### clone

          public IndexEntry clone()

      Create a cloned copy of this IndexEntryImpl.

      Specified by:
        `clone` in interface `IndexEntry`
      Overrides:
        `clone` in class `Object`
      Returns:
        Cloned copy of this IndexEntryImpl.

    - #### resolveBytes

          public void resolveBytes(IndexTableSegment parentSegment)
                            throws NullPointerException,
                                   EndOfDataException

      Description copied from interface: `IndexEntry`

      Resolves any bytes that could not be parsed initially without the context of an index table segment in the context of the given index table segment. The result of calling this method is to set the slice offset and position table properties using the slice count and position table count of the index table segment.

      Specified by:
        `resolveBytes` in interface `IndexEntry`
      Parameters:
        `parentSegment` - Segment that owns the index entry and provides the slice count and position table count values.
      Throws:
        `NullPointerException` - The given parent segment is `null`.
        `EndOfDataException` - Insufficient data in the unresolved bytes of each index entry to be resolved to arrays of the required size.
      See Also:
        `IndexTableSegment.getSliceCount()`, `IndexTableSegment.getPosTableCount()`

    - #### appendXMLChildren

          public void appendXMLChildren(Node parent)

      Description copied from interface: `XMLSerializable`

      Append extra child elements to the given parent node to serialize the value of an object to an XML fragment. Methods of the `XMLBuilder` class are provided to help with this process.

      Specified by:
        `appendXMLChildren` in interface `XMLSerializable`
      Parameters:
        `parent` - XML parent element to append child nodes to.

    - #### getComment

          public String getComment()

      Description copied from interface: `XMLSerializable`

      Include a comment when serializing a value to XML. The comment will be inserted as the first child node of the element representing the class.

      Specified by:
        `getComment` in interface `XMLSerializable`
      Returns:
        Comment to add as the first child node of the element representing this class.

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### createFromBuffer

          public static final IndexEntry createFromBuffer(ByteBuffer buffer)
                                                   throws NullPointerException,
                                                          EndOfDataException

      Throws:
        `NullPointerException`
        `EndOfDataException`

(c)2007-2016 Richard Cartwright, all rights reserved. Licensed under Apache 2 license and subject to the AMWA IPR policy.