Check for the existence of AVSampleBufferAudioRenderer.h before redeclaring AVSampleB...
[WebKit-https.git] / Source / WebCore / platform / 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 "SoftLinking.h"
29 #import <objc/runtime.h>
30
31 #if USE(APPLE_INTERNAL_SDK)
32
33 #import <AVFoundation/AVAssetCache_Private.h>
34 #import <AVFoundation/AVOutputContext.h>
35 #import <AVFoundation/AVPlayerLayer_Private.h>
36 #import <AVFoundation/AVPlayer_Private.h>
37
38 #if PLATFORM(IOS) && HAVE(AVKIT)
39 #import <AVKit/AVPlayerViewController_WebKitOnly.h>
40 #endif
41
42 #if !PLATFORM(IOS)
43 #import <AVFoundation/AVStreamDataParser.h>
44 #endif
45
46 #else
47
48 #import <AVFoundation/AVPlayer.h>
49
50 #if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS)
51
52 NS_ASSUME_NONNULL_BEGIN
53
54 @class AVOutputContext;
55 @interface AVOutputContext : NSObject <NSSecureCoding>
56 @property (nonatomic, readonly) NSString *deviceName;
57 + (instancetype)outputContext;
58 @end
59
60 @interface AVPlayer (AVPlayerExternalPlaybackSupportPrivate)
61 @property (nonatomic, retain) AVOutputContext *outputContext;
62 @end
63
64 NS_ASSUME_NONNULL_END
65
66 #endif // ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS)
67
68 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101200) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 100000)
69 #import <AVFoundation/AVAssetCache.h>
70 #else
71 @interface AVAssetCache : NSObject
72 @end
73 #endif
74 NS_ASSUME_NONNULL_BEGIN
75 @interface AVAssetCache ()
76 + (AVAssetCache *)assetCacheWithURL:(NSURL *)URL;
77 - (id)initWithURL:(NSURL *)URL;
78 - (NSArray *)allKeys;
79 - (NSDate *)lastModifiedDateOfEntryForKey:(NSString *)key;
80 - (void)removeEntryForKey:(NSString *)key;
81 @property (nonatomic, readonly, copy) NSURL *URL;
82 @end
83 NS_ASSUME_NONNULL_END
84
85 #if PLATFORM(IOS) && !PLATFORM(IOS_SIMULATOR)
86 @interface AVPlayer (AVPlayerVideoSleepPrevention)
87 @property (nonatomic, getter=_preventsSleepDuringVideoPlayback, setter=_setPreventsSleepDuringVideoPlayback:) BOOL preventsSleepDuringVideoPlayback;
88 @end
89
90 #endif // PLATFORM(IOS) && !PLATFORM(IOS_SIMULATOR)
91
92 #if !PLATFORM(IOS)
93
94 #pragma mark -
95 #pragma mark AVStreamDataParser
96
97 @protocol AVStreamDataParserOutputHandling <NSObject>
98 @end
99
100 typedef int32_t CMPersistentTrackID;
101
102 NS_ASSUME_NONNULL_BEGIN
103 typedef NS_ENUM(NSUInteger, AVStreamDataParserOutputMediaDataFlags) {
104     AVStreamDataParserOutputMediaDataReserved = 1 << 0
105 };
106
107 typedef NS_ENUM(NSUInteger, AVStreamDataParserStreamDataFlags) {
108     AVStreamDataParserStreamDataDiscontinuity = 1 << 0,
109 };
110
111 @interface AVStreamDataParser : NSObject
112 - (void)setDelegate:(nullable id<AVStreamDataParserOutputHandling>)delegate;
113 - (void)appendStreamData:(NSData *)data;
114 - (void)appendStreamData:(NSData *)data withFlags:(AVStreamDataParserStreamDataFlags)flags;
115 - (void)setShouldProvideMediaData:(BOOL)shouldProvideMediaData forTrackID:(CMPersistentTrackID)trackID;
116 - (BOOL)shouldProvideMediaDataForTrackID:(CMPersistentTrackID)trackID;
117 - (void)providePendingMediaData;
118 - (void)processContentKeyResponseData:(NSData *)contentKeyResponseData forTrackID:(CMPersistentTrackID)trackID;
119 - (void)processContentKeyResponseError:(NSError *)error forTrackID:(CMPersistentTrackID)trackID;
120 - (void)renewExpiringContentKeyResponseDataForTrackID:(CMPersistentTrackID)trackID;
121 - (NSData *)streamingContentKeyRequestDataForApp:(NSData *)appIdentifier contentIdentifier:(NSData *)contentIdentifier trackID:(CMPersistentTrackID)trackID options:(NSDictionary *)options error:(NSError **)outError;
122 @end
123
124 NS_ASSUME_NONNULL_END
125
126 #endif // !PLATFORM(IOS)
127 #endif // USE(APPLE_INTERNAL_SDK)
128
129 #if PLATFORM(MAC) && (!USE(APPLE_INTERNAL_SDK) || __MAC_OS_X_VERSION_MIN_REQUIRED < 101200)
130 NS_ASSUME_NONNULL_BEGIN
131 @interface AVStreamDataParser (AVStreamDataParserPrivate)
132 + (NSString *)outputMIMECodecParameterForInputMIMECodecParameter:(NSString *)inputMIMECodecParameter;
133 @end
134 NS_ASSUME_NONNULL_END
135 #endif
136
137 #if PLATFORM(IOS) && (!HAVE(AVKIT) || !USE(APPLE_INTERNAL_SDK))
138 #import <AVFoundation/AVPlayerLayer.h>
139 @interface AVPlayerLayer (AVPlayerLayerPictureInPictureModeSupportPrivate)
140 - (void)setPIPModeEnabled:(BOOL)flag;
141 @end
142 #endif // !HAVE(AVKIT)
143
144
145 // FIXME: Wrap in a #if USE(APPLE_INTERNAL_SDK) once these SPI land
146 #import <AVFoundation/AVAsset.h>
147 #import <AVFoundation/AVAssetResourceLoader.h>
148
149 NS_ASSUME_NONNULL_BEGIN
150
151 @interface AVAssetResourceLoader (AVAssetResourceLoaderPrivate)
152 @property (nonatomic, readonly) id<NSURLSessionDataDelegate> URLSessionDataDelegate;
153 @property (nonatomic, readonly) NSOperationQueue *URLSessionDataDelegateQueue;
154 @property (nonatomic, nullable, retain) NSURLSession *URLSession;
155 @end
156
157 @interface AVAsset (AVAssetFragmentsPrivate)
158 @property (nonatomic, readonly) CMTime overallDurationHint;
159 @end
160
161 NS_ASSUME_NONNULL_END
162
163 #import <CoreMedia/CMSampleBuffer.h>
164 #import <CoreMedia/CMSync.h>
165
166 NS_ASSUME_NONNULL_BEGIN
167
168 @interface AVSampleBufferRenderSynchronizer : NSObject
169 - (CMTimebaseRef)timebase;
170 - (float)rate;
171 - (void)setRate:(float)rate;
172 - (void)setRate:(float)rate time:(CMTime)time;
173 - (NSArray *)renderers;
174 - (void)addRenderer:(id)renderer;
175 - (void)removeRenderer:(id)renderer atTime:(CMTime)time withCompletionHandler:(void (^)(BOOL didRemoveRenderer))completionHandler;
176 - (id)addPeriodicTimeObserverForInterval:(CMTime)interval queue:(dispatch_queue_t)queue usingBlock:(void (^)(CMTime time))block;
177 - (id)addBoundaryTimeObserverForTimes:(NSArray *)times queue:(dispatch_queue_t)queue usingBlock:(void (^)(void))block;
178 - (void)removeTimeObserver:(id)observer;
179 @end
180
181 NS_ASSUME_NONNULL_END
182
183 #if __has_include("AVSampleBufferAudioRenderer.h")
184 #import ("AVSampleBufferAudioRenderer")
185 #else
186
187 NS_ASSUME_NONNULL_BEGIN
188
189 @interface AVSampleBufferAudioRenderer : NSObject
190 - (NSInteger)status;
191 - (NSError*)error;
192 - (void)enqueueSampleBuffer:(CMSampleBufferRef)sampleBuffer;
193 - (void)flush;
194 - (BOOL)isReadyForMoreMediaData;
195 - (void)requestMediaDataWhenReadyOnQueue:(dispatch_queue_t)queue usingBlock:(void (^)(void))block;
196 - (void)stopRequestingMediaData;
197 - (void)setVolume:(float)volume;
198 - (void)setMuted:(BOOL)muted;
199 @property (nonatomic, copy) NSString *audioTimePitchAlgorithm;
200 @end
201
202 #endif // __has_include("AVSampleBufferAudioRenderer.h")
203
204 NS_ASSUME_NONNULL_END