|
| 1 | +//===--- CoreMediaOverlayShims.h ---===// |
| 2 | +// |
| 3 | +// This source file is part of the Swift.org open source project |
| 4 | +// |
| 5 | +// Copyright (c) 2019 Apple Inc. and the Swift project authors |
| 6 | +// Licensed under Apache License v2.0 with Runtime Library Exception |
| 7 | +// |
| 8 | +// See https://swift.org/LICENSE.txt for license information |
| 9 | +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors |
| 10 | +// |
| 11 | +//===----------------------------------------------------------------------===// |
| 12 | +// |
| 13 | +// This file contains replacements for the initializers of some CoreMedia |
| 14 | +// objects that return the created instance as an out parameter and thus |
| 15 | +// cannot be used in Swift as-is. |
| 16 | +// |
| 17 | +//===----------------------------------------------------------------------===// |
| 18 | + |
| 19 | +#ifndef SWIFT_STDLIB_SHIMS_COREMEDIA_OVERLAY_H |
| 20 | +#define SWIFT_STDLIB_SHIMS_COREMEDIA_OVERLAY_H |
| 21 | + |
| 22 | +@import CoreMedia; |
| 23 | +@import CoreFoundation; |
| 24 | + |
| 25 | +#if __has_feature(nullability) |
| 26 | +#pragma clang assume_nonnull begin |
| 27 | +#endif |
| 28 | + |
| 29 | +// slurped from CoreAudio headers that are sometime private. |
| 30 | +typedef UInt32 AudioObjectID; |
| 31 | +typedef AudioObjectID AudioDeviceID; |
| 32 | + |
| 33 | +// slurped from CoreMedia headers; see https://bugs.swift.org/browse/SR-2999 |
| 34 | +typedef struct CM_BRIDGED_TYPE(id) OpaqueCMBlockBuffer *CMBlockBufferRef; |
| 35 | +typedef struct CM_BRIDGED_TYPE(id) opaqueCMBufferQueue *CMBufferQueueRef; |
| 36 | +typedef struct CM_BRIDGED_TYPE(id) OpaqueCMClock* CMClockRef; |
| 37 | +typedef const struct CM_BRIDGED_TYPE(id) opaqueCMFormatDescription *CMFormatDescriptionRef; |
| 38 | +typedef struct CM_BRIDGED_TYPE(id) opaqueCMSampleBuffer *CMSampleBufferRef; |
| 39 | +typedef struct CM_BRIDGED_TYPE(id) opaqueCMSimpleQueue *CMSimpleQueueRef; |
| 40 | +typedef struct CM_BRIDGED_TYPE(id) OpaqueCMTimebase* CMTimebaseRef; |
| 41 | + |
| 42 | +#define INIT_REFERENCING(Type, availability) \ |
| 43 | +CM_INLINE CM_RETURNS_RETAINED_PARAMETER Type##Ref CM_NONNULL \ |
| 44 | + Type##Retain( \ |
| 45 | + Type##Ref CM_NONNULL object) \ |
| 46 | + CF_SWIFT_NAME(Type.init(referencing:)) \ |
| 47 | + CF_REFINED_FOR_SWIFT \ |
| 48 | + availability ;\ |
| 49 | +CM_INLINE CM_RETURNS_RETAINED_PARAMETER Type##Ref CM_NONNULL \ |
| 50 | + Type##Retain( \ |
| 51 | + Type##Ref CM_NONNULL object) \ |
| 52 | +{ \ |
| 53 | + return (Type##Ref)CFRetain(object);\ |
| 54 | +} |
| 55 | + |
| 56 | +INIT_REFERENCING(CMClock, API_AVAILABLE(macosx(10.8)) API_UNAVAILABLE(ios, tvos, watchos)) |
| 57 | + |
| 58 | +INIT_REFERENCING(CMBlockBuffer, API_AVAILABLE(macos(10.7), ios(4.0), tvos(9.0), watchos(6.0))) |
| 59 | + |
| 60 | +INIT_REFERENCING(CMBufferQueue, API_AVAILABLE(macos(10.7), ios(4.0), tvos(9.0), watchos(6.0))) |
| 61 | + |
| 62 | +INIT_REFERENCING(CMFormatDescription, API_AVAILABLE(macos(10.7), ios(4.0), tvos(9.0), watchos(6.0))) |
| 63 | + |
| 64 | +INIT_REFERENCING(CMSampleBuffer, API_AVAILABLE(macos(10.7), ios(4.0), tvos(9.0), watchos(6.0))) |
| 65 | + |
| 66 | +INIT_REFERENCING(CMSimpleQueue, API_AVAILABLE(macos(10.7), ios(4.0), tvos(9.0), watchos(6.0))) |
| 67 | + |
| 68 | +INIT_REFERENCING(CMTimebase, API_AVAILABLE(macos(10.7), ios(4.0), tvos(9.0), watchos(6.0))) |
| 69 | + |
| 70 | +#if __has_feature(nullability) |
| 71 | +#pragma clang assume_nonnull end |
| 72 | +#endif |
| 73 | + |
| 74 | + |
| 75 | +#endif // SWIFT_STDLIB_SHIMS_COREMEDIA_OVERLAY_H |
0 commit comments