CMTime Reference
| Derived from | |
| Framework | |
| Declared in | CMTime.h |
Overview
This document describes the API for creating and manipulating CMTime structs.
CMTime structs are non-opaque 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 non-numeric 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 wall-clock 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 OS X v10.7 and later.
Declared In
CMTime.hCMTimeAdd
Returns the sum of two CMTimes.
CMTime CMTimeAdd ( CMTime addend1, CMTime addend2 );
Parameters
- addend1
CMTimeto be added.- addend2
Another
CMTimeto 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 OS X v10.7 and later.
Declared In
CMTime.hCMTimeCompare
Returns the numerical relationship of two CMTimes.
int32_t CMTimeCompare ( CMTime time1, CMTime time2 );
Parameters
- time1
First
CMTimein comparison.- time2
Second
CMTimein comparison.
Return Value
The numerical relationship of the two CMTimes.
-1 is returned if
time1is less thantime2.1 is returned if
time1is greater thantime2.0 is returned if
time1andtime2are 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 OS X v10.7 and later.
Declared In
CMTime.hCMTimeConvertScale
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
CMTimeis 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 non-numeric (i.e.. infinite, indefinite, invalid), the result will be similarly non-numeric.
Availability
- Available in OS X v10.7 and later.
Declared In
CMTime.hCMTimeCopyAsDictionary
Returns a CFDictionary version of a CMTime.
CFDictionaryRef CMTimeCopyAsDictionary ( CMTime time, CFAllocatorRef allocator );
Parameters
- time
CMTimefrom which to create dictionary.- allocator
CFAllocatorwith which to create dictionary. PasskCFAllocatorDefaultto 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 OS X v10.7 and later.
Declared In
CMTime.hCMTimeCopyDescription
Creates a CFString with a description of a CMTime ( Similar to CFCopyDescription ).
CFStringRef CMTimeCopyDescription ( CFAllocatorRef allocator, CMTime time );
Parameters
- allocator
CFAllocatorwith which to create the description. PasskCFAllocatorDefaultto use the default allocator.- time
CMTimeto 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 OS X v10.7 and later.
Declared In
CMTime.hCMTimeGetSeconds
Converts a CMTime to seconds.
Float64 CMTimeGetSeconds ( CMTime time );
Parameters
- time
CMTimeto 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 OS X v10.7 and later.
Declared In
CMTime.hCMTimeMake
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 OS X v10.7 and later.
Declared In
CMTime.hCMTimeMakeFromDictionary
Reconstitutes a CMTime struct from a CFDictionary previously created by CMTimeCopyAsDictionary.
CMTime CMTimeMakeFromDictionary ( CFDictionaryRef dict );
Parameters
- dict
CFDictionaryfrom which to createCMTime.
Return Value
The created CMTime.
Discussion
For keys in the dictionary, see “Dictionary Keys.”
Availability
- Available in OS X v10.7 and later.
Declared In
CMTime.hCMTimeMakeWithEpoch
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 OS X v10.7 and later.
Declared In
CMTime.hCMTimeMakeWithSeconds
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
preferredTimeScalefield 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 OS X v10.7 and later.
Declared In
CMTime.hCMTimeMaximum
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 OS X v10.7 and later.
Declared In
CMTime.hCMTimeMinimum
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 OS X v10.7 and later.
Declared In
CMTime.hCMTimeMultiply
Returns the product of a CMTime and a 32-bit integer.
CMTime CMTimeMultiply ( CMTime time, int32_t multiplier );
Parameters
- time
The
CMTimethat will be multiplied.- multiplier
A 32-bit integer.
CMTime timeandmultiplierwill be multiplied.
Return Value
The product of the CMTime and the 32-bit 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 OS X v10.7 and later.
Declared In
CMTime.hCMTimeMultiplyByFloat64
Returns the product of a CMTime and a 64-bit float.
CMTime CMTimeMultiplyByFloat64 ( CMTime time, Float64 multiplier );
Parameters
- time
The
CMTimethat will be multiplied.- multiplier
A 64-bit float.
CMTime timeandmultiplierwill be multiplied.
Return Value
The product of the CMTime and the 64-bit 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 OS X v10.7 and later.
Declared In
CMTime.hCMTimeShow
Prints a description of the CMTime (Similar to CFShow).
void CMTimeShow ( CMTime time );
Parameters
- time
CMTimeto show.
Discussion
This is most useful from within gdb.
Availability
- Available in OS X v10.7 and later.
Declared In
CMTime.hCMTimeSubtract
Returns the difference of two CMTimes.
CMTime CMTimeSubtract ( CMTime minuend, CMTime subtrahend );
Parameters
- minuend
The
CMTimefrom which the subtrahend will be subtracted.- subtrahend
The
CMTimethat 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 OS X v10.7 and later.
Declared In
CMTime.hCMTIME_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 OS X v10.7 and later.
Declared In
CMTime.hCMTIME_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 OS X v10.7 and later.
Declared In
CMTime.hCMTIME_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 OS X v10.7 and later.
Declared In
CMTime.hCMTIME_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 OS X v10.7 and later.
Declared In
CMTime.hCMTIME_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 non-flags fields are ignored, so they can contain anything.
Availability
- Available in OS X v10.7 and later.
Declared In
CMTime.hCMTIME_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 OS X v10.7 and later.
Declared In
CMTime.hCMTIME_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 non-flags fields are ignored, so they can contain anything.
Availability
- Available in OS X v10.7 and later.
Declared In
CMTime.hCMTIME_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 OS X v10.7 and later.
Declared In
CMTime.hData 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
valueThe value of the CMTime.
value/timescale= seconds.timescaleThe timescale of the CMTime.
value/timescale= seconds.flagsA bitfield representing the flags set for the CMTime.
For example,
kCMTimeFlags_Valid. See “CMTime Flags” for possible values.epochThe epoch of the CMTime.
You use the epoch to differentiate between equal timestamps that are actually different because of looping, multi-item 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 OS X v10.7 and later.
Declared In
CMTime.hCMTimeEpoch
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 OS X v10.7 and later.
Declared In
CMTime.hCMTimeFlags
A type to specify the flag bits for a CMTime.
typedef uint32_t CMTimeFlags;
Discussion
For possible values, see “CMTime Flags.”
Availability
- Available in OS X v10.7 and later.
Declared In
CMTime.hCMTimeRoundingMethod
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 OS X v10.7 and later.
Declared In
CMTime.hCMTimeScale
Denominator of rational CMTime.
typedef int32_t CMTimeScale;
Discussion
Timescales must be positive.
Availability
- Available in OS X v10.7 and later.
Declared In
CMTime.hCMTimeValue
Numerator of rational CMTime.
typedef int64_t CMTimeValue;
Availability
- Available in OS X v10.7 and later.
Declared In
CMTime.hConstants
Time Constants
Constants to initialize CMTime structures.
const CMTime kCMTimeInvalid; const CMTime kCMTimeIndefinite; const CMTime kCMTimePositiveInfinity; const CMTime kCMTimeNegativeInfinity; const CMTime kCMTimeZero;
Constants
kCMTimeInvalidUse this constant to initialize an invalid
CMTime.All fields are 0, so you can
callocor fill with0's to make lots of them. Do not test against this using(time == kCMTimeInvalid), there are manyCMTimesother than this that are also invalid. UseCMTIME_IS_INVALID(time)instead.Available in OS X v10.7 and later.
Declared in
CMTime.h.kCMTimeIndefiniteUse 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 OS X v10.7 and later.
Declared in
CMTime.h.kCMTimePositiveInfinityUse this constant to initialize a
CMTimeto +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 OS X v10.7 and later.
Declared in
CMTime.h.kCMTimeNegativeInfinityUse this constant to initialize a
CMTimeto -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 OS X v10.7 and later.
Declared in
CMTime.h.kCMTimeZeroUse this constant to initialize a
CMTimeto 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 OS X v10.7 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_ValidIndicates that the time is valid.
Available in OS X v10.7 and later.
Declared in
CMTime.h.kCMTimeFlags_HasBeenRoundedIndicates that the time has been rounded.
Available in OS X v10.7 and later.
Declared in
CMTime.h.kCMTimeFlags_PositiveInfinityIndicates that the time is +infinity.
Available in OS X v10.7 and later.
Declared in
CMTime.h.kCMTimeFlags_NegativeInfinityIndicates that the time is -infinity.
Available in OS X v10.7 and later.
Declared in
CMTime.h.kCMTimeFlags_IndefiniteIndicates that the time is indefinite.
Available in OS X v10.7 and later.
Declared in
CMTime.h.kCMTimeFlags_ImpliedValueFlagsMaskIndicates that the time is +infinity, -infinity, or indefinite.
Available in OS X v10.7 and later.
Declared in
CMTime.h.
Maximum Timescale
A constant to define the maximum timescale.
#define kCMTimeMaxTimescale 0x7fffffffL
Constants
kCMTimeMaxTimescaleThe maximum timescale.
Available in OS X v10.7 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_RoundHalfAwayFromZeroRound towards zero if abs(fraction) is < 0.5, away from 0 if abs(fraction) is >= 0.5.
Available in OS X v10.7 and later.
Declared in
CMTime.h.kCMTimeRoundingMethod_RoundTowardZeroRound towards zero if fraction is != 0.
Available in OS X v10.7 and later.
Declared in
CMTime.h.kCMTimeRoundingMethod_RoundAwayFromZeroRound away from zero if abs(fraction) is > 0.
Available in OS X v10.7 and later.
Declared in
CMTime.h.kCMTimeRoundingMethod_QuickTimeUse
kCMTimeRoundingMethod_RoundTowardZeroif converting from larger to smaller scale (that is, from more precision to less precision), but usekCMTimeRoundingMethod_RoundAwayFromZeroif 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
CMTimein this case (-1/newTimescale).Available in OS X v10.7 and later.
Declared in
CMTime.h.kCMTimeRoundingMethod_RoundTowardPositiveInfinityRound towards +infinity if fraction is != 0.
Available in OS X v10.7 and later.
Declared in
CMTime.h.kCMTimeRoundingMethod_RoundTowardNegativeInfinityRound towards -infinity if fraction is != 0.
Available in OS X v10.7 and later.
Declared in
CMTime.h.kCMTimeRoundingMethod_DefaultSynonym for
kCMTimeRoundingMethod_RoundHalfAwayFromZero.Available in OS X v10.7 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
kCMTimeValueKeyCFDictionarykey for the value field ofCMTime(aCFNumbercontaining an int64_t value).Available in OS X v10.7 and later.
Declared in
CMTime.h.kCMTimeScaleKeyCFDictionarykey for the timescale field ofCMTime(aCFNumbercontaining an int32_t value).Available in OS X v10.7 and later.
Declared in
CMTime.h.kCMTimeEpochKeyCFDictionarykey for the epoch field ofCMTime(aCFNumbercontaining an int64_t value).Available in OS X v10.7 and later.
Declared in
CMTime.h.kCMTimeFlagsKeyCFDictionarykey for the flags field ofCMTime(aCFNumbercontaining an int32_t value).Available in OS X v10.7 and later.
Declared in
CMTime.h.
Discussion
See also CMTimeCopyAsDictionary and CMTimeMakeFromDictionary.
© 2003, 2013 Apple Inc. All Rights Reserved. (Last updated: 2013-01-28)