blob: 714794fb3ce354de110da08a419a705dfd9ad171 [file] [log] [blame]
jer.noble@apple.com561e6922016-04-15 17:50:26 +00001/*
2 * Copyright (C) 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. ``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 WebPlaybackSessionInterfaceAVKit_h
28#define WebPlaybackSessionInterfaceAVKit_h
29
30#if PLATFORM(IOS)
31
32#include "EventListener.h"
33#include "HTMLMediaElementEnums.h"
34#include "Timer.h"
35#include "WebPlaybackSessionInterface.h"
36#include <functional>
37#include <objc/objc.h>
38#include <wtf/RefCounted.h>
39#include <wtf/RefPtr.h>
40#include <wtf/RetainPtr.h>
41
42OBJC_CLASS WebAVPlayerController;
43OBJC_CLASS AVPlayerViewController;
44OBJC_CLASS UIViewController;
45OBJC_CLASS UIWindow;
46OBJC_CLASS UIView;
47
48namespace WTF {
49class String;
50}
51
52namespace WebCore {
53class IntRect;
54class WebPlaybackSessionModel;
55class WebPlaybackSessionChangeObserver;
56
57class WebPlaybackSessionInterfaceAVKitClient {
58public:
59 virtual ~WebPlaybackSessionInterfaceAVKitClient() { }
60
61 virtual void externalPlaybackEnabledChanged(bool) = 0;
62};
63
64class WEBCORE_EXPORT WebPlaybackSessionInterfaceAVKit
65 : public WebPlaybackSessionInterface
66 , public RefCounted<WebPlaybackSessionInterfaceAVKit> {
67
68public:
69 static Ref<WebPlaybackSessionInterfaceAVKit> create()
70 {
71 return adoptRef(*new WebPlaybackSessionInterfaceAVKit());
72 }
73 virtual ~WebPlaybackSessionInterfaceAVKit();
74 WEBCORE_EXPORT void setWebPlaybackSessionModel(WebPlaybackSessionModel*);
jer.noble@apple.comf7a97792016-05-05 23:18:20 +000075 WebPlaybackSessionModel* webPlaybackSessionModel() const { return m_playbackSessionModel; }
jer.noble@apple.com561e6922016-04-15 17:50:26 +000076 void setClient(WebPlaybackSessionInterfaceAVKitClient* client) { m_client = client; }
77
78 WEBCORE_EXPORT void resetMediaState() override;
79 WEBCORE_EXPORT void setDuration(double) override;
80 WEBCORE_EXPORT void setCurrentTime(double currentTime, double anchorTime) override;
81 WEBCORE_EXPORT void setBufferedTime(double) override;
82 WEBCORE_EXPORT void setRate(bool isPlaying, float playbackRate) override;
83 WEBCORE_EXPORT void setSeekableRanges(const TimeRanges&) override;
84 WEBCORE_EXPORT void setCanPlayFastReverse(bool) override;
85 WEBCORE_EXPORT void setAudioMediaSelectionOptions(const Vector<WTF::String>& options, uint64_t selectedIndex) override;
86 WEBCORE_EXPORT void setLegibleMediaSelectionOptions(const Vector<WTF::String>& options, uint64_t selectedIndex) override;
87 WEBCORE_EXPORT void setExternalPlayback(bool enabled, ExternalPlaybackTargetType, WTF::String localizedDeviceName) override;
88 WEBCORE_EXPORT void setWirelessVideoPlaybackDisabled(bool) override;
89 bool wirelessVideoPlaybackDisabled() const;
90
91 WEBCORE_EXPORT virtual void invalidate();
92
93 WebAVPlayerController *playerController() const { return m_playerController.get(); }
94
95protected:
96 WEBCORE_EXPORT WebPlaybackSessionInterfaceAVKit();
97
98 RetainPtr<WebAVPlayerController> m_playerController;
99 WebPlaybackSessionModel* m_playbackSessionModel { nullptr };
100 WebPlaybackSessionInterfaceAVKitClient* m_client { nullptr};
101
102 bool m_wirelessVideoPlaybackDisabled { true };
103};
104
105}
106
107#endif
108
109#endif