Remove pre-Sierra-OS-specific code in WebCore
[WebKit-https.git] / Source / WebCore / PAL / pal / spi / mac / AVFoundationSPI.h
1 /*
2  * Copyright (C) 2015-2016 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 #pragma once
27
28 #import <objc/runtime.h>
29 #import <wtf/SoftLinking.h>
30
31 #if USE(APPLE_INTERNAL_SDK)
32
33 #import <AVFoundation/AVAssetCache_Private.h>
34 #import <AVFoundation/AVOutputContext.h>
35 #import <AVFoundation/AVPlayerItem_Private.h>
36 #import <AVFoundation/AVPlayerLayer_Private.h>
37 #import <AVFoundation/AVPlayer_Private.h>
38
39 #if PLATFORM(IOS) && HAVE(AVKIT)
40 #import <AVKit/AVPlayerViewController_WebKitOnly.h>
41 #endif
42
43 #if !PLATFORM(IOS)
44 #import <AVFoundation/AVStreamDataParser.h>
45 #endif
46
47 #else
48
49 #import <AVFoundation/AVPlayer.h>
50 #import <AVFoundation/AVPlayerItem.h>
51
52 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101300) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000)
53 NS_ASSUME_NONNULL_BEGIN
54 @interface AVPlayerItem ()
55 @property (nonatomic, readonly) NSTimeInterval seekableTimeRangesLastModifiedTime NS_AVAILABLE(10_13, 11_0);
56 @property (nonatomic, readonly) NSTimeInterval liveUpdateInterval;
57 @end
58 NS_ASSUME_NONNULL_END
59 #endif // (PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101300) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000)
60
61 #if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS)
62
63 NS_ASSUME_NONNULL_BEGIN
64
65 @class AVOutputContext;
66 @interface AVOutputContext : NSObject <NSSecureCoding>
67 @property (nonatomic, readonly) NSString *deviceName;
68 + (instancetype)outputContext;
69 @end
70
71 @interface AVPlayer (AVPlayerExternalPlaybackSupportPrivate)
72 @property (nonatomic, retain) AVOutputContext *outputContext;
73 @end
74
75 NS_ASSUME_NONNULL_END
76
77 #endif // ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS)
78
79 #import <AVFoundation/AVAssetCache.h>
80 NS_ASSUME_NONNULL_BEGIN
81 @interface AVAssetCache ()
82 + (AVAssetCache *)assetCacheWithURL:(NSURL *)URL;
83 - (id)initWithURL:(NSURL *)URL;
84 - (NSArray *)allKeys;
85 - (NSDate *)lastModifiedDateOfEntryForKey:(NSString *)key;
86 - (void)removeEntryForKey:(NSString *)key;
87 @property (nonatomic, readonly, copy) NSURL *URL;
88 @end
89 NS_ASSUME_NONNULL_END
90
91 #if PLATFORM(IOS) && !PLATFORM(IOS_SIMULATOR)
92 @interface AVPlayer (AVPlayerVideoSleepPrevention)
93 @property (nonatomic, getter=_preventsSleepDuringVideoPlayback, setter=_setPreventsSleepDuringVideoPlayback:) BOOL preventsSleepDuringVideoPlayback;
94 @end
95
96 #endif // PLATFORM(IOS) && !PLATFORM(IOS_SIMULATOR)
97
98 #if PLATFORM(IOS)
99 typedef NS_ENUM(NSInteger, AVPlayerExternalPlaybackType) {
100     AVPlayerExternalPlaybackTypeNone,
101     AVPlayerExternalPlaybackTypeAirPlay,
102     AVPlayerExternalPlaybackTypeTVOut,
103 };
104
105 @interface AVPlayer (AVPlayerExternalPlaybackSupportPrivate)
106 @property (nonatomic, readonly) AVPlayerExternalPlaybackType externalPlaybackType;
107 @end
108 #endif
109
110 #if !PLATFORM(IOS)
111
112 #pragma mark -
113 #pragma mark AVStreamDataParser
114
115 @protocol AVStreamDataParserOutputHandling <NSObject>
116 @end
117
118 typedef int32_t CMPersistentTrackID;
119
120 NS_ASSUME_NONNULL_BEGIN
121 typedef NS_ENUM(NSUInteger, AVStreamDataParserOutputMediaDataFlags) {
122     AVStreamDataParserOutputMediaDataReserved = 1 << 0
123 };
124
125 typedef NS_ENUM(NSUInteger, AVStreamDataParserStreamDataFlags) {
126     AVStreamDataParserStreamDataDiscontinuity = 1 << 0,
127 };
128
129 @interface AVStreamDataParser : NSObject
130 - (void)setDelegate:(nullable id<AVStreamDataParserOutputHandling>)delegate;
131 - (void)appendStreamData:(NSData *)data;
132 - (void)appendStreamData:(NSData *)data withFlags:(AVStreamDataParserStreamDataFlags)flags;
133 - (void)setShouldProvideMediaData:(BOOL)shouldProvideMediaData forTrackID:(CMPersistentTrackID)trackID;
134 - (BOOL)shouldProvideMediaDataForTrackID:(CMPersistentTrackID)trackID;
135 - (void)providePendingMediaData;
136 - (void)processContentKeyResponseData:(NSData *)contentKeyResponseData forTrackID:(CMPersistentTrackID)trackID;
137 - (void)processContentKeyResponseError:(NSError *)error forTrackID:(CMPersistentTrackID)trackID;
138 - (void)renewExpiringContentKeyResponseDataForTrackID:(CMPersistentTrackID)trackID;
139 - (NSData *)streamingContentKeyRequestDataForApp:(NSData *)appIdentifier contentIdentifier:(NSData *)contentIdentifier trackID:(CMPersistentTrackID)trackID options:(NSDictionary *)options error:(NSError **)outError;
140 @end
141
142 NS_ASSUME_NONNULL_END
143
144 #if HAVE(AVCONTENTKEYSESSION)
145 #import <AVFoundation/AVContentKeySession.h>
146 @interface AVStreamDataParser () <AVContentKeyRecipient>
147 @end
148 #endif
149
150 #endif // !PLATFORM(IOS)
151 #endif // USE(APPLE_INTERNAL_SDK)
152
153 #if PLATFORM(MAC) && !USE(APPLE_INTERNAL_SDK)
154 NS_ASSUME_NONNULL_BEGIN
155 @interface AVStreamDataParser (AVStreamDataParserPrivate)
156 + (NSString *)outputMIMECodecParameterForInputMIMECodecParameter:(NSString *)inputMIMECodecParameter;
157 @end
158 NS_ASSUME_NONNULL_END
159 #endif
160
161 #if PLATFORM(IOS) && (!HAVE(AVKIT) || !USE(APPLE_INTERNAL_SDK))
162 #import <AVFoundation/AVPlayerLayer.h>
163 @interface AVPlayerLayer (AVPlayerLayerPictureInPictureModeSupportPrivate)
164 - (void)setPIPModeEnabled:(BOOL)flag;
165 @end
166 #endif // !HAVE(AVKIT)
167
168
169 // FIXME: Wrap in a #if USE(APPLE_INTERNAL_SDK) once these SPI land
170 #import <AVFoundation/AVAsset.h>
171 #import <AVFoundation/AVAssetResourceLoader.h>
172
173 NS_ASSUME_NONNULL_BEGIN
174
175 @interface AVAssetResourceLoader (AVAssetResourceLoaderPrivate)
176 @property (nonatomic, readonly) id<NSURLSessionDataDelegate> URLSessionDataDelegate;
177 @property (nonatomic, readonly) NSOperationQueue *URLSessionDataDelegateQueue;
178 @property (nonatomic, nullable, retain) NSURLSession *URLSession;
179 @end
180
181 @interface AVAsset (AVAssetFragmentsPrivate)
182 @property (nonatomic, readonly) CMTime overallDurationHint;
183 @end
184
185 NS_ASSUME_NONNULL_END
186
187 #import <CoreMedia/CMSampleBuffer.h>
188 #import <CoreMedia/CMSync.h>
189
190 #if __has_include(<AVFoundation/AVSampleBufferRenderSynchronizer.h>)
191 #import <AVFoundation/AVSampleBufferRenderSynchronizer.h>
192
193 NS_ASSUME_NONNULL_BEGIN
194 @interface AVSampleBufferRenderSynchronizer (AVSampleBufferRenderSynchronizerPrivate)
195 - (void)removeRenderer:(id)renderer atTime:(CMTime)time withCompletionHandler:(void (^)(BOOL didRemoveRenderer))completionHandler;
196 @end
197 NS_ASSUME_NONNULL_END
198
199 #else
200
201 NS_ASSUME_NONNULL_BEGIN
202
203 @interface AVSampleBufferRenderSynchronizer : NSObject
204 - (CMTimebaseRef)timebase;
205 - (float)rate;
206 - (void)setRate:(float)rate;
207 - (void)setRate:(float)rate time:(CMTime)time;
208 - (NSArray *)renderers;
209 - (void)addRenderer:(id)renderer;
210 - (void)removeRenderer:(id)renderer atTime:(CMTime)time withCompletionHandler:(void (^)(BOOL didRemoveRenderer))completionHandler;
211 - (id)addPeriodicTimeObserverForInterval:(CMTime)interval queue:(dispatch_queue_t)queue usingBlock:(void (^)(CMTime time))block;
212 - (id)addBoundaryTimeObserverForTimes:(NSArray *)times queue:(dispatch_queue_t)queue usingBlock:(void (^)(void))block;
213 - (void)removeTimeObserver:(id)observer;
214 @end
215
216 NS_ASSUME_NONNULL_END
217
218 #endif // __has_include(<AVFoundation/AVSampleBufferRenderSynchronizer.h>)
219
220 #if ((PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED < 101300) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MAX_ALLOWED < 110000)) && __has_include(<AVFoundation/AVQueuedSampleBufferRendering.h>)
221 #import <AVFoundation/AVQueuedSampleBufferRendering.h>
222 #elif __has_include(<AVFoundation/AVSampleBufferDisplayLayer.h>)
223 #import <AVFoundation/AVSampleBufferDisplayLayer.h>
224 #else
225
226 NS_ASSUME_NONNULL_BEGIN
227
228 #pragma mark -
229 #pragma mark AVSampleBufferDisplayLayer
230
231 @interface AVSampleBufferDisplayLayer : CALayer
232 - (NSInteger)status;
233 - (NSError*)error;
234 - (void)enqueueSampleBuffer:(CMSampleBufferRef)sampleBuffer;
235 - (void)flush;
236 - (void)flushAndRemoveImage;
237 - (BOOL)isReadyForMoreMediaData;
238 - (void)requestMediaDataWhenReadyOnQueue:(dispatch_queue_t)queue usingBlock:(void (^)(void))block;
239 - (void)stopRequestingMediaData;
240 @end
241
242 NS_ASSUME_NONNULL_END
243
244 #endif // __has_include(<AVFoundation/AVSampleBufferDisplayLayer.h>)
245
246 #if ((PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED < 101300) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MAX_ALLOWED < 110000)) && __has_include(<AVFoundation/AVQueuedSampleBufferRendering.h>)
247 // Nothing to do, AVfoundation/AVQueuedSampleBufferRendering.h was imported above.
248 #elif __has_include(<AVFoundation/AVSampleBufferAudioRenderer.h>)
249 #import <AVFoundation/AVSampleBufferAudioRenderer.h>
250 #else
251
252 NS_ASSUME_NONNULL_BEGIN
253
254 @interface AVSampleBufferAudioRenderer : NSObject
255 - (NSInteger)status;
256 - (NSError*)error;
257 - (void)enqueueSampleBuffer:(CMSampleBufferRef)sampleBuffer;
258 - (void)flush;
259 - (BOOL)isReadyForMoreMediaData;
260 - (void)requestMediaDataWhenReadyOnQueue:(dispatch_queue_t)queue usingBlock:(void (^)(void))block;
261 - (void)stopRequestingMediaData;
262 - (void)setVolume:(float)volume;
263 - (void)setMuted:(BOOL)muted;
264 @property (nonatomic, copy) NSString *audioTimePitchAlgorithm;
265 @end
266
267 NS_ASSUME_NONNULL_END
268
269 #endif // __has_include(<AVFoundation/AVSampleBufferAudioRenderer.h>)