|
Media Authoring with Java API |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecttv.amwa.maj.embeddable.TimecodeValue
public final class TimecodeValue
Implementation of a value that represents video tape or audio tape timecode information. The timecode interface is capable of representing timecode values specified by SMPTE 12M.
Representation of timecode values based on a frame offset from the start of an item of content. This class also models the number of frames per second associated with a timecode value and whether the timecode requires the calculation of drop frames.
All methods that operate on the timecode value, such as
compareTo(tv.amwa.maj.record.TimecodeValue)
, toString()
and
convertToRealTime()
respect the number of frames-per-second and drop frame
values. See the method descriptions for more details.
This implementation can support high frame rate television. In this case, timecode values
will format in a way that is not compatible with SMPTE 12M. For example, a timecode value of
00:00:21:135
represents the 135th frame of the frame 21 seconds into a 300
fps item, frame 6435.
TimecodeSegment.getTimecode()
,
TimecodeSegment
,
Serialized FormNested Class Summary | |
---|---|
class |
TimecodeValue.TimeComponents
Component parts of a timecode value, represented as hours, minutes, seconds and frames in a second. |
Field Summary | |
---|---|
static String |
DROP_TAG
|
static String |
FPS_TAG
|
static String |
TIMECODESTART_TAG
|
static String |
TIMECODEVALUE_TAG
|
Constructor Summary | |
---|---|
TimecodeValue()
Create a default timecode value. |
|
TimecodeValue(boolean drop,
long startFrame,
short fps)
Create a timecode value. |
|
TimecodeValue(short fps,
short hours,
short minutes,
short seconds,
short frames,
boolean drop)
Create a new timecode value from the given hours, minutes, seconds and frames according to the given number of frames per second and whether the timecode value requires drop frame calculations. |
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. |
void |
appendXMLGrandchildren(Node timecodeElement)
Append just the child elements specifying the value of this timecode to the given node. |
static TimecodeValue |
calculateDuration(TimecodeValue startValue,
TimecodeValue endValue)
Calculate the duration of a piece of media from its start timecode and end timecode. |
static TimecodeValue |
calculateEndTimecode(TimecodeValue startValue,
TimecodeValue duration)
Calculate the end timecode for a segment of media from its start timecode and a timecode value representing its duration. |
static TimecodeValue |
castFromInterface(TimecodeValue alien)
Cast a value the implements the TimecodeValue interface
to concrete value of this implementation. |
TimecodeValue |
clone()
Creates a cloned deep copy of this embeddable value. |
int |
compareTo(TimecodeValue o)
Chronologically compare this timecode value to another one based on real time, which is calculated to take account of frames per second and drop frame values. |
TimecodeValue.TimeComponents |
convertToActualTimeValues()
Converts this timecode into a TimecodeValue.TimeComponents value. |
TimeStruct |
convertToRealTime()
Converts the timecode value to a real time, taking account of the frames per second and drop frame values. |
boolean |
equals(Object o)
Check to see if another timecode value is equal to this one. |
boolean |
getDrop()
Determines whether the timecode is drop ( true value) or
nondrop (false value). |
short |
getFps()
Returns the frames per second of the videotape or audio tape of the timecode. |
long |
getStartOffset()
Returns the timecode value by the number of frames offset from the start of the video or audio. |
int |
hashCode()
Returns a hash code value for this embeddable object. |
static TimecodeValue |
parseTimecode(String timecodeText)
Parses a SMPTE-style string representation of a timecode and creates a MAJ API timecode value, implying default values for the frames per second and drop frame parameters from the timecode text. |
static TimecodeValue |
parseTimecode(String timecodeText,
short fps)
Parses a SMPTE-style string representation of a timecode and creates a MAJ API timecode value, working out the drop frame value from the given timcode text. |
static TimecodeValue |
parseTimecode(String timecodeText,
short fps,
boolean drop)
Parses a SMPTE-style string representation of a timecode and creates a MAJ API timecode value, with all parameters specified. |
void |
setDrop(boolean drop)
Sets whether the timecode is drop ( true value) or
nondrop (false value). |
void |
setFps(short fps)
Sets the frames per second of the videotape or audio tape of the timecode. |
void |
setPropertiesFromInterface(TimecodeValue castFrom)
Set the properties of this value from another value that implements that implements the TimecodeValue interface. |
void |
setStartOffset(long startFrame)
Sets the timecode value by the number of frames offset from the start of the video or audio. |
String |
toString()
Converts this string to a timecode value representation in accordance with the following timecode specifications: |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String TIMECODEVALUE_TAG
public static final String TIMECODESTART_TAG
public static final String FPS_TAG
public static final String DROP_TAG
Constructor Detail |
---|
public TimecodeValue(boolean drop, @FrameOffset long startFrame, @UInt16 short fps) throws IllegalArgumentException
Create a timecode value.
drop
- Indicates whether the timecode is drop (True value) or nondrop (False value).startFrame
- Specifies the timecode as the number of frames offset from
the start of the video or audio.fps
- Frames per second of the videotape or audio tape.
IllegalArgumentException
- The frames per second value is not a positive value.public TimecodeValue()
Create a default timecode value. Default values are non-drop, start frame set to 0 and frame rate of 0 frames per second.
public TimecodeValue(@UInt16 short fps, short hours, short minutes, short seconds, short frames, boolean drop) throws IllegalArgumentException
Create a new timecode value from the given hours, minutes, seconds and frames according to the given number of frames per second and whether the timecode value requires drop frame calculations. Internally, these values are converted to an offset value.
This method does not apply strict boundaries. Negative values and values greater than the acceptable bounds when displaying a timecode will be accepted and mapped to an appropriate offset. For example, the following three calls to this method create equivalent timecode values:
time1 = new TimecodeValue(25, 0, 0, 63, 0, false); time2 = new TimecodeValue(25, 0, 1, 03, 0, false); time3 = new TimecodeValue(25, 0, 1, 04, -25, false);
fps
- Number of frames per second for this timecode value.hours
- Number of hours since the start of an item represented by this timecode.minutes
- Number of minutes in the hour of an item represented by this timecode.seconds
- Number of seconds in the minute of an item represented by this timecode.frames
- Number of frames through the second of an item represented by this timecode.drop
- Does this timecode require drop frame calculation?
IllegalArgumentException
- The number of frames per second is not a positive (greater than zero)
number.Method Detail |
---|
public static TimecodeValue castFromInterface(TimecodeValue alien) throws NullPointerException
Cast a value the implements the TimecodeValue
interface
to concrete value of this implementation.
alien
- Value to cast to a concrete instance.
NullPointerException
- Argument is null
.public final void setPropertiesFromInterface(TimecodeValue castFrom)
Set the properties of this value from another value that implements that
implements the TimecodeValue
interface.
castFrom
- Value to use to set this timecode value.public boolean getDrop()
TimecodeValue
Determines whether the timecode is drop (true
value) or
nondrop (false
value).
If drop is set to true
, the real frames-per-second rate represented
by the timecode is 29.97. Calculations of the real time represented by a timecode
or to create a textual representation of the time code drop 108 selected frames
per hour.
getDrop
in interface TimecodeValue
public void setDrop(boolean drop)
TimecodeValue
Sets whether the timecode is drop (true
value) or
nondrop (false
value).
setDrop
in interface TimecodeValue
drop
- Is the timecode a drop value?public short getFps()
TimecodeValue
Returns the frames per second of the videotape or audio tape of the timecode.
getFps
in interface TimecodeValue
public void setFps(short fps)
TimecodeValue
Sets the frames per second of the videotape or audio tape of the timecode.
setFps
in interface TimecodeValue
fps
- Frames per second of the videotape or audiotape of the timecode.public long getStartOffset()
TimecodeValue
Returns the timecode value by the number of frames offset from the start of the video or audio.
getStartOffset
in interface TimecodeValue
public void setStartOffset(long startFrame)
TimecodeValue
Sets the timecode value by the number of frames offset from the start of the video or audio.
setStartOffset
in interface TimecodeValue
startFrame
- Frame offset value to use to set the timecode.public int hashCode()
MAJCommon
Returns a hash code value for this embeddable object.
hashCode
in interface MAJCommon
hashCode
in class Object
Object.hashCode()
public final boolean equals(Object o)
Check to see if another timecode value is equal to this one. Two timecode values are equal if they have the same start frame, number of frames per second and consistent drop frame or non-drop frame values.
To check to see if two timecode values are equal in time, use
compareTo(tv.amwa.maj.record.TimecodeValue)
.
equals
in interface MAJCommon
equals
in class Object
o
- Object to test for equality with this one.
Object.equals(Object)
public final int compareTo(TimecodeValue o) throws NullPointerException
Chronologically compare this timecode value to another one based on real time, which is calculated to take account of frames per second and drop frame values.
compareTo
in interface Comparable<TimecodeValue>
o
- Timecode value to compare this value to.
NullPointerException
- The given timecode value to compare to this one is null
.public String toString()
Converts this string to a timecode value representation in accordance with the following timecode specifications:
The format of the returned value is "hh:mm:ss;ff
" for timecodes with drop
frames and "hh:mm:ss:ff
" for timecodes with no drop frame. The componest of the
value of the timecode are:
hh
is the number of hoursmm
is the number of minutes;ss
is the number of seconds;ff
is the number of frames through this second.For high frame rate television, the number of frames throgh a second may extend to "fff
"
when the value is greater than 99.
toString
in interface MAJCommon
toString
in class Object
Object.toString()
public TimeStruct convertToRealTime() throws NumberFormatException
Converts the timecode value to a real time, taking account of the frames
per second and drop frame values. The value returned is a
TimeStruct
value, containing the
hours, minutes, seconds and fractions of a second represented by the
frame offset value returned by getStartOffset()
.
NumberFormatException
- The timecode value is larger than the range it is
possible to represent with a time structure value.public static final TimecodeValue parseTimecode(String timecodeText, @UInt16 short fps, boolean drop) throws NumberFormatException, IllegalArgumentException
Parses a SMPTE-style string representation of a timecode and creates a MAJ API timecode value, with all parameters specified. The method will try and parse both drop and non-drop values, working with both SMPTE-12M values and a broader definition of timecodes as required for high frame rate television.
The format of a timecode parsed by this method is:
:
<minute>:
<second>:
<frame>The hour, minute, second and frame values should all be Java short
values. The number of digits is not significant, although values are limited to being Int16
.
For example, the values "01:02:03:04"
is parsed the same as "1:2:003:4".
timecodeText
- String representation of a timecode value.fps
- Number of frames per second this timecode is measured against.drop
- Whether this timecode has drop values or not?
NumberFormatException
- It is not possible to parse the given value to a MAJ API timecode value.
IllegalArgumentException
- The given frames per second value is not a negative value.public static final TimecodeValue parseTimecode(String timecodeText, @UInt16 short fps) throws IllegalArgumentException, NumberFormatException
Parses a SMPTE-style string representation of a timecode and creates a MAJ API timecode value,
working out the drop frame value from the given timcode text.
The method will try and parse both drop and non-drop values, working with both SMPTE-12M values
and a broader definition of timecodes as required for high frame rate television. This method
assumes any value with a ";
" in it is a drop-frame value; otherwise the value is
assumed to be a non-drop timecode.
String timecode representations are parsed as follows:
:
<minute>:
<second>:
<frame>:
<minute>:
<second>;
<frame>The hour, minute, second and frame values should all be Java short
values. The number of digits is not significant, although values are limited to being Int16
.
For example, the values "01:02:03:04"
is parsed the same as "1:2:003:4".
timecodeText
- String representation of a timecode value.fps
- Number of frames per second this timecode is measured against.
NumberFormatException
- It is not possible to parse the given value to a MAJ API timecode value.
IllegalArgumentException
- The given frames per second value is not a negative value.public static final TimecodeValue parseTimecode(String timecodeText) throws IllegalArgumentException, NumberFormatException
Parses a SMPTE-style string representation of a timecode and creates a MAJ API timecode value,
implying default values for the frames per second and drop frame parameters from the timecode text.
The method will try and parse both drop and non-drop values, working with both SMPTE-12M values
and a broader definition of timecodes as required for high frame rate television. This method
assumes any value with a ";
" in it is a drop-frame value at 30 fps; otherwise the value is
assumed to be a non-drop timecode at 25 fps.
String timecode representations are parsed as follows:
:
<minute>:
<second>:
<frame>:
<minute>:
<second>;
<frame>The hour, minute, second and frame values should all be Java short
values. The number of digits is not significant, although values are limited to being Int16
.
For example, the values "01:02:03:04"
is parsed the same as "1:2:003:4".
timecodeText
- String representation of a timecode value.
NumberFormatException
- It is not possible to parse the given value to a MAJ API timecode value.
IllegalArgumentException
- The given frames per second value is not a negative value.public TimecodeValue.TimeComponents convertToActualTimeValues()
Converts this timecode into a TimecodeValue.TimeComponents
value. This method will
carry out drop frame calculations if required.
public final TimecodeValue clone()
MAJCommon
Creates a cloned deep copy of this embeddable value. 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
embeddable values must implement the Cloneable
interface.
clone
in interface MAJCommon
clone
in class Object
Object.clone()
public void appendXMLChildren(Node parent)
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.
appendXMLChildren
in interface XMLSerializable
parent
- XML parent element to append child nodes to.public void appendXMLGrandchildren(Node timecodeElement)
Append just the child elements specifying the value of this timecode to the given node.
timecodeElement
- Element to append timecode specifiers to.public static final TimecodeValue calculateDuration(TimecodeValue startValue, TimecodeValue endValue) throws IllegalArgumentException
Calculate the duration of a piece of media from its start timecode and end timecode. The value returned is a timecode representing the duration. Both values must be specified with the same number of frames per second and matching drop timecode specifications. The end value must be the same or greater than the start value.
To calculate the number of frames of an item of media, call getStartOffset()
on the value
returned by this method.
startValue
- Start timecode at the beginning of the segment of media, sometimes known as
SOM (Start Of Message).endValue
- End timecode at the end of the segment of media, sometimes known as EOM (End Of
Message).
IllegalArgumentException
- It was not possible to calculate the duration as the timecode values
are incompatible or the start value is after the end value.LengthType
,
calculateEndTimecode(tv.amwa.maj.record.TimecodeValue, tv.amwa.maj.record.TimecodeValue)
public static final TimecodeValue calculateEndTimecode(TimecodeValue startValue, TimecodeValue duration) throws IllegalArgumentException
Calculate the end timecode for a segment of media from its start timecode and a timecode value representing its duration. Both values must be specified with the same number of frames per second and matching drop timecode specifications.
startValue
- Start timecode at the beginning of a segment of media.duration
- Duration of the media specified as a timecode value.
IllegalArgumentException
- It was not possible to calculate the end timecode as the timecode values
are incompatible.calculateDuration(tv.amwa.maj.record.TimecodeValue, tv.amwa.maj.record.TimecodeValue)
|
Media Authoring with Java API |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |