Function

CMTimeMultiplyByRatio(_:multiplier:divisor:)

Returns the result of multiplying a CMTime by an integer, then dividing by another integer.

Declaration

func CMTimeMultiplyByRatio(_ time: CMTime, multiplier: Int32, divisor: Int32) -> CMTime

Parameters

time

The CMTime to be multiplied then divided.

multiplier

The value by which to multiply.

divisor

The value by which to divide.

Return Value

A value equal to (time * multiplier) / divisor.

Discussion

The exact rational value will be preserved, if possible without overflow. If an overflow would occur, a new timescale will be chosen so as to minimize the rounding error. 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 denominator, and either the time or the numerator, are zero, the result will be kCMTimeInvalid. If only the denominator is zero, the result will be either kCMTimePositiveInfinity or kCMTimeNegativeInfinity, depending on the signs of the other arguments.

If time is invalid, the result will be invalid. If time is infinite, the result will be similarly infinite. If time is indefinite, the result will be indefinite.

See Also

Performing Common Operations

func CMTimeAdd(CMTime, CMTime) -> CMTime

Returns the sum of two CMTimes.

func CMTimeSubtract(CMTime, CMTime) -> CMTime

Returns the difference of two CMTimes.

func CMTimeMultiply(CMTime, multiplier: Int32) -> CMTime

Returns the product of a CMTime and a 32-bit integer.

func CMTimeMultiplyByFloat64(CMTime, multiplier: Float64) -> CMTime

Returns the product of a CMTime and a 64-bit float.

func CMTimeConvertScale(CMTime, timescale: Int32, method: CMTimeRoundingMethod) -> CMTime

Returns a new CMTime containing the source CMTime converted to a new timescale (rounding as requested).