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

Makes a valid
CMTime
with value and timescale. Epoch is implied to be 0.Declaration
Swift
func CMTimeMake(_
value
: Int64, _timescale
: Int32) > CMTimeObjectiveC
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
Import Statement
import CoreMedia
Availability
Available in iOS 4.0 and later.

Reconstitutes a
CMTime
struct from aCFDictionary
previously created byCMTimeCopyAsDictionary
.Declaration
Swift
func CMTimeMakeFromDictionary(_
dict
: CFDictionary!) > CMTimeObjectiveC
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.
Import Statement
import CoreMedia
Availability
Available in iOS 4.0 and later.

Makes a valid
CMTime
with value, scale and epoch.Declaration
Swift
func CMTimeMakeWithEpoch(_
value
: Int64, _timescale
: Int32, _epoch
: Int64) > CMTimeObjectiveC
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
.Import Statement
import CoreMedia
Availability
Available in iOS 4.0 and later.

Makes a
CMTime
from a Float64 number of seconds, and a preferred timescale.Declaration
Swift
func CMTimeMakeWithSeconds(_
seconds
: Float64, _preferredTimeScale
: Int32) > CMTimeObjectiveC
CMTime CMTimeMakeWithSeconds ( Float64 seconds, int32_t preferredTimeScale );
Parameters
seconds
Initializes the
seconds
field of the resultingCMTime
.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 invalidCMTime
. 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. ThekCMTimeFlags_HasBeenRounded
flag will be set if the result, when converted back to seconds, is not exactly equal to the original seconds value.Import Statement
import CoreMedia
Availability
Available in iOS 4.0 and later.

Returns the absolute value of a
CMTime
.Declaration
Parameters
time
A
CMTime
.Return Value
Same as the argument time, with sign inverted if negative.
Import Statement
import CoreMedia
Availability
Available in iOS 4.0 and later.

Returns the sum of two
CMTimes
.Declaration
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 bekCMTimeMaxTimescale
, 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 haskCMTimeFlags_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.
Import Statement
import CoreMedia
Availability
Available in iOS 4.0 and later.

Returns the numerical relationship of two
CMTimes
.Declaration
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 useCMTIME_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 < invalidInvalid
CMTimes
are considered to be equal to other invalidCMTimes
, and greater than any otherCMTime
. Positive infinity is considered to be less than any invalidCMTime
, equal to itself, and greater than any otherCMTime
. An indefiniteCMTime
is considered to be less than any invalidCMTime
, less than positive infinity, equal to itself, and greater than any otherCMTime
. Negative infinity is considered to be equal to itself, and less than any otherCMTime
.Import Statement
import CoreMedia
Availability
Available in iOS 4.0 and later.

Returns a new
CMTime
containing the sourceCMTime
converted to a new timescale (rounding as requested).Declaration
Swift
func CMTimeConvertScale(_
time
: CMTime, _newTimescale
: Int32, _method
: CMTimeRoundingMethod) > CMTimeObjectiveC
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 ofCMTimeRoundingMethod
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.Import Statement
import CoreMedia
Availability
Available in iOS 4.0 and later.

Returns a
CFDictionary
version of aCMTime
.Declaration
Swift
func CMTimeCopyAsDictionary(_
time
: CMTime, _allocator
: CFAllocator!) > CFDictionary!ObjectiveC
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 theCMTime
.Discussion
This is useful when putting
CMTimes
in Core Foundation container types. For keys in the resulting dictionary, see Dictionary Keys.Import Statement
import CoreMedia
Availability
Available in iOS 4.0 and later.

Creates a
CFString
with a description of aCMTime
( Similar toCFCopyDescription
).Declaration
Swift
func CMTimeCopyDescription(_
allocator
: CFAllocator!, _time
: CMTime) > CFString!ObjectiveC
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 containsCMTime
fields. It is also useful from other client debugging code. The caller owns the returnedCFString
, and is responsible for releasing it.Import Statement
import CoreMedia
Availability
Available in iOS 4.0 and later.

Converts a
CMTime
to seconds.Declaration
Swift
func CMTimeGetSeconds(_
time
: CMTime) > Float64ObjectiveC
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 theCMTime
is infinite, +/ infinity is returned. If theCMTime
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.Import Statement
import CoreMedia
Availability
Available in iOS 4.0 and later.

Returns the greater of two
CMTimes
(as defined byCMTimeCompare
).Declaration
Parameters
time1
A
CMTime
.time2
Another
CMTime
.Return Value
The greater of the two
CMTimes
.Import Statement
import CoreMedia
Availability
Available in iOS 4.0 and later.

Returns the lesser of two CMTimes (as defined by
CMTimeCompare
).Declaration
Parameters
time1
A
CMTime
.time2
Another
CMTime
.Return Value
The lesser of the two
CMTimes
.Import Statement
import CoreMedia
Availability
Available in iOS 4.0 and later.

Returns the product of a CMTime and a 32bit integer.
Declaration
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'skCMTimeFlags_HasBeenRounded
flag will be set. This flag will also be set if theCMTime
operand haskCMTimeFlags_HasBeenRounded
set. If theCMTime
operand is invalid, the result will be invalid. If theCMTime
operand is valid, but infinite, the result will be infinite, and of an appropriate sign, give the signs of both operands. If theCMTime
operand is valid, but indefinite, the result will be indefinite.Import Statement
import CoreMedia
Availability
Available in iOS 4.0 and later.

Returns the product of a
CMTime
and a 64bit float.Declaration
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 theCMTime
operand haskCMTimeFlags_HasBeenRounded
set. If theCMTime
operand is invalid, the result will be invalid. If theCMTime
operand is valid, but infinite, the result will be infinite, and of an appropriate sign, given the signs of both operands. If theCMTime
operand is valid, but indefinite, the result will be indefinite.Import Statement
import CoreMedia
Availability
Available in iOS 4.0 and later.

Prints a description of the
CMTime
(Similar toCFShow
).Parameters
time
CMTime
to show.Discussion
This is most useful from within gdb.
Import Statement
import CoreMedia
Availability
Available in iOS 4.0 and later.

Returns the difference of two
CMTimes
.Declaration
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 bekCMTimeMaxTimescale
, 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 haskCMTimeFlags_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.
Import Statement
import CoreMedia
Availability
Available in iOS 4.0 and later.

Returns a Boolean value that indicates whether the specified comparison of two CMTimes is true.
Declaration
ObjectiveC
#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.
Import Statement
Availability
Available in iOS 4.0 and later.

Returns a Boolean value that indicates whether a given time is valid.
Declaration
ObjectiveC
#define CMTIME_IS_VALID(time) ((Boolean)(((time).flags & kCMTimeFlags_Valid) != 0))
Return Value
true
if theCMTime
is valid, otherwisefalse
.Import Statement
Availability
Available in iOS 4.0 and later.

Returns a Boolean value that indicates whether a given time is invalid.
Declaration
ObjectiveC
#define CMTIME_IS_INVALID(time) (! CMTIME_IS_VALID(time))
Return Value
true
if theCMTime
is invalid, otherwisefalse
.Import Statement
Availability
Available in iOS 4.0 and later.

Returns a Boolean value that indicates whether a given time is positive infinity.
Declaration
ObjectiveC
#define CMTIME_IS_POSITIVE_INFINITY(time) ((Boolean)(CMTIME_IS_VALID(time) && (((time).flags & kCMTimeFlags_PositiveInfinity) != 0)))
Return Value
true
if theCMTime
is positive infinity, otherwisefalse
.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.Import Statement
Availability
Available in iOS 4.0 and later.

Returns a Boolean value that indicates whether a given time is negative infinity.
Declaration
ObjectiveC
#define CMTIME_IS_NEGATIVE_INFINITY(time) ((Boolean)(CMTIME_IS_VALID(time) && (((time).flags & kCMTimeFlags_NegativeInfinity) != 0)))
Return Value
true
if theCMTime
is negative infinity, otherwisefalse
.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.Import Statement
Availability
Available in iOS 4.0 and later.

Returns a Boolean value that indicates whether a given time is indefinite.
Declaration
ObjectiveC
#define CMTIME_IS_INDEFINITE(time) ((Boolean)(CMTIME_IS_VALID(time) && (((time).flags & kCMTimeFlags_Indefinite) != 0)))
Return Value
true
if theCMTime
is indefinite, otherwisefalse
.Import Statement
Availability
Available in iOS 4.0 and later.

Returns a Boolean value that indicates whether a given time is numeric.
Declaration
ObjectiveC
#define CMTIME_IS_NUMERIC(time) ((Boolean)(((time).flags & (kCMTimeFlags_Valid  kCMTimeFlags_ImpliedValueFlagsMask)) == kCMTimeFlags_Valid))
Return Value
true
if theCMTime
is numeric, otherwisefalse
. Returnsfalse
if theCMTime
is invalid, indefinite, or +/ infinity.Discussion
A numeric time contains a usable value/timescale/epoch.
Import Statement
Availability
Available in iOS 4.0 and later.

Returns a Boolean value that indicates whether a given time has been rounded.
Declaration
ObjectiveC
#define CMTIME_HAS_BEEN_ROUNDED(time) ((Boolean)(CMTIME_IS_NUMERIC(time) && (((time).flags & kCMTimeFlags_HasBeenRounded) != 0)))
Return Value
true
if theCMTime
has been rounded, otherwisefalse
(the time is completely accurate).Import Statement
Availability
Available in iOS 4.0 and later.

Defines a structure that represents a rational time value
int64
/int32
.Declaration
Swift
struct CMTime { var value: CMTimeValue var timescale: CMTimeScale var flags: CMTimeFlags var epoch: CMTimeEpoch }
ObjectiveC
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.

Numerator of rational
CMTime
.Declaration
Swift
typealias CMTimeValue = Int64
ObjectiveC
typedef int64_t CMTimeValue;
Import Statement
import CoreMedia
Availability
Available in iOS 4.0 and later.

Denominator of rational
CMTime
.Declaration
Swift
typealias CMTimeScale = Int32
ObjectiveC
typedef int32_t CMTimeScale;
Discussion
Timescales must be positive.
Import Statement
import CoreMedia
Availability
Available in iOS 4.0 and later.

The epoch to which a
CMTime
refers.Declaration
Swift
typealias CMTimeEpoch = Int64
ObjectiveC
typedef int64_t CMTimeEpoch;
Discussion
The epoch is typically
0
, but you might use a different value, for example, in a loop.Import Statement
import CoreMedia
Availability
Available in iOS 4.0 and later.

A type to specify the flag bits for a
CMTime
.Declaration
Swift
struct CMTimeFlags : RawOptionSetType { init(_
rawValue
: UInt32) init(rawValuerawValue
: UInt32) static var Valid: CMTimeFlags { get } static var HasBeenRounded: CMTimeFlags { get } static var PositiveInfinity: CMTimeFlags { get } static var NegativeInfinity: CMTimeFlags { get } static var Indefinite: CMTimeFlags { get } static var ImpliedValueFlagsMask: CMTimeFlags { get } }ObjectiveC
typedef uint32_t CMTimeFlags;
Discussion
For possible values, see CMTime Flags.
Import Statement
import CoreMedia
Availability
Available in iOS 4.0 and later.

Type for constants used to specify the rounding method to use when computing
time.value
during timescale conversions.Declaration
Swift
enum CMTimeRoundingMethod : UInt32 { case RoundHalfAwayFromZero case RoundTowardZero case RoundAwayFromZero case QuickTime case RoundTowardPositiveInfinity case RoundTowardNegativeInfinity }
ObjectiveC
typedef uint32_t CMTimeRoundingMethod;
Discussion
For possible values, see Rounding Methods.
Import Statement
import CoreMedia
Availability
Available in iOS 4.0 and later.

Constants to initialize
CMTime
structures.Declaration
Swift
let kCMTimeInvalid: CMTime let kCMTimeIndefinite: CMTime let kCMTimePositiveInfinity: CMTime let kCMTimeNegativeInfinity: CMTime let kCMTimeZero: CMTime
ObjectiveC
const CMTime kCMTimeInvalid; const CMTime kCMTimeIndefinite; const CMTime kCMTimePositiveInfinity; const CMTime kCMTimeNegativeInfinity; const CMTime kCMTimeZero;
Constants

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

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

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

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

kCMTimeZero
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.
Import Statement


Constants to specify flags for
CMTime
.Declaration
Swift
struct CMTimeFlags : RawOptionSetType { init(_
rawValue
: UInt32) init(rawValuerawValue
: UInt32) static var Valid: CMTimeFlags { get } static var HasBeenRounded: CMTimeFlags { get } static var PositiveInfinity: CMTimeFlags { get } static var NegativeInfinity: CMTimeFlags { get } static var Indefinite: CMTimeFlags { get } static var ImpliedValueFlagsMask: CMTimeFlags { get } }ObjectiveC
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

Valid
kCMTimeFlags_Valid
Indicates that the time is valid.
Available in iOS 4.0 and later.

HasBeenRounded
kCMTimeFlags_HasBeenRounded
Indicates that the time has been rounded.
Available in iOS 4.0 and later.

PositiveInfinity
kCMTimeFlags_PositiveInfinity
Indicates that the time is +infinity.
Available in iOS 4.0 and later.

NegativeInfinity
kCMTimeFlags_NegativeInfinity
Indicates that the time is infinity.
Available in iOS 4.0 and later.

Indefinite
kCMTimeFlags_Indefinite
Indicates that the time is indefinite.
Available in iOS 4.0 and later.

ImpliedValueFlagsMask
kCMTimeFlags_ImpliedValueFlagsMask
Indicates that the time is +infinity, infinity, or indefinite.
Available in iOS 4.0 and later.
Import Statement


A constant to define the maximum timescale.
Declaration
Swift
var kCMTimeMaxTimescale: Int { get }
ObjectiveC
#define kCMTimeMaxTimescale 0x7fffffffL
Constants
Import Statement

Constants used to specify the rounding method to use when computing
time.value
during timescale conversions.Declaration
Swift
enum CMTimeRoundingMethod : UInt32 { case RoundHalfAwayFromZero case RoundTowardZero case RoundAwayFromZero case QuickTime case RoundTowardPositiveInfinity case RoundTowardNegativeInfinity }
ObjectiveC
enum { kCMTimeRoundingMethod_RoundHalfAwayFromZero = 1, kCMTimeRoundingMethod_RoundTowardZero = 2, kCMTimeRoundingMethod_RoundAwayFromZero = 3, kCMTimeRoundingMethod_QuickTime = 4, kCMTimeRoundingMethod_RoundTowardPositiveInfinity = 5, kCMTimeRoundingMethod_RoundTowardNegativeInfinity = 6, kCMTimeRoundingMethod_Default = kCMTimeRoundingMethod_RoundHalfAwayFromZero };
Constants

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

RoundTowardZero
kCMTimeRoundingMethod_RoundTowardZero
Round towards zero if fraction is != 0.
Available in iOS 4.0 and later.

RoundAwayFromZero
kCMTimeRoundingMethod_RoundAwayFromZero
Round away from zero if abs(fraction) is > 0.
Available in iOS 4.0 and later.

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

RoundTowardPositiveInfinity
kCMTimeRoundingMethod_RoundTowardPositiveInfinity
Round towards +infinity if fraction is != 0.
Available in iOS 4.0 and later.

RoundTowardNegativeInfinity
kCMTimeRoundingMethod_RoundTowardNegativeInfinity
Round towards infinity if fraction is != 0.
Available in iOS 4.0 and later.

kCMTimeRoundingMethod_Default
kCMTimeRoundingMethod_Default
Synonym for
kCMTimeRoundingMethod_RoundHalfAwayFromZero
.Available in iOS 4.0 and later.
Import Statement


Keys to access values of a CMTime represented by a CFDictionary.
Declaration
Swift
let kCMTimeValueKey: CFString! let kCMTimeScaleKey: CFString! let kCMTimeEpochKey: CFString! let kCMTimeFlagsKey: CFString!
ObjectiveC
const CFStringRef kCMTimeValueKey; const CFStringRef kCMTimeScaleKey; const CFStringRef kCMTimeEpochKey; const CFStringRef kCMTimeFlagsKey;
Constants

kCMTimeValueKey
kCMTimeValueKey
CFDictionary
key for the value field ofCMTime
(aCFNumber
containing an int64_t value).Available in iOS 4.0 and later.

kCMTimeScaleKey
kCMTimeScaleKey
CFDictionary
key for the timescale field ofCMTime
(aCFNumber
containing an int32_t value).Available in iOS 4.0 and later.

kCMTimeEpochKey
kCMTimeEpochKey
CFDictionary
key for the epoch field ofCMTime
(aCFNumber
containing an int64_t value).Available in iOS 4.0 and later.

kCMTimeFlagsKey
kCMTimeFlagsKey
CFDictionary
key for the flags field ofCMTime
(aCFNumber
containing an int32_t value).Available in iOS 4.0 and later.
Discussion
See also
CMTimeCopyAsDictionary
andCMTimeMakeFromDictionary
.Import Statement

Copyright © 2015 Apple Inc. All rights reserved. Terms of Use  Privacy Policy  Updated: 20130128