Files
swift-mirror/stdlib/public/Darwin/CoreMedia/CMTimeRange.swift
Jordan Rose d20a7ca64e [CMake] Switch to building the overlays in Swift 5 mode (#24350)
Now that that's stabilized, we don't have to keep them in Swift 4 mode
any longer. (Arguably we don't need the CMake variable at all, but it
may be useful again in the future.)

rdar://problem/49040980
2019-04-29 17:55:20 -07:00

87 lines
2.6 KiB
Swift

//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
@_exported import CoreMedia // Clang module
// CMTIMERANGE_IS_VALID
// CMTIMERANGE_IS_INVALID
// CMTIMERANGE_IS_INDEFINITE
// CMTIMERANGE_IS_EMPTY
// CMTimeRangeGetEnd
// CMTimeRangeGetUnion
// CMTimeRangeGetIntersection
// CMTimeRangeContainsTime
// CMTimeRangeContainsTimeRange
// CMTimeRangeFromTimeToTime
extension CMTimeRange {
public init(start: CMTime, end: CMTime) {
self = CMTimeRangeFromTimeToTime(start: start, end: end)
}
public var isValid: Bool {
return self.start.isValid &&
self.duration.isValid &&
(self.duration.epoch == 0) &&
(self.duration.value >= 0)
}
public var isIndefinite: Bool {
return self.isValid &&
(self.start.isIndefinite || self.duration.isIndefinite)
}
public var isEmpty: Bool {
return self.isValid && (self.duration == .zero)
}
public var end: CMTime {
return CMTimeRangeGetEnd(self)
}
public func union(_ otherRange: CMTimeRange) -> CMTimeRange {
return CMTimeRangeGetUnion(self, otherRange: otherRange)
}
public func intersection(_ otherRange: CMTimeRange) -> CMTimeRange {
return CMTimeRangeGetIntersection(self, otherRange: otherRange)
}
public func containsTime(_ time: CMTime) -> Bool {
return CMTimeRangeContainsTime(self, time: time)
}
public func containsTimeRange(_ range: CMTimeRange) -> Bool {
return CMTimeRangeContainsTimeRange(self, otherRange: range)
}
}
public func CMTIMERANGE_IS_VALID (_ range: CMTimeRange) -> Bool {
return range.isValid
}
public func CMTIMERANGE_IS_INVALID (_ range: CMTimeRange) -> Bool {
return !range.isValid
}
public func CMTIMERANGE_IS_INDEFINITE (_ range: CMTimeRange) -> Bool {
return range.isIndefinite
}
public func CMTIMERANGE_IS_EMPTY (_ range: CMTimeRange) -> Bool {
return range.isEmpty
}
// CMTimeRangeEqual
extension CMTimeRange : Equatable {
public static func == (range1: CMTimeRange, range2: CMTimeRange) -> Bool {
return CMTimeRangeEqual(range1, range2)
}
public static func != (range1: CMTimeRange, range2: CMTimeRange) -> Bool {
return !CMTimeRangeEqual(range1, range2)
}
}