Skip to content

[5.1][Shims] Add CoreMedia overlay shims #25738

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions stdlib/public/SwiftShims/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ set(sources
UnicodeShims.h
Visibility.h

CoreMediaOverlayShims.h
DispatchOverlayShims.h
NetworkOverlayShims.h
OSOverlayShims.h
Expand Down
75 changes: 75 additions & 0 deletions stdlib/public/SwiftShims/CoreMediaOverlayShims.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
//===--- CoreMediaOverlayShims.h ---===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2019 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
//
//===----------------------------------------------------------------------===//
//
// This file contains replacements for the initializers of some CoreMedia
// objects that return the created instance as an out parameter and thus
// cannot be used in Swift as-is.
//
//===----------------------------------------------------------------------===//

#ifndef SWIFT_STDLIB_SHIMS_COREMEDIA_OVERLAY_H
#define SWIFT_STDLIB_SHIMS_COREMEDIA_OVERLAY_H

@import CoreMedia;
@import CoreFoundation;

#if __has_feature(nullability)
#pragma clang assume_nonnull begin
#endif

// slurped from CoreAudio headers that are sometime private.
typedef UInt32 AudioObjectID;
typedef AudioObjectID AudioDeviceID;

// slurped from CoreMedia headers; see https://bugs.swift.org/browse/SR-2999
typedef struct CM_BRIDGED_TYPE(id) OpaqueCMBlockBuffer *CMBlockBufferRef;
typedef struct CM_BRIDGED_TYPE(id) opaqueCMBufferQueue *CMBufferQueueRef;
typedef struct CM_BRIDGED_TYPE(id) OpaqueCMClock* CMClockRef;
typedef const struct CM_BRIDGED_TYPE(id) opaqueCMFormatDescription *CMFormatDescriptionRef;
typedef struct CM_BRIDGED_TYPE(id) opaqueCMSampleBuffer *CMSampleBufferRef;
typedef struct CM_BRIDGED_TYPE(id) opaqueCMSimpleQueue *CMSimpleQueueRef;
typedef struct CM_BRIDGED_TYPE(id) OpaqueCMTimebase* CMTimebaseRef;

#define INIT_REFERENCING(Type, availability) \
CM_INLINE CM_RETURNS_RETAINED_PARAMETER Type##Ref CM_NONNULL \
Type##Retain( \
Type##Ref CM_NONNULL object) \
CF_SWIFT_NAME(Type.init(referencing:)) \
CF_REFINED_FOR_SWIFT \
availability ;\
CM_INLINE CM_RETURNS_RETAINED_PARAMETER Type##Ref CM_NONNULL \
Type##Retain( \
Type##Ref CM_NONNULL object) \
{ \
return (Type##Ref)CFRetain(object);\
}

INIT_REFERENCING(CMClock, API_AVAILABLE(macosx(10.8)) API_UNAVAILABLE(ios, tvos, watchos))

INIT_REFERENCING(CMBlockBuffer, API_AVAILABLE(macos(10.7), ios(4.0), tvos(9.0), watchos(6.0)))

INIT_REFERENCING(CMBufferQueue, API_AVAILABLE(macos(10.7), ios(4.0), tvos(9.0), watchos(6.0)))

INIT_REFERENCING(CMFormatDescription, API_AVAILABLE(macos(10.7), ios(4.0), tvos(9.0), watchos(6.0)))

INIT_REFERENCING(CMSampleBuffer, API_AVAILABLE(macos(10.7), ios(4.0), tvos(9.0), watchos(6.0)))

INIT_REFERENCING(CMSimpleQueue, API_AVAILABLE(macos(10.7), ios(4.0), tvos(9.0), watchos(6.0)))

INIT_REFERENCING(CMTimebase, API_AVAILABLE(macos(10.7), ios(4.0), tvos(9.0), watchos(6.0)))

#if __has_feature(nullability)
#pragma clang assume_nonnull end
#endif


#endif // SWIFT_STDLIB_SHIMS_COREMEDIA_OVERLAY_H
4 changes: 4 additions & 0 deletions stdlib/public/SwiftShims/module.modulemap
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,7 @@ module _SwiftNetworkOverlayShims {
module _SwiftClockKitOverlayShims {
header "ClockKitOverlayShims.h"
}

module _SwiftCoreMediaOverlayShims {
header "CoreMediaOverlayShims.h"
}