cc7189c744e09ec0ad033b5af7594e0dd61d77e7
[WebKit-https.git] / Source / WebCore / platform / spi / cocoa / AVKitSPI.h
1 /*
2  * Copyright (C) 2014, 2015 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 #import "SoftLinking.h"
27 #import <objc/runtime.h>
28
29 #if PLATFORM(IOS)
30 #import <AVKit/AVKit.h>
31 #import <QuartzCore/QuartzCore.h>
32 #import <UIKit/UIKit.h>
33
34 #if USE(APPLE_INTERNAL_SDK)
35
36 #import <AVKit/AVPlayerController.h>
37 #pragma clang diagnostic push
38 #pragma clang diagnostic ignored "-Wobjc-property-no-attribute"
39 #import <AVKit/AVPlayerLayerView.h>
40 #pragma clang diagnostic pop
41 #import <AVKit/AVPlayerViewController_Private.h>
42 #import <AVKit/AVPlayerViewController_WebKitOnly.h>
43
44 #else
45
46 @interface AVPlayerController : UIResponder
47 @end
48
49 @interface AVPlayerController (Details)
50 typedef NS_ENUM(NSInteger, AVPlayerControllerStatus) {
51     AVPlayerControllerStatusUnknown = 0,
52     AVPlayerControllerStatusReadyToPlay = 2,
53 };
54
55 typedef NS_ENUM(NSInteger, AVPlayerControllerExternalPlaybackType) {
56     AVPlayerControllerExternalPlaybackTypeNone = 0,
57     AVPlayerControllerExternalPlaybackTypeAirPlay = 1,
58     AVPlayerControllerExternalPlaybackTypeTVOut = 2,
59 };
60
61 @property (NS_NONATOMIC_IOSONLY, readonly) AVPlayerControllerStatus status;
62 @end
63
64 @class AVPlayerLayer;
65
66 @interface AVPictureInPicturePlayerLayerView : UIView
67 @property (nonatomic, readonly) AVPlayerLayer *playerLayer;
68 @end
69
70 @interface AVPlayerLayerView : UIView
71 @property (nonatomic, readonly) AVPlayerLayer *playerLayer;
72 @property (nonatomic, readonly) AVPictureInPicturePlayerLayerView *pictureInPicturePlayerLayerView;
73 - (void)startRoutingVideoToPictureInPicturePlayerLayerView;
74 - (void)stopRoutingVideoToPictureInPicturePlayerLayerView;
75 @end
76
77 @protocol AVPlayerViewControllerDelegate <NSObject>
78 @optional
79 typedef NS_ENUM(NSInteger, AVPlayerViewControllerExitFullScreenReason) {
80     AVPlayerViewControllerExitFullScreenReasonDoneButtonTapped,
81     AVPlayerViewControllerExitFullScreenReasonFullScreenButtonTapped,
82     AVPlayerViewControllerExitFullScreenReasonPinchGestureHandled,
83     AVPlayerViewControllerExitFullScreenReasonRemoteControlStopEventReceived,
84     AVPlayerViewControllerExitFullScreenReasonPictureInPictureStarted
85 };
86 - (BOOL)playerViewController:(AVPlayerViewController *)playerViewController shouldExitFullScreenWithReason:(AVPlayerViewControllerExitFullScreenReason)reason;
87 - (void)playerViewController:(AVPlayerViewController *)playerViewController restoreUserInterfaceForPictureInPictureStopWithCompletionHandler:(void (^)(BOOL restored))completionHandler;
88 @end
89
90 @interface AVPlayerViewController (Details)
91 - (instancetype)initWithPlayerLayerView:(AVPlayerLayerView *)playerLayerView;
92 - (void)enterFullScreenAnimated:(BOOL)animated completionHandler:(void (^)(BOOL success, NSError *))completionHandler;
93 - (void)exitFullScreenAnimated:(BOOL)animated completionHandler:(void (^)(BOOL success, NSError *))completionHandler;
94
95 - (BOOL)isPictureInPicturePossible;
96 - (void)startPictureInPicture;
97 - (void)stopPictureInPicture;
98
99 @property (nonatomic) BOOL allowsPictureInPicturePlayback;
100 @property (nonatomic, strong) AVPlayerController *playerController;
101 @property (nonatomic, weak) id <AVPlayerViewControllerDelegate> delegate;
102 @end
103
104 #endif // USE(APPLE_INTERNAL_SDK)
105
106 #if USE(APPLE_INTERNAL_SDK) && __IPHONE_OS_VERSION_MIN_REQUIRED < 90000
107
108 #import <AVKit/AVValueTiming.h>
109
110 #else
111
112 @interface AVValueTiming : NSObject <NSCoding, NSCopying, NSMutableCopying>
113 @end
114
115 @interface AVValueTiming (Details)
116 + (AVValueTiming *)valueTimingWithAnchorValue:(double)anchorValue anchorTimeStamp:(NSTimeInterval)timeStamp rate:(double)rate;
117 @property (NS_NONATOMIC_IOSONLY, readonly) double currentValue;
118 @end
119
120 #endif
121
122 #endif // PLATFORM(IOS)
123
124 #if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS)
125
126 #if USE(APPLE_INTERNAL_SDK)
127
128 #import <AVKit/AVOutputDeviceMenuController.h>
129
130 #else
131
132 @class AVOutputContext;
133
134 NS_CLASS_AVAILABLE_MAC(10_11)
135 @interface AVOutputDeviceMenuController : NSObject
136
137 - (instancetype)initWithOutputContext:(AVOutputContext *)outputContext NS_DESIGNATED_INITIALIZER;
138
139 @property (readonly) AVOutputContext *outputContext;
140 @property (readonly, getter=isExternalOutputDeviceAvailable) BOOL externalOutputDeviceAvailable;
141 @property (readonly, getter=isExternalOutputDevicePicked) BOOL externalOutputDevicePicked;
142
143 - (void)showMenuForRect:(NSRect)screenRect appearanceName:(NSString *)appearanceName;
144 - (BOOL)showMenuForRect:(NSRect)screenRect appearanceName:(NSString *)appearanceName allowReselectionOfSelectedOutputDevice:(BOOL)allowReselectionOfSelectedOutputDevice;
145
146 @end
147
148
149 #endif
150
151 #endif