Media Authoring
with Java API

tv.amwa.maj.entity
Class TimecodeStream

java.lang.Object
  extended by tv.amwa.maj.entity.InterchangeObject
      extended by tv.amwa.maj.entity.Component
          extended by tv.amwa.maj.entity.Segment
              extended by tv.amwa.maj.entity.TimecodeStream
All Implemented Interfaces:
Serializable, Cloneable, MAJCommon, Component, InterchangeObject, Segment, TimecodeStream, XMLSerializable
Direct Known Subclasses:
TimecodeStream12M

@AAFClass(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.")
public abstract class TimecodeStream
extends Segment
implements TimecodeStream, Serializable, Cloneable, MAJCommon

Implements a representation of a stream of timecode data.

THE COMMENTS FOR THIS CLASS ARE INCOMPLETE.

Author:
Richard Cartwright
See Also:
Serialized Form

Nested Class Summary
static class TimecodeStream.XMLHandler
           
 
Nested classes/interfaces inherited from class tv.amwa.maj.entity.Segment
Segment.SegmentXMLHandler
 
Nested classes/interfaces inherited from class tv.amwa.maj.entity.Component
Component.ComponentAttributesXMLHandler, Component.ComponentUserCommentsXMLHandler, Component.ComponentXMLHandler, Component.KLVDataXMLHandler
 
Nested classes/interfaces inherited from class tv.amwa.maj.entity.InterchangeObject
InterchangeObject.InterchangeObjectXMLHandler
 
Field Summary
 
Fields inherited from class tv.amwa.maj.entity.Component
COMPONENT_ITEM
 
Constructor Summary
TimecodeStream()
           
 
Method Summary
 void appendXMLChildren(Node parent)
          Append child elements to the given parent node to serialize the value of an object to an XML fragment.
 boolean equals(Object o)
          Tests to see if the given object is equal to this interchange object.
 TimecodeValue getPositionTimecode(long position)
          Returns the timecode value for a given frame of this timecode stream.
 Rational getSampleRate()
          Returns the sample rate of the timecode stream, which specifies the sample rate of the timecode data contained in the source property.
abstract  int getSampleSize()
          Returns the size of one sample of the timecode data of this timecode stream, measured in bytes.
 byte[] getSource()
          Returns the data buffer containing the stream of timecode data of this timecode stream.
 int getSourceBufferLength()
          Returns the length of the timecode stream buffer contained within the timecode stream object.
 TCSource getSourceType()
          Returns the kind of timecode of this timecode stream, which is one of LTC or VITC.
 byte[] 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.
 int hashCode()
          Returns a hash code value for this interchange object.
abstract  byte[] packTimecode(TimecodeValue timecode, byte[] packedBuffer)
          Pack a given timecode value into a give byte array.
abstract  byte[] packUserBits(byte[] userBits, byte[] 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 setPropertiesFromInterface(TimecodeStream castFrom)
           
 void setSampleRate(Rational sampleRate)
          Sets the sample rate of this timecode stream, which specifies the sample rate of the timecode data contained in the source property.
 void setSource(byte[] value)
          Sets the data buffer containing the stream of timecode data of this timecode stream.
 void setSourceType(TCSource sourceType)
          Sets the kind of timecode of this timecode stream, which is one of LTC or VITC.
 void setUserDataAtPosition(long position, byte[] buffer)
          Sets the user data (userbits) for a particular frame of the timecode stream.
abstract  TimecodeValue unpackTimecode(byte[] buffer, short fps)
          Unpack a timecode value from the given buffer for the given number of frames per second.
abstract  byte[] unpackUserBits(byte[] buffer)
          Unpack user data from the given sample of the timecode stream.
 
Methods inherited from class tv.amwa.maj.entity.Segment
clone, setPropertiesFromInterface
 
Methods inherited from class tv.amwa.maj.entity.Component
appendAttribute, appendAttribute, appendComment, appendComment, appendKLVData, countAttributes, countComments, countKLVData, getAttributes, getComments, getDataDefinition, getKLVData, getLength, getLengthPresent, removeAttribute, removeComment, removeKLVData, setDataDefinition, setLength, setLengthPresent, setPropertiesFromInterface
 
Methods inherited from class tv.amwa.maj.entity.InterchangeObject
castFromInterface, countProperties, createOptionalPropertyValue, disableGenerationTracking, enableGenerationTracking, getDefinition, getGeneration, getGenerationAUID, getProperties, getPropertyValue, isGenerationTracked, isPropertyPresent, omitOpionalProperty, registerImplementation, setPropertiesFromInterface, setPropertyValue, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface tv.amwa.maj.iface.Component
appendAttribute, appendAttribute, appendComment, appendComment, appendKLVData, countAttributes, countComments, countKLVData, getAttributes, getComments, getDataDefinition, getKLVData, getLength, removeAttribute, removeComment, removeKLVData, setDataDefinition, setLength
 
Methods inherited from interface tv.amwa.maj.iface.InterchangeObject
countProperties, createOptionalPropertyValue, disableGenerationTracking, enableGenerationTracking, getDefinition, getGeneration, getGenerationAUID, getProperties, getPropertyValue, isGenerationTracked, isPropertyPresent, omitOpionalProperty, setPropertyValue
 
Methods inherited from interface tv.amwa.maj.entity.MAJCommon
clone, toString
 

Constructor Detail

TimecodeStream

public TimecodeStream()
Method Detail

setPropertiesFromInterface

public final void setPropertiesFromInterface(TimecodeStream castFrom)

getSampleRate

@AAFProperty(uuid1=67371265,
             uuid2=513,
             uuid3=0,
             uuid4={6,14,43,52,1,1,1,2},
             definedName="SampleRate",
             typeName="Rational",
             optional=false,
             uniqueIdentifier=false,
             pid=5633)
public Rational getSampleRate()
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:
getSampleRate in interface TimecodeStream
Returns:
Sample rate of this timecode stream.

setSampleRate

public void setSampleRate(Rational sampleRate)
                   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:
setSampleRate in interface TimecodeStream
Parameters:
sampleRate - Sample rate of this timecode stream.
Throws:
NullPointerException

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.

getSource

@AAFProperty(uuid1=67568384,
             uuid2=0,
             uuid3=0,
             uuid4={6,14,43,52,1,1,1,2},
             definedName="Source",
             typeName="Stream",
             optional=false,
             uniqueIdentifier=false,
             pid=5634)
public byte[] getSource()
Description copied from interface: TimecodeStream

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

Specified by:
getSource in interface TimecodeStream
Returns:
Stream of timecode data stored in this timecode stream.
See Also:
TimecodeStream.getSampleRate()

setSource

public void setSource(byte[] value)
               throws NullPointerException
Description copied from interface: TimecodeStream

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

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

getSourceBufferLength

public int getSourceBufferLength()
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.
See Also:
TimecodeStream.getSource()

getSourceType

@AAFProperty(uuid1=67371521,
             uuid2=0,
             uuid3=0,
             uuid4={6,14,43,52,1,1,1,1},
             definedName="SourceType",
             typeName="TCSource",
             optional=false,
             uniqueIdentifier=false,
             pid=5635)
public TCSource getSourceType()
Description copied from interface: TimecodeStream

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

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

setSourceType

public void setSourceType(TCSource sourceType)
                   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:
setSourceType in interface TimecodeStream
Parameters:
sourceType - Kind of timecode of this timecode stream.
Throws:
NullPointerException

getUserDataAtPosition

public byte[] getUserDataAtPosition(long position)
                             throws PositionOutOfRangeException
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.
See Also:
TimecodeStream.getUserDataLength()

setUserDataAtPosition

public void setUserDataAtPosition(long position,
                                  byte[] buffer)
                           throws NullPointerException,
                                  PositionOutOfRangeException
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.

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
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.

setPositionTimecode

public void setPositionTimecode(long position,
                                TimecodeValue timecode)
                         throws NullPointerException,
                                PositionOutOfRangeException
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.

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 Segment
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 Segment
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(byte[] 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 byte[] packTimecode(TimecodeValue timecode,
                                    byte[] 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 byte[] unpackUserBits(byte[] 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 byte[] packUserBits(byte[] userBits,
                                    byte[] 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.

equals

public boolean equals(Object o)
Description copied from interface: MAJCommon

Tests to see if the given object is equal to this interchange object. To be equal, the given value must be not null, share the same interface to its value and each of the properties of the value must each be equal.

Specified by:
equals in interface MAJCommon
Overrides:
equals in class Component
Parameters:
o - Object to test for equality with.
Returns:
Is the given object equals to this value?
See Also:
Object.equals(Object)

hashCode

public int hashCode()
Description copied from interface: MAJCommon

Returns a hash code value for this interchange object.

Specified by:
hashCode in interface MAJCommon
Overrides:
hashCode in class Component
Returns:
Hash code value for this interchange object.
See Also:
Object.hashCode()

appendXMLChildren

public void appendXMLChildren(Node parent)
Description copied from interface: XMLSerializable

Append 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
Overrides:
appendXMLChildren in class Component
Parameters:
parent - XML parent element to append child nodes to.

Media Authoring
with Java API

(c) 2007-2008 Richard Cartwright, all rights reserved. Subject to the terms of the AAF SDK Public Source License.