Media Authoring
with Java API

tv.amwa.maj.entity
Class TimecodeStream12M

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
                  extended by tv.amwa.maj.entity.TimecodeStream12M
All Implemented Interfaces:
Serializable, Cloneable, MAJCommon, Component, InterchangeObject, Segment, TimecodeStream, TimecodeStream12M, XMLSerializable

@AAFClass(uuid1=218169601,
          uuid2=257,
          uuid3=5632,
          uuid4={6,14,43,52,2,6,1,1},
          definedName="TimecodeStream12M",
          description="The TimecodeStream12M class specifies a stream of timecode data in the SMPTE 12M format.")
public class TimecodeStream12M
extends TimecodeStream
implements TimecodeStream12M, Serializable, Cloneable, MAJCommon

Implements a representation of a stream of timecode data in the SMPTE 12M format.

THE COMMENTS FOR THIS CLASS ARE INCOMPLETE.

The byte stream is laid out as a sequence of bits numbered 0-79 with bit 0 being the first bit. The data is stored as a 10-byte array, and bit 0 is the MSB of the first byte.

The bit definitions are as follows:

bitsdescriptionextraction expression
0-3units of frames(foo[bits0_7] >> 4) & 0x0F
4-7first binary groupfoo[bits0_7] & 0x0F
8-9tens of frames(foo[bits8_15] >> 6) & 0x03
10drop frame(foo[bits8_15] >> 5) & 0x01
11color frame(foo[bits8_15] >> 4) & 0x01
12-15second binary groupfoo[bits8_15] & 0x0F
16-19units of seconds(foo[bits16_23] >> 4) & 0x0F
20-23third binary groupfoo[bits16_23] & 0x0F
24-26tens of seconds(foo[bits24_31] >> 5) & 0x07
27bi-phase mark phase correction bit(foo[bits24_31] >> 7) & 0x01
28-31fourth binary groupfoo[bits24_31] & 0x0F
32-35units of minutes(foo[bits32_39] >> 4) & 0x0F
36-39fifth binary groupfoo[bits32_39] & 0x0F
40-42tens of minutes(foo[bits40_47] >> 5) & 0x07
43binary group flag bit(foo[bits40_47] >> 4) & 0x01
44-47sixth binary groupfoo[bits40_47] & 0x0F
48-51units of hours(foo[bits48_55] >> 4) & 0x0F
52-55seventh binary groupfoo[bits48_55] & 0x0F
56-57tens of hours(foo[bits56_63] >> 6) & 0x03
58unassigned address bit(foo[bits56_63] >> 5) & 0x01
59binary group flag bit(foo[bits56_63] >> 4) & 0x01
60-63eighth binary groupfoo[bits56_63] & 0x0F
64-71synch word (fixed 0x3F)
72-79synch word (fixed 0xFD)

Timecode streams are useful to store user bits that were specified in the timecode on the videotape.

Author:
Richard Cartwright
See Also:
Serialized Form

Nested Class Summary
static class TimecodeStream12M.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
static String TIMECODESTREAM12M_TAG
           
 
Fields inherited from class tv.amwa.maj.entity.Component
COMPONENT_ITEM
 
Fields inherited from interface tv.amwa.maj.iface.TimecodeStream12M
INCLUDESYNC_DEFAULT
 
Constructor Summary
TimecodeStream12M(Rational sampleRate, byte[] source, TCSource sourceType)
          Creates and initializes a new SMPTE 12M-compliant timecode stream, which specifies a stream of timecode data in the SMPTE 12M format.
 
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.
 TimecodeStream12M clone()
          Creates a cloned copy of this entity.
 boolean equals(Object o)
          Tests to see if the given object is equal to this interchange object.
 boolean getIncludeSync()
          Returns true if the synchronization data is included in the timecode stream; otherwise false if the synchronization data has a fixed value and is omitted from the timecode stream.
 int getSampleSize()
          Returns the size of one sample of the timecode data of this timecode stream, measured in bytes.
 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.
 byte[] packTimecode(TimecodeValue timecode, byte[] packedBuffer)
          Pack a given timecode value into a give byte array.
 byte[] packUserBits(byte[] userBits, byte[] packedBuffer)
          Pack user data from the given byte array into the given packed buffer.
 void setIncludeSync(Boolean includeSync)
          Sets true if synchronization data is included in this timecode stream and false if the synchronization data has a fixed value and is omitted from the timecode stream.
 void setPropertiesFromInterface(TimecodeStream12M castFrom)
           
 TimecodeValue unpackTimecode(byte[] buffer, short fps)
          Unpack a timecode value from the given buffer for the given number of frames per second.
 byte[] unpackUserBits(byte[] buffer)
          Unpack user data from the given sample of the timecode stream.
 
Methods inherited from class tv.amwa.maj.entity.TimecodeStream
getPositionTimecode, getSampleRate, getSource, getSourceBufferLength, getSourceType, getUserDataAtPosition, segmentOffsetToTC, segmentTCToOffset, setPositionTimecode, setPropertiesFromInterface, setSampleRate, setSource, setSourceType, setUserDataAtPosition
 
Methods inherited from class tv.amwa.maj.entity.Segment
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, wait, wait, wait
 
Methods inherited from interface tv.amwa.maj.iface.TimecodeStream
getPositionTimecode, getSampleRate, getSource, getSourceBufferLength, getSourceType, getUserDataAtPosition, setPositionTimecode, setSampleRate, setSource, setSourceType, setUserDataAtPosition
 
Methods inherited from interface tv.amwa.maj.iface.Segment
segmentOffsetToTC, segmentTCToOffset
 
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
toString
 

Field Detail

TIMECODESTREAM12M_TAG

public static final String TIMECODESTREAM12M_TAG
See Also:
Constant Field Values
Constructor Detail

TimecodeStream12M

public TimecodeStream12M(Rational sampleRate,
                         @DataBuffer
                         byte[] source,
                         TCSource sourceType)
                  throws NullPointerException,
                         IllegalArgumentException

Creates and initializes a new SMPTE 12M-compliant timecode stream, which specifies a stream of timecode data in the SMPTE 12M format.

Parameters:
sampleRate - Sample rate of the timecode data contained in the source property.
source - The timecode data.
sourceType - Kind of timecode data.
Throws:
NullPointerException - One or more of the arguments is null and all are required.
IllegalArgumentException
Method Detail

setPropertiesFromInterface

public final void setPropertiesFromInterface(TimecodeStream12M castFrom)
See Also:
InterchangeObject.setPropertiesFromInterface(tv.amwa.maj.iface.InterchangeObject)

getIncludeSync

@AAFProperty(uuid1=67371265,
             uuid2=1024,
             uuid3=0,
             uuid4={6,14,43,52,1,1,1,1},
             definedName="IncludeSync",
             typeName="Boolean",
             optional=true,
             uniqueIdentifier=false,
             pid=5889)
public boolean getIncludeSync()
Description copied from interface: TimecodeStream12M

Returns true if the synchronization data is included in the timecode stream; otherwise false if the synchronization data has a fixed value and is omitted from the timecode stream.

If this optional property is omitted, the default value of false is returned.

Specified by:
getIncludeSync in interface TimecodeStream12M
Returns:
Is synchronization data included in the timecode stream?
See Also:
TimecodeStream12M.INCLUDESYNC_DEFAULT

setIncludeSync

public void setIncludeSync(Boolean includeSync)
Description copied from interface: TimecodeStream12M

Sets true if synchronization data is included in this timecode stream and false if the synchronization data has a fixed value and is omitted from the timecode stream.

The default value for this optional property is false. Set this optional property to null to omit it.

Specified by:
setIncludeSync in interface TimecodeStream12M
Parameters:
includeSync - Is synchronization data included in the timecode stream?
See Also:
TimecodeStream12M.INCLUDESYNC_DEFAULT

getSampleSize

public 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
Specified by:
getSampleSize in class TimecodeStream
Returns:
Size of one sample of the timecode data of this timecode stream.

getUserDataLength

public 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
Specified by:
getUserDataLength in class TimecodeStream
Returns:
Length of user data for one frame of this timecode stream.
See Also:
TimecodeStream.getUserDataAtPosition(long)

packTimecode

public byte[] packTimecode(TimecodeValue timecode,
                           byte[] packedBuffer)
                    throws NullPointerException,
                           IllegalArgumentException
Description copied from class: TimecodeStream

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

Specified by:
packTimecode in class TimecodeStream
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.

packUserBits

public byte[] packUserBits(byte[] userBits,
                           byte[] packedBuffer)
                    throws NullPointerException,
                           IllegalArgumentException
Description copied from class: TimecodeStream

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

Specified by:
packUserBits in class TimecodeStream
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.

unpackTimecode

public TimecodeValue unpackTimecode(byte[] buffer,
                                    short fps)
                             throws NullPointerException,
                                    IllegalArgumentException
Description copied from class: TimecodeStream

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

Specified by:
unpackTimecode in class TimecodeStream
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.

unpackUserBits

public byte[] unpackUserBits(byte[] buffer)
                      throws NullPointerException,
                             IllegalArgumentException
Description copied from class: TimecodeStream

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

Specified by:
unpackUserBits in class TimecodeStream
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.

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 TimecodeStream
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 TimecodeStream
Returns:
Hash code value for this interchange object.
See Also:
Object.hashCode()

clone

public TimecodeStream12M clone()
Description copied from interface: MAJCommon

Creates a cloned copy of this entity. The clone will be initialized to have the same value as this value but exists independently from then on. Changes to this value will not effect the clone and changes to the clone will not effect this. MAJ API clones are true deep clones with no shared references to areas of memory within the original.

This method does not throw a CloneNotSupportedException as all entity values must implement the Cloneable interface. If a cloning error does occur, a null value will be returned but this is very unlikely to happen.

Specified by:
clone in interface MAJCommon
Overrides:
clone in class Segment
Returns:
Independent clone of this value, which is a deep copy.
See Also:
Object.clone()

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