Remove "virtual" from all lines that have both "virtual" and "override".
[WebKit-https.git] / Source / WebCore / platform / ios / WebVideoFullscreenInterfaceAVKit.h
1 /*
2  * Copyright (C) 2014 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. ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26
27 #ifndef WebVideoFullscreenInterfaceAVKit_h
28 #define WebVideoFullscreenInterfaceAVKit_h
29
30 #if PLATFORM(IOS)
31
32 #include <WebCore/EventListener.h>
33 #include <WebCore/HTMLMediaElementEnums.h>
34 #include <WebCore/PlatformLayer.h>
35 #include <WebCore/Timer.h>
36 #include <WebCore/WebVideoFullscreenInterface.h>
37 #include <functional>
38 #include <objc/objc.h>
39 #include <wtf/RefCounted.h>
40 #include <wtf/RefPtr.h>
41 #include <wtf/RetainPtr.h>
42
43 OBJC_CLASS WebAVPlayerController;
44 OBJC_CLASS AVPlayerViewController;
45 OBJC_CLASS UIViewController;
46 OBJC_CLASS UIWindow;
47 OBJC_CLASS UIView;
48 OBJC_CLASS CALayer;
49 OBJC_CLASS WebAVPlayerLayerView;
50 OBJC_CLASS WebAVPlayerLayer;
51
52 namespace WTF {
53 class String;
54 }
55
56 namespace WebCore {
57 class IntRect;
58 class WebVideoFullscreenModel;
59 class WebVideoFullscreenChangeObserver;
60     
61 class WEBCORE_EXPORT WebVideoFullscreenInterfaceAVKit
62     : public WebVideoFullscreenInterface
63     , public RefCounted<WebVideoFullscreenInterfaceAVKit> {
64
65 public:
66     static Ref<WebVideoFullscreenInterfaceAVKit> create()
67     {
68         return adoptRef(*new WebVideoFullscreenInterfaceAVKit());
69     }
70     virtual ~WebVideoFullscreenInterfaceAVKit();
71     WEBCORE_EXPORT void setWebVideoFullscreenModel(WebVideoFullscreenModel*);
72     WEBCORE_EXPORT void setWebVideoFullscreenChangeObserver(WebVideoFullscreenChangeObserver*);
73     
74     WEBCORE_EXPORT void resetMediaState() override;
75     WEBCORE_EXPORT void setDuration(double) override;
76     WEBCORE_EXPORT void setCurrentTime(double currentTime, double anchorTime) override;
77     WEBCORE_EXPORT void setBufferedTime(double bufferedTime) override;
78     WEBCORE_EXPORT void setRate(bool isPlaying, float playbackRate) override;
79     WEBCORE_EXPORT void setVideoDimensions(bool hasVideo, float width, float height) override;
80     WEBCORE_EXPORT void setSeekableRanges(const TimeRanges&) override;
81     WEBCORE_EXPORT void setCanPlayFastReverse(bool) override;
82     WEBCORE_EXPORT void setAudioMediaSelectionOptions(const Vector<WTF::String>& options, uint64_t selectedIndex) override;
83     WEBCORE_EXPORT void setLegibleMediaSelectionOptions(const Vector<WTF::String>& options, uint64_t selectedIndex) override;
84     WEBCORE_EXPORT void setExternalPlayback(bool enabled, ExternalPlaybackTargetType, WTF::String localizedDeviceName) override;
85     WEBCORE_EXPORT void setWirelessVideoPlaybackDisabled(bool) override;
86
87     WEBCORE_EXPORT virtual void setupFullscreen(UIView&, const IntRect& initialRect, UIView *, HTMLMediaElementEnums::VideoFullscreenMode, bool allowsPictureInPicturePlayback);
88     WEBCORE_EXPORT virtual void enterFullscreen();
89     WEBCORE_EXPORT virtual void exitFullscreen(const IntRect& finalRect);
90     WEBCORE_EXPORT virtual void cleanupFullscreen();
91     WEBCORE_EXPORT virtual void invalidate();
92     WEBCORE_EXPORT virtual void requestHideAndExitFullscreen();
93     WEBCORE_EXPORT virtual void preparedToReturnToInline(bool visible, const IntRect& inlineRect);
94
95     enum class ExitFullScreenReason {
96         DoneButtonTapped,
97         FullScreenButtonTapped,
98         PinchGestureHandled,
99         RemoteControlStopEventReceived,
100         PictureInPictureStarted
101     };
102
103     bool shouldExitFullscreenWithReason(ExitFullScreenReason);
104     HTMLMediaElementEnums::VideoFullscreenMode mode() const { return m_mode; }
105     bool allowsPictureInPicturePlayback() const { return m_allowsPictureInPicturePlayback; }
106     WEBCORE_EXPORT bool mayAutomaticallyShowVideoPictureInPicture() const;
107     void fullscreenMayReturnToInline(std::function<void(bool)> callback);
108     bool wirelessVideoPlaybackDisabled() const;
109     void applicationDidBecomeActive();
110
111     void willStartPictureInPicture();
112     void didStartPictureInPicture();
113     void failedToStartPictureInPicture();
114     void willStopPictureInPicture();
115     void didStopPictureInPicture();
116     void prepareForPictureInPictureStopWithCompletionHandler(void (^)(BOOL));
117
118     void setMode(HTMLMediaElementEnums::VideoFullscreenMode);
119     void clearMode(HTMLMediaElementEnums::VideoFullscreenMode);
120     bool hasMode(HTMLMediaElementEnums::VideoFullscreenMode mode) const { return m_mode & mode; }
121     bool isMode(HTMLMediaElementEnums::VideoFullscreenMode mode) const { return m_mode == mode; }
122
123 protected:
124     WEBCORE_EXPORT WebVideoFullscreenInterfaceAVKit();
125     void beginSession();
126     void enterPictureInPicture();
127     void enterFullscreenStandard();
128     void watchdogTimerFired();
129
130     RetainPtr<WebAVPlayerController> m_playerController;
131     RetainPtr<AVPlayerViewController> m_playerViewController;
132     WebVideoFullscreenModel* m_videoFullscreenModel { nullptr };
133     WebVideoFullscreenChangeObserver* m_fullscreenChangeObserver { nullptr };
134
135     // These are only used when fullscreen is presented in a separate window.
136     RetainPtr<UIWindow> m_window;
137     RetainPtr<UIViewController> m_viewController;
138     RetainPtr<UIView> m_parentView;
139     RetainPtr<UIWindow> m_parentWindow;
140     RetainPtr<WebAVPlayerLayerView> m_playerLayerView;
141     HTMLMediaElementEnums::VideoFullscreenMode m_mode { HTMLMediaElementEnums::VideoFullscreenModeNone };
142     std::function<void(bool)> m_prepareToInlineCallback;
143     Timer m_watchdogTimer;
144     bool m_allowsPictureInPicturePlayback { false };
145     bool m_exitRequested { false };
146     bool m_exitCompleted { false };
147     bool m_enterRequested { false };
148     bool m_wirelessVideoPlaybackDisabled { true };
149     bool m_shouldReturnToFullscreenWhenStoppingPiP { false };
150     bool m_shouldReturnToFullscreenAfterEnteringForeground { false };
151
152     void doEnterFullscreen();
153 };
154
155 }
156
157 #endif
158
159 #endif