CMTime Reference
Overview
This document describes the API for creating and manipulating CMTime
structs.
CMTime
structs are nonopaque mutable structs representing times (either timestamps or durations).
A CMTime
is represented as a rational number, with a numerator (an int64_t
value), and a denominator (an int32_t
timescale). Conceptually, the timescale specifies the fraction of a second each unit in the numerator occupies. Thus if the timescale is 4, each unit represents a quarter of a second; if the timescale is 10, each unit represents a tenth of a second, and so on. In addition to a simple time value, a CMTime can represent nonnumeric values: +infinity, infinity, and indefinite. Using a flag CMTime indicates whether the time been rounded at some point.
CMTimes
contain an epoch number, which is usually set to 0, but can be used to distinguish unrelated timelines: for example, it could be incremented each time through a presentation loop, to differentiate between time N in loop 0 from time N in loop 1.
You can convert CMTimes
to and from immutable CFDictionaries (see CFDictionaryRef
) using CMTimeCopyAsDictionary
and CMTimeMakeFromDictionary
, for use in annotations and various Core Foundation containers.
Additional functions for managing dates and times are described in Time Utilities Reference. Note that CMTime
is designed for media timelines whereas functions in Time Utilities Reference
are designed for working with wallclock time in Core Foundation framework; see also AV Foundation Constants Reference.
Functions by Task
Creating CMTime
Working with CMTime

CMTimeAbsoluteValue

CMTimeAdd

CMTimeCompare

CMTimeConvertScale

CMTimeCopyAsDictionary

CMTimeCopyDescription

CMTimeGetSeconds

CMTimeMaximum

CMTimeMinimum

CMTimeMultiply

CMTimeMultiplyByFloat64

CMTimeShow

CMTimeSubtract
Comparing CMTime
Functions
CMTimeAbsoluteValue
Returns the absolute value of a CMTime
.
CMTime CMTimeAbsoluteValue ( CMTime time );
Parameters
 time
A
CMTime
.
Return Value
Same as the argument time, with sign inverted if negative.
Availability
 Available in iOS 4.0 and later.
Declared In
CMTime.h
CMTimeAdd
Returns the sum of two CMTimes
.
CMTime CMTimeAdd ( CMTime addend1, CMTime addend2 );
Parameters
 addend1
CMTime
to be added. addend2
Another
CMTime
to be added.
Return Value
The sum of the two CMTimes (addend1 + addend2).
Discussion
If the operands both have the same timescale, the timescale of the result will be the same as the operands' timescale. If the operands have different timescales, the timescale of the result will be the least common multiple of the operands' timescales. If that LCM timescale is greater than kCMTimeMaxTimescale
, the result timescale will be kCMTimeMaxTimescale
, and default rounding will be applied when converting the result to this timescale. If the result value overflows, the result timescale will be repeatedly halved until the result value no longer overflows. Again, default rounding will be applied when converting the result to this timescale. If the result value still overflows when timescale == 1, then the result will be either positive or negative infinity, depending on the direction of the overflow.
If any rounding occurs for any reason, the result's kCMTimeFlags_HasBeenRounded
flag will be set. This flag will also be set if either of the operands has kCMTimeFlags_HasBeenRounded
set. If either of the operands is invalid, the result will be invalid. If the operands are valid, but just one operand is infinite, the result will be similarly infinite. If the operands are valid, and both are infinite, the results will be as follows:
+infinity + +infinity == +infinity
infinity + infinity == infinity
+infinity + infinity == invalid
infinity + +infinity == invalid
If the operands are valid, not infinite, and either or both is indefinite, the result will be indefinite. If the two operands are numeric (i.e.. valid, not infinite, not indefinite), but have different nonzero epochs, the result will be invalid. If they have the same nonzero epoch, the result will have epoch zero (a duration). Times in different epochs cannot be added or subtracted, because epoch length is unknown. Times in epoch zero are considered to be durations and can be added to times in other epochs. Times in different epochs can be compared, however, because numerically greater epochs always occur after numerically lesser epochs.
Availability
 Available in iOS 4.0 and later.
Declared In
CMTime.h
CMTimeCompare
Returns the numerical relationship of two CMTimes
.
int32_t CMTimeCompare ( CMTime time1, CMTime time2 );
Parameters
 time1
First
CMTime
in comparison. time2
Second
CMTime
in comparison.
Return Value
The numerical relationship of the two CMTimes.
1 is returned if
time1
is less thantime2
.1 is returned if
time1
is greater thantime2
.0 is returned if
time1
andtime2
are equal.
Discussion
When comparing CMTimes
, it is recommended to use CMTIME_COMPARE_INLINE
macro since it makes comparison expressions much more readable by putting the comparison operation between the operands.
If the two CMTimes
are numeric (i.e.. not invalid, infinite, or indefinite), and have different epochs, it is considered that times in numerically larger epochs are always greater than times in numerically smaller epochs. Since this routine will be used to sort lists by time, it needs to give all values (even invalid and indefinite ones) a strict ordering to guarantee that sort algorithms terminate safely. The order chosen is somewhat arbitrary: infinity < all finite values < indefinite < +infinity < invalid
Invalid CMTimes
are considered to be equal to other invalid CMTimes
, and greater than any other CMTime
. Positive infinity is considered to be less than any invalid CMTime
, equal to itself, and greater than any other CMTime
. An indefinite CMTime
is considered to be less than any invalid CMTime
, less than positive infinity, equal to itself, and greater than any other CMTime
. Negative infinity is considered to be equal to itself, and less than any other CMTime
.
Availability
 Available in iOS 4.0 and later.
Declared In
CMTime.h
CMTimeConvertScale
Returns a new CMTime
containing the source CMTime
converted to a new timescale (rounding as requested).
CMTime CMTimeConvertScale ( CMTime time, int32_t newTimescale, CMTimeRoundingMethod method );
Parameters
 time
Source CMTime.
 newTimescale
The timescale to which the source
CMTime
is converted. method
The requested rounding method.
Return Value
The converted CMTime
.
Discussion
If the value needs to be rounded, the kCMTimeFlags_HasBeenRounded
flag will be set. See definition of CMTimeRoundingMethod
for a discussion of the various rounding methods available. If the source time is nonnumeric (i.e.. infinite, indefinite, invalid), the result will be similarly nonnumeric.
Availability
 Available in iOS 4.0 and later.
Declared In
CMTime.h
CMTimeCopyAsDictionary
Returns a CFDictionary
version of a CMTime
.
CFDictionaryRef CMTimeCopyAsDictionary ( CMTime time, CFAllocatorRef allocator );
Parameters
 time
CMTime
from which to create dictionary. allocator
CFAllocator
with which to create dictionary. PasskCFAllocatorDefault
to use the default allocator.
Return Value
A CFDictionary
version of the CMTime
.
Discussion
This is useful when putting CMTimes
in Core Foundation container types. For keys in the resulting dictionary, see “Dictionary Keys.”
Availability
 Available in iOS 4.0 and later.
Declared In
CMTime.h
CMTimeCopyDescription
Creates a CFString
with a description of a CMTime
( Similar to CFCopyDescription
).
CFStringRef CMTimeCopyDescription ( CFAllocatorRef allocator, CMTime time );
Parameters
 allocator
CFAllocator
with which to create the description. PasskCFAllocatorDefault
to use the default allocator. time
CMTime
to be described.
Return Value
The created CFString
description.
Discussion
This is used from within CFShow
on an object that contains CMTime
fields. It is also useful from other client debugging code. The caller owns the returned CFString
, and is responsible for releasing it.
Availability
 Available in iOS 4.0 and later.
Declared In
CMTime.h
CMTimeGetSeconds
Converts a CMTime
to seconds.
Float64 CMTimeGetSeconds ( CMTime time );
Parameters
 time
CMTime
to be converted.
Return Value
The resulting Float64 number of seconds.
Discussion
If the CMTime
is invalid or indefinite, NaN is returned. If the CMTime
is infinite, +/ infinity is returned. If the CMTime
is numeric, epoch is ignored, and ^{time.value} / _{time.timescale} is returned. The division is done in Float64, so the fraction is not lost in the returned result.
Availability
 Available in iOS 4.0 and later.
Declared In
CMTime.h
CMTimeMake
Makes a valid CMTime
with value and timescale. Epoch is implied to be 0.
CMTime CMTimeMake ( int64_t value, int32_t timescale );
Parameters
 value
Initializes the value field of the resulting
CMTime
. timescale
Initializes the timescale field of the resulting
CMTime
.
Return Value
The resulting CMTime
Availability
 Available in iOS 4.0 and later.
Declared In
CMTime.h
CMTimeMakeFromDictionary
Reconstitutes a CMTime
struct from a CFDictionary
previously created by CMTimeCopyAsDictionary
.
CMTime CMTimeMakeFromDictionary ( CFDictionaryRef dict );
Parameters
 dict
CFDictionary
from which to createCMTime
.
Return Value
The created CMTime
.
Discussion
For keys in the dictionary, see “Dictionary Keys.”
Availability
 Available in iOS 4.0 and later.
Declared In
CMTime.h
CMTimeMakeWithEpoch
Makes a valid CMTime
with value, scale and epoch.
CMTime CMTimeMakeWithEpoch ( int64_t value, int32_t timescale, int64_t epoch );
Parameters
 value
Initializes the value field of the resulting
CMTime
. timescale
Initializes the scale field of the resulting
CMTime
. epoch
Initializes the epoch field of the resulting
CMTime
.
Return Value
The resulting CMTime
.
Availability
 Available in iOS 4.0 and later.
Declared In
CMTime.h
CMTimeMakeWithSeconds
Makes a CMTime
from a Float64 number of seconds, and a preferred timescale.
CMTime CMTimeMakeWithSeconds ( Float64 seconds, int32_t preferredTimeScale );
Parameters
 seconds
Initializes the seconds field of the resulting
CMTime
. preferredTimeScale
Initializes the
preferredTimeScale
field of the resultingCMTime
.
Return Value
The resulting CMTime
.
Discussion
The epoch of the result will be zero. If preferredTimeScale is <= 0, the result will be an invalid CMTime
. If the preferred timescale will cause an overflow, the timescale will be halved repeatedly until the overflow goes away, or the timescale is 1. If it still overflows at that point, the result will be +/ infinity. The kCMTimeFlags_HasBeenRounded
flag will be set if the result, when converted back to seconds, is not exactly equal to the original seconds value.
Availability
 Available in iOS 4.0 and later.
Declared In
CMTime.h
CMTimeMaximum
Returns the greater of two CMTimes
(as defined by CMTimeCompare
).
CMTime CMTimeMaximum ( CMTime time1, CMTime time2 );
Parameters
 time1
A
CMTime
. time2
Another
CMTime
.
Return Value
The greater of the two CMTimes
.
Availability
 Available in iOS 4.0 and later.
Declared In
CMTime.h
CMTimeMinimum
Returns the lesser of two CMTimes (as defined by CMTimeCompare
).
CMTime CMTimeMinimum ( CMTime time1, CMTime time2 );
Parameters
 time1
A
CMTime
. time2
Another
CMTime
.
Return Value
The lesser of the two CMTimes
.
Availability
 Available in iOS 4.0 and later.
Declared In
CMTime.h
CMTimeMultiply
Returns the product of a CMTime and a 32bit integer.
CMTime CMTimeMultiply ( CMTime time, int32_t multiplier );
Parameters
 time
The
CMTime
that will be multiplied. multiplier
A 32bit integer.
CMTime time
andmultiplier
will be multiplied.
Return Value
The product of the CMTime
and the 32bit integer.
Discussion
The result will have the same timescale as the CMTime
operand. If the result value overflows, the result timescale will be repeatedly halved until the result value no longer overflows. Again, default rounding will be applied when converting the result to this timescale. If the result value still overflows when timescale == 1, then the result will be either positive or negative infinity, depending on the direction of the overflow.
If any rounding occurs for any reason, the result's kCMTimeFlags_HasBeenRounded
flag will be set. This flag will also be set if the CMTime
operand has kCMTimeFlags_HasBeenRounded
set. If the CMTime
operand is invalid, the result will be invalid. If the CMTime
operand is valid, but infinite, the result will be infinite, and of an appropriate sign, give the signs of both operands. If the CMTime
operand is valid, but indefinite, the result will be indefinite.
Availability
 Available in iOS 4.0 and later.
Declared In
CMTime.h
CMTimeMultiplyByFloat64
Returns the product of a CMTime
and a 64bit float.
CMTime CMTimeMultiplyByFloat64 ( CMTime time, Float64 multiplier );
Parameters
 time
The
CMTime
that will be multiplied. multiplier
A 64bit float.
CMTime time
andmultiplier
will be multiplied.
Return Value
The product of the CMTime
and the 64bit float.
Discussion
The result will initially have the same timescale as the CMTime operand. If the result timescale is less than 65536, it will be repeatedly doubled until it is at least 65536. If the result value overflows, the result timescale will be repeatedly halved until the result value no longer overflows. Again, default rounding will be applied when converting the result to this timescale. If the result value still overflows when timescale == 1, then the result will be either positive or negative infinity, depending on the direction of the overflow. If any rounding occurs for any reason, the result's kCMTimeFlags_HasBeenRounded
flag will be set. This flag will also be set if the CMTime
operand has kCMTimeFlags_HasBeenRounded
set. If the CMTime
operand is invalid, the result will be invalid. If the CMTime
operand is valid, but infinite, the result will be infinite, and of an appropriate sign, given the signs of both operands. If the CMTime
operand is valid, but indefinite, the result will be indefinite.
Availability
 Available in iOS 4.0 and later.
Declared In
CMTime.h
CMTimeShow
Prints a description of the CMTime
(Similar to CFShow
).
void CMTimeShow ( CMTime time );
Parameters
 time
CMTime
to show.
Discussion
This is most useful from within gdb.
Availability
 Available in iOS 4.0 and later.
Declared In
CMTime.h
CMTimeSubtract
Returns the difference of two CMTimes
.
CMTime CMTimeSubtract ( CMTime minuend, CMTime subtrahend );
Parameters
 minuend
The
CMTime
from which the subtrahend will be subtracted. subtrahend
The
CMTime
that will be subtracted from the minuend.
Return Value
The difference of the two CMTimes (minuend  subtrahend).
Discussion
If the operands both have the same timescale, the timescale of the result will be the same as the operands' timescale. If the operands have different timescales, the timescale of the result will be the least common multiple of the operands' timescales. If that LCM timescale is greater than kCMTimeMaxTimescale
, the result timescale will be kCMTimeMaxTimescale
, and default rounding will be applied when converting the result to this timescale.
If the result value overflows, the result timescale will be repeatedly halved until the result value no longer overflows. Again, default rounding will be applied when converting the result to this timescale. If the result value still overflows when timescale == 1, then the result will be either positive or negative infinity, depending on the direction of the overflow.
If any rounding occurs for any reason, the result's kCMTimeFlags_HasBeenRounded
flag will be set. This flag will also be set if either of the operands has kCMTimeFlags_HasBeenRounded
set. If either of the operands is invalid, the result will be invalid. If the operands are valid, but just one operand is infinite, the result will be similarly infinite. If the operands are valid, and both are infinite, the results will be as follows:
+infinity  +infinity == invalid
infinity  infinity == invalid
+infinity  infinity == +infinity
infinity  +infinity == infinity
If the operands are valid, not infinite, and either or both is indefinite, the result will be indefinite. If the two operands are numeric (i.e.. valid, not infinite, not indefinite), but have different nonzero epochs, the result will be invalid. If they have the same nonzero epoch, the result will have epoch zero (a duration). Times in different epochs cannot be added or subtracted, because epoch length is unknown. Times in epoch zero are considered to be durations and can be subtracted from times in other epochs. Times in different epochs can be compared, however, because numerically greater epochs always occur after numerically lesser epochs.
Availability
 Available in iOS 4.0 and later.
Declared In
CMTime.h
CMTIME_COMPARE_INLINE
Returns a Boolean value that indicates whether the specified comparison of two CMTimes is true.
#define CMTIME_COMPARE_INLINE(time1, comparator, time2) ((Boolean)(CMTimeCompare(time1, time2) comparator 0))
Discussion
For example:
CMTIME_COMPARE_INLINE(time1, <=, time2) 
will return true if time1 <= time2.
Availability
 Available in iOS 4.0 and later.
Declared In
CMTime.h
CMTIME_HAS_BEEN_ROUNDED
Returns a Boolean value that indicates whether a given time has been rounded.
#define CMTIME_HAS_BEEN_ROUNDED(time) ((Boolean)(CMTIME_IS_NUMERIC(time) && (((time).flags & kCMTimeFlags_HasBeenRounded) != 0)))
Return Value
true
if the CMTime
has been rounded, otherwise false
(the time is completely accurate).
Availability
 Available in iOS 4.0 and later.
Declared In
CMTime.h
CMTIME_IS_INDEFINITE
Returns a Boolean value that indicates whether a given time is indefinite.
#define CMTIME_IS_INDEFINITE(time) ((Boolean)(CMTIME_IS_VALID(time) && (((time).flags & kCMTimeFlags_Indefinite) != 0)))
Return Value
true
if the CMTime
is indefinite, otherwise false
.
Availability
 Available in iOS 4.0 and later.
Declared In
CMTime.h
CMTIME_IS_INVALID
Returns a Boolean value that indicates whether a given time is invalid.
#define CMTIME_IS_INVALID(time) (! CMTIME_IS_VALID(time))
Return Value
true
if the CMTime
is invalid, otherwise false
.
Availability
 Available in iOS 4.0 and later.
Declared In
CMTime.h
CMTIME_IS_NEGATIVE_INFINITY
Returns a Boolean value that indicates whether a given time is negative infinity.
#define CMTIME_IS_NEGATIVE_INFINITY(time) ((Boolean)(CMTIME_IS_VALID(time) && (((time).flags & kCMTimeFlags_NegativeInfinity) != 0)))
Return Value
true
if the CMTime
is negative infinity, otherwise false
.
Discussion
Use this instead of (myTime == kCMTimeNegativeInfinity)
, since there are many CMTime structs that represent positive infinity. This is because the nonflags fields are ignored, so they can contain anything.
Availability
 Available in iOS 4.0 and later.
Declared In
CMTime.h
CMTIME_IS_NUMERIC
Returns a Boolean value that indicates whether a given time is numeric.
#define CMTIME_IS_NUMERIC(time) ((Boolean)(((time).flags & (kCMTimeFlags_Valid  kCMTimeFlags_ImpliedValueFlagsMask)) == kCMTimeFlags_Valid))
Return Value
true
if the CMTime
is numeric, otherwise false
. Returns false
if the CMTime
is invalid, indefinite, or +/ infinity.
Discussion
A numeric time contains a usable value/timescale/epoch.
Availability
 Available in iOS 4.0 and later.
Declared In
CMTime.h
CMTIME_IS_POSITIVE_INFINITY
Returns a Boolean value that indicates whether a given time is positive infinity.
#define CMTIME_IS_POSITIVE_INFINITY(time) ((Boolean)(CMTIME_IS_VALID(time) && (((time).flags & kCMTimeFlags_PositiveInfinity) != 0)))
Return Value
true
if the CMTime
is positive infinity, otherwise false
.
Discussion
Use this instead of (myTime == kCMTimePositiveInfinity)
, since there are many CMTime structs that represent positive infinity. This is because the nonflags fields are ignored, so they can contain anything.
Availability
 Available in iOS 4.0 and later.
Declared In
CMTime.h
CMTIME_IS_VALID
Returns a Boolean value that indicates whether a given time is valid.
#define CMTIME_IS_VALID(time) ((Boolean)(((time).flags & kCMTimeFlags_Valid) != 0))
Return Value
true
if the CMTime
is valid, otherwise false
.
Availability
 Available in iOS 4.0 and later.
Declared In
CMTime.h
Data Types
CMTime
Defines a structure that represents a rational time value int64
/int32
.
typedef struct { CMTimeValue value; CMTimeScale timescale; CMTimeFlags flags; CMTimeEpoch epoch; } CMTime;
Fields
value
The value of the CMTime.
value/timescale
= seconds.timescale
The timescale of the CMTime.
value/timescale
= seconds.flags
A bitfield representing the flags set for the CMTime.
For example,
kCMTimeFlags_Valid
. See “CMTime Flags” for possible values.epoch
The epoch of the CMTime.
You use the epoch to differentiate between equal timestamps that are actually different because of looping, multiitem sequencing, and so on.
The epoch is used during comparison: greater epochs happen after lesser ones. Addition or subtraction is only possible within a single epoch, however, since the epoch length may be unknown or variable.
Availability
 Available in iOS 4.0 and later.
Declared In
CMTime.h
CMTimeEpoch
The epoch to which a CMTime
refers.
typedef int64_t CMTimeEpoch;
Discussion
The epoch is typically 0
, but you might use a different value, for example, in a loop.
Availability
 Available in iOS 4.0 and later.
Declared In
CMTime.h
CMTimeFlags
A type to specify the flag bits for a CMTime
.
typedef uint32_t CMTimeFlags;
Discussion
For possible values, see “CMTime Flags.”
Availability
 Available in iOS 4.0 and later.
Declared In
CMTime.h
CMTimeRoundingMethod
Type for constants used to specify the rounding method to use when computing time.value
during timescale conversions.
typedef uint32_t CMTimeRoundingMethod;
Discussion
For possible values, see “Rounding Methods.”
Availability
 Available in iOS 4.0 and later.
Declared In
CMTime.h
CMTimeScale
Denominator of rational CMTime
.
typedef int32_t CMTimeScale;
Discussion
Timescales must be positive.
Availability
 Available in iOS 4.0 and later.
Declared In
CMTime.h
CMTimeValue
Numerator of rational CMTime
.
typedef int64_t CMTimeValue;
Availability
 Available in iOS 4.0 and later.
Declared In
CMTime.h
Constants
Time Constants
Constants to initialize CMTime
structures.
const CMTime kCMTimeInvalid; const CMTime kCMTimeIndefinite; const CMTime kCMTimePositiveInfinity; const CMTime kCMTimeNegativeInfinity; const CMTime kCMTimeZero;
Constants
kCMTimeInvalid
Use this constant to initialize an invalid
CMTime
.All fields are 0, so you can
calloc
or fill with0
's to make lots of them. Do not test against this using(time == kCMTimeInvalid)
, there are manyCMTimes
other than this that are also invalid. UseCMTIME_IS_INVALID(time)
instead.Available in iOS 4.0 and later.
Declared in
CMTime.h
.kCMTimeIndefinite
Use this constant to initialize an indefinite
CMTime
(for example, the duration of a live broadcast).Do not test against this using
(time == kCMTimeIndefinite)
, there are many CMTimes other than this that are also indefinite. UseCMTIME_IS_INDEFINITE(time)
instead.Available in iOS 4.0 and later.
Declared in
CMTime.h
.kCMTimePositiveInfinity
Use this constant to initialize a
CMTime
to +infinity.Do not test against this using
(time == kCMTimePositiveInfinity)
, there are many CMTimes other than this that are also +infinity. UseCMTIME_IS_POSITIVE_INFINITY(time)
instead.Available in iOS 4.0 and later.
Declared in
CMTime.h
.kCMTimeNegativeInfinity
Use this constant to initialize a
CMTime
to infinity.Do not test against this using
(time == kCMTimeNegativeInfinity)
, there are many CMTimes other than this that are also infinity. UseCMTIME_IS_NEGATIVE_INFINITY(time)
instead.Available in iOS 4.0 and later.
Declared in
CMTime.h
.kCMTimeZero
Use this constant to initialize a
CMTime
to 0.Do not test against this using
(time == kCMTimeZero)
, there are many CMTimes other than this that are also 0. UseCMTimeCompare(time, kCMTimeZero)
instead.Available in iOS 4.0 and later.
Declared in
CMTime.h
.
CMTime Flags
Constants to specify flags for CMTime
.
enum { kCMTimeFlags_Valid = 1UL<<0, kCMTimeFlags_HasBeenRounded = 1UL<<1, kCMTimeFlags_PositiveInfinity = 1UL<<2, kCMTimeFlags_NegativeInfinity = 1UL<<3, kCMTimeFlags_Indefinite = 1UL<<4, kCMTimeFlags_ImpliedValueFlagsMask = kCMTimeFlags_PositiveInfinity  kCMTimeFlags_NegativeInfinity  kCMTimeFlags_Indefinite };
Constants
kCMTimeFlags_Valid
Indicates that the time is valid.
Available in iOS 4.0 and later.
Declared in
CMTime.h
.kCMTimeFlags_HasBeenRounded
Indicates that the time has been rounded.
Available in iOS 4.0 and later.
Declared in
CMTime.h
.kCMTimeFlags_PositiveInfinity
Indicates that the time is +infinity.
Available in iOS 4.0 and later.
Declared in
CMTime.h
.kCMTimeFlags_NegativeInfinity
Indicates that the time is infinity.
Available in iOS 4.0 and later.
Declared in
CMTime.h
.kCMTimeFlags_Indefinite
Indicates that the time is indefinite.
Available in iOS 4.0 and later.
Declared in
CMTime.h
.kCMTimeFlags_ImpliedValueFlagsMask
Indicates that the time is +infinity, infinity, or indefinite.
Available in iOS 4.0 and later.
Declared in
CMTime.h
.
Maximum Timescale
A constant to define the maximum timescale.
#define kCMTimeMaxTimescale 0x7fffffffL
Constants
kCMTimeMaxTimescale
The maximum timescale.
Available in iOS 4.0 and later.
Declared in
CMTime.h
.
Rounding Methods
Constants used to specify the rounding method to use when computing time.value
during timescale conversions.
enum { kCMTimeRoundingMethod_RoundHalfAwayFromZero = 1, kCMTimeRoundingMethod_RoundTowardZero = 2, kCMTimeRoundingMethod_RoundAwayFromZero = 3, kCMTimeRoundingMethod_QuickTime = 4, kCMTimeRoundingMethod_RoundTowardPositiveInfinity = 5, kCMTimeRoundingMethod_RoundTowardNegativeInfinity = 6, kCMTimeRoundingMethod_Default = kCMTimeRoundingMethod_RoundHalfAwayFromZero };
Constants
kCMTimeRoundingMethod_RoundHalfAwayFromZero
Round towards zero if abs(fraction) is < 0.5, away from 0 if abs(fraction) is >= 0.5.
Available in iOS 4.0 and later.
Declared in
CMTime.h
.kCMTimeRoundingMethod_RoundTowardZero
Round towards zero if fraction is != 0.
Available in iOS 4.0 and later.
Declared in
CMTime.h
.kCMTimeRoundingMethod_RoundAwayFromZero
Round away from zero if abs(fraction) is > 0.
Available in iOS 4.0 and later.
Declared in
CMTime.h
.kCMTimeRoundingMethod_QuickTime
Use
kCMTimeRoundingMethod_RoundTowardZero
if converting from larger to smaller scale (that is, from more precision to less precision), but usekCMTimeRoundingMethod_RoundAwayFromZero
if converting from smaller to larger scale (i.e. from less precision to more precision).Also, never round a negative number down to 0; always return the smallest magnitude negative
CMTime
in this case (1/newTimescale).Available in iOS 4.0 and later.
Declared in
CMTime.h
.kCMTimeRoundingMethod_RoundTowardPositiveInfinity
Round towards +infinity if fraction is != 0.
Available in iOS 4.0 and later.
Declared in
CMTime.h
.kCMTimeRoundingMethod_RoundTowardNegativeInfinity
Round towards infinity if fraction is != 0.
Available in iOS 4.0 and later.
Declared in
CMTime.h
.kCMTimeRoundingMethod_Default
Synonym for
kCMTimeRoundingMethod_RoundHalfAwayFromZero
.Available in iOS 4.0 and later.
Declared in
CMTime.h
.
Dictionary Keys
Keys to access values of a CMTime represented by a CFDictionary.
const CFStringRef kCMTimeValueKey; const CFStringRef kCMTimeScaleKey; const CFStringRef kCMTimeEpochKey; const CFStringRef kCMTimeFlagsKey;
Constants
kCMTimeValueKey
CFDictionary
key for the value field ofCMTime
(aCFNumber
containing an int64_t value).Available in iOS 4.0 and later.
Declared in
CMTime.h
.kCMTimeScaleKey
CFDictionary
key for the timescale field ofCMTime
(aCFNumber
containing an int32_t value).Available in iOS 4.0 and later.
Declared in
CMTime.h
.kCMTimeEpochKey
CFDictionary
key for the epoch field ofCMTime
(aCFNumber
containing an int64_t value).Available in iOS 4.0 and later.
Declared in
CMTime.h
.kCMTimeFlagsKey
CFDictionary
key for the flags field ofCMTime
(aCFNumber
containing an int32_t value).Available in iOS 4.0 and later.
Declared in
CMTime.h
.
Discussion
See also CMTimeCopyAsDictionary
and CMTimeMakeFromDictionary
.
Copyright © 2003, 2013 Apple Inc. All Rights Reserved. Terms of Use  Privacy Policy  Updated: 20130128