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

tv.amwa.maj.model.impl

## Class TimecodeStreamImpl

- java.lang.Object
- - tv.amwa.maj.model.impl.InterchangeObjectImpl
  - - tv.amwa.maj.model.impl.ComponentImpl
    - - tv.amwa.maj.model.impl.SegmentImpl
      - - tv.amwa.maj.model.impl.TimecodeStreamImpl

- All Implemented Interfaces:
    Serializable, Cloneable, QComponent, QSegment, MediaEntity, MetadataObject, Component, InterchangeObject, Segment, TimecodeStream
  Direct Known Subclasses:
    TimecodeStream12MImpl

      @MediaClass(uuid1=218169601,
                  uuid2=257,
                  uuid3=5376,
                  uuid4={6,14,43,52,2,6,1,1},
                  definedName="TimecodeStream",
                  description="The TimecodeStream class specifies a stream of timecode data.",
                  symbol="TimecodeStream")
      public abstract class TimecodeStreamImpl
      extends SegmentImpl
      implements TimecodeStream, Serializable, Cloneable

  Implements a representation of a stream of timecode data.

  See Also:
    Serialized Form

- - ### Field Summary

    - ### Fields inherited from class tv.amwa.maj.model.impl.InterchangeObjectImpl

      `ObjectClassPropertyID`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TimecodeStreamImpl()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `TimecodeStream` | `clone()` Create a cloned copy of this interchange object.
    `TimecodeValue` | `getPositionTimecode(long position)` Returns the timecode value for a given frame of this timecode stream.
    `abstract int` | `getSampleSize()` Returns the size of one sample of the timecode data of this timecode stream, measured in bytes.
    `long` | `getSourceBufferLength()` Returns the length of the timecode stream buffer contained within the timecode stream object.
    `TCSource` | `getTimecodeSource()` Returns the kind of timecode of this timecode stream, which is one of LTC or VITC.
    `Stream` | `getTimecodeStreamData()` Returns the data buffer containing the stream of timecode data of this timecode stream.
    `Rational` | `getTimecodeStreamSampleRate()` Returns the sample rate of the timecode stream, which specifies the sample rate of the timecode data contained in the source property.
    `String` | `getTimecodeStreamSampleRateString()`
    `ByteBuffer` | `getUserDataAtPosition(long position)` Returns the user data (user-bits) for a particular frame of this timecode stream.
    `abstract int` | `getUserDataLength()` Returns the length of user data for one frame of this timecode stream.
    `static TCSource` | `initializeTimecodeSource()`
    `static Stream` | `initializeTimecodeStreamData()`
    `static Rational` | `initializeTimecodeStreamSampleRate()`
    `abstract ByteBuffer` | `packTimecode(TimecodeValue timecode, ByteBuffer packedBuffer)` Pack a given timecode value into a give byte array.
    `abstract ByteBuffer` | `packUserBits(ByteBuffer userBits, ByteBuffer packedBuffer)` Pack user data from the given byte array into the given packed buffer.
    `TimecodeValue` | `segmentOffsetToTC(long offset)` Converts the given segment offset to a timecode value.
    `long` | `segmentTCToOffset(TimecodeValue timecode, Rational editRate)` Converts the given timecode and edit rate to a segment offset value.
    `void` | `setPositionTimecode(long position, TimecodeValue timecode)` Sets the timecode value for a given frame of this timecode stream.
    `void` | `setTimecodeSource(TCSource timecodeSource)` Sets the kind of timecode of this timecode stream, which is one of LTC or VITC.
    `void` | `setTimecodeStreamData(Stream timecodeStreamData)` Sets the data buffer containing the stream of timecode data of this timecode stream.
    `void` | `setTimecodeStreamSampleRate(Rational timecodeStreamSampleRate)` Sets the sample rate of this timecode stream, which specifies the sample rate of the timecode data contained in the source property.
    `void` | `setTimecodeStreamSampleRateString(String timecodeStreamSampleRate)`
    `void` | `setUserDataAtPosition(long position, ByteBuffer buffer)` Sets the user data (userbits) for a particular frame of the timecode stream.
    `abstract TimecodeValue` | `unpackTimecode(ByteBuffer buffer, short fps)` Unpack a timecode value from the given buffer for the given number of frames per second.
    `abstract ByteBuffer` | `unpackUserBits(ByteBuffer buffer)` Unpack user data from the given sample of the timecode stream.

    - ### Methods inherited from class tv.amwa.maj.model.impl.SegmentImpl

      `generateSequence, getCutPoint, getKeyOffset, getPackLayerKeyIndicator, getSegmentBlob, getTrackBlob, getTrackKeyRenderSequence, getTrackName, getTrackRenderSequence, setCutPoint, setKeyOffset, setPackLayerKeyIndicator, setSegmentBlob, setTrackBlob, setTrackKeyRenderSequence, setTrackName, setTrackRenderSequence`

    - ### Methods inherited from class tv.amwa.maj.model.impl.ComponentImpl

      `appendComponentAttribute, appendComponentAttribute, appendComponentKLVData, appendComponentUserComment, appendComponentUserComment, clearComponentAttributes, clearComponentKLVData, clearComponentUserComments, countComponentAttributes, countComponentKLVData, countComponentUserComments, getComment, getComponentAttributes, getComponentDataDefinition, getComponentKLVData, getComponentLength, getComponentUserComments, getEditName, getJupiterClipOffset, getJupiterID, getLengthPresent, initializeComponentDataDefinition, prependComponentAttribute, prependComponentKLVData, prependComponentUserComment, removeComponentAttribute, removeComponentKLVData, removeComponentUserComment, setComponentDataDefinition, setComponentLength, setComponentLengthFromStream, setEditName, setJupiterClipOffset, setJupiterID, setLengthPresent`

    - ### Methods inherited from class tv.amwa.maj.model.impl.InterchangeObjectImpl

      `addApplicationPlugin, appendXMLChildren, clearApplicationPlugins, containsApplicationPlugin, containsApplicationPlugin, countApplicationPlugins, deepEquals, disableGenerationTracking, enableGenerationTracking, equals, getApplicationPlugins, getGeneration, getLinkedGenerationID, getLinkedGenerationIDString, getObjectClass, getPersistentID, getPersistentIndex, hashCode, isGenerationTracked, removeApplicationPlugin, removeApplicationPlugin, setLinkedGenerationID, setLinkedGenerationIDString, setObjectClass, setPersistentID, setPersistentIndex, toString`

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

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

    - ### Methods inherited from interface tv.amwa.maj.model.Segment

      `generateSequence`

    - ### Methods inherited from interface tv.amwa.maj.model.Component

      `appendComponentAttribute, appendComponentAttribute, appendComponentKLVData, appendComponentUserComment, appendComponentUserComment, clearComponentAttributes, clearComponentKLVData, clearComponentUserComments, countComponentAttributes, countComponentKLVData, countComponentUserComments, getComponentAttributes, getComponentDataDefinition, getComponentKLVData, getComponentLength, getComponentUserComments, getLengthPresent, removeComponentAttribute, removeComponentKLVData, removeComponentUserComment, setComponentDataDefinition, setComponentLength, setLengthPresent`

    - ### Methods inherited from interface tv.amwa.maj.model.InterchangeObject

      `addApplicationPlugin, clearApplicationPlugins, containsApplicationPlugin, containsApplicationPlugin, countApplicationPlugins, deepEquals, disableGenerationTracking, enableGenerationTracking, equals, getApplicationPlugins, getGeneration, getLinkedGenerationID, getObjectClass, isGenerationTracked, removeApplicationPlugin, removeApplicationPlugin, setLinkedGenerationID, setObjectClass, toString`

    - ### Methods inherited from interface tv.amwa.maj.industry.MediaEntity

      `getPersistentID, setPersistentIndex`

- - ### Constructor Detail

    - #### TimecodeStreamImpl

          public TimecodeStreamImpl()

  - ### Method Detail

    - #### getTimecodeStreamSampleRate

          @MediaProperty(uuid1=67371265,
                         uuid2=513,
                         uuid3=0,
                         uuid4={6,14,43,52,1,1,1,2},
                         definedName="TimecodeStreamSampleRate",
                         aliases="SampleRate",
                         typeName="Rational",
                         optional=false,
                         uniqueIdentifier=false,
                         pid=5633,
                         symbol="TimecodeStreamSampleRate")
          public Rational getTimecodeStreamSampleRate()

      Description copied from interface: `TimecodeStream`

      Returns the sample rate of the timecode stream, which specifies the sample rate of the timecode data contained in the source property.

      Specified by:
        `getTimecodeStreamSampleRate` in interface `TimecodeStream`
      Returns:
        Sample rate of this timecode stream.

    - #### setTimecodeStreamSampleRate

          @MediaPropertySetter(value="TimecodeStreamSampleRate")
          public void setTimecodeStreamSampleRate(Rational timecodeStreamSampleRate)
                                                                                                  throws NullPointerException

      Description copied from interface: `TimecodeStream`

      Sets the sample rate of this timecode stream, which specifies the sample rate of the timecode data contained in the source property.

      Specified by:
        `setTimecodeStreamSampleRate` in interface `TimecodeStream`
      Parameters:
        `timecodeStreamSampleRate` - Sample rate of this timecode stream.
      Throws:
        `NullPointerException`

    - #### initializeTimecodeStreamSampleRate

          public static final Rational initializeTimecodeStreamSampleRate()

    - #### getSampleSize

          public abstract int getSampleSize()

      Description copied from interface: `TimecodeStream`

      Returns the size of one sample of the timecode data of this timecode stream, measured in bytes.

      Specified by:
        `getSampleSize` in interface `TimecodeStream`
      Returns:
        Size of one sample of the timecode data of this timecode stream.

    - #### getTimecodeStreamData

          @MediaProperty(uuid1=67568384,
                         uuid2=0,
                         uuid3=0,
                         uuid4={6,14,43,52,1,1,1,2},
                         definedName="TimecodeStreamData",
                         aliases="Source",
                         typeName="Stream",
                         optional=false,
                         uniqueIdentifier=false,
                         pid=5634,
                         symbol="TimecodeStreamData")
          public Stream getTimecodeStreamData()

      Description copied from interface: `TimecodeStream`

      Returns the data buffer containing the stream of timecode data of this timecode stream.

      Specified by:
        `getTimecodeStreamData` in interface `TimecodeStream`
      Returns:
        Stream of timecode data stored in this timecode stream.
      See Also:
        `TimecodeStream.getTimecodeStreamSampleRate()`

    - #### setTimecodeStreamData

          @MediaPropertySetter(value="TimecodeStreamData")
          public void setTimecodeStreamData(Stream timecodeStreamData)
                                                                                      throws NullPointerException

      Description copied from interface: `TimecodeStream`

      Sets the data buffer containing the stream of timecode data of this timecode stream.

      Specified by:
        `setTimecodeStreamData` in interface `TimecodeStream`
      Parameters:
        `timecodeStreamData` - Stream of timecode data to store in this timecode stream.
      Throws:
        `NullPointerException` - The given timecode stream source property is `null`.
      See Also:
        `TimecodeStream.setTimecodeStreamSampleRate(Rational)`

    - #### initializeTimecodeStreamData

          public static final Stream initializeTimecodeStreamData()

    - #### getSourceBufferLength

          public long getSourceBufferLength()
                                     throws IOException

      Description copied from interface: `TimecodeStream`

      Returns the length of the timecode stream buffer contained within the timecode stream object. This is the size of the buffer and not the number of timecode entries in the stream.

      Specified by:
        `getSourceBufferLength` in interface `TimecodeStream`
      Returns:
        Length of the timecode stream buffer contained within the timecode stream object.
      Throws:
        `IOException` - Cannot access the underlying stream to determine the length.
      See Also:
        `TimecodeStream.getTimecodeStreamData()`

    - #### getTimecodeSource

          @MediaProperty(uuid1=67371521,
                         uuid2=0,
                         uuid3=0,
                         uuid4={6,14,43,52,1,1,1,1},
                         definedName="TimecodeSource",
                         aliases="SourceType",
                         typeName="TCSource",
                         optional=false,
                         uniqueIdentifier=false,
                         pid=5635,
                         symbol="TimecodeSource")
          public TCSource getTimecodeSource()

      Description copied from interface: `TimecodeStream`

      Returns the kind of timecode of this timecode stream, which is one of LTC or VITC.

      Specified by:
        `getTimecodeSource` in interface `TimecodeStream`
      Returns:
        Kind of timecode of this timecode stream.

    - #### setTimecodeSource

          @MediaPropertySetter(value="TimecodeSource")
          public void setTimecodeSource(TCSource timecodeSource)
                                                                              throws NullPointerException

      Description copied from interface: `TimecodeStream`

      Sets the kind of timecode of this timecode stream, which is one of LTC or VITC.

      Specified by:
        `setTimecodeSource` in interface `TimecodeStream`
      Parameters:
        `timecodeSource` - Kind of timecode of this timecode stream.
      Throws:
        `NullPointerException`

    - #### initializeTimecodeSource

          public static final TCSource initializeTimecodeSource()

    - #### getUserDataAtPosition

          public ByteBuffer getUserDataAtPosition(long position)
                                           throws PositionOutOfRangeException,
                                                  IOException

      Description copied from interface: `TimecodeStream`

      Returns the user data (user-bits) for a particular frame of this timecode stream.

      Specified by:
        `getUserDataAtPosition` in interface `TimecodeStream`
      Parameters:
        `position` - Zero-based index to the frame to get the user bits from.
      Returns:
        User-bits from the timecode data for this given frame.
      Throws:
        `PositionOutOfRangeException` - The given user data is outside the acceptable range for this timecode stream.
        `IOException` - Error occurred when trying to read from the underlying stream.
      See Also:
        `TimecodeStream.getUserDataLength()`

    - #### setUserDataAtPosition

          public void setUserDataAtPosition(long position,
                                            ByteBuffer buffer)
                                     throws NullPointerException,
                                            PositionOutOfRangeException,
                                            IOException

      Description copied from interface: `TimecodeStream`

      Sets the user data (userbits) for a particular frame of the timecode stream.

      Specified by:
        `setUserDataAtPosition` in interface `TimecodeStream`
      Parameters:
        `position` - Zero-based offset to the userbits to set.
        `buffer` - User data for the specified frame.
      Throws:
        `NullPointerException` - The given user data buffer is `null`.
        `PositionOutOfRangeException` - The given user data is outside the acceptable range for this timecode stream.
        `IOException` - Error occurred when trying to access date from the underlying stream.

    - #### getUserDataLength

          public abstract int getUserDataLength()

      Description copied from interface: `TimecodeStream`

      Returns the length of user data for one frame of this timecode stream.

      Specified by:
        `getUserDataLength` in interface `TimecodeStream`
      Returns:
        Length of user data for one frame of this timecode stream.
      See Also:
        `TimecodeStream.getUserDataAtPosition(long)`

    - #### getPositionTimecode

          public TimecodeValue getPositionTimecode(long position)
                                            throws PositionOutOfRangeException,
                                                   IOException

      Description copied from interface: `TimecodeStream`

      Returns the timecode value for a given frame of this timecode stream. The frame index must be within the length of the stream.

      Specified by:
        `getPositionTimecode` in interface `TimecodeStream`
      Parameters:
        `position` - Frame to find the timecode value for from the timecode stream.
      Returns:
        Timecode value at the given frame from the timecode stream.
      Throws:
        `PositionOutOfRangeException` - Frame index is outside the length of this timecode stream.
        `IOException` - Error occurred when trying to access data from the underlying stream.

    - #### setPositionTimecode

          public void setPositionTimecode(long position,
                                          TimecodeValue timecode)
                                   throws NullPointerException,
                                          PositionOutOfRangeException,
                                          IOException

      Description copied from interface: `TimecodeStream`

      Sets the timecode value for a given frame of this timecode stream. The frame index must be within the length of the stream.

      Specified by:
        `setPositionTimecode` in interface `TimecodeStream`
      Parameters:
        `position` - Zero-based offset to set the timecode value at.
        `timecode` - Timecode value to set at the given frame for the timecode stream.
      Throws:
        `NullPointerException` - The given timecode value is `null`.
        `PositionOutOfRangeException` - Frame index is outside the length of the stream.
        `IOException` - Error occurred when trying to write data to the underlying stream.

    - #### segmentOffsetToTC

          public TimecodeValue segmentOffsetToTC(long offset)
                                          throws IllegalArgumentException

      Description copied from interface: `Segment`

      Converts the given segment offset to a timecode value.

      Specified by:
        `segmentOffsetToTC` in interface `Segment`
      Overrides:
        `segmentOffsetToTC` in class `SegmentImpl`
      Parameters:
        `offset` - Segment offset to be converted to a timecode.
      Returns:
        Converted timecode value.
      Throws:
        `IllegalArgumentException`
      See Also:
        `Segment.segmentTCToOffset(TimecodeValue, Rational)`

    - #### segmentTCToOffset

          public long segmentTCToOffset(TimecodeValue timecode,
                                        Rational editRate)
                                 throws NullPointerException,
                                        TimecodeNotFoundException,
                                        BadSampleOffsetException

      Description copied from interface: `Segment`

      Converts the given timecode and edit rate to a segment offset value.

      Specified by:
        `segmentTCToOffset` in interface `Segment`
      Overrides:
        `segmentTCToOffset` in class `SegmentImpl`
      Parameters:
        `timecode` - Timecode to be converted to an offset.
        `editRate` - Edit rate of the given timecode.
      Returns:
        Frame offset into the segment.
      Throws:
        `NullPointerException` - One or both of the given timecode and/or edit rate is/are `null`.
        `TimecodeNotFoundException` - The given timecode is not available in this segment.
        `BadSampleOffsetException` - The given timecode is outside the bounds of the timecode values represented by this segment.
      See Also:
        `Segment.segmentOffsetToTC(long)`

    - #### unpackTimecode

          public abstract TimecodeValue unpackTimecode(ByteBuffer buffer,
                                                       short fps)
                                                throws NullPointerException,
                                                       IllegalArgumentException

      Unpack a timecode value from the given buffer for the given number of frames per second.

      Parameters:
        `buffer` - Data buffer containing bytes representing one timecode value.
        `fps` - Frames per second of the current timecode stream.
      Returns:
        Deserialized timecode value from the given data buffer.
      Throws:
        `NullPointerException` - Argument is null.
        `IllegalArgumentException` - The given buffer does not contain sufficient data to unpack a timecode value or the frame per second value is not a positive value.

    - #### packTimecode

          public abstract ByteBuffer packTimecode(TimecodeValue timecode,
                                                  ByteBuffer packedBuffer)
                                           throws NullPointerException,
                                                  IllegalArgumentException

      Pack a given timecode value into a give byte array. Any user bits in the given packed buffer are preserved.

      Parameters:
        `timecode` - Timecode value to serialize.
        `packedBuffer` - Array of bytes into which the timecode should be packed.
      Returns:
        Serialized version of the given timecode value.
      Throws:
        `NullPointerException` - One or more of the arguments is null.
        `IllegalArgumentException` - The given array of packed bytes is the wrong length to allow the packing of a timecode value.

    - #### unpackUserBits

          public abstract ByteBuffer unpackUserBits(ByteBuffer buffer)
                                             throws NullPointerException,
                                                    IllegalArgumentException

      Unpack user data from the given sample of the timecode stream.

      Parameters:
        `buffer` - Buffer to use to unpack user data from.
      Returns:
        User data contained within the given sample.
      Throws:
        `NullPointerException` - Argument is null.
        `IllegalArgumentException` - The given data buffer is too short to enable user bits to be extracted.

    - #### packUserBits

          public abstract ByteBuffer packUserBits(ByteBuffer userBits,
                                                  ByteBuffer packedBuffer)
                                           throws NullPointerException,
                                                  IllegalArgumentException

      Pack user data from the given byte array into the given packed buffer.

      Parameters:
        `userBits` - User bits to set for a timecode value.
        `packedBuffer` - Buffer to pack user bits into.
      Returns:
        Buffer with the given user bits set.
      Throws:
        `NullPointerException` - One or more of the arguments is null.
        `IllegalArgumentException` - The packed buffer or array of user bits are of the wrong length.

    - #### clone

          public TimecodeStream clone()

      Description copied from interface: `InterchangeObject`

      Create a cloned copy of this interchange object.

      Specified by:
        `clone` in interface `MediaEntity`
      Specified by:
        `clone` in interface `Component`
      Specified by:
        `clone` in interface `InterchangeObject`
      Specified by:
        `clone` in interface `Segment`
      Specified by:
        `clone` in interface `TimecodeStream`
      Overrides:
        `clone` in class `SegmentImpl`
      Returns:
        Cloned copy of this interchange object.

    - #### getTimecodeStreamSampleRateString

          public String getTimecodeStreamSampleRateString()

    - #### setTimecodeStreamSampleRateString

          public void setTimecodeStreamSampleRateString(String timecodeStreamSampleRate)

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