| Differences between
and this patch
- a/Source/WebKit/ChangeLog +183 lines
Lines 1-3 a/Source/WebKit/ChangeLog_sec1
1
2020-06-24  David Kilzer  <ddkilzer@apple.com>
2
3
        Use ObjectIdentifier<> instead of uint64_t for context IDs in VideoFullscreenManagerProxy
4
        <https://webkit.org/b/212392>
5
        <rdar://problem/61799040>
6
7
        Reviewed by Youenn Fablet.
8
9
        Switch from uint64_t to WebKit::PlaybackSessionContextIdentifier
10
        for contextId values.
11
12
        * Scripts/webkit/messages.py:
13
        (types_that_cannot_be_forward_declared):
14
        - Add WebKit::PlaybackSessionContextIdentifier to list.
15
        * UIProcess/Cocoa/PlaybackSessionManagerProxy.h:
16
        (WebKit::PlaybackSessionManagerProxy::controlsManagerContextId const):
17
        * UIProcess/Cocoa/PlaybackSessionManagerProxy.messages.in:
18
        * UIProcess/Cocoa/PlaybackSessionManagerProxy.mm:
19
        (WebKit::PlaybackSessionManagerProxy::createModelAndInterface):
20
        (WebKit::PlaybackSessionManagerProxy::ensureModelAndInterface):
21
        (WebKit::PlaybackSessionManagerProxy::ensureModel):
22
        (WebKit::PlaybackSessionManagerProxy::ensureInterface):
23
        (WebKit::PlaybackSessionManagerProxy::addClientForContext):
24
        (WebKit::PlaybackSessionManagerProxy::removeClientForContext):
25
        (WebKit::PlaybackSessionManagerProxy::setUpPlaybackControlsManagerWithID):
26
        (WebKit::PlaybackSessionManagerProxy::clearPlaybackControlsManager):
27
        (WebKit::PlaybackSessionManagerProxy::currentTimeChanged):
28
        (WebKit::PlaybackSessionManagerProxy::bufferedTimeChanged):
29
        (WebKit::PlaybackSessionManagerProxy::seekableRangesVectorChanged):
30
        (WebKit::PlaybackSessionManagerProxy::canPlayFastReverseChanged):
31
        (WebKit::PlaybackSessionManagerProxy::audioMediaSelectionOptionsChanged):
32
        (WebKit::PlaybackSessionManagerProxy::legibleMediaSelectionOptionsChanged):
33
        (WebKit::PlaybackSessionManagerProxy::audioMediaSelectionIndexChanged):
34
        (WebKit::PlaybackSessionManagerProxy::legibleMediaSelectionIndexChanged):
35
        (WebKit::PlaybackSessionManagerProxy::externalPlaybackPropertiesChanged):
36
        (WebKit::PlaybackSessionManagerProxy::wirelessVideoPlaybackDisabledChanged):
37
        (WebKit::PlaybackSessionManagerProxy::mutedChanged):
38
        (WebKit::PlaybackSessionManagerProxy::volumeChanged):
39
        (WebKit::PlaybackSessionManagerProxy::durationChanged):
40
        (WebKit::PlaybackSessionManagerProxy::playbackStartedTimeChanged):
41
        (WebKit::PlaybackSessionManagerProxy::rateChanged):
42
        (WebKit::PlaybackSessionManagerProxy::pictureInPictureSupportedChanged):
43
        (WebKit::PlaybackSessionManagerProxy::handleControlledElementIDResponse const):
44
        (WebKit::PlaybackSessionManagerProxy::play):
45
        (WebKit::PlaybackSessionManagerProxy::pause):
46
        (WebKit::PlaybackSessionManagerProxy::togglePlayState):
47
        (WebKit::PlaybackSessionManagerProxy::beginScrubbing):
48
        (WebKit::PlaybackSessionManagerProxy::endScrubbing):
49
        (WebKit::PlaybackSessionManagerProxy::seekToTime):
50
        (WebKit::PlaybackSessionManagerProxy::fastSeek):
51
        (WebKit::PlaybackSessionManagerProxy::beginScanningForward):
52
        (WebKit::PlaybackSessionManagerProxy::beginScanningBackward):
53
        (WebKit::PlaybackSessionManagerProxy::endScanning):
54
        (WebKit::PlaybackSessionManagerProxy::selectAudioMediaOption):
55
        (WebKit::PlaybackSessionManagerProxy::selectLegibleMediaOption):
56
        (WebKit::PlaybackSessionManagerProxy::togglePictureInPicture):
57
        (WebKit::PlaybackSessionManagerProxy::toggleMuted):
58
        (WebKit::PlaybackSessionManagerProxy::setMuted):
59
        (WebKit::PlaybackSessionManagerProxy::setVolume):
60
        (WebKit::PlaybackSessionManagerProxy::setPlayingOnSecondScreen):
61
        - Remove MESSAGE_CHECK_CONTEXTID() since it is now redundant.
62
        * UIProcess/Cocoa/VideoFullscreenManagerProxy.h:
63
        * UIProcess/Cocoa/VideoFullscreenManagerProxy.messages.in:
64
        * UIProcess/Cocoa/VideoFullscreenManagerProxy.mm:
65
        (WebKit::VideoFullscreenModelContext::VideoFullscreenModelContext):
66
        (WebKit::VideoFullscreenManagerProxy::requestRouteSharingPolicyAndContextUID):
67
        (WebKit::VideoFullscreenManagerProxy::createModelAndInterface):
68
        (WebKit::VideoFullscreenManagerProxy::ensureModelAndInterface):
69
        (WebKit::VideoFullscreenManagerProxy::ensureModel):
70
        (WebKit::VideoFullscreenManagerProxy::ensureInterface):
71
        (WebKit::VideoFullscreenManagerProxy::findInterface):
72
        (WebKit::VideoFullscreenManagerProxy::addClientForContext):
73
        (WebKit::VideoFullscreenManagerProxy::removeClientForContext):
74
        (WebKit::VideoFullscreenManagerProxy::setupFullscreenWithID):
75
        (WebKit::VideoFullscreenManagerProxy::setHasVideo):
76
        (WebKit::VideoFullscreenManagerProxy::setVideoDimensions):
77
        (WebKit::VideoFullscreenManagerProxy::enterFullscreen):
78
        (WebKit::VideoFullscreenManagerProxy::exitFullscreen):
79
        (WebKit::VideoFullscreenManagerProxy::exitFullscreenWithoutAnimationToMode):
80
        (WebKit::VideoFullscreenManagerProxy::setInlineRect):
81
        (WebKit::VideoFullscreenManagerProxy::setHasVideoContentLayer):
82
        (WebKit::VideoFullscreenManagerProxy::cleanupFullscreen):
83
        (WebKit::VideoFullscreenManagerProxy::preparedToReturnToInline):
84
        (WebKit::VideoFullscreenManagerProxy::preparedToExitFullscreen):
85
        (WebKit::VideoFullscreenManagerProxy::requestFullscreenMode):
86
        (WebKit::VideoFullscreenManagerProxy::requestUpdateInlineRect):
87
        (WebKit::VideoFullscreenManagerProxy::requestVideoContentLayer):
88
        (WebKit::VideoFullscreenManagerProxy::returnVideoContentLayer):
89
        (WebKit::VideoFullscreenManagerProxy::didSetupFullscreen):
90
        (WebKit::VideoFullscreenManagerProxy::willExitFullscreen):
91
        (WebKit::VideoFullscreenManagerProxy::didExitFullscreen):
92
        (WebKit::VideoFullscreenManagerProxy::didEnterFullscreen):
93
        (WebKit::VideoFullscreenManagerProxy::didCleanupFullscreen):
94
        (WebKit::VideoFullscreenManagerProxy::setVideoLayerFrame):
95
        (WebKit::VideoFullscreenManagerProxy::setVideoLayerGravity):
96
        (WebKit::VideoFullscreenManagerProxy::fullscreenModeChanged):
97
        (WebKit::VideoFullscreenManagerProxy::fullscreenMayReturnToInline):
98
        - Remove MESSAGE_CHECK_CONTEXTID() since it is now redundant.
99
        * WebKit.xcodeproj/project.pbxproj:
100
        - Add PlaybackSessionContextIdentifier.h to the project.
101
        * WebProcess/cocoa/PlaybackSessionContextIdentifier.h: Add.
102
        * WebProcess/cocoa/PlaybackSessionManager.h:
103
        * WebProcess/cocoa/PlaybackSessionManager.messages.in:
104
        * WebProcess/cocoa/PlaybackSessionManager.mm:
105
        (WebKit::PlaybackSessionInterfaceContext::PlaybackSessionInterfaceContext):
106
        (WebKit::PlaybackSessionManager::createModelAndInterface):
107
        (WebKit::PlaybackSessionManager::ensureModelAndInterface):
108
        (WebKit::PlaybackSessionManager::ensureModel):
109
        (WebKit::PlaybackSessionManager::ensureInterface):
110
        (WebKit::PlaybackSessionManager::removeContext):
111
        (WebKit::PlaybackSessionManager::addClientForContext):
112
        (WebKit::PlaybackSessionManager::removeClientForContext):
113
        (WebKit::PlaybackSessionManager::setUpPlaybackControlsManager):
114
        (WebKit::PlaybackSessionManager::clearPlaybackControlsManager):
115
        (WebKit::PlaybackSessionManager::contextIdForMediaElement):
116
        (WebKit::PlaybackSessionManager::durationChanged):
117
        (WebKit::PlaybackSessionManager::currentTimeChanged):
118
        (WebKit::PlaybackSessionManager::bufferedTimeChanged):
119
        (WebKit::PlaybackSessionManager::playbackStartedTimeChanged):
120
        (WebKit::PlaybackSessionManager::rateChanged):
121
        (WebKit::PlaybackSessionManager::seekableRangesChanged):
122
        (WebKit::PlaybackSessionManager::canPlayFastReverseChanged):
123
        (WebKit::PlaybackSessionManager::audioMediaSelectionOptionsChanged):
124
        (WebKit::PlaybackSessionManager::legibleMediaSelectionOptionsChanged):
125
        (WebKit::PlaybackSessionManager::externalPlaybackChanged):
126
        (WebKit::PlaybackSessionManager::audioMediaSelectionIndexChanged):
127
        (WebKit::PlaybackSessionManager::legibleMediaSelectionIndexChanged):
128
        (WebKit::PlaybackSessionManager::wirelessVideoPlaybackDisabledChanged):
129
        (WebKit::PlaybackSessionManager::mutedChanged):
130
        (WebKit::PlaybackSessionManager::volumeChanged):
131
        (WebKit::PlaybackSessionManager::isPictureInPictureSupportedChanged):
132
        (WebKit::PlaybackSessionManager::play):
133
        (WebKit::PlaybackSessionManager::pause):
134
        (WebKit::PlaybackSessionManager::togglePlayState):
135
        (WebKit::PlaybackSessionManager::beginScrubbing):
136
        (WebKit::PlaybackSessionManager::endScrubbing):
137
        (WebKit::PlaybackSessionManager::seekToTime):
138
        (WebKit::PlaybackSessionManager::fastSeek):
139
        (WebKit::PlaybackSessionManager::beginScanningForward):
140
        (WebKit::PlaybackSessionManager::beginScanningBackward):
141
        (WebKit::PlaybackSessionManager::endScanning):
142
        (WebKit::PlaybackSessionManager::selectAudioMediaOption):
143
        (WebKit::PlaybackSessionManager::selectLegibleMediaOption):
144
        (WebKit::PlaybackSessionManager::handleControlledElementIDRequest):
145
        (WebKit::PlaybackSessionManager::togglePictureInPicture):
146
        (WebKit::PlaybackSessionManager::toggleMuted):
147
        (WebKit::PlaybackSessionManager::setMuted):
148
        (WebKit::PlaybackSessionManager::setVolume):
149
        (WebKit::PlaybackSessionManager::setPlayingOnSecondScreen):
150
        (WebKit::nextContextId): Delete.
151
        - Replace with PlaybackSessionContextIdentifier::generate().
152
        * WebProcess/cocoa/VideoFullscreenManager.h:
153
        (WebKit::VideoFullscreenInterfaceContext::create):
154
        * WebProcess/cocoa/VideoFullscreenManager.messages.in:
155
        * WebProcess/cocoa/VideoFullscreenManager.mm:
156
        (WebKit::VideoFullscreenInterfaceContext::VideoFullscreenInterfaceContext):
157
        (WebKit::VideoFullscreenManager::createModelAndInterface):
158
        (WebKit::VideoFullscreenManager::ensureModelAndInterface):
159
        (WebKit::VideoFullscreenManager::ensureModel):
160
        (WebKit::VideoFullscreenManager::ensureInterface):
161
        (WebKit::VideoFullscreenManager::removeContext):
162
        (WebKit::VideoFullscreenManager::addClientForContext):
163
        (WebKit::VideoFullscreenManager::removeClientForContext):
164
        (WebKit::VideoFullscreenManager::enterVideoFullscreenForVideoElement):
165
        (WebKit::VideoFullscreenManager::exitVideoFullscreenForVideoElement):
166
        (WebKit::VideoFullscreenManager::exitVideoFullscreenToModeWithoutAnimation):
167
        (WebKit::VideoFullscreenManager::hasVideoChanged):
168
        (WebKit::VideoFullscreenManager::videoDimensionsChanged):
169
        (WebKit::VideoFullscreenManager::requestFullscreenMode):
170
        (WebKit::VideoFullscreenManager::fullscreenModeChanged):
171
        (WebKit::VideoFullscreenManager::requestUpdateInlineRect):
172
        (WebKit::VideoFullscreenManager::requestVideoContentLayer):
173
        (WebKit::VideoFullscreenManager::returnVideoContentLayer):
174
        (WebKit::VideoFullscreenManager::didSetupFullscreen):
175
        (WebKit::VideoFullscreenManager::willExitFullscreen):
176
        (WebKit::VideoFullscreenManager::didEnterFullscreen):
177
        (WebKit::VideoFullscreenManager::didExitFullscreen):
178
        (WebKit::VideoFullscreenManager::didCleanupFullscreen):
179
        (WebKit::VideoFullscreenManager::setVideoLayerGravityEnum):
180
        (WebKit::VideoFullscreenManager::fullscreenMayReturnToInline):
181
        (WebKit::VideoFullscreenManager::requestRouteSharingPolicyAndContextUID):
182
        (WebKit::VideoFullscreenManager::setVideoLayerFrameFenced):
183
1
2020-06-23  Wenson Hsieh  <wenson_hsieh@apple.com>
184
2020-06-23  Wenson Hsieh  <wenson_hsieh@apple.com>
2
185
3
        REGRESSION (r244633): Mail flashes when copying text in an email
186
        REGRESSION (r244633): Mail flashes when copying text in an email
- a/Source/WebKit/Scripts/webkit/messages.py +1 lines
Lines 241-246 def types_that_cannot_be_forward_declared(): a/Source/WebKit/Scripts/webkit/messages.py_sec1
241
        'WebKit::MDNSRegisterIdentifier',
241
        'WebKit::MDNSRegisterIdentifier',
242
        'WebKit::MediaPlayerPrivateRemoteIdentifier',
242
        'WebKit::MediaPlayerPrivateRemoteIdentifier',
243
        'WebKit::MediaRecorderIdentifier',
243
        'WebKit::MediaRecorderIdentifier',
244
        'WebKit::PlaybackSessionContextIdentifier',
244
        'WebKit::PluginProcessType',
245
        'WebKit::PluginProcessType',
245
        'WebKit::RemoteAudioDestinationIdentifier',
246
        'WebKit::RemoteAudioDestinationIdentifier',
246
        'WebKit::RemoteAudioSessionIdentifier',
247
        'WebKit::RemoteAudioSessionIdentifier',
- a/Source/WebKit/UIProcess/Cocoa/PlaybackSessionManagerProxy.h -48 / +49 lines
Lines 28-33 a/Source/WebKit/UIProcess/Cocoa/PlaybackSessionManagerProxy.h_sec1
28
#if PLATFORM(IOS_FAMILY) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
28
#if PLATFORM(IOS_FAMILY) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
29
29
30
#include "MessageReceiver.h"
30
#include "MessageReceiver.h"
31
#include "PlaybackSessionContextIdentifier.h"
31
#include <WebCore/GraphicsLayer.h>
32
#include <WebCore/GraphicsLayer.h>
32
#include <WebCore/MediaSelectionOption.h>
33
#include <WebCore/MediaSelectionOption.h>
33
#include <WebCore/PlatformView.h>
34
#include <WebCore/PlatformView.h>
Lines 58-64 class PlaybackSessionManagerProxy; a/Source/WebKit/UIProcess/Cocoa/PlaybackSessionManagerProxy.h_sec2
58
59
59
class PlaybackSessionModelContext final: public RefCounted<PlaybackSessionModelContext>, public WebCore::PlaybackSessionModel  {
60
class PlaybackSessionModelContext final: public RefCounted<PlaybackSessionModelContext>, public WebCore::PlaybackSessionModel  {
60
public:
61
public:
61
    static Ref<PlaybackSessionModelContext> create(PlaybackSessionManagerProxy& manager, uint64_t contextId)
62
    static Ref<PlaybackSessionModelContext> create(PlaybackSessionManagerProxy& manager, PlaybackSessionContextIdentifier contextId)
62
    {
63
    {
63
        return adoptRef(*new PlaybackSessionModelContext(manager, contextId));
64
        return adoptRef(*new PlaybackSessionModelContext(manager, contextId));
64
    }
65
    }
Lines 91-97 public: a/Source/WebKit/UIProcess/Cocoa/PlaybackSessionManagerProxy.h_sec3
91
private:
92
private:
92
    friend class VideoFullscreenModelContext;
93
    friend class VideoFullscreenModelContext;
93
94
94
    PlaybackSessionModelContext(PlaybackSessionManagerProxy& manager, uint64_t contextId)
95
    PlaybackSessionModelContext(PlaybackSessionManagerProxy& manager, PlaybackSessionContextIdentifier contextId)
95
        : m_manager(&manager)
96
        : m_manager(&manager)
96
        , m_contextId(contextId)
97
        , m_contextId(contextId)
97
    {
98
    {
Lines 141-147 private: a/Source/WebKit/UIProcess/Cocoa/PlaybackSessionManagerProxy.h_sec4
141
    bool isPictureInPictureActive() const final { return m_pictureInPictureActive; }
142
    bool isPictureInPictureActive() const final { return m_pictureInPictureActive; }
142
143
143
    PlaybackSessionManagerProxy* m_manager;
144
    PlaybackSessionManagerProxy* m_manager;
144
    uint64_t m_contextId;
145
    PlaybackSessionContextIdentifier m_contextId;
145
    HashSet<WebCore::PlaybackSessionModelClient*> m_clients;
146
    HashSet<WebCore::PlaybackSessionModelClient*> m_clients;
146
    double m_playbackStartedTime { 0 };
147
    double m_playbackStartedTime { 0 };
147
    bool m_playbackStartedTimeNeedsUpdate { false };
148
    bool m_playbackStartedTimeNeedsUpdate { false };
Lines 187-245 private: a/Source/WebKit/UIProcess/Cocoa/PlaybackSessionManagerProxy.h_sec5
187
    void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;
188
    void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;
188
189
189
    typedef std::tuple<RefPtr<PlaybackSessionModelContext>, RefPtr<PlatformPlaybackSessionInterface>> ModelInterfaceTuple;
190
    typedef std::tuple<RefPtr<PlaybackSessionModelContext>, RefPtr<PlatformPlaybackSessionInterface>> ModelInterfaceTuple;
190
    ModelInterfaceTuple createModelAndInterface(uint64_t contextId);
191
    ModelInterfaceTuple createModelAndInterface(PlaybackSessionContextIdentifier);
191
    ModelInterfaceTuple& ensureModelAndInterface(uint64_t contextId);
192
    ModelInterfaceTuple& ensureModelAndInterface(PlaybackSessionContextIdentifier);
192
    PlaybackSessionModelContext& ensureModel(uint64_t contextId);
193
    PlaybackSessionModelContext& ensureModel(PlaybackSessionContextIdentifier);
193
    PlatformPlaybackSessionInterface& ensureInterface(uint64_t contextId);
194
    PlatformPlaybackSessionInterface& ensureInterface(PlaybackSessionContextIdentifier);
194
    void addClientForContext(uint64_t contextId);
195
    void addClientForContext(PlaybackSessionContextIdentifier);
195
    void removeClientForContext(uint64_t contextId);
196
    void removeClientForContext(PlaybackSessionContextIdentifier);
196
197
197
    uint64_t controlsManagerContextId() const { return m_controlsManagerContextId; }
198
    PlaybackSessionContextIdentifier controlsManagerContextId() const { return m_controlsManagerContextId; }
198
199
199
    // Messages from PlaybackSessionManager
200
    // Messages from PlaybackSessionManager
200
    void setUpPlaybackControlsManagerWithID(uint64_t contextId);
201
    void setUpPlaybackControlsManagerWithID(PlaybackSessionContextIdentifier);
201
    void clearPlaybackControlsManager();
202
    void clearPlaybackControlsManager();
202
    void currentTimeChanged(uint64_t contextId, double currentTime, double hostTime);
203
    void currentTimeChanged(PlaybackSessionContextIdentifier, double currentTime, double hostTime);
203
    void bufferedTimeChanged(uint64_t contextId, double bufferedTime);
204
    void bufferedTimeChanged(PlaybackSessionContextIdentifier, double bufferedTime);
204
    void seekableRangesVectorChanged(uint64_t contextId, Vector<std::pair<double, double>> ranges, double lastModifiedTime, double liveUpdateInterval);
205
    void seekableRangesVectorChanged(PlaybackSessionContextIdentifier, Vector<std::pair<double, double>> ranges, double lastModifiedTime, double liveUpdateInterval);
205
    void canPlayFastReverseChanged(uint64_t contextId, bool value);
206
    void canPlayFastReverseChanged(PlaybackSessionContextIdentifier, bool value);
206
    void audioMediaSelectionOptionsChanged(uint64_t contextId, Vector<WebCore::MediaSelectionOption> options, uint64_t selectedIndex);
207
    void audioMediaSelectionOptionsChanged(PlaybackSessionContextIdentifier, Vector<WebCore::MediaSelectionOption> options, uint64_t selectedIndex);
207
    void legibleMediaSelectionOptionsChanged(uint64_t contextId, Vector<WebCore::MediaSelectionOption> options, uint64_t selectedIndex);
208
    void legibleMediaSelectionOptionsChanged(PlaybackSessionContextIdentifier, Vector<WebCore::MediaSelectionOption> options, uint64_t selectedIndex);
208
    void audioMediaSelectionIndexChanged(uint64_t contextId, uint64_t selectedIndex);
209
    void audioMediaSelectionIndexChanged(PlaybackSessionContextIdentifier, uint64_t selectedIndex);
209
    void legibleMediaSelectionIndexChanged(uint64_t contextId, uint64_t selectedIndex);
210
    void legibleMediaSelectionIndexChanged(PlaybackSessionContextIdentifier, uint64_t selectedIndex);
210
    void externalPlaybackPropertiesChanged(uint64_t contextId, bool enabled, uint32_t targetType, String localizedDeviceName);
211
    void externalPlaybackPropertiesChanged(PlaybackSessionContextIdentifier, bool enabled, uint32_t targetType, String localizedDeviceName);
211
    void wirelessVideoPlaybackDisabledChanged(uint64_t contextId, bool);
212
    void wirelessVideoPlaybackDisabledChanged(PlaybackSessionContextIdentifier, bool);
212
    void durationChanged(uint64_t contextId, double duration);
213
    void durationChanged(PlaybackSessionContextIdentifier, double duration);
213
    void playbackStartedTimeChanged(uint64_t contextId, double playbackStartedTime);
214
    void playbackStartedTimeChanged(PlaybackSessionContextIdentifier, double playbackStartedTime);
214
    void rateChanged(uint64_t contextId, bool isPlaying, double rate);
215
    void rateChanged(PlaybackSessionContextIdentifier, bool isPlaying, double rate);
215
    void handleControlledElementIDResponse(uint64_t, String) const;
216
    void handleControlledElementIDResponse(PlaybackSessionContextIdentifier, String) const;
216
    void mutedChanged(uint64_t contextId, bool muted);
217
    void mutedChanged(PlaybackSessionContextIdentifier, bool muted);
217
    void volumeChanged(uint64_t contextId, double volume);
218
    void volumeChanged(PlaybackSessionContextIdentifier, double volume);
218
    void pictureInPictureSupportedChanged(uint64_t contextId, bool pictureInPictureSupported);
219
    void pictureInPictureSupportedChanged(PlaybackSessionContextIdentifier, bool pictureInPictureSupported);
219
220
220
    // Messages to PlaybackSessionManager
221
    // Messages to PlaybackSessionManager
221
    void play(uint64_t contextId);
222
    void play(PlaybackSessionContextIdentifier);
222
    void pause(uint64_t contextId);
223
    void pause(PlaybackSessionContextIdentifier);
223
    void togglePlayState(uint64_t contextId);
224
    void togglePlayState(PlaybackSessionContextIdentifier);
224
    void beginScrubbing(uint64_t contextId);
225
    void beginScrubbing(PlaybackSessionContextIdentifier);
225
    void endScrubbing(uint64_t contextId);
226
    void endScrubbing(PlaybackSessionContextIdentifier);
226
    void seekToTime(uint64_t contextId, double time, double before, double after);
227
    void seekToTime(PlaybackSessionContextIdentifier, double time, double before, double after);
227
    void fastSeek(uint64_t contextId, double time);
228
    void fastSeek(PlaybackSessionContextIdentifier, double time);
228
    void beginScanningForward(uint64_t contextId);
229
    void beginScanningForward(PlaybackSessionContextIdentifier);
229
    void beginScanningBackward(uint64_t contextId);
230
    void beginScanningBackward(PlaybackSessionContextIdentifier);
230
    void endScanning(uint64_t contextId);
231
    void endScanning(PlaybackSessionContextIdentifier);
231
    void selectAudioMediaOption(uint64_t contextId, uint64_t index);
232
    void selectAudioMediaOption(PlaybackSessionContextIdentifier, uint64_t index);
232
    void selectLegibleMediaOption(uint64_t contextId, uint64_t index);
233
    void selectLegibleMediaOption(PlaybackSessionContextIdentifier, uint64_t index);
233
    void togglePictureInPicture(uint64_t contextId);
234
    void togglePictureInPicture(PlaybackSessionContextIdentifier);
234
    void toggleMuted(uint64_t contextId);
235
    void toggleMuted(PlaybackSessionContextIdentifier);
235
    void setMuted(uint64_t contextId, bool);
236
    void setMuted(PlaybackSessionContextIdentifier, bool);
236
    void setVolume(uint64_t contextId, double);
237
    void setVolume(PlaybackSessionContextIdentifier, double);
237
    void setPlayingOnSecondScreen(uint64_t contextId, bool);
238
    void setPlayingOnSecondScreen(PlaybackSessionContextIdentifier, bool);
238
239
239
    WebPageProxy* m_page;
240
    WebPageProxy* m_page;
240
    HashMap<uint64_t, ModelInterfaceTuple> m_contextMap;
241
    HashMap<PlaybackSessionContextIdentifier, ModelInterfaceTuple> m_contextMap;
241
    uint64_t m_controlsManagerContextId { 0 };
242
    PlaybackSessionContextIdentifier m_controlsManagerContextId;
242
    HashCountedSet<uint64_t> m_clientCounts;
243
    HashCountedSet<PlaybackSessionContextIdentifier> m_clientCounts;
243
};
244
};
244
245
245
} // namespace WebKit
246
} // namespace WebKit
- a/Source/WebKit/UIProcess/Cocoa/PlaybackSessionManagerProxy.messages.in -18 / +18 lines
Lines 22-46 a/Source/WebKit/UIProcess/Cocoa/PlaybackSessionManagerProxy.messages.in_sec1
22
22
23
#if PLATFORM(IOS_FAMILY) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
23
#if PLATFORM(IOS_FAMILY) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
24
messages -> PlaybackSessionManagerProxy {
24
messages -> PlaybackSessionManagerProxy {
25
    CurrentTimeChanged(uint64_t contextId, double currentTime, double hostTime)
25
    CurrentTimeChanged(WebKit::PlaybackSessionContextIdentifier contextId, double currentTime, double hostTime)
26
    BufferedTimeChanged(uint64_t contextId, double bufferedTime)
26
    BufferedTimeChanged(WebKit::PlaybackSessionContextIdentifier contextId, double bufferedTime)
27
    SeekableRangesVectorChanged(uint64_t contextId, Vector<std::pair<double, double>> ranges, double lastModifiedTime, double liveUpdateInterval)
27
    SeekableRangesVectorChanged(WebKit::PlaybackSessionContextIdentifier contextId, Vector<std::pair<double, double>> ranges, double lastModifiedTime, double liveUpdateInterval)
28
    CanPlayFastReverseChanged(uint64_t contextId, bool value)
28
    CanPlayFastReverseChanged(WebKit::PlaybackSessionContextIdentifier contextId, bool value)
29
    AudioMediaSelectionOptionsChanged(uint64_t contextId, Vector<WebCore::MediaSelectionOption> options, uint64_t selectedIndex)
29
    AudioMediaSelectionOptionsChanged(WebKit::PlaybackSessionContextIdentifier contextId, Vector<WebCore::MediaSelectionOption> options, uint64_t selectedIndex)
30
    LegibleMediaSelectionOptionsChanged(uint64_t contextId, Vector<WebCore::MediaSelectionOption> options, uint64_t selectedIndex)
30
    LegibleMediaSelectionOptionsChanged(WebKit::PlaybackSessionContextIdentifier contextId, Vector<WebCore::MediaSelectionOption> options, uint64_t selectedIndex)
31
    AudioMediaSelectionIndexChanged(uint64_t contextId, uint64_t selectedIndex)
31
    AudioMediaSelectionIndexChanged(WebKit::PlaybackSessionContextIdentifier contextId, uint64_t selectedIndex)
32
    LegibleMediaSelectionIndexChanged(uint64_t contextId, uint64_t selectedIndex)
32
    LegibleMediaSelectionIndexChanged(WebKit::PlaybackSessionContextIdentifier contextId, uint64_t selectedIndex)
33
    ExternalPlaybackPropertiesChanged(uint64_t contextId, bool enabled, uint32_t targetType, String localizedDeviceName)
33
    ExternalPlaybackPropertiesChanged(WebKit::PlaybackSessionContextIdentifier contextId, bool enabled, uint32_t targetType, String localizedDeviceName)
34
    WirelessVideoPlaybackDisabledChanged(uint64_t contextId, bool disabled)
34
    WirelessVideoPlaybackDisabledChanged(WebKit::PlaybackSessionContextIdentifier contextId, bool disabled)
35
    DurationChanged(uint64_t contextId, double duration)
35
    DurationChanged(WebKit::PlaybackSessionContextIdentifier contextId, double duration)
36
    PlaybackStartedTimeChanged(uint64_t contextId, double playbackStartedTime)
36
    PlaybackStartedTimeChanged(WebKit::PlaybackSessionContextIdentifier contextId, double playbackStartedTime)
37
    RateChanged(uint64_t contextId, bool isPlaying, double rate)
37
    RateChanged(WebKit::PlaybackSessionContextIdentifier contextId, bool isPlaying, double rate)
38
    MutedChanged(uint64_t contextId, bool muted);
38
    MutedChanged(WebKit::PlaybackSessionContextIdentifier contextId, bool muted);
39
    VolumeChanged(uint64_t contextId, double volume);
39
    VolumeChanged(WebKit::PlaybackSessionContextIdentifier contextId, double volume);
40
    PictureInPictureSupportedChanged(uint64_t contextID, bool pictureInPictureSupported)
40
    PictureInPictureSupportedChanged(WebKit::PlaybackSessionContextIdentifier contextId, bool pictureInPictureSupported)
41
    SetUpPlaybackControlsManagerWithID(uint64_t contextId)
41
    SetUpPlaybackControlsManagerWithID(WebKit::PlaybackSessionContextIdentifier contextId)
42
    ClearPlaybackControlsManager()
42
    ClearPlaybackControlsManager()
43
43
44
    HandleControlledElementIDResponse(uint64_t contextId, String id)
44
    HandleControlledElementIDResponse(WebKit::PlaybackSessionContextIdentifier contextId, String id)
45
}
45
}
46
#endif
46
#endif
- a/Source/WebKit/UIProcess/Cocoa/PlaybackSessionManagerProxy.mm -65 / +43 lines
Lines 1-5 a/Source/WebKit/UIProcess/Cocoa/PlaybackSessionManagerProxy.mm_sec1
1
/*
1
/*
2
 * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
2
 * Copyright (C) 2016-2020 Apple Inc. All rights reserved.
3
 *
3
 *
4
 * Redistribution and use in source and binary forms, with or without
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
5
 * modification, are permitted provided that the following conditions
Lines 33-40 a/Source/WebKit/UIProcess/Cocoa/PlaybackSessionManagerProxy.mm_sec2
33
#import "WebPageProxy.h"
33
#import "WebPageProxy.h"
34
#import "WebProcessProxy.h"
34
#import "WebProcessProxy.h"
35
35
36
#define MESSAGE_CHECK_CONTEXTID(identifier) MESSAGE_CHECK_BASE(m_contextMap.isValidKey(identifier), m_page->process().connection())
37
38
namespace WebKit {
36
namespace WebKit {
39
using namespace WebCore;
37
using namespace WebCore;
40
38
Lines 324-330 void PlaybackSessionManagerProxy::invalidate() a/Source/WebKit/UIProcess/Cocoa/PlaybackSessionManagerProxy.mm_sec3
324
        interface->invalidate();
322
        interface->invalidate();
325
}
323
}
326
324
327
PlaybackSessionManagerProxy::ModelInterfaceTuple PlaybackSessionManagerProxy::createModelAndInterface(uint64_t contextId)
325
PlaybackSessionManagerProxy::ModelInterfaceTuple PlaybackSessionManagerProxy::createModelAndInterface(PlaybackSessionContextIdentifier contextId)
328
{
326
{
329
    Ref<PlaybackSessionModelContext> model = PlaybackSessionModelContext::create(*this, contextId);
327
    Ref<PlaybackSessionModelContext> model = PlaybackSessionModelContext::create(*this, contextId);
330
    Ref<PlatformPlaybackSessionInterface> interface = PlatformPlaybackSessionInterface::create(model);
328
    Ref<PlatformPlaybackSessionInterface> interface = PlatformPlaybackSessionInterface::create(model);
Lines 332-338 PlaybackSessionManagerProxy::ModelInterfaceTuple PlaybackSessionManagerProxy::cr a/Source/WebKit/UIProcess/Cocoa/PlaybackSessionManagerProxy.mm_sec4
332
    return std::make_tuple(WTFMove(model), WTFMove(interface));
330
    return std::make_tuple(WTFMove(model), WTFMove(interface));
333
}
331
}
334
332
335
PlaybackSessionManagerProxy::ModelInterfaceTuple& PlaybackSessionManagerProxy::ensureModelAndInterface(uint64_t contextId)
333
PlaybackSessionManagerProxy::ModelInterfaceTuple& PlaybackSessionManagerProxy::ensureModelAndInterface(PlaybackSessionContextIdentifier contextId)
336
{
334
{
337
    auto addResult = m_contextMap.add(contextId, ModelInterfaceTuple());
335
    auto addResult = m_contextMap.add(contextId, ModelInterfaceTuple());
338
    if (addResult.isNewEntry)
336
    if (addResult.isNewEntry)
Lines 340-361 PlaybackSessionManagerProxy::ModelInterfaceTuple& PlaybackSessionManagerProxy::e a/Source/WebKit/UIProcess/Cocoa/PlaybackSessionManagerProxy.mm_sec5
340
    return addResult.iterator->value;
338
    return addResult.iterator->value;
341
}
339
}
342
340
343
PlaybackSessionModelContext& PlaybackSessionManagerProxy::ensureModel(uint64_t contextId)
341
PlaybackSessionModelContext& PlaybackSessionManagerProxy::ensureModel(PlaybackSessionContextIdentifier contextId)
344
{
342
{
345
    return *std::get<0>(ensureModelAndInterface(contextId));
343
    return *std::get<0>(ensureModelAndInterface(contextId));
346
}
344
}
347
345
348
PlatformPlaybackSessionInterface& PlaybackSessionManagerProxy::ensureInterface(uint64_t contextId)
346
PlatformPlaybackSessionInterface& PlaybackSessionManagerProxy::ensureInterface(PlaybackSessionContextIdentifier contextId)
349
{
347
{
350
    return *std::get<1>(ensureModelAndInterface(contextId));
348
    return *std::get<1>(ensureModelAndInterface(contextId));
351
}
349
}
352
350
353
void PlaybackSessionManagerProxy::addClientForContext(uint64_t contextId)
351
void PlaybackSessionManagerProxy::addClientForContext(PlaybackSessionContextIdentifier contextId)
354
{
352
{
355
    m_clientCounts.add(contextId);
353
    m_clientCounts.add(contextId);
356
}
354
}
357
355
358
void PlaybackSessionManagerProxy::removeClientForContext(uint64_t contextId)
356
void PlaybackSessionManagerProxy::removeClientForContext(PlaybackSessionContextIdentifier contextId)
359
{
357
{
360
    if (!m_clientCounts.remove(contextId))
358
    if (!m_clientCounts.remove(contextId))
361
        return;
359
        return;
Lines 366-374 void PlaybackSessionManagerProxy::removeClientForContext(uint64_t contextId) a/Source/WebKit/UIProcess/Cocoa/PlaybackSessionManagerProxy.mm_sec6
366
364
367
#pragma mark Messages from PlaybackSessionManager
365
#pragma mark Messages from PlaybackSessionManager
368
366
369
void PlaybackSessionManagerProxy::setUpPlaybackControlsManagerWithID(uint64_t contextId)
367
void PlaybackSessionManagerProxy::setUpPlaybackControlsManagerWithID(PlaybackSessionContextIdentifier contextId)
370
{
368
{
371
    MESSAGE_CHECK_CONTEXTID(contextId);
372
    if (m_controlsManagerContextId == contextId)
369
    if (m_controlsManagerContextId == contextId)
373
        return;
370
        return;
374
371
Lines 388-412 void PlaybackSessionManagerProxy::clearPlaybackControlsManager() a/Source/WebKit/UIProcess/Cocoa/PlaybackSessionManagerProxy.mm_sec7
388
        return;
385
        return;
389
386
390
    removeClientForContext(m_controlsManagerContextId);
387
    removeClientForContext(m_controlsManagerContextId);
391
    m_controlsManagerContextId = 0;
388
    m_controlsManagerContextId = { };
392
    m_page->videoControlsManagerDidChange();
389
    m_page->videoControlsManagerDidChange();
393
}
390
}
394
391
395
void PlaybackSessionManagerProxy::currentTimeChanged(uint64_t contextId, double currentTime, double hostTime)
392
void PlaybackSessionManagerProxy::currentTimeChanged(PlaybackSessionContextIdentifier contextId, double currentTime, double hostTime)
396
{
393
{
397
    MESSAGE_CHECK_CONTEXTID(contextId);
398
    ensureModel(contextId).currentTimeChanged(currentTime);
394
    ensureModel(contextId).currentTimeChanged(currentTime);
399
}
395
}
400
396
401
void PlaybackSessionManagerProxy::bufferedTimeChanged(uint64_t contextId, double bufferedTime)
397
void PlaybackSessionManagerProxy::bufferedTimeChanged(PlaybackSessionContextIdentifier contextId, double bufferedTime)
402
{
398
{
403
    MESSAGE_CHECK_CONTEXTID(contextId);
404
    ensureModel(contextId).bufferedTimeChanged(bufferedTime);
399
    ensureModel(contextId).bufferedTimeChanged(bufferedTime);
405
}
400
}
406
401
407
void PlaybackSessionManagerProxy::seekableRangesVectorChanged(uint64_t contextId, Vector<std::pair<double, double>> ranges, double lastModifiedTime, double liveUpdateInterval)
402
void PlaybackSessionManagerProxy::seekableRangesVectorChanged(PlaybackSessionContextIdentifier contextId, Vector<std::pair<double, double>> ranges, double lastModifiedTime, double liveUpdateInterval)
408
{
403
{
409
    MESSAGE_CHECK_CONTEXTID(contextId);
410
    Ref<TimeRanges> timeRanges = TimeRanges::create();
404
    Ref<TimeRanges> timeRanges = TimeRanges::create();
411
    for (const auto& range : ranges) {
405
    for (const auto& range : ranges) {
412
        ASSERT(isfinite(range.first));
406
        ASSERT(isfinite(range.first));
Lines 418-507 void PlaybackSessionManagerProxy::seekableRangesVectorChanged(uint64_t contextId a/Source/WebKit/UIProcess/Cocoa/PlaybackSessionManagerProxy.mm_sec8
418
    ensureModel(contextId).seekableRangesChanged(timeRanges, lastModifiedTime, liveUpdateInterval);
412
    ensureModel(contextId).seekableRangesChanged(timeRanges, lastModifiedTime, liveUpdateInterval);
419
}
413
}
420
414
421
void PlaybackSessionManagerProxy::canPlayFastReverseChanged(uint64_t contextId, bool value)
415
void PlaybackSessionManagerProxy::canPlayFastReverseChanged(PlaybackSessionContextIdentifier contextId, bool value)
422
{
416
{
423
    MESSAGE_CHECK_CONTEXTID(contextId);
424
    ensureModel(contextId).canPlayFastReverseChanged(value);
417
    ensureModel(contextId).canPlayFastReverseChanged(value);
425
}
418
}
426
419
427
void PlaybackSessionManagerProxy::audioMediaSelectionOptionsChanged(uint64_t contextId, Vector<MediaSelectionOption> options, uint64_t selectedIndex)
420
void PlaybackSessionManagerProxy::audioMediaSelectionOptionsChanged(PlaybackSessionContextIdentifier contextId, Vector<MediaSelectionOption> options, uint64_t selectedIndex)
428
{
421
{
429
    MESSAGE_CHECK_CONTEXTID(contextId);
430
    ensureModel(contextId).audioMediaSelectionOptionsChanged(options, selectedIndex);
422
    ensureModel(contextId).audioMediaSelectionOptionsChanged(options, selectedIndex);
431
}
423
}
432
424
433
void PlaybackSessionManagerProxy::legibleMediaSelectionOptionsChanged(uint64_t contextId, Vector<MediaSelectionOption> options, uint64_t selectedIndex)
425
void PlaybackSessionManagerProxy::legibleMediaSelectionOptionsChanged(PlaybackSessionContextIdentifier contextId, Vector<MediaSelectionOption> options, uint64_t selectedIndex)
434
{
426
{
435
    MESSAGE_CHECK_CONTEXTID(contextId);
436
    ensureModel(contextId).legibleMediaSelectionOptionsChanged(options, selectedIndex);
427
    ensureModel(contextId).legibleMediaSelectionOptionsChanged(options, selectedIndex);
437
}
428
}
438
429
439
void PlaybackSessionManagerProxy::audioMediaSelectionIndexChanged(uint64_t contextId, uint64_t selectedIndex)
430
void PlaybackSessionManagerProxy::audioMediaSelectionIndexChanged(PlaybackSessionContextIdentifier contextId, uint64_t selectedIndex)
440
{
431
{
441
    MESSAGE_CHECK_CONTEXTID(contextId);
442
    ensureModel(contextId).audioMediaSelectionIndexChanged(selectedIndex);
432
    ensureModel(contextId).audioMediaSelectionIndexChanged(selectedIndex);
443
}
433
}
444
434
445
void PlaybackSessionManagerProxy::legibleMediaSelectionIndexChanged(uint64_t contextId, uint64_t selectedIndex)
435
void PlaybackSessionManagerProxy::legibleMediaSelectionIndexChanged(PlaybackSessionContextIdentifier contextId, uint64_t selectedIndex)
446
{
436
{
447
    MESSAGE_CHECK_CONTEXTID(contextId);
448
    ensureModel(contextId).legibleMediaSelectionIndexChanged(selectedIndex);
437
    ensureModel(contextId).legibleMediaSelectionIndexChanged(selectedIndex);
449
}
438
}
450
439
451
void PlaybackSessionManagerProxy::externalPlaybackPropertiesChanged(uint64_t contextId, bool enabled, uint32_t targetType, String localizedDeviceName)
440
void PlaybackSessionManagerProxy::externalPlaybackPropertiesChanged(PlaybackSessionContextIdentifier contextId, bool enabled, uint32_t targetType, String localizedDeviceName)
452
{
441
{
453
    MESSAGE_CHECK_CONTEXTID(contextId);
454
    PlaybackSessionModel::ExternalPlaybackTargetType type = static_cast<PlaybackSessionModel::ExternalPlaybackTargetType>(targetType);
442
    PlaybackSessionModel::ExternalPlaybackTargetType type = static_cast<PlaybackSessionModel::ExternalPlaybackTargetType>(targetType);
455
    ASSERT(type == PlaybackSessionModel::TargetTypeAirPlay || type == PlaybackSessionModel::TargetTypeTVOut || type == PlaybackSessionModel::TargetTypeNone);
443
    ASSERT(type == PlaybackSessionModel::TargetTypeAirPlay || type == PlaybackSessionModel::TargetTypeTVOut || type == PlaybackSessionModel::TargetTypeNone);
456
444
457
    ensureModel(contextId).externalPlaybackChanged(enabled, type, localizedDeviceName);
445
    ensureModel(contextId).externalPlaybackChanged(enabled, type, localizedDeviceName);
458
}
446
}
459
447
460
void PlaybackSessionManagerProxy::wirelessVideoPlaybackDisabledChanged(uint64_t contextId, bool disabled)
448
void PlaybackSessionManagerProxy::wirelessVideoPlaybackDisabledChanged(PlaybackSessionContextIdentifier contextId, bool disabled)
461
{
449
{
462
    MESSAGE_CHECK_CONTEXTID(contextId);
463
    ensureModel(contextId).wirelessVideoPlaybackDisabledChanged(disabled);
450
    ensureModel(contextId).wirelessVideoPlaybackDisabledChanged(disabled);
464
}
451
}
465
452
466
void PlaybackSessionManagerProxy::mutedChanged(uint64_t contextId, bool muted)
453
void PlaybackSessionManagerProxy::mutedChanged(PlaybackSessionContextIdentifier contextId, bool muted)
467
{
454
{
468
    MESSAGE_CHECK_CONTEXTID(contextId);
469
    ensureModel(contextId).mutedChanged(muted);
455
    ensureModel(contextId).mutedChanged(muted);
470
}
456
}
471
457
472
void PlaybackSessionManagerProxy::volumeChanged(uint64_t contextId, double volume)
458
void PlaybackSessionManagerProxy::volumeChanged(PlaybackSessionContextIdentifier contextId, double volume)
473
{
459
{
474
    MESSAGE_CHECK_CONTEXTID(contextId);
475
    ensureModel(contextId).volumeChanged(volume);
460
    ensureModel(contextId).volumeChanged(volume);
476
}
461
}
477
462
478
void PlaybackSessionManagerProxy::durationChanged(uint64_t contextId, double duration)
463
void PlaybackSessionManagerProxy::durationChanged(PlaybackSessionContextIdentifier contextId, double duration)
479
{
464
{
480
    MESSAGE_CHECK_CONTEXTID(contextId);
481
    ensureModel(contextId).durationChanged(duration);
465
    ensureModel(contextId).durationChanged(duration);
482
}
466
}
483
467
484
void PlaybackSessionManagerProxy::playbackStartedTimeChanged(uint64_t contextId, double playbackStartedTime)
468
void PlaybackSessionManagerProxy::playbackStartedTimeChanged(PlaybackSessionContextIdentifier contextId, double playbackStartedTime)
485
{
469
{
486
    MESSAGE_CHECK_CONTEXTID(contextId);
487
    ensureModel(contextId).playbackStartedTimeChanged(playbackStartedTime);
470
    ensureModel(contextId).playbackStartedTimeChanged(playbackStartedTime);
488
}
471
}
489
472
490
void PlaybackSessionManagerProxy::rateChanged(uint64_t contextId, bool isPlaying, double rate)
473
void PlaybackSessionManagerProxy::rateChanged(PlaybackSessionContextIdentifier contextId, bool isPlaying, double rate)
491
{
474
{
492
    MESSAGE_CHECK_CONTEXTID(contextId);
493
    ensureModel(contextId).rateChanged(isPlaying, rate);
475
    ensureModel(contextId).rateChanged(isPlaying, rate);
494
}
476
}
495
477
496
void PlaybackSessionManagerProxy::pictureInPictureSupportedChanged(uint64_t contextId, bool supported)
478
void PlaybackSessionManagerProxy::pictureInPictureSupportedChanged(PlaybackSessionContextIdentifier contextId, bool supported)
497
{
479
{
498
    MESSAGE_CHECK_CONTEXTID(contextId);
499
    ensureModel(contextId).pictureInPictureSupportedChanged(supported);
480
    ensureModel(contextId).pictureInPictureSupportedChanged(supported);
500
}
481
}
501
482
502
void PlaybackSessionManagerProxy::handleControlledElementIDResponse(uint64_t contextId, String identifier) const
483
void PlaybackSessionManagerProxy::handleControlledElementIDResponse(PlaybackSessionContextIdentifier contextId, String identifier) const
503
{
484
{
504
    MESSAGE_CHECK_CONTEXTID(contextId);
505
#if PLATFORM(MAC)
485
#if PLATFORM(MAC)
506
    if (contextId == m_controlsManagerContextId)
486
    if (contextId == m_controlsManagerContextId)
507
        m_page->handleControlledElementIDResponse(identifier);
487
        m_page->handleControlledElementIDResponse(identifier);
Lines 514-600 void PlaybackSessionManagerProxy::handleControlledElementIDResponse(uint64_t con a/Source/WebKit/UIProcess/Cocoa/PlaybackSessionManagerProxy.mm_sec9
514
494
515
#pragma mark Messages to PlaybackSessionManager
495
#pragma mark Messages to PlaybackSessionManager
516
496
517
void PlaybackSessionManagerProxy::play(uint64_t contextId)
497
void PlaybackSessionManagerProxy::play(PlaybackSessionContextIdentifier contextId)
518
{
498
{
519
    m_page->send(Messages::PlaybackSessionManager::Play(contextId));
499
    m_page->send(Messages::PlaybackSessionManager::Play(contextId));
520
}
500
}
521
501
522
void PlaybackSessionManagerProxy::pause(uint64_t contextId)
502
void PlaybackSessionManagerProxy::pause(PlaybackSessionContextIdentifier contextId)
523
{
503
{
524
    m_page->send(Messages::PlaybackSessionManager::Pause(contextId));
504
    m_page->send(Messages::PlaybackSessionManager::Pause(contextId));
525
}
505
}
526
506
527
void PlaybackSessionManagerProxy::togglePlayState(uint64_t contextId)
507
void PlaybackSessionManagerProxy::togglePlayState(PlaybackSessionContextIdentifier contextId)
528
{
508
{
529
    m_page->send(Messages::PlaybackSessionManager::TogglePlayState(contextId));
509
    m_page->send(Messages::PlaybackSessionManager::TogglePlayState(contextId));
530
}
510
}
531
511
532
void PlaybackSessionManagerProxy::beginScrubbing(uint64_t contextId)
512
void PlaybackSessionManagerProxy::beginScrubbing(PlaybackSessionContextIdentifier contextId)
533
{
513
{
534
    m_page->send(Messages::PlaybackSessionManager::BeginScrubbing(contextId));
514
    m_page->send(Messages::PlaybackSessionManager::BeginScrubbing(contextId));
535
}
515
}
536
516
537
void PlaybackSessionManagerProxy::endScrubbing(uint64_t contextId)
517
void PlaybackSessionManagerProxy::endScrubbing(PlaybackSessionContextIdentifier contextId)
538
{
518
{
539
    m_page->send(Messages::PlaybackSessionManager::EndScrubbing(contextId));
519
    m_page->send(Messages::PlaybackSessionManager::EndScrubbing(contextId));
540
}
520
}
541
521
542
void PlaybackSessionManagerProxy::seekToTime(uint64_t contextId, double time, double toleranceBefore, double toleranceAfter)
522
void PlaybackSessionManagerProxy::seekToTime(PlaybackSessionContextIdentifier contextId, double time, double toleranceBefore, double toleranceAfter)
543
{
523
{
544
    m_page->send(Messages::PlaybackSessionManager::SeekToTime(contextId, time, toleranceBefore, toleranceAfter));
524
    m_page->send(Messages::PlaybackSessionManager::SeekToTime(contextId, time, toleranceBefore, toleranceAfter));
545
}
525
}
546
526
547
void PlaybackSessionManagerProxy::fastSeek(uint64_t contextId, double time)
527
void PlaybackSessionManagerProxy::fastSeek(PlaybackSessionContextIdentifier contextId, double time)
548
{
528
{
549
    m_page->send(Messages::PlaybackSessionManager::FastSeek(contextId, time));
529
    m_page->send(Messages::PlaybackSessionManager::FastSeek(contextId, time));
550
}
530
}
551
531
552
void PlaybackSessionManagerProxy::beginScanningForward(uint64_t contextId)
532
void PlaybackSessionManagerProxy::beginScanningForward(PlaybackSessionContextIdentifier contextId)
553
{
533
{
554
    m_page->send(Messages::PlaybackSessionManager::BeginScanningForward(contextId));
534
    m_page->send(Messages::PlaybackSessionManager::BeginScanningForward(contextId));
555
}
535
}
556
536
557
void PlaybackSessionManagerProxy::beginScanningBackward(uint64_t contextId)
537
void PlaybackSessionManagerProxy::beginScanningBackward(PlaybackSessionContextIdentifier contextId)
558
{
538
{
559
    m_page->send(Messages::PlaybackSessionManager::BeginScanningBackward(contextId));
539
    m_page->send(Messages::PlaybackSessionManager::BeginScanningBackward(contextId));
560
}
540
}
561
541
562
void PlaybackSessionManagerProxy::endScanning(uint64_t contextId)
542
void PlaybackSessionManagerProxy::endScanning(PlaybackSessionContextIdentifier contextId)
563
{
543
{
564
    m_page->send(Messages::PlaybackSessionManager::EndScanning(contextId));
544
    m_page->send(Messages::PlaybackSessionManager::EndScanning(contextId));
565
}
545
}
566
546
567
void PlaybackSessionManagerProxy::selectAudioMediaOption(uint64_t contextId, uint64_t index)
547
void PlaybackSessionManagerProxy::selectAudioMediaOption(PlaybackSessionContextIdentifier contextId, uint64_t index)
568
{
548
{
569
    m_page->send(Messages::PlaybackSessionManager::SelectAudioMediaOption(contextId, index));
549
    m_page->send(Messages::PlaybackSessionManager::SelectAudioMediaOption(contextId, index));
570
}
550
}
571
551
572
void PlaybackSessionManagerProxy::selectLegibleMediaOption(uint64_t contextId, uint64_t index)
552
void PlaybackSessionManagerProxy::selectLegibleMediaOption(PlaybackSessionContextIdentifier contextId, uint64_t index)
573
{
553
{
574
    m_page->send(Messages::PlaybackSessionManager::SelectLegibleMediaOption(contextId, index));
554
    m_page->send(Messages::PlaybackSessionManager::SelectLegibleMediaOption(contextId, index));
575
}
555
}
576
556
577
void PlaybackSessionManagerProxy::togglePictureInPicture(uint64_t contextId)
557
void PlaybackSessionManagerProxy::togglePictureInPicture(PlaybackSessionContextIdentifier contextId)
578
{
558
{
579
    m_page->send(Messages::PlaybackSessionManager::TogglePictureInPicture(contextId));
559
    m_page->send(Messages::PlaybackSessionManager::TogglePictureInPicture(contextId));
580
}
560
}
581
561
582
void PlaybackSessionManagerProxy::toggleMuted(uint64_t contextId)
562
void PlaybackSessionManagerProxy::toggleMuted(PlaybackSessionContextIdentifier contextId)
583
{
563
{
584
    m_page->send(Messages::PlaybackSessionManager::ToggleMuted(contextId));
564
    m_page->send(Messages::PlaybackSessionManager::ToggleMuted(contextId));
585
}
565
}
586
566
587
void PlaybackSessionManagerProxy::setMuted(uint64_t contextId, bool muted)
567
void PlaybackSessionManagerProxy::setMuted(PlaybackSessionContextIdentifier contextId, bool muted)
588
{
568
{
589
    m_page->send(Messages::PlaybackSessionManager::SetMuted(contextId, muted));
569
    m_page->send(Messages::PlaybackSessionManager::SetMuted(contextId, muted));
590
}
570
}
591
571
592
void PlaybackSessionManagerProxy::setVolume(uint64_t contextId, double volume)
572
void PlaybackSessionManagerProxy::setVolume(PlaybackSessionContextIdentifier contextId, double volume)
593
{
573
{
594
    m_page->send(Messages::PlaybackSessionManager::SetVolume(contextId, volume));
574
    m_page->send(Messages::PlaybackSessionManager::SetVolume(contextId, volume));
595
}
575
}
596
576
597
void PlaybackSessionManagerProxy::setPlayingOnSecondScreen(uint64_t contextId, bool value)
577
void PlaybackSessionManagerProxy::setPlayingOnSecondScreen(PlaybackSessionContextIdentifier contextId, bool value)
598
{
578
{
599
    if (m_page)
579
    if (m_page)
600
        m_page->send(Messages::PlaybackSessionManager::SetPlayingOnSecondScreen(contextId, value));
580
        m_page->send(Messages::PlaybackSessionManager::SetPlayingOnSecondScreen(contextId, value));
Lines 617-622 PlatformPlaybackSessionInterface* PlaybackSessionManagerProxy::controlsManagerIn a/Source/WebKit/UIProcess/Cocoa/PlaybackSessionManagerProxy.mm_sec10
617
597
618
} // namespace WebKit
598
} // namespace WebKit
619
599
620
#undef MESSAGE_CHECK_CONTEXTID
621
622
#endif // PLATFORM(IOS_FAMILY) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
600
#endif // PLATFORM(IOS_FAMILY) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
- a/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.h -38 / +39 lines
Lines 28-33 a/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.h_sec1
28
#if ENABLE(VIDEO_PRESENTATION_MODE)
28
#if ENABLE(VIDEO_PRESENTATION_MODE)
29
29
30
#include "MessageReceiver.h"
30
#include "MessageReceiver.h"
31
#include "PlaybackSessionContextIdentifier.h"
31
#include <WebCore/AudioSession.h>
32
#include <WebCore/AudioSession.h>
32
#include <WebCore/GraphicsLayer.h>
33
#include <WebCore/GraphicsLayer.h>
33
#include <WebCore/PlatformView.h>
34
#include <WebCore/PlatformView.h>
Lines 63-69 class VideoFullscreenModelContext final a/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.h_sec2
63
    , public WebCore::VideoFullscreenModel
64
    , public WebCore::VideoFullscreenModel
64
    , public WebCore::VideoFullscreenChangeObserver  {
65
    , public WebCore::VideoFullscreenChangeObserver  {
65
public:
66
public:
66
    static Ref<VideoFullscreenModelContext> create(VideoFullscreenManagerProxy& manager, PlaybackSessionModelContext& playbackSessionModel, uint64_t contextId)
67
    static Ref<VideoFullscreenModelContext> create(VideoFullscreenManagerProxy& manager, PlaybackSessionModelContext& playbackSessionModel, PlaybackSessionContextIdentifier contextId)
67
    {
68
    {
68
        return adoptRef(*new VideoFullscreenModelContext(manager, playbackSessionModel, contextId));
69
        return adoptRef(*new VideoFullscreenModelContext(manager, playbackSessionModel, contextId));
69
    }
70
    }
Lines 75-81 public: a/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.h_sec3
75
    void setLayerHostView(RetainPtr<PlatformView>&& layerHostView) { m_layerHostView = WTFMove(layerHostView); }
76
    void setLayerHostView(RetainPtr<PlatformView>&& layerHostView) { m_layerHostView = WTFMove(layerHostView); }
76
77
77
private:
78
private:
78
    VideoFullscreenModelContext(VideoFullscreenManagerProxy&, PlaybackSessionModelContext&, uint64_t);
79
    VideoFullscreenModelContext(VideoFullscreenManagerProxy&, PlaybackSessionModelContext&, PlaybackSessionContextIdentifier);
79
80
80
    // VideoFullscreenModel
81
    // VideoFullscreenModel
81
    void addClient(WebCore::VideoFullscreenModelClient&) override;
82
    void addClient(WebCore::VideoFullscreenModelClient&) override;
Lines 110-116 private: a/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.h_sec4
110
111
111
    VideoFullscreenManagerProxy* m_manager;
112
    VideoFullscreenManagerProxy* m_manager;
112
    Ref<PlaybackSessionModelContext> m_playbackSessionModel;
113
    Ref<PlaybackSessionModelContext> m_playbackSessionModel;
113
    uint64_t m_contextId;
114
    PlaybackSessionContextIdentifier m_contextId;
114
    RetainPtr<PlatformView> m_layerHostView;
115
    RetainPtr<PlatformView> m_layerHostView;
115
    HashSet<WebCore::VideoFullscreenModelClient*> m_clients;
116
    HashSet<WebCore::VideoFullscreenModelClient*> m_clients;
116
    WebCore::FloatSize m_videoDimensions;
117
    WebCore::FloatSize m_videoDimensions;
Lines 132-138 public: a/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.h_sec5
132
133
133
    void setMockVideoPresentationModeEnabled(bool enabled) { m_mockVideoPresentationModeEnabled = enabled; }
134
    void setMockVideoPresentationModeEnabled(bool enabled) { m_mockVideoPresentationModeEnabled = enabled; }
134
135
135
    void requestRouteSharingPolicyAndContextUID(uint64_t contextId, CompletionHandler<void(WebCore::RouteSharingPolicy, String)>&&);
136
    void requestRouteSharingPolicyAndContextUID(PlaybackSessionContextIdentifier, CompletionHandler<void(WebCore::RouteSharingPolicy, String)>&&);
136
137
137
    bool isPlayingVideoInEnhancedFullscreen() const;
138
    bool isPlayingVideoInEnhancedFullscreen() const;
138
139
Lines 147-197 private: a/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.h_sec6
147
    void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
148
    void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
148
149
149
    typedef std::tuple<RefPtr<VideoFullscreenModelContext>, RefPtr<PlatformVideoFullscreenInterface>> ModelInterfaceTuple;
150
    typedef std::tuple<RefPtr<VideoFullscreenModelContext>, RefPtr<PlatformVideoFullscreenInterface>> ModelInterfaceTuple;
150
    ModelInterfaceTuple createModelAndInterface(uint64_t contextId);
151
    ModelInterfaceTuple createModelAndInterface(PlaybackSessionContextIdentifier);
151
    ModelInterfaceTuple& ensureModelAndInterface(uint64_t contextId);
152
    ModelInterfaceTuple& ensureModelAndInterface(PlaybackSessionContextIdentifier);
152
    VideoFullscreenModelContext& ensureModel(uint64_t contextId);
153
    VideoFullscreenModelContext& ensureModel(PlaybackSessionContextIdentifier);
153
    PlatformVideoFullscreenInterface& ensureInterface(uint64_t contextId);
154
    PlatformVideoFullscreenInterface& ensureInterface(PlaybackSessionContextIdentifier);
154
    PlatformVideoFullscreenInterface* findInterface(uint64_t contextId);
155
    PlatformVideoFullscreenInterface* findInterface(PlaybackSessionContextIdentifier);
155
    void addClientForContext(uint64_t contextId);
156
    void addClientForContext(PlaybackSessionContextIdentifier);
156
    void removeClientForContext(uint64_t contextId);
157
    void removeClientForContext(PlaybackSessionContextIdentifier);
157
158
158
    void hasVideoInPictureInPictureDidChange(bool);
159
    void hasVideoInPictureInPictureDidChange(bool);
159
160
160
    // Messages from VideoFullscreenManager
161
    // Messages from VideoFullscreenManager
161
    void setupFullscreenWithID(uint64_t contextId, uint32_t videoLayerID, const WebCore::IntRect& initialRect, float hostingScaleFactor, WebCore::HTMLMediaElementEnums::VideoFullscreenMode, bool allowsPictureInPicture, bool standby);
162
    void setupFullscreenWithID(PlaybackSessionContextIdentifier, uint32_t videoLayerID, const WebCore::IntRect& initialRect, float hostingScaleFactor, WebCore::HTMLMediaElementEnums::VideoFullscreenMode, bool allowsPictureInPicture, bool standby);
162
    void setInlineRect(uint64_t contextId, const WebCore::IntRect& inlineRect, bool visible);
163
    void setInlineRect(PlaybackSessionContextIdentifier, const WebCore::IntRect& inlineRect, bool visible);
163
    void setHasVideoContentLayer(uint64_t contextId, bool value);
164
    void setHasVideoContentLayer(PlaybackSessionContextIdentifier, bool value);
164
    void setHasVideo(uint64_t contextId, bool);
165
    void setHasVideo(PlaybackSessionContextIdentifier, bool);
165
    void setVideoDimensions(uint64_t contextId, const WebCore::FloatSize&);
166
    void setVideoDimensions(PlaybackSessionContextIdentifier, const WebCore::FloatSize&);
166
    void enterFullscreen(uint64_t contextId);
167
    void enterFullscreen(PlaybackSessionContextIdentifier);
167
    void exitFullscreen(uint64_t contextId, WebCore::IntRect finalRect);
168
    void exitFullscreen(PlaybackSessionContextIdentifier, WebCore::IntRect finalRect);
168
    void cleanupFullscreen(uint64_t contextId);
169
    void cleanupFullscreen(PlaybackSessionContextIdentifier);
169
    void preparedToReturnToInline(uint64_t contextId, bool visible, WebCore::IntRect inlineRect);
170
    void preparedToReturnToInline(PlaybackSessionContextIdentifier, bool visible, WebCore::IntRect inlineRect);
170
    void preparedToExitFullscreen(uint64_t contextId);
171
    void preparedToExitFullscreen(PlaybackSessionContextIdentifier);
171
    void exitFullscreenWithoutAnimationToMode(uint64_t contextId, WebCore::HTMLMediaElementEnums::VideoFullscreenMode);
172
    void exitFullscreenWithoutAnimationToMode(PlaybackSessionContextIdentifier, WebCore::HTMLMediaElementEnums::VideoFullscreenMode);
172
173
173
    // Messages to VideoFullscreenManager
174
    // Messages to VideoFullscreenManager
174
    void requestFullscreenMode(uint64_t contextId, WebCore::HTMLMediaElementEnums::VideoFullscreenMode, bool finishedWithMedia = false);
175
    void requestFullscreenMode(PlaybackSessionContextIdentifier, WebCore::HTMLMediaElementEnums::VideoFullscreenMode, bool finishedWithMedia = false);
175
    void requestUpdateInlineRect(uint64_t contextId);
176
    void requestUpdateInlineRect(PlaybackSessionContextIdentifier);
176
    void requestVideoContentLayer(uint64_t contextId);
177
    void requestVideoContentLayer(PlaybackSessionContextIdentifier);
177
    void returnVideoContentLayer(uint64_t contextId);
178
    void returnVideoContentLayer(PlaybackSessionContextIdentifier);
178
    void didSetupFullscreen(uint64_t contextId);
179
    void didSetupFullscreen(PlaybackSessionContextIdentifier);
179
    void willExitFullscreen(uint64_t contextId);
180
    void willExitFullscreen(PlaybackSessionContextIdentifier);
180
    void didExitFullscreen(uint64_t contextId);
181
    void didExitFullscreen(PlaybackSessionContextIdentifier);
181
    void didEnterFullscreen(uint64_t contextId);
182
    void didEnterFullscreen(PlaybackSessionContextIdentifier);
182
    void didCleanupFullscreen(uint64_t contextId);
183
    void didCleanupFullscreen(PlaybackSessionContextIdentifier);
183
    void setVideoLayerFrame(uint64_t contextId, WebCore::FloatRect);
184
    void setVideoLayerFrame(PlaybackSessionContextIdentifier, WebCore::FloatRect);
184
    void setVideoLayerGravity(uint64_t contextId, WebCore::MediaPlayerEnums::VideoGravity);
185
    void setVideoLayerGravity(PlaybackSessionContextIdentifier, WebCore::MediaPlayerEnums::VideoGravity);
185
    void fullscreenModeChanged(uint64_t contextId, WebCore::HTMLMediaElementEnums::VideoFullscreenMode);
186
    void fullscreenModeChanged(PlaybackSessionContextIdentifier, WebCore::HTMLMediaElementEnums::VideoFullscreenMode);
186
    void fullscreenMayReturnToInline(uint64_t contextId);
187
    void fullscreenMayReturnToInline(PlaybackSessionContextIdentifier);
187
188
188
    bool m_mockVideoPresentationModeEnabled { false };
189
    bool m_mockVideoPresentationModeEnabled { false };
189
190
190
    WebPageProxy* m_page;
191
    WebPageProxy* m_page;
191
    Ref<PlaybackSessionManagerProxy> m_playbackSessionManagerProxy;
192
    Ref<PlaybackSessionManagerProxy> m_playbackSessionManagerProxy;
192
    HashMap<uint64_t, ModelInterfaceTuple> m_contextMap;
193
    HashMap<PlaybackSessionContextIdentifier, ModelInterfaceTuple> m_contextMap;
193
    uint64_t m_controlsManagerContextId { 0 };
194
    PlaybackSessionContextIdentifier m_controlsManagerContextId;
194
    HashMap<uint64_t, int> m_clientCounts;
195
    HashMap<PlaybackSessionContextIdentifier, int> m_clientCounts;
195
};
196
};
196
197
197
} // namespace WebKit
198
} // namespace WebKit
- a/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.messages.in -11 / +11 lines
Lines 22-37 a/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.messages.in_sec1
22
22
23
#if ENABLE(VIDEO_PRESENTATION_MODE)
23
#if ENABLE(VIDEO_PRESENTATION_MODE)
24
messages -> VideoFullscreenManagerProxy {
24
messages -> VideoFullscreenManagerProxy {
25
    SetHasVideo(uint64_t contextId, bool hasVideo)
25
    SetHasVideo(WebKit::PlaybackSessionContextIdentifier contextId, bool hasVideo)
26
    SetVideoDimensions(uint64_t contextId, WebCore::FloatSize videoDimensions)
26
    SetVideoDimensions(WebKit::PlaybackSessionContextIdentifier contextId, WebCore::FloatSize videoDimensions)
27
    SetupFullscreenWithID(uint64_t contextId, uint32_t videoLayerID, WebCore::IntRect initialRect, float hostingScaleFactor, WebCore::HTMLMediaElementEnums::VideoFullscreenMode videoFullscreenMode, bool allowsPictureInPicture, bool standby)
27
    SetupFullscreenWithID(WebKit::PlaybackSessionContextIdentifier contextId, uint32_t videoLayerID, WebCore::IntRect initialRect, float hostingScaleFactor, WebCore::HTMLMediaElementEnums::VideoFullscreenMode videoFullscreenMode, bool allowsPictureInPicture, bool standby)
28
    EnterFullscreen(uint64_t contextId)
28
    EnterFullscreen(WebKit::PlaybackSessionContextIdentifier contextId)
29
    ExitFullscreen(uint64_t contextId, WebCore::IntRect finalRect)
29
    ExitFullscreen(WebKit::PlaybackSessionContextIdentifier contextId, WebCore::IntRect finalRect)
30
    SetInlineRect(uint64_t contextId, WebCore::IntRect inlineRect, bool visible)
30
    SetInlineRect(WebKit::PlaybackSessionContextIdentifier contextId, WebCore::IntRect inlineRect, bool visible)
31
    SetHasVideoContentLayer(uint64_t contextId, bool value)
31
    SetHasVideoContentLayer(WebKit::PlaybackSessionContextIdentifier contextId, bool value)
32
    CleanupFullscreen(uint64_t contextId)
32
    CleanupFullscreen(WebKit::PlaybackSessionContextIdentifier contextId)
33
    PreparedToReturnToInline(uint64_t contextId, bool visible, WebCore::IntRect inlineRect)
33
    PreparedToReturnToInline(WebKit::PlaybackSessionContextIdentifier contextId, bool visible, WebCore::IntRect inlineRect)
34
    PreparedToExitFullscreen(uint64_t contextId)
34
    PreparedToExitFullscreen(WebKit::PlaybackSessionContextIdentifier contextId)
35
    ExitFullscreenWithoutAnimationToMode(uint64_t contextId, WebCore::HTMLMediaElementEnums::VideoFullscreenMode videoFullscreenMode)
35
    ExitFullscreenWithoutAnimationToMode(WebKit::PlaybackSessionContextIdentifier contextId, WebCore::HTMLMediaElementEnums::VideoFullscreenMode videoFullscreenMode)
36
}
36
}
37
#endif
37
#endif
- a/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm -49 / +35 lines
Lines 122-128 @end a/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm_sec1
122
#endif
122
#endif
123
123
124
#define MESSAGE_CHECK(assertion) MESSAGE_CHECK_BASE(assertion, m_page->process().connection())
124
#define MESSAGE_CHECK(assertion) MESSAGE_CHECK_BASE(assertion, m_page->process().connection())
125
#define MESSAGE_CHECK_CONTEXTID(identifier) MESSAGE_CHECK_BASE(m_contextMap.isValidKey(identifier), m_page->process().connection())
126
125
127
namespace WebKit {
126
namespace WebKit {
128
using namespace WebCore;
127
using namespace WebCore;
Lines 159-165 void VideoFullscreenManagerProxy::applicationDidBecomeActive() a/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm_sec2
159
158
160
#pragma mark - VideoFullscreenModelContext
159
#pragma mark - VideoFullscreenModelContext
161
160
162
VideoFullscreenModelContext::VideoFullscreenModelContext(VideoFullscreenManagerProxy& manager, PlaybackSessionModelContext& playbackSessionModel, uint64_t contextId)
161
VideoFullscreenModelContext::VideoFullscreenModelContext(VideoFullscreenManagerProxy& manager, PlaybackSessionModelContext& playbackSessionModel, PlaybackSessionContextIdentifier contextId)
163
    : m_manager(&manager)
162
    : m_manager(&manager)
164
    , m_playbackSessionModel(playbackSessionModel)
163
    , m_playbackSessionModel(playbackSessionModel)
165
    , m_contextId(contextId)
164
    , m_contextId(contextId)
Lines 404-415 void VideoFullscreenManagerProxy::applicationDidBecomeActive() a/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm_sec3
404
        interface->applicationDidBecomeActive();
403
        interface->applicationDidBecomeActive();
405
}
404
}
406
405
407
void VideoFullscreenManagerProxy::requestRouteSharingPolicyAndContextUID(uint64_t contextId, CompletionHandler<void(WebCore::RouteSharingPolicy, String)>&& callback)
406
void VideoFullscreenManagerProxy::requestRouteSharingPolicyAndContextUID(PlaybackSessionContextIdentifier contextId, CompletionHandler<void(WebCore::RouteSharingPolicy, String)>&& callback)
408
{
407
{
409
    m_page->sendWithAsyncReply(Messages::VideoFullscreenManager::RequestRouteSharingPolicyAndContextUID(contextId), WTFMove(callback));
408
    m_page->sendWithAsyncReply(Messages::VideoFullscreenManager::RequestRouteSharingPolicyAndContextUID(contextId), WTFMove(callback));
410
}
409
}
411
410
412
VideoFullscreenManagerProxy::ModelInterfaceTuple VideoFullscreenManagerProxy::createModelAndInterface(uint64_t contextId)
411
VideoFullscreenManagerProxy::ModelInterfaceTuple VideoFullscreenManagerProxy::createModelAndInterface(PlaybackSessionContextIdentifier contextId)
413
{
412
{
414
    auto& playbackSessionModel = m_playbackSessionManagerProxy->ensureModel(contextId);
413
    auto& playbackSessionModel = m_playbackSessionManagerProxy->ensureModel(contextId);
415
    Ref<VideoFullscreenModelContext> model = VideoFullscreenModelContext::create(*this, playbackSessionModel, contextId);
414
    Ref<VideoFullscreenModelContext> model = VideoFullscreenModelContext::create(*this, playbackSessionModel, contextId);
Lines 423-429 VideoFullscreenManagerProxy::ModelInterfaceTuple VideoFullscreenManagerProxy::cr a/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm_sec4
423
    return std::make_tuple(WTFMove(model), WTFMove(interface));
422
    return std::make_tuple(WTFMove(model), WTFMove(interface));
424
}
423
}
425
424
426
VideoFullscreenManagerProxy::ModelInterfaceTuple& VideoFullscreenManagerProxy::ensureModelAndInterface(uint64_t contextId)
425
VideoFullscreenManagerProxy::ModelInterfaceTuple& VideoFullscreenManagerProxy::ensureModelAndInterface(PlaybackSessionContextIdentifier contextId)
427
{
426
{
428
    auto addResult = m_contextMap.add(contextId, ModelInterfaceTuple());
427
    auto addResult = m_contextMap.add(contextId, ModelInterfaceTuple());
429
    if (addResult.isNewEntry)
428
    if (addResult.isNewEntry)
Lines 431-447 VideoFullscreenManagerProxy::ModelInterfaceTuple& VideoFullscreenManagerProxy::e a/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm_sec5
431
    return addResult.iterator->value;
430
    return addResult.iterator->value;
432
}
431
}
433
432
434
VideoFullscreenModelContext& VideoFullscreenManagerProxy::ensureModel(uint64_t contextId)
433
VideoFullscreenModelContext& VideoFullscreenManagerProxy::ensureModel(PlaybackSessionContextIdentifier contextId)
435
{
434
{
436
    return *std::get<0>(ensureModelAndInterface(contextId));
435
    return *std::get<0>(ensureModelAndInterface(contextId));
437
}
436
}
438
437
439
PlatformVideoFullscreenInterface& VideoFullscreenManagerProxy::ensureInterface(uint64_t contextId)
438
PlatformVideoFullscreenInterface& VideoFullscreenManagerProxy::ensureInterface(PlaybackSessionContextIdentifier contextId)
440
{
439
{
441
    return *std::get<1>(ensureModelAndInterface(contextId));
440
    return *std::get<1>(ensureModelAndInterface(contextId));
442
}
441
}
443
442
444
PlatformVideoFullscreenInterface* VideoFullscreenManagerProxy::findInterface(uint64_t contextId)
443
PlatformVideoFullscreenInterface* VideoFullscreenManagerProxy::findInterface(PlaybackSessionContextIdentifier contextId)
445
{
444
{
446
    auto it = m_contextMap.find(contextId);
445
    auto it = m_contextMap.find(contextId);
447
    if (it == m_contextMap.end())
446
    if (it == m_contextMap.end())
Lines 450-463 PlatformVideoFullscreenInterface* VideoFullscreenManagerProxy::findInterface(uin a/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm_sec6
450
    return std::get<1>(it->value).get();
449
    return std::get<1>(it->value).get();
451
}
450
}
452
451
453
void VideoFullscreenManagerProxy::addClientForContext(uint64_t contextId)
452
void VideoFullscreenManagerProxy::addClientForContext(PlaybackSessionContextIdentifier contextId)
454
{
453
{
455
    auto addResult = m_clientCounts.add(contextId, 1);
454
    auto addResult = m_clientCounts.add(contextId, 1);
456
    if (!addResult.isNewEntry)
455
    if (!addResult.isNewEntry)
457
        addResult.iterator->value++;
456
        addResult.iterator->value++;
458
}
457
}
459
458
460
void VideoFullscreenManagerProxy::removeClientForContext(uint64_t contextId)
459
void VideoFullscreenManagerProxy::removeClientForContext(PlaybackSessionContextIdentifier contextId)
461
{
460
{
462
    ASSERT(m_clientCounts.contains(contextId));
461
    ASSERT(m_clientCounts.contains(contextId));
463
462
Lines 507-515 void VideoFullscreenManagerProxy::hasVideoInPictureInPictureDidChange(bool value a/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm_sec7
507
506
508
#pragma mark Messages from VideoFullscreenManager
507
#pragma mark Messages from VideoFullscreenManager
509
508
510
void VideoFullscreenManagerProxy::setupFullscreenWithID(uint64_t contextId, uint32_t videoLayerID, const WebCore::IntRect& initialRect, float hostingDeviceScaleFactor, HTMLMediaElementEnums::VideoFullscreenMode videoFullscreenMode, bool allowsPictureInPicture, bool standby)
509
void VideoFullscreenManagerProxy::setupFullscreenWithID(PlaybackSessionContextIdentifier contextId, uint32_t videoLayerID, const WebCore::IntRect& initialRect, float hostingDeviceScaleFactor, HTMLMediaElementEnums::VideoFullscreenMode videoFullscreenMode, bool allowsPictureInPicture, bool standby)
511
{
510
{
512
    MESSAGE_CHECK_CONTEXTID(contextId);
513
    MESSAGE_CHECK(videoLayerID);
511
    MESSAGE_CHECK(videoLayerID);
514
512
515
    auto& [model, interface] = ensureModelAndInterface(contextId);
513
    auto& [model, interface] = ensureModelAndInterface(contextId);
Lines 550-558 void VideoFullscreenManagerProxy::setupFullscreenWithID(uint64_t contextId, uint a/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm_sec8
550
#endif
548
#endif
551
}
549
}
552
550
553
void VideoFullscreenManagerProxy::setHasVideo(uint64_t contextId, bool hasVideo)
551
void VideoFullscreenManagerProxy::setHasVideo(PlaybackSessionContextIdentifier contextId, bool hasVideo)
554
{
552
{
555
    MESSAGE_CHECK_CONTEXTID(contextId);
556
    if (m_mockVideoPresentationModeEnabled)
553
    if (m_mockVideoPresentationModeEnabled)
557
        return;
554
        return;
558
555
Lines 560-568 void VideoFullscreenManagerProxy::setHasVideo(uint64_t contextId, bool hasVideo) a/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm_sec9
560
        interface->hasVideoChanged(hasVideo);
557
        interface->hasVideoChanged(hasVideo);
561
}
558
}
562
559
563
void VideoFullscreenManagerProxy::setVideoDimensions(uint64_t contextId, const FloatSize& videoDimensions)
560
void VideoFullscreenManagerProxy::setVideoDimensions(PlaybackSessionContextIdentifier contextId, const FloatSize& videoDimensions)
564
{
561
{
565
    MESSAGE_CHECK_CONTEXTID(contextId);
566
    if (m_mockVideoPresentationModeEnabled)
562
    if (m_mockVideoPresentationModeEnabled)
567
        return;
563
        return;
568
564
Lines 570-578 void VideoFullscreenManagerProxy::setVideoDimensions(uint64_t contextId, const F a/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm_sec10
570
        interface->videoDimensionsChanged(videoDimensions);
566
        interface->videoDimensionsChanged(videoDimensions);
571
}
567
}
572
568
573
void VideoFullscreenManagerProxy::enterFullscreen(uint64_t contextId)
569
void VideoFullscreenManagerProxy::enterFullscreen(PlaybackSessionContextIdentifier contextId)
574
{
570
{
575
    MESSAGE_CHECK_CONTEXTID(contextId);
576
    if (m_mockVideoPresentationModeEnabled) {
571
    if (m_mockVideoPresentationModeEnabled) {
577
        didEnterFullscreen(contextId);
572
        didEnterFullscreen(contextId);
578
        setVideoLayerFrame(contextId, {0, 0, 200, 150});
573
        setVideoLayerFrame(contextId, {0, 0, 200, 150});
Lines 594-603 void VideoFullscreenManagerProxy::enterFullscreen(uint64_t contextId) a/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm_sec11
594
    }
589
    }
595
}
590
}
596
591
597
void VideoFullscreenManagerProxy::exitFullscreen(uint64_t contextId, WebCore::IntRect finalRect)
592
void VideoFullscreenManagerProxy::exitFullscreen(PlaybackSessionContextIdentifier contextId, WebCore::IntRect finalRect)
598
{
593
{
599
    MESSAGE_CHECK_CONTEXTID(contextId);
600
601
    ASSERT(m_contextMap.contains(contextId));
594
    ASSERT(m_contextMap.contains(contextId));
602
    if (!m_contextMap.contains(contextId))
595
    if (!m_contextMap.contains(contextId))
603
        return;
596
        return;
Lines 623-631 void VideoFullscreenManagerProxy::exitFullscreen(uint64_t contextId, WebCore::In a/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm_sec12
623
#endif
616
#endif
624
}
617
}
625
618
626
void VideoFullscreenManagerProxy::exitFullscreenWithoutAnimationToMode(uint64_t contextId, WebCore::HTMLMediaElementEnums::VideoFullscreenMode targetMode)
619
void VideoFullscreenManagerProxy::exitFullscreenWithoutAnimationToMode(PlaybackSessionContextIdentifier contextId, WebCore::HTMLMediaElementEnums::VideoFullscreenMode targetMode)
627
{
620
{
628
    MESSAGE_CHECK_CONTEXTID(contextId);
629
    if (m_mockVideoPresentationModeEnabled)
621
    if (m_mockVideoPresentationModeEnabled)
630
        return;
622
        return;
631
623
Lines 644-661 void VideoFullscreenManagerProxy::exitFullscreenWithoutAnimationToMode(uint64_t a/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm_sec13
644
636
645
#if PLATFORM(IOS_FAMILY)
637
#if PLATFORM(IOS_FAMILY)
646
638
647
void VideoFullscreenManagerProxy::setInlineRect(uint64_t contextId, const WebCore::IntRect& inlineRect, bool visible)
639
void VideoFullscreenManagerProxy::setInlineRect(PlaybackSessionContextIdentifier contextId, const WebCore::IntRect& inlineRect, bool visible)
648
{
640
{
649
    MESSAGE_CHECK_CONTEXTID(contextId);
650
    if (m_mockVideoPresentationModeEnabled)
641
    if (m_mockVideoPresentationModeEnabled)
651
        return;
642
        return;
652
643
653
    ensureInterface(contextId).setInlineRect(inlineRect, visible);
644
    ensureInterface(contextId).setInlineRect(inlineRect, visible);
654
}
645
}
655
646
656
void VideoFullscreenManagerProxy::setHasVideoContentLayer(uint64_t contextId, bool value)
647
void VideoFullscreenManagerProxy::setHasVideoContentLayer(PlaybackSessionContextIdentifier contextId, bool value)
657
{
648
{
658
    MESSAGE_CHECK_CONTEXTID(contextId);
659
    if (m_mockVideoPresentationModeEnabled) {
649
    if (m_mockVideoPresentationModeEnabled) {
660
        if (value)
650
        if (value)
661
            didSetupFullscreen(contextId);
651
            didSetupFullscreen(contextId);
Lines 670-690 void VideoFullscreenManagerProxy::setHasVideoContentLayer(uint64_t contextId, bo a/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm_sec14
670
660
671
#else
661
#else
672
662
673
NO_RETURN_DUE_TO_ASSERT void VideoFullscreenManagerProxy::setInlineRect(uint64_t, const WebCore::IntRect&, bool)
663
NO_RETURN_DUE_TO_ASSERT void VideoFullscreenManagerProxy::setInlineRect(PlaybackSessionContextIdentifier, const WebCore::IntRect&, bool)
674
{
664
{
675
    ASSERT_NOT_REACHED();
665
    ASSERT_NOT_REACHED();
676
}
666
}
677
667
678
NO_RETURN_DUE_TO_ASSERT void VideoFullscreenManagerProxy::setHasVideoContentLayer(uint64_t, bool)
668
NO_RETURN_DUE_TO_ASSERT void VideoFullscreenManagerProxy::setHasVideoContentLayer(PlaybackSessionContextIdentifier, bool)
679
{
669
{
680
    ASSERT_NOT_REACHED();
670
    ASSERT_NOT_REACHED();
681
}
671
}
682
672
683
#endif
673
#endif
684
674
685
void VideoFullscreenManagerProxy::cleanupFullscreen(uint64_t contextId)
675
void VideoFullscreenManagerProxy::cleanupFullscreen(PlaybackSessionContextIdentifier contextId)
686
{
676
{
687
    MESSAGE_CHECK_CONTEXTID(contextId);
688
    if (m_mockVideoPresentationModeEnabled) {
677
    if (m_mockVideoPresentationModeEnabled) {
689
        didCleanupFullscreen(contextId);
678
        didCleanupFullscreen(contextId);
690
        return;
679
        return;
Lines 693-701 void VideoFullscreenManagerProxy::cleanupFullscreen(uint64_t contextId) a/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm_sec15
693
    ensureInterface(contextId).cleanupFullscreen();
682
    ensureInterface(contextId).cleanupFullscreen();
694
}
683
}
695
684
696
void VideoFullscreenManagerProxy::preparedToReturnToInline(uint64_t contextId, bool visible, WebCore::IntRect inlineRect)
685
void VideoFullscreenManagerProxy::preparedToReturnToInline(PlaybackSessionContextIdentifier contextId, bool visible, WebCore::IntRect inlineRect)
697
{
686
{
698
    MESSAGE_CHECK_CONTEXTID(contextId);
699
    m_page->fullscreenMayReturnToInline();
687
    m_page->fullscreenMayReturnToInline();
700
688
701
#if !PLATFORM(IOS_FAMILY)
689
#if !PLATFORM(IOS_FAMILY)
Lines 713-721 void VideoFullscreenManagerProxy::preparedToReturnToInline(uint64_t contextId, b a/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm_sec16
713
#endif
701
#endif
714
}
702
}
715
703
716
void VideoFullscreenManagerProxy::preparedToExitFullscreen(uint64_t contextId)
704
void VideoFullscreenManagerProxy::preparedToExitFullscreen(PlaybackSessionContextIdentifier contextId)
717
{
705
{
718
    MESSAGE_CHECK_CONTEXTID(contextId);
719
    if (m_mockVideoPresentationModeEnabled)
706
    if (m_mockVideoPresentationModeEnabled)
720
        return;
707
        return;
721
708
Lines 724-772 void VideoFullscreenManagerProxy::preparedToExitFullscreen(uint64_t contextId) a/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm_sec17
724
711
725
#pragma mark Messages to VideoFullscreenManager
712
#pragma mark Messages to VideoFullscreenManager
726
713
727
void VideoFullscreenManagerProxy::requestFullscreenMode(uint64_t contextId, WebCore::HTMLMediaElementEnums::VideoFullscreenMode mode, bool finishedWithMedia)
714
void VideoFullscreenManagerProxy::requestFullscreenMode(PlaybackSessionContextIdentifier contextId, WebCore::HTMLMediaElementEnums::VideoFullscreenMode mode, bool finishedWithMedia)
728
{
715
{
729
    m_page->send(Messages::VideoFullscreenManager::RequestFullscreenMode(contextId, mode, finishedWithMedia));
716
    m_page->send(Messages::VideoFullscreenManager::RequestFullscreenMode(contextId, mode, finishedWithMedia));
730
}
717
}
731
718
732
void VideoFullscreenManagerProxy::requestUpdateInlineRect(uint64_t contextId)
719
void VideoFullscreenManagerProxy::requestUpdateInlineRect(PlaybackSessionContextIdentifier contextId)
733
{
720
{
734
    m_page->send(Messages::VideoFullscreenManager::RequestUpdateInlineRect(contextId));
721
    m_page->send(Messages::VideoFullscreenManager::RequestUpdateInlineRect(contextId));
735
}
722
}
736
723
737
void VideoFullscreenManagerProxy::requestVideoContentLayer(uint64_t contextId)
724
void VideoFullscreenManagerProxy::requestVideoContentLayer(PlaybackSessionContextIdentifier contextId)
738
{
725
{
739
    m_page->send(Messages::VideoFullscreenManager::RequestVideoContentLayer(contextId));
726
    m_page->send(Messages::VideoFullscreenManager::RequestVideoContentLayer(contextId));
740
}
727
}
741
728
742
void VideoFullscreenManagerProxy::returnVideoContentLayer(uint64_t contextId)
729
void VideoFullscreenManagerProxy::returnVideoContentLayer(PlaybackSessionContextIdentifier contextId)
743
{
730
{
744
    m_page->send(Messages::VideoFullscreenManager::ReturnVideoContentLayer(contextId));
731
    m_page->send(Messages::VideoFullscreenManager::ReturnVideoContentLayer(contextId));
745
}
732
}
746
733
747
void VideoFullscreenManagerProxy::didSetupFullscreen(uint64_t contextId)
734
void VideoFullscreenManagerProxy::didSetupFullscreen(PlaybackSessionContextIdentifier contextId)
748
{
735
{
749
    m_page->send(Messages::VideoFullscreenManager::DidSetupFullscreen(contextId));
736
    m_page->send(Messages::VideoFullscreenManager::DidSetupFullscreen(contextId));
750
}
737
}
751
738
752
void VideoFullscreenManagerProxy::willExitFullscreen(uint64_t contextId)
739
void VideoFullscreenManagerProxy::willExitFullscreen(PlaybackSessionContextIdentifier contextId)
753
{
740
{
754
    m_page->send(Messages::VideoFullscreenManager::WillExitFullscreen(contextId));
741
    m_page->send(Messages::VideoFullscreenManager::WillExitFullscreen(contextId));
755
}
742
}
756
743
757
void VideoFullscreenManagerProxy::didExitFullscreen(uint64_t contextId)
744
void VideoFullscreenManagerProxy::didExitFullscreen(PlaybackSessionContextIdentifier contextId)
758
{
745
{
759
    m_page->send(Messages::VideoFullscreenManager::DidExitFullscreen(contextId));
746
    m_page->send(Messages::VideoFullscreenManager::DidExitFullscreen(contextId));
760
    m_page->didExitFullscreen();
747
    m_page->didExitFullscreen();
761
}
748
}
762
749
763
void VideoFullscreenManagerProxy::didEnterFullscreen(uint64_t contextId)
750
void VideoFullscreenManagerProxy::didEnterFullscreen(PlaybackSessionContextIdentifier contextId)
764
{
751
{
765
    m_page->send(Messages::VideoFullscreenManager::DidEnterFullscreen(contextId));
752
    m_page->send(Messages::VideoFullscreenManager::DidEnterFullscreen(contextId));
766
    m_page->didEnterFullscreen();
753
    m_page->didEnterFullscreen();
767
}
754
}
768
755
769
void VideoFullscreenManagerProxy::didCleanupFullscreen(uint64_t contextId)
756
void VideoFullscreenManagerProxy::didCleanupFullscreen(PlaybackSessionContextIdentifier contextId)
770
{
757
{
771
    auto& [model, interface] = ensureModelAndInterface(contextId);
758
    auto& [model, interface] = ensureModelAndInterface(contextId);
772
759
Lines 779-785 void VideoFullscreenManagerProxy::didCleanupFullscreen(uint64_t contextId) a/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm_sec18
779
    removeClientForContext(contextId);
766
    removeClientForContext(contextId);
780
}
767
}
781
768
782
void VideoFullscreenManagerProxy::setVideoLayerFrame(uint64_t contextId, WebCore::FloatRect frame)
769
void VideoFullscreenManagerProxy::setVideoLayerFrame(PlaybackSessionContextIdentifier contextId, WebCore::FloatRect frame)
783
{
770
{
784
    @autoreleasepool {
771
    @autoreleasepool {
785
#if PLATFORM(IOS_FAMILY)
772
#if PLATFORM(IOS_FAMILY)
Lines 795-811 void VideoFullscreenManagerProxy::setVideoLayerFrame(uint64_t contextId, WebCore a/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm_sec19
795
    }
782
    }
796
}
783
}
797
784
798
void VideoFullscreenManagerProxy::setVideoLayerGravity(uint64_t contextId, WebCore::MediaPlayerEnums::VideoGravity gravity)
785
void VideoFullscreenManagerProxy::setVideoLayerGravity(PlaybackSessionContextIdentifier contextId, WebCore::MediaPlayerEnums::VideoGravity gravity)
799
{
786
{
800
    m_page->send(Messages::VideoFullscreenManager::SetVideoLayerGravityEnum(contextId, (unsigned)gravity));
787
    m_page->send(Messages::VideoFullscreenManager::SetVideoLayerGravityEnum(contextId, (unsigned)gravity));
801
}
788
}
802
789
803
void VideoFullscreenManagerProxy::fullscreenModeChanged(uint64_t contextId, WebCore::HTMLMediaElementEnums::VideoFullscreenMode mode)
790
void VideoFullscreenManagerProxy::fullscreenModeChanged(PlaybackSessionContextIdentifier contextId, WebCore::HTMLMediaElementEnums::VideoFullscreenMode mode)
804
{
791
{
805
    m_page->send(Messages::VideoFullscreenManager::FullscreenModeChanged(contextId, mode));
792
    m_page->send(Messages::VideoFullscreenManager::FullscreenModeChanged(contextId, mode));
806
}
793
}
807
794
808
void VideoFullscreenManagerProxy::fullscreenMayReturnToInline(uint64_t contextId)
795
void VideoFullscreenManagerProxy::fullscreenMayReturnToInline(PlaybackSessionContextIdentifier contextId)
809
{
796
{
810
    bool isViewVisible = m_page->isViewVisible();
797
    bool isViewVisible = m_page->isViewVisible();
811
    m_page->send(Messages::VideoFullscreenManager::FullscreenMayReturnToInline(contextId, isViewVisible));
798
    m_page->send(Messages::VideoFullscreenManager::FullscreenMayReturnToInline(contextId, isViewVisible));
Lines 815-821 void VideoFullscreenManagerProxy::fullscreenMayReturnToInline(uint64_t contextId a/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm_sec20
815
802
816
} // namespace WebKit
803
} // namespace WebKit
817
804
818
#undef MESSAGE_CHECK_CONTEXTID
819
#undef MESSAGE_CHECK
805
#undef MESSAGE_CHECK
820
806
821
#endif // ENABLE(VIDEO_PRESENTATION_MODE)
807
#endif // ENABLE(VIDEO_PRESENTATION_MODE)
- a/Source/WebKit/WebKit.xcodeproj/project.pbxproj +4 lines
Lines 934-939 a/Source/WebKit/WebKit.xcodeproj/project.pbxproj_sec1
934
		41FAF5F51E3C0649001AE678 /* WebRTCResolver.h in Headers */ = {isa = PBXBuildFile; fileRef = 41FAF5F41E3C0641001AE678 /* WebRTCResolver.h */; };
934
		41FAF5F51E3C0649001AE678 /* WebRTCResolver.h in Headers */ = {isa = PBXBuildFile; fileRef = 41FAF5F41E3C0641001AE678 /* WebRTCResolver.h */; };
935
		41FAF5F81E3C1021001AE678 /* LibWebRTCResolver.h in Headers */ = {isa = PBXBuildFile; fileRef = 41FAF5F61E3C0B47001AE678 /* LibWebRTCResolver.h */; };
935
		41FAF5F81E3C1021001AE678 /* LibWebRTCResolver.h in Headers */ = {isa = PBXBuildFile; fileRef = 41FAF5F61E3C0B47001AE678 /* LibWebRTCResolver.h */; };
936
		4459984222833E8700E61373 /* SyntheticEditingCommandType.h in Headers */ = {isa = PBXBuildFile; fileRef = 4459984122833E6000E61373 /* SyntheticEditingCommandType.h */; };
936
		4459984222833E8700E61373 /* SyntheticEditingCommandType.h in Headers */ = {isa = PBXBuildFile; fileRef = 4459984122833E6000E61373 /* SyntheticEditingCommandType.h */; };
937
		446DC64C24A2D8E50061F390 /* PlaybackSessionContextIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 446DC64B24A2D8AD0061F390 /* PlaybackSessionContextIdentifier.h */; };
937
		4482734724528F6000A95493 /* CocoaImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 4482734624528F6000A95493 /* CocoaImage.h */; };
938
		4482734724528F6000A95493 /* CocoaImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 4482734624528F6000A95493 /* CocoaImage.h */; };
938
		449D90DA21FDC30B00F677C0 /* LocalAuthenticationSoftLink.mm in Sources */ = {isa = PBXBuildFile; fileRef = 449D90D821FD63FE00F677C0 /* LocalAuthenticationSoftLink.mm */; };
939
		449D90DA21FDC30B00F677C0 /* LocalAuthenticationSoftLink.mm in Sources */ = {isa = PBXBuildFile; fileRef = 449D90D821FD63FE00F677C0 /* LocalAuthenticationSoftLink.mm */; };
939
		44E936FD2447C2D8009FA3E3 /* LegacyCustomProtocolID.h in Headers */ = {isa = PBXBuildFile; fileRef = 44E936FC2447C256009FA3E3 /* LegacyCustomProtocolID.h */; };
940
		44E936FD2447C2D8009FA3E3 /* LegacyCustomProtocolID.h in Headers */ = {isa = PBXBuildFile; fileRef = 44E936FC2447C256009FA3E3 /* LegacyCustomProtocolID.h */; };
Lines 3536-3541 a/Source/WebKit/WebKit.xcodeproj/project.pbxproj_sec2
3536
		41FCD6BF23CE044000C62567 /* RemoteSampleBufferDisplayLayerManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteSampleBufferDisplayLayerManager.h; sourceTree = "<group>"; };
3537
		41FCD6BF23CE044000C62567 /* RemoteSampleBufferDisplayLayerManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteSampleBufferDisplayLayerManager.h; sourceTree = "<group>"; };
3537
		4450AEBF1DC3FAE5009943F2 /* SharedMemoryCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SharedMemoryCocoa.cpp; sourceTree = "<group>"; };
3538
		4450AEBF1DC3FAE5009943F2 /* SharedMemoryCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SharedMemoryCocoa.cpp; sourceTree = "<group>"; };
3538
		4459984122833E6000E61373 /* SyntheticEditingCommandType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SyntheticEditingCommandType.h; sourceTree = "<group>"; };
3539
		4459984122833E6000E61373 /* SyntheticEditingCommandType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SyntheticEditingCommandType.h; sourceTree = "<group>"; };
3540
		446DC64B24A2D8AD0061F390 /* PlaybackSessionContextIdentifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlaybackSessionContextIdentifier.h; sourceTree = "<group>"; };
3539
		4482734624528F6000A95493 /* CocoaImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CocoaImage.h; sourceTree = "<group>"; };
3541
		4482734624528F6000A95493 /* CocoaImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CocoaImage.h; sourceTree = "<group>"; };
3540
		449D90D821FD63FE00F677C0 /* LocalAuthenticationSoftLink.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LocalAuthenticationSoftLink.mm; sourceTree = "<group>"; };
3542
		449D90D821FD63FE00F677C0 /* LocalAuthenticationSoftLink.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LocalAuthenticationSoftLink.mm; sourceTree = "<group>"; };
3541
		44A481C621F2D27B00F2F919 /* ClientCertificateAuthenticationXPCConstants.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ClientCertificateAuthenticationXPCConstants.cpp; sourceTree = "<group>"; };
3543
		44A481C621F2D27B00F2F919 /* ClientCertificateAuthenticationXPCConstants.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ClientCertificateAuthenticationXPCConstants.cpp; sourceTree = "<group>"; };
Lines 8381-8386 a/Source/WebKit/WebKit.xcodeproj/project.pbxproj_sec3
8381
			children = (
8383
			children = (
8382
				CD4570CB2440FB2A00A3DCEB /* AudioSessionRoutingArbitrator.cpp */,
8384
				CD4570CB2440FB2A00A3DCEB /* AudioSessionRoutingArbitrator.cpp */,
8383
				CD4570CA2440FB2A00A3DCEB /* AudioSessionRoutingArbitrator.h */,
8385
				CD4570CA2440FB2A00A3DCEB /* AudioSessionRoutingArbitrator.h */,
8386
				446DC64B24A2D8AD0061F390 /* PlaybackSessionContextIdentifier.h */,
8384
				CDA29A191CBDBF4100901CCF /* PlaybackSessionManager.h */,
8387
				CDA29A191CBDBF4100901CCF /* PlaybackSessionManager.h */,
8385
				CDA29A1C1CBDBF5B00901CCF /* PlaybackSessionManager.messages.in */,
8388
				CDA29A1C1CBDBF5B00901CCF /* PlaybackSessionManager.messages.in */,
8386
				CDA29A181CBDBF4100901CCF /* PlaybackSessionManager.mm */,
8389
				CDA29A181CBDBF4100901CCF /* PlaybackSessionManager.mm */,
Lines 11002-11007 a/Source/WebKit/WebKit.xcodeproj/project.pbxproj_sec4
11002
				2D8710171828415D0018FA01 /* PlatformCALayerRemoteCustom.h in Headers */,
11005
				2D8710171828415D0018FA01 /* PlatformCALayerRemoteCustom.h in Headers */,
11003
				2D8949F1182044F600E898AA /* PlatformCALayerRemoteTiledBacking.h in Headers */,
11006
				2D8949F1182044F600E898AA /* PlatformCALayerRemoteTiledBacking.h in Headers */,
11004
				BCC43ABB127B95DC00317F16 /* PlatformPopupMenuData.h in Headers */,
11007
				BCC43ABB127B95DC00317F16 /* PlatformPopupMenuData.h in Headers */,
11008
				446DC64C24A2D8E50061F390 /* PlaybackSessionContextIdentifier.h in Headers */,
11005
				CDA29A1B1CBDBF4100901CCF /* PlaybackSessionManager.h in Headers */,
11009
				CDA29A1B1CBDBF4100901CCF /* PlaybackSessionManager.h in Headers */,
11006
				CDA29A291CBEB67A00901CCF /* PlaybackSessionManagerMessages.h in Headers */,
11010
				CDA29A291CBEB67A00901CCF /* PlaybackSessionManagerMessages.h in Headers */,
11007
				CDA29A201CBEB5FB00901CCF /* PlaybackSessionManagerProxy.h in Headers */,
11011
				CDA29A201CBEB5FB00901CCF /* PlaybackSessionManagerProxy.h in Headers */,
- a/Source/WebKit/WebProcess/cocoa/PlaybackSessionContextIdentifier.h +35 lines
Line 0 a/Source/WebKit/WebProcess/cocoa/PlaybackSessionContextIdentifier.h_sec1
1
/*
2
 * Copyright (C) 2020 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
#include <wtf/ObjectIdentifier.h>
29
30
namespace WebKit {
31
32
enum PlaybackSessionContextIdentifierType { };
33
using PlaybackSessionContextIdentifier = ObjectIdentifier<PlaybackSessionContextIdentifierType>;
34
35
}
- a/Source/WebKit/WebProcess/cocoa/PlaybackSessionManager.h -50 / +51 lines
Lines 1-5 a/Source/WebKit/WebProcess/cocoa/PlaybackSessionManager.h_sec1
1
/*
1
/*
2
 * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
2
 * Copyright (C) 2016-2020 Apple Inc. All rights reserved.
3
 *
3
 *
4
 * Redistribution and use in source and binary forms, with or without
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
5
 * modification, are permitted provided that the following conditions
Lines 28-33 a/Source/WebKit/WebProcess/cocoa/PlaybackSessionManager.h_sec2
28
#if PLATFORM(IOS_FAMILY) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
28
#if PLATFORM(IOS_FAMILY) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
29
29
30
#include "MessageReceiver.h"
30
#include "MessageReceiver.h"
31
#include "PlaybackSessionContextIdentifier.h"
31
#include <WebCore/EventListener.h>
32
#include <WebCore/EventListener.h>
32
#include <WebCore/HTMLMediaElementEnums.h>
33
#include <WebCore/HTMLMediaElementEnums.h>
33
#include <WebCore/PlatformCALayer.h>
34
#include <WebCore/PlatformCALayer.h>
Lines 57-63 class PlaybackSessionInterfaceContext final a/Source/WebKit/WebProcess/cocoa/PlaybackSessionManager.h_sec3
57
    : public RefCounted<PlaybackSessionInterfaceContext>
58
    : public RefCounted<PlaybackSessionInterfaceContext>
58
    , public WebCore::PlaybackSessionModelClient {
59
    , public WebCore::PlaybackSessionModelClient {
59
public:
60
public:
60
    static Ref<PlaybackSessionInterfaceContext> create(PlaybackSessionManager& manager, uint64_t contextId)
61
    static Ref<PlaybackSessionInterfaceContext> create(PlaybackSessionManager& manager, PlaybackSessionContextIdentifier contextId)
61
    {
62
    {
62
        return adoptRef(*new PlaybackSessionInterfaceContext(manager, contextId));
63
        return adoptRef(*new PlaybackSessionInterfaceContext(manager, contextId));
63
    }
64
    }
Lines 86-95 private: a/Source/WebKit/WebProcess/cocoa/PlaybackSessionManager.h_sec4
86
    void volumeChanged(double) final;
87
    void volumeChanged(double) final;
87
    void isPictureInPictureSupportedChanged(bool) final;
88
    void isPictureInPictureSupportedChanged(bool) final;
88
89
89
    PlaybackSessionInterfaceContext(PlaybackSessionManager&, uint64_t contextId);
90
    PlaybackSessionInterfaceContext(PlaybackSessionManager&, PlaybackSessionContextIdentifier);
90
91
91
    PlaybackSessionManager* m_manager;
92
    PlaybackSessionManager* m_manager;
92
    uint64_t m_contextId;
93
    PlaybackSessionContextIdentifier m_contextId;
93
};
94
};
94
95
95
class PlaybackSessionManager : public RefCounted<PlaybackSessionManager>, private IPC::MessageReceiver {
96
class PlaybackSessionManager : public RefCounted<PlaybackSessionManager>, private IPC::MessageReceiver {
Lines 103-109 public: a/Source/WebKit/WebProcess/cocoa/PlaybackSessionManager.h_sec5
103
104
104
    void setUpPlaybackControlsManager(WebCore::HTMLMediaElement&);
105
    void setUpPlaybackControlsManager(WebCore::HTMLMediaElement&);
105
    void clearPlaybackControlsManager();
106
    void clearPlaybackControlsManager();
106
    uint64_t contextIdForMediaElement(WebCore::HTMLMediaElement&);
107
    PlaybackSessionContextIdentifier contextIdForMediaElement(WebCore::HTMLMediaElement&);
107
108
108
    WebCore::HTMLMediaElement* currentPlaybackControlsElement() const;
109
    WebCore::HTMLMediaElement* currentPlaybackControlsElement() const;
109
110
Lines 114-170 protected: a/Source/WebKit/WebProcess/cocoa/PlaybackSessionManager.h_sec6
114
    explicit PlaybackSessionManager(WebPage&);
115
    explicit PlaybackSessionManager(WebPage&);
115
116
116
    typedef std::tuple<RefPtr<WebCore::PlaybackSessionModelMediaElement>, RefPtr<PlaybackSessionInterfaceContext>> ModelInterfaceTuple;
117
    typedef std::tuple<RefPtr<WebCore::PlaybackSessionModelMediaElement>, RefPtr<PlaybackSessionInterfaceContext>> ModelInterfaceTuple;
117
    ModelInterfaceTuple createModelAndInterface(uint64_t contextId);
118
    ModelInterfaceTuple createModelAndInterface(PlaybackSessionContextIdentifier);
118
    ModelInterfaceTuple& ensureModelAndInterface(uint64_t contextId);
119
    ModelInterfaceTuple& ensureModelAndInterface(PlaybackSessionContextIdentifier);
119
    WebCore::PlaybackSessionModelMediaElement& ensureModel(uint64_t contextId);
120
    WebCore::PlaybackSessionModelMediaElement& ensureModel(PlaybackSessionContextIdentifier);
120
    PlaybackSessionInterfaceContext& ensureInterface(uint64_t contextId);
121
    PlaybackSessionInterfaceContext& ensureInterface(PlaybackSessionContextIdentifier);
121
    void removeContext(uint64_t contextId);
122
    void removeContext(PlaybackSessionContextIdentifier);
122
    void addClientForContext(uint64_t contextId);
123
    void addClientForContext(PlaybackSessionContextIdentifier);
123
    void removeClientForContext(uint64_t contextId);
124
    void removeClientForContext(PlaybackSessionContextIdentifier);
124
125
125
    // Interface to PlaybackSessionInterfaceContext
126
    // Interface to PlaybackSessionInterfaceContext
126
    void durationChanged(uint64_t contextId, double);
127
    void durationChanged(PlaybackSessionContextIdentifier, double);
127
    void currentTimeChanged(uint64_t contextId, double currentTime, double anchorTime);
128
    void currentTimeChanged(PlaybackSessionContextIdentifier, double currentTime, double anchorTime);
128
    void bufferedTimeChanged(uint64_t contextId, double bufferedTime);
129
    void bufferedTimeChanged(PlaybackSessionContextIdentifier, double bufferedTime);
129
    void playbackStartedTimeChanged(uint64_t contextId, double playbackStartedTime);
130
    void playbackStartedTimeChanged(PlaybackSessionContextIdentifier, double playbackStartedTime);
130
    void rateChanged(uint64_t contextId, bool isPlaying, float playbackRate);
131
    void rateChanged(PlaybackSessionContextIdentifier, bool isPlaying, float playbackRate);
131
    void seekableRangesChanged(uint64_t contextId, const WebCore::TimeRanges&, double lastModifiedTime, double liveUpdateInterval);
132
    void seekableRangesChanged(PlaybackSessionContextIdentifier, const WebCore::TimeRanges&, double lastModifiedTime, double liveUpdateInterval);
132
    void canPlayFastReverseChanged(uint64_t contextId, bool value);
133
    void canPlayFastReverseChanged(PlaybackSessionContextIdentifier, bool value);
133
    void audioMediaSelectionOptionsChanged(uint64_t contextId, const Vector<WebCore::MediaSelectionOption>& options, uint64_t selectedIndex);
134
    void audioMediaSelectionOptionsChanged(PlaybackSessionContextIdentifier, const Vector<WebCore::MediaSelectionOption>& options, uint64_t selectedIndex);
134
    void legibleMediaSelectionOptionsChanged(uint64_t contextId, const Vector<WebCore::MediaSelectionOption>& options, uint64_t selectedIndex);
135
    void legibleMediaSelectionOptionsChanged(PlaybackSessionContextIdentifier, const Vector<WebCore::MediaSelectionOption>& options, uint64_t selectedIndex);
135
    void audioMediaSelectionIndexChanged(uint64_t contextId, uint64_t selectedIndex);
136
    void audioMediaSelectionIndexChanged(PlaybackSessionContextIdentifier, uint64_t selectedIndex);
136
    void legibleMediaSelectionIndexChanged(uint64_t contextId, uint64_t selectedIndex);
137
    void legibleMediaSelectionIndexChanged(PlaybackSessionContextIdentifier, uint64_t selectedIndex);
137
    void externalPlaybackChanged(uint64_t contextId, bool enabled, WebCore::PlaybackSessionModel::ExternalPlaybackTargetType, String localizedDeviceName);
138
    void externalPlaybackChanged(PlaybackSessionContextIdentifier, bool enabled, WebCore::PlaybackSessionModel::ExternalPlaybackTargetType, String localizedDeviceName);
138
    void wirelessVideoPlaybackDisabledChanged(uint64_t contextId, bool);
139
    void wirelessVideoPlaybackDisabledChanged(PlaybackSessionContextIdentifier, bool);
139
    void mutedChanged(uint64_t contextId, bool);
140
    void mutedChanged(PlaybackSessionContextIdentifier, bool);
140
    void volumeChanged(uint64_t contextId, double);
141
    void volumeChanged(PlaybackSessionContextIdentifier, double);
141
    void isPictureInPictureSupportedChanged(uint64_t contextId, bool);
142
    void isPictureInPictureSupportedChanged(PlaybackSessionContextIdentifier, bool);
142
143
143
    // Messages from PlaybackSessionManagerProxy
144
    // Messages from PlaybackSessionManagerProxy
144
    void play(uint64_t contextId);
145
    void play(PlaybackSessionContextIdentifier);
145
    void pause(uint64_t contextId);
146
    void pause(PlaybackSessionContextIdentifier);
146
    void togglePlayState(uint64_t contextId);
147
    void togglePlayState(PlaybackSessionContextIdentifier);
147
    void beginScrubbing(uint64_t contextId);
148
    void beginScrubbing(PlaybackSessionContextIdentifier);
148
    void endScrubbing(uint64_t contextId);
149
    void endScrubbing(PlaybackSessionContextIdentifier);
149
    void seekToTime(uint64_t contextId, double time, double toleranceBefore, double toleranceAfter);
150
    void seekToTime(PlaybackSessionContextIdentifier, double time, double toleranceBefore, double toleranceAfter);
150
    void fastSeek(uint64_t contextId, double time);
151
    void fastSeek(PlaybackSessionContextIdentifier, double time);
151
    void beginScanningForward(uint64_t contextId);
152
    void beginScanningForward(PlaybackSessionContextIdentifier);
152
    void beginScanningBackward(uint64_t contextId);
153
    void beginScanningBackward(PlaybackSessionContextIdentifier);
153
    void endScanning(uint64_t contextId);
154
    void endScanning(PlaybackSessionContextIdentifier);
154
    void selectAudioMediaOption(uint64_t contextId, uint64_t index);
155
    void selectAudioMediaOption(PlaybackSessionContextIdentifier, uint64_t index);
155
    void selectLegibleMediaOption(uint64_t contextId, uint64_t index);
156
    void selectLegibleMediaOption(PlaybackSessionContextIdentifier, uint64_t index);
156
    void handleControlledElementIDRequest(uint64_t contextId);
157
    void handleControlledElementIDRequest(PlaybackSessionContextIdentifier);
157
    void togglePictureInPicture(uint64_t contextId);
158
    void togglePictureInPicture(PlaybackSessionContextIdentifier);
158
    void toggleMuted(uint64_t contextId);
159
    void toggleMuted(PlaybackSessionContextIdentifier);
159
    void setMuted(uint64_t contextId, bool muted);
160
    void setMuted(PlaybackSessionContextIdentifier, bool muted);
160
    void setVolume(uint64_t contextId, double volume);
161
    void setVolume(PlaybackSessionContextIdentifier, double volume);
161
    void setPlayingOnSecondScreen(uint64_t contextId, bool value);
162
    void setPlayingOnSecondScreen(PlaybackSessionContextIdentifier, bool value);
162
163
163
    WebPage* m_page;
164
    WebPage* m_page;
164
    HashMap<WebCore::HTMLMediaElement*, uint64_t> m_mediaElements;
165
    HashMap<WebCore::HTMLMediaElement*, PlaybackSessionContextIdentifier> m_mediaElements;
165
    HashMap<uint64_t, ModelInterfaceTuple> m_contextMap;
166
    HashMap<PlaybackSessionContextIdentifier, ModelInterfaceTuple> m_contextMap;
166
    uint64_t m_controlsManagerContextId { 0 };
167
    PlaybackSessionContextIdentifier m_controlsManagerContextId;
167
    HashCountedSet<uint64_t> m_clientCounts;
168
    HashCountedSet<PlaybackSessionContextIdentifier> m_clientCounts;
168
};
169
};
169
170
170
} // namespace WebKit
171
} // namespace WebKit
- a/Source/WebKit/WebProcess/cocoa/PlaybackSessionManager.messages.in -19 / +19 lines
Lines 1-4 a/Source/WebKit/WebProcess/cocoa/PlaybackSessionManager.messages.in_sec1
1
# Copyright (C) 2016 Apple Inc. All rights reserved.
1
# Copyright (C) 2016-2020 Apple Inc. All rights reserved.
2
#
2
#
3
# Redistribution and use in source and binary forms, with or without
3
# Redistribution and use in source and binary forms, with or without
4
# modification, are permitted provided that the following conditions
4
# modification, are permitted provided that the following conditions
Lines 23-45 a/Source/WebKit/WebProcess/cocoa/PlaybackSessionManager.messages.in_sec2
23
23
24
#if PLATFORM(IOS_FAMILY) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
24
#if PLATFORM(IOS_FAMILY) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
25
messages -> PlaybackSessionManager {
25
messages -> PlaybackSessionManager {
26
    Play(uint64_t contextId)
26
    Play(WebKit::PlaybackSessionContextIdentifier contextId)
27
    Pause(uint64_t contextId)
27
    Pause(WebKit::PlaybackSessionContextIdentifier contextId)
28
    TogglePlayState(uint64_t contextId)
28
    TogglePlayState(WebKit::PlaybackSessionContextIdentifier contextId)
29
    BeginScrubbing(uint64_t contextId)
29
    BeginScrubbing(WebKit::PlaybackSessionContextIdentifier contextId)
30
    EndScrubbing(uint64_t contextId)
30
    EndScrubbing(WebKit::PlaybackSessionContextIdentifier contextId)
31
    SeekToTime(uint64_t contextId, double time, double toleranceBefore, double toleranceAfter)
31
    SeekToTime(WebKit::PlaybackSessionContextIdentifier contextId, double time, double toleranceBefore, double toleranceAfter)
32
    FastSeek(uint64_t contextId, double time)
32
    FastSeek(WebKit::PlaybackSessionContextIdentifier contextId, double time)
33
    BeginScanningForward(uint64_t contextId)
33
    BeginScanningForward(WebKit::PlaybackSessionContextIdentifier contextId)
34
    BeginScanningBackward(uint64_t contextId)
34
    BeginScanningBackward(WebKit::PlaybackSessionContextIdentifier contextId)
35
    EndScanning(uint64_t contextId)
35
    EndScanning(WebKit::PlaybackSessionContextIdentifier contextId)
36
    SelectAudioMediaOption(uint64_t contextId, uint64_t index)
36
    SelectAudioMediaOption(WebKit::PlaybackSessionContextIdentifier contextId, uint64_t index)
37
    SelectLegibleMediaOption(uint64_t contextId, uint64_t index)
37
    SelectLegibleMediaOption(WebKit::PlaybackSessionContextIdentifier contextId, uint64_t index)
38
    HandleControlledElementIDRequest(uint64_t contextId)
38
    HandleControlledElementIDRequest(WebKit::PlaybackSessionContextIdentifier contextId)
39
    TogglePictureInPicture(uint64_t contextId)
39
    TogglePictureInPicture(WebKit::PlaybackSessionContextIdentifier contextId)
40
    ToggleMuted(uint64_t contextId)
40
    ToggleMuted(WebKit::PlaybackSessionContextIdentifier contextId)
41
    SetMuted(uint64_t contextId, bool muted)
41
    SetMuted(WebKit::PlaybackSessionContextIdentifier contextId, bool muted)
42
    SetVolume(uint64_t contextId, double volume)
42
    SetVolume(WebKit::PlaybackSessionContextIdentifier contextId, double volume)
43
    SetPlayingOnSecondScreen(uint64_t contextId, bool value)
43
    SetPlayingOnSecondScreen(WebKit::PlaybackSessionContextIdentifier contextId, bool value)
44
}
44
}
45
#endif
45
#endif
- a/Source/WebKit/WebProcess/cocoa/PlaybackSessionManager.mm -55 / +53 lines
Lines 1-5 a/Source/WebKit/WebProcess/cocoa/PlaybackSessionManager.mm_sec1
1
/*
1
/*
2
 * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
2
 * Copyright (C) 2016-2020 Apple Inc. All rights reserved.
3
 *
3
 *
4
 * Redistribution and use in source and binary forms, with or without
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
5
 * modification, are permitted provided that the following conditions
Lines 46-60 a/Source/WebKit/WebProcess/cocoa/PlaybackSessionManager.mm_sec2
46
namespace WebKit {
46
namespace WebKit {
47
using namespace WebCore;
47
using namespace WebCore;
48
48
49
static uint64_t nextContextId()
50
{
51
    static uint64_t contextId = 0;
52
    return ++contextId;
53
}
54
55
#pragma mark - PlaybackSessionInterfaceContext
49
#pragma mark - PlaybackSessionInterfaceContext
56
50
57
PlaybackSessionInterfaceContext::PlaybackSessionInterfaceContext(PlaybackSessionManager& manager, uint64_t contextId)
51
PlaybackSessionInterfaceContext::PlaybackSessionInterfaceContext(PlaybackSessionManager& manager, PlaybackSessionContextIdentifier contextId)
58
    : m_manager(&manager)
52
    : m_manager(&manager)
59
    , m_contextId(contextId)
53
    , m_contextId(contextId)
60
{
54
{
Lines 197-203 void PlaybackSessionManager::invalidate() a/Source/WebKit/WebProcess/cocoa/PlaybackSessionManager.mm_sec3
197
    m_page = nullptr;
191
    m_page = nullptr;
198
}
192
}
199
193
200
PlaybackSessionManager::ModelInterfaceTuple PlaybackSessionManager::createModelAndInterface(uint64_t contextId)
194
PlaybackSessionManager::ModelInterfaceTuple PlaybackSessionManager::createModelAndInterface(PlaybackSessionContextIdentifier contextId)
201
{
195
{
202
    auto model = PlaybackSessionModelMediaElement::create();
196
    auto model = PlaybackSessionModelMediaElement::create();
203
    auto interface = PlaybackSessionInterfaceContext::create(*this, contextId);
197
    auto interface = PlaybackSessionInterfaceContext::create(*this, contextId);
Lines 206-212 PlaybackSessionManager::ModelInterfaceTuple PlaybackSessionManager::createModelA a/Source/WebKit/WebProcess/cocoa/PlaybackSessionManager.mm_sec4
206
    return std::make_tuple(WTFMove(model), WTFMove(interface));
200
    return std::make_tuple(WTFMove(model), WTFMove(interface));
207
}
201
}
208
202
209
PlaybackSessionManager::ModelInterfaceTuple& PlaybackSessionManager::ensureModelAndInterface(uint64_t contextId)
203
PlaybackSessionManager::ModelInterfaceTuple& PlaybackSessionManager::ensureModelAndInterface(PlaybackSessionContextIdentifier contextId)
210
{
204
{
211
    auto addResult = m_contextMap.add(contextId, ModelInterfaceTuple());
205
    auto addResult = m_contextMap.add(contextId, ModelInterfaceTuple());
212
    if (addResult.isNewEntry)
206
    if (addResult.isNewEntry)
Lines 214-230 PlaybackSessionManager::ModelInterfaceTuple& PlaybackSessionManager::ensureModel a/Source/WebKit/WebProcess/cocoa/PlaybackSessionManager.mm_sec5
214
    return addResult.iterator->value;
208
    return addResult.iterator->value;
215
}
209
}
216
210
217
WebCore::PlaybackSessionModelMediaElement& PlaybackSessionManager::ensureModel(uint64_t contextId)
211
WebCore::PlaybackSessionModelMediaElement& PlaybackSessionManager::ensureModel(PlaybackSessionContextIdentifier contextId)
218
{
212
{
219
    return *std::get<0>(ensureModelAndInterface(contextId));
213
    return *std::get<0>(ensureModelAndInterface(contextId));
220
}
214
}
221
215
222
PlaybackSessionInterfaceContext& PlaybackSessionManager::ensureInterface(uint64_t contextId)
216
PlaybackSessionInterfaceContext& PlaybackSessionManager::ensureInterface(PlaybackSessionContextIdentifier contextId)
223
{
217
{
224
    return *std::get<1>(ensureModelAndInterface(contextId));
218
    return *std::get<1>(ensureModelAndInterface(contextId));
225
}
219
}
226
220
227
void PlaybackSessionManager::removeContext(uint64_t contextId)
221
void PlaybackSessionManager::removeContext(PlaybackSessionContextIdentifier contextId)
228
{
222
{
229
    auto& [model, interface] = ensureModelAndInterface(contextId);
223
    auto& [model, interface] = ensureModelAndInterface(contextId);
230
224
Lines 236-247 void PlaybackSessionManager::removeContext(uint64_t contextId) a/Source/WebKit/WebProcess/cocoa/PlaybackSessionManager.mm_sec6
236
    m_contextMap.remove(contextId);
230
    m_contextMap.remove(contextId);
237
}
231
}
238
232
239
void PlaybackSessionManager::addClientForContext(uint64_t contextId)
233
void PlaybackSessionManager::addClientForContext(PlaybackSessionContextIdentifier contextId)
240
{
234
{
241
    m_clientCounts.add(contextId);
235
    m_clientCounts.add(contextId);
242
}
236
}
243
237
244
void PlaybackSessionManager::removeClientForContext(uint64_t contextId)
238
void PlaybackSessionManager::removeClientForContext(PlaybackSessionContextIdentifier contextId)
245
{
239
{
246
    ASSERT(m_clientCounts.contains(contextId));
240
    ASSERT(m_clientCounts.contains(contextId));
247
    if (m_clientCounts.remove(contextId))
241
    if (m_clientCounts.remove(contextId))
Lines 252-258 void PlaybackSessionManager::setUpPlaybackControlsManager(WebCore::HTMLMediaElem a/Source/WebKit/WebProcess/cocoa/PlaybackSessionManager.mm_sec7
252
{
246
{
253
    auto foundIterator = m_mediaElements.find(&mediaElement);
247
    auto foundIterator = m_mediaElements.find(&mediaElement);
254
    if (foundIterator != m_mediaElements.end()) {
248
    if (foundIterator != m_mediaElements.end()) {
255
        uint64_t contextId = foundIterator->value;
249
        auto contextId = foundIterator->value;
256
        if (m_controlsManagerContextId == contextId)
250
        if (m_controlsManagerContextId == contextId)
257
            return;
251
            return;
258
252
Lines 261-267 void PlaybackSessionManager::setUpPlaybackControlsManager(WebCore::HTMLMediaElem a/Source/WebKit/WebProcess/cocoa/PlaybackSessionManager.mm_sec8
261
        if (previousContextId)
255
        if (previousContextId)
262
            removeClientForContext(previousContextId);
256
            removeClientForContext(previousContextId);
263
    } else {
257
    } else {
264
        auto contextId = m_mediaElements.ensure(&mediaElement, [&] { return nextContextId(); }).iterator->value;
258
        auto contextId = m_mediaElements.ensure(&mediaElement, [&] {
259
            return PlaybackSessionContextIdentifier::generate();
260
        }).iterator->value;
265
261
266
        auto previousContextId = m_controlsManagerContextId;
262
        auto previousContextId = m_controlsManagerContextId;
267
        m_controlsManagerContextId = contextId;
263
        m_controlsManagerContextId = contextId;
Lines 283-298 void PlaybackSessionManager::clearPlaybackControlsManager() a/Source/WebKit/WebProcess/cocoa/PlaybackSessionManager.mm_sec9
283
        return;
279
        return;
284
280
285
    removeClientForContext(m_controlsManagerContextId);
281
    removeClientForContext(m_controlsManagerContextId);
286
    m_controlsManagerContextId = 0;
282
    m_controlsManagerContextId = { };
287
283
288
    m_page->videoControlsManagerDidChange();
284
    m_page->videoControlsManagerDidChange();
289
    m_page->send(Messages::PlaybackSessionManagerProxy::ClearPlaybackControlsManager());
285
    m_page->send(Messages::PlaybackSessionManagerProxy::ClearPlaybackControlsManager());
290
}
286
}
291
287
292
uint64_t PlaybackSessionManager::contextIdForMediaElement(WebCore::HTMLMediaElement& mediaElement)
288
PlaybackSessionContextIdentifier PlaybackSessionManager::contextIdForMediaElement(WebCore::HTMLMediaElement& mediaElement)
293
{
289
{
294
    auto addResult = m_mediaElements.ensure(&mediaElement, [&] { return nextContextId(); });
290
    auto addResult = m_mediaElements.ensure(&mediaElement, [&] {
295
    uint64_t contextId = addResult.iterator->value;
291
        return PlaybackSessionContextIdentifier::generate();
292
    });
293
    auto contextId = addResult.iterator->value;
296
    ensureModel(contextId).setMediaElement(&mediaElement);
294
    ensureModel(contextId).setMediaElement(&mediaElement);
297
    return contextId;
295
    return contextId;
298
}
296
}
Lines 311-342 WebCore::HTMLMediaElement* PlaybackSessionManager::currentPlaybackControlsElemen a/Source/WebKit/WebProcess/cocoa/PlaybackSessionManager.mm_sec10
311
309
312
#pragma mark Interface to PlaybackSessionInterfaceContext:
310
#pragma mark Interface to PlaybackSessionInterfaceContext:
313
311
314
void PlaybackSessionManager::durationChanged(uint64_t contextId, double duration)
312
void PlaybackSessionManager::durationChanged(PlaybackSessionContextIdentifier contextId, double duration)
315
{
313
{
316
    m_page->send(Messages::PlaybackSessionManagerProxy::DurationChanged(contextId, duration));
314
    m_page->send(Messages::PlaybackSessionManagerProxy::DurationChanged(contextId, duration));
317
}
315
}
318
316
319
void PlaybackSessionManager::currentTimeChanged(uint64_t contextId, double currentTime, double anchorTime)
317
void PlaybackSessionManager::currentTimeChanged(PlaybackSessionContextIdentifier contextId, double currentTime, double anchorTime)
320
{
318
{
321
    m_page->send(Messages::PlaybackSessionManagerProxy::CurrentTimeChanged(contextId, currentTime, anchorTime));
319
    m_page->send(Messages::PlaybackSessionManagerProxy::CurrentTimeChanged(contextId, currentTime, anchorTime));
322
}
320
}
323
321
324
void PlaybackSessionManager::bufferedTimeChanged(uint64_t contextId, double bufferedTime)
322
void PlaybackSessionManager::bufferedTimeChanged(PlaybackSessionContextIdentifier contextId, double bufferedTime)
325
{
323
{
326
    m_page->send(Messages::PlaybackSessionManagerProxy::BufferedTimeChanged(contextId, bufferedTime));
324
    m_page->send(Messages::PlaybackSessionManagerProxy::BufferedTimeChanged(contextId, bufferedTime));
327
}
325
}
328
326
329
void PlaybackSessionManager::playbackStartedTimeChanged(uint64_t contextId, double playbackStartedTime)
327
void PlaybackSessionManager::playbackStartedTimeChanged(PlaybackSessionContextIdentifier contextId, double playbackStartedTime)
330
{
328
{
331
    m_page->send(Messages::PlaybackSessionManagerProxy::PlaybackStartedTimeChanged(contextId, playbackStartedTime));
329
    m_page->send(Messages::PlaybackSessionManagerProxy::PlaybackStartedTimeChanged(contextId, playbackStartedTime));
332
}
330
}
333
331
334
void PlaybackSessionManager::rateChanged(uint64_t contextId, bool isPlaying, float playbackRate)
332
void PlaybackSessionManager::rateChanged(PlaybackSessionContextIdentifier contextId, bool isPlaying, float playbackRate)
335
{
333
{
336
    m_page->send(Messages::PlaybackSessionManagerProxy::RateChanged(contextId, isPlaying, playbackRate));
334
    m_page->send(Messages::PlaybackSessionManagerProxy::RateChanged(contextId, isPlaying, playbackRate));
337
}
335
}
338
336
339
void PlaybackSessionManager::seekableRangesChanged(uint64_t contextId, const WebCore::TimeRanges& timeRanges, double lastModifiedTime, double liveUpdateInterval)
337
void PlaybackSessionManager::seekableRangesChanged(PlaybackSessionContextIdentifier contextId, const WebCore::TimeRanges& timeRanges, double lastModifiedTime, double liveUpdateInterval)
340
{
338
{
341
    Vector<std::pair<double, double>> rangesVector;
339
    Vector<std::pair<double, double>> rangesVector;
342
    for (unsigned i = 0; i < timeRanges.length(); i++) {
340
    for (unsigned i = 0; i < timeRanges.length(); i++) {
Lines 347-508 void PlaybackSessionManager::seekableRangesChanged(uint64_t contextId, const Web a/Source/WebKit/WebProcess/cocoa/PlaybackSessionManager.mm_sec11
347
    m_page->send(Messages::PlaybackSessionManagerProxy::SeekableRangesVectorChanged(contextId, WTFMove(rangesVector), lastModifiedTime, liveUpdateInterval));
345
    m_page->send(Messages::PlaybackSessionManagerProxy::SeekableRangesVectorChanged(contextId, WTFMove(rangesVector), lastModifiedTime, liveUpdateInterval));
348
}
346
}
349
347
350
void PlaybackSessionManager::canPlayFastReverseChanged(uint64_t contextId, bool value)
348
void PlaybackSessionManager::canPlayFastReverseChanged(PlaybackSessionContextIdentifier contextId, bool value)
351
{
349
{
352
    m_page->send(Messages::PlaybackSessionManagerProxy::CanPlayFastReverseChanged(contextId, value));
350
    m_page->send(Messages::PlaybackSessionManagerProxy::CanPlayFastReverseChanged(contextId, value));
353
}
351
}
354
352
355
void PlaybackSessionManager::audioMediaSelectionOptionsChanged(uint64_t contextId, const Vector<MediaSelectionOption>& options, uint64_t selectedIndex)
353
void PlaybackSessionManager::audioMediaSelectionOptionsChanged(PlaybackSessionContextIdentifier contextId, const Vector<MediaSelectionOption>& options, uint64_t selectedIndex)
356
{
354
{
357
    m_page->send(Messages::PlaybackSessionManagerProxy::AudioMediaSelectionOptionsChanged(contextId, options, selectedIndex));
355
    m_page->send(Messages::PlaybackSessionManagerProxy::AudioMediaSelectionOptionsChanged(contextId, options, selectedIndex));
358
}
356
}
359
357
360
void PlaybackSessionManager::legibleMediaSelectionOptionsChanged(uint64_t contextId, const Vector<MediaSelectionOption>& options, uint64_t selectedIndex)
358
void PlaybackSessionManager::legibleMediaSelectionOptionsChanged(PlaybackSessionContextIdentifier contextId, const Vector<MediaSelectionOption>& options, uint64_t selectedIndex)
361
{
359
{
362
    m_page->send(Messages::PlaybackSessionManagerProxy::LegibleMediaSelectionOptionsChanged(contextId, options, selectedIndex));
360
    m_page->send(Messages::PlaybackSessionManagerProxy::LegibleMediaSelectionOptionsChanged(contextId, options, selectedIndex));
363
}
361
}
364
362
365
void PlaybackSessionManager::externalPlaybackChanged(uint64_t contextId, bool enabled, PlaybackSessionModel::ExternalPlaybackTargetType targetType, String localizedDeviceName)
363
void PlaybackSessionManager::externalPlaybackChanged(PlaybackSessionContextIdentifier contextId, bool enabled, PlaybackSessionModel::ExternalPlaybackTargetType targetType, String localizedDeviceName)
366
{
364
{
367
    m_page->send(Messages::PlaybackSessionManagerProxy::ExternalPlaybackPropertiesChanged(contextId, enabled, static_cast<uint32_t>(targetType), localizedDeviceName));
365
    m_page->send(Messages::PlaybackSessionManagerProxy::ExternalPlaybackPropertiesChanged(contextId, enabled, static_cast<uint32_t>(targetType), localizedDeviceName));
368
}
366
}
369
367
370
void PlaybackSessionManager::audioMediaSelectionIndexChanged(uint64_t contextId, uint64_t selectedIndex)
368
void PlaybackSessionManager::audioMediaSelectionIndexChanged(PlaybackSessionContextIdentifier contextId, uint64_t selectedIndex)
371
{
369
{
372
    m_page->send(Messages::PlaybackSessionManagerProxy::AudioMediaSelectionIndexChanged(contextId, selectedIndex));
370
    m_page->send(Messages::PlaybackSessionManagerProxy::AudioMediaSelectionIndexChanged(contextId, selectedIndex));
373
}
371
}
374
372
375
void PlaybackSessionManager::legibleMediaSelectionIndexChanged(uint64_t contextId, uint64_t selectedIndex)
373
void PlaybackSessionManager::legibleMediaSelectionIndexChanged(PlaybackSessionContextIdentifier contextId, uint64_t selectedIndex)
376
{
374
{
377
    m_page->send(Messages::PlaybackSessionManagerProxy::LegibleMediaSelectionIndexChanged(contextId, selectedIndex));
375
    m_page->send(Messages::PlaybackSessionManagerProxy::LegibleMediaSelectionIndexChanged(contextId, selectedIndex));
378
}
376
}
379
377
380
void PlaybackSessionManager::wirelessVideoPlaybackDisabledChanged(uint64_t contextId, bool disabled)
378
void PlaybackSessionManager::wirelessVideoPlaybackDisabledChanged(PlaybackSessionContextIdentifier contextId, bool disabled)
381
{
379
{
382
    m_page->send(Messages::PlaybackSessionManagerProxy::WirelessVideoPlaybackDisabledChanged(contextId, disabled));
380
    m_page->send(Messages::PlaybackSessionManagerProxy::WirelessVideoPlaybackDisabledChanged(contextId, disabled));
383
}
381
}
384
382
385
void PlaybackSessionManager::mutedChanged(uint64_t contextId, bool muted)
383
void PlaybackSessionManager::mutedChanged(PlaybackSessionContextIdentifier contextId, bool muted)
386
{
384
{
387
    m_page->send(Messages::PlaybackSessionManagerProxy::MutedChanged(contextId, muted));
385
    m_page->send(Messages::PlaybackSessionManagerProxy::MutedChanged(contextId, muted));
388
}
386
}
389
387
390
void PlaybackSessionManager::volumeChanged(uint64_t contextId, double volume)
388
void PlaybackSessionManager::volumeChanged(PlaybackSessionContextIdentifier contextId, double volume)
391
{
389
{
392
    m_page->send(Messages::PlaybackSessionManagerProxy::VolumeChanged(contextId, volume));
390
    m_page->send(Messages::PlaybackSessionManagerProxy::VolumeChanged(contextId, volume));
393
}
391
}
394
392
395
void PlaybackSessionManager::isPictureInPictureSupportedChanged(uint64_t contextId, bool supported)
393
void PlaybackSessionManager::isPictureInPictureSupportedChanged(PlaybackSessionContextIdentifier contextId, bool supported)
396
{
394
{
397
    m_page->send(Messages::PlaybackSessionManagerProxy::PictureInPictureSupportedChanged(contextId, supported));
395
    m_page->send(Messages::PlaybackSessionManagerProxy::PictureInPictureSupportedChanged(contextId, supported));
398
}
396
}
399
397
400
#pragma mark Messages from PlaybackSessionManagerProxy:
398
#pragma mark Messages from PlaybackSessionManagerProxy:
401
399
402
void PlaybackSessionManager::play(uint64_t contextId)
400
void PlaybackSessionManager::play(PlaybackSessionContextIdentifier contextId)
403
{
401
{
404
    UserGestureIndicator indicator(ProcessingUserGesture);
402
    UserGestureIndicator indicator(ProcessingUserGesture);
405
    ensureModel(contextId).play();
403
    ensureModel(contextId).play();
406
}
404
}
407
405
408
void PlaybackSessionManager::pause(uint64_t contextId)
406
void PlaybackSessionManager::pause(PlaybackSessionContextIdentifier contextId)
409
{
407
{
410
    UserGestureIndicator indicator(ProcessingUserGesture);
408
    UserGestureIndicator indicator(ProcessingUserGesture);
411
    ensureModel(contextId).pause();
409
    ensureModel(contextId).pause();
412
}
410
}
413
411
414
void PlaybackSessionManager::togglePlayState(uint64_t contextId)
412
void PlaybackSessionManager::togglePlayState(PlaybackSessionContextIdentifier contextId)
415
{
413
{
416
    UserGestureIndicator indicator(ProcessingUserGesture);
414
    UserGestureIndicator indicator(ProcessingUserGesture);
417
    ensureModel(contextId).togglePlayState();
415
    ensureModel(contextId).togglePlayState();
418
}
416
}
419
417
420
void PlaybackSessionManager::beginScrubbing(uint64_t contextId)
418
void PlaybackSessionManager::beginScrubbing(PlaybackSessionContextIdentifier contextId)
421
{
419
{
422
    UserGestureIndicator indicator(ProcessingUserGesture);
420
    UserGestureIndicator indicator(ProcessingUserGesture);
423
    ensureModel(contextId).beginScrubbing();
421
    ensureModel(contextId).beginScrubbing();
424
}
422
}
425
423
426
void PlaybackSessionManager::endScrubbing(uint64_t contextId)
424
void PlaybackSessionManager::endScrubbing(PlaybackSessionContextIdentifier contextId)
427
{
425
{
428
    UserGestureIndicator indicator(ProcessingUserGesture);
426
    UserGestureIndicator indicator(ProcessingUserGesture);
429
    ensureModel(contextId).endScrubbing();
427
    ensureModel(contextId).endScrubbing();
430
}
428
}
431
429
432
void PlaybackSessionManager::seekToTime(uint64_t contextId, double time, double toleranceBefore, double toleranceAfter)
430
void PlaybackSessionManager::seekToTime(PlaybackSessionContextIdentifier contextId, double time, double toleranceBefore, double toleranceAfter)
433
{
431
{
434
    UserGestureIndicator indicator(ProcessingUserGesture);
432
    UserGestureIndicator indicator(ProcessingUserGesture);
435
    ensureModel(contextId).seekToTime(time, toleranceBefore, toleranceAfter);
433
    ensureModel(contextId).seekToTime(time, toleranceBefore, toleranceAfter);
436
}
434
}
437
435
438
void PlaybackSessionManager::fastSeek(uint64_t contextId, double time)
436
void PlaybackSessionManager::fastSeek(PlaybackSessionContextIdentifier contextId, double time)
439
{
437
{
440
    UserGestureIndicator indicator(ProcessingUserGesture);
438
    UserGestureIndicator indicator(ProcessingUserGesture);
441
    ensureModel(contextId).fastSeek(time);
439
    ensureModel(contextId).fastSeek(time);
442
}
440
}
443
441
444
void PlaybackSessionManager::beginScanningForward(uint64_t contextId)
442
void PlaybackSessionManager::beginScanningForward(PlaybackSessionContextIdentifier contextId)
445
{
443
{
446
    UserGestureIndicator indicator(ProcessingUserGesture);
444
    UserGestureIndicator indicator(ProcessingUserGesture);
447
    ensureModel(contextId).beginScanningForward();
445
    ensureModel(contextId).beginScanningForward();
448
}
446
}
449
447
450
void PlaybackSessionManager::beginScanningBackward(uint64_t contextId)
448
void PlaybackSessionManager::beginScanningBackward(PlaybackSessionContextIdentifier contextId)
451
{
449
{
452
    UserGestureIndicator indicator(ProcessingUserGesture);
450
    UserGestureIndicator indicator(ProcessingUserGesture);
453
    ensureModel(contextId).beginScanningBackward();
451
    ensureModel(contextId).beginScanningBackward();
454
}
452
}
455
453
456
void PlaybackSessionManager::endScanning(uint64_t contextId)
454
void PlaybackSessionManager::endScanning(PlaybackSessionContextIdentifier contextId)
457
{
455
{
458
    UserGestureIndicator indicator(ProcessingUserGesture);
456
    UserGestureIndicator indicator(ProcessingUserGesture);
459
    ensureModel(contextId).endScanning();
457
    ensureModel(contextId).endScanning();
460
}
458
}
461
459
462
void PlaybackSessionManager::selectAudioMediaOption(uint64_t contextId, uint64_t index)
460
void PlaybackSessionManager::selectAudioMediaOption(PlaybackSessionContextIdentifier contextId, uint64_t index)
463
{
461
{
464
    UserGestureIndicator indicator(ProcessingUserGesture);
462
    UserGestureIndicator indicator(ProcessingUserGesture);
465
    ensureModel(contextId).selectAudioMediaOption(index);
463
    ensureModel(contextId).selectAudioMediaOption(index);
466
}
464
}
467
465
468
void PlaybackSessionManager::selectLegibleMediaOption(uint64_t contextId, uint64_t index)
466
void PlaybackSessionManager::selectLegibleMediaOption(PlaybackSessionContextIdentifier contextId, uint64_t index)
469
{
467
{
470
    UserGestureIndicator indicator(ProcessingUserGesture);
468
    UserGestureIndicator indicator(ProcessingUserGesture);
471
    ensureModel(contextId).selectLegibleMediaOption(index);
469
    ensureModel(contextId).selectLegibleMediaOption(index);
472
}
470
}
473
471
474
void PlaybackSessionManager::handleControlledElementIDRequest(uint64_t contextId)
472
void PlaybackSessionManager::handleControlledElementIDRequest(PlaybackSessionContextIdentifier contextId)
475
{
473
{
476
    auto element = ensureModel(contextId).mediaElement();
474
    auto element = ensureModel(contextId).mediaElement();
477
    if (element)
475
    if (element)
478
        m_page->send(Messages::PlaybackSessionManagerProxy::HandleControlledElementIDResponse(contextId, element->getIdAttribute()));
476
        m_page->send(Messages::PlaybackSessionManagerProxy::HandleControlledElementIDResponse(contextId, element->getIdAttribute()));
479
}
477
}
480
478
481
void PlaybackSessionManager::togglePictureInPicture(uint64_t contextId)
479
void PlaybackSessionManager::togglePictureInPicture(PlaybackSessionContextIdentifier contextId)
482
{
480
{
483
    UserGestureIndicator indicator(ProcessingUserGesture);
481
    UserGestureIndicator indicator(ProcessingUserGesture);
484
    ensureModel(contextId).togglePictureInPicture();
482
    ensureModel(contextId).togglePictureInPicture();
485
}
483
}
486
484
487
void PlaybackSessionManager::toggleMuted(uint64_t contextId)
485
void PlaybackSessionManager::toggleMuted(PlaybackSessionContextIdentifier contextId)
488
{
486
{
489
    UserGestureIndicator indicator(ProcessingUserGesture);
487
    UserGestureIndicator indicator(ProcessingUserGesture);
490
    ensureModel(contextId).toggleMuted();
488
    ensureModel(contextId).toggleMuted();
491
}
489
}
492
490
493
void PlaybackSessionManager::setMuted(uint64_t contextId, bool muted)
491
void PlaybackSessionManager::setMuted(PlaybackSessionContextIdentifier contextId, bool muted)
494
{
492
{
495
    UserGestureIndicator indicator(ProcessingUserGesture);
493
    UserGestureIndicator indicator(ProcessingUserGesture);
496
    ensureModel(contextId).setMuted(muted);
494
    ensureModel(contextId).setMuted(muted);
497
}
495
}
498
496
499
void PlaybackSessionManager::setVolume(uint64_t contextId, double volume)
497
void PlaybackSessionManager::setVolume(PlaybackSessionContextIdentifier contextId, double volume)
500
{
498
{
501
    UserGestureIndicator indicator(ProcessingUserGesture);
499
    UserGestureIndicator indicator(ProcessingUserGesture);
502
    ensureModel(contextId).setVolume(volume);
500
    ensureModel(contextId).setVolume(volume);
503
}
501
}
504
502
505
void PlaybackSessionManager::setPlayingOnSecondScreen(uint64_t contextId, bool value)
503
void PlaybackSessionManager::setPlayingOnSecondScreen(PlaybackSessionContextIdentifier contextId, bool value)
506
{
504
{
507
    UserGestureIndicator indicator(ProcessingUserGesture);
505
    UserGestureIndicator indicator(ProcessingUserGesture);
508
    ensureModel(contextId).setPlayingOnSecondScreen(value);
506
    ensureModel(contextId).setPlayingOnSecondScreen(value);
- a/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.h -33 / +33 lines
Lines 1-5 a/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.h_sec1
1
/*
1
/*
2
 * Copyright (C) 2014 Apple Inc. All rights reserved.
2
 * Copyright (C) 2014-2020 Apple Inc. All rights reserved.
3
 *
3
 *
4
 * Redistribution and use in source and binary forms, with or without
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
5
 * modification, are permitted provided that the following conditions
Lines 29-34 a/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.h_sec2
29
29
30
#include "Connection.h"
30
#include "Connection.h"
31
#include "MessageReceiver.h"
31
#include "MessageReceiver.h"
32
#include "PlaybackSessionContextIdentifier.h"
32
#include "VideoFullscreenManagerMessagesReplies.h"
33
#include "VideoFullscreenManagerMessagesReplies.h"
33
#include <WebCore/EventListener.h>
34
#include <WebCore/EventListener.h>
34
#include <WebCore/HTMLMediaElementEnums.h>
35
#include <WebCore/HTMLMediaElementEnums.h>
Lines 62-68 class VideoFullscreenInterfaceContext a/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.h_sec3
62
    : public RefCounted<VideoFullscreenInterfaceContext>
63
    : public RefCounted<VideoFullscreenInterfaceContext>
63
    , public WebCore::VideoFullscreenModelClient {
64
    , public WebCore::VideoFullscreenModelClient {
64
public:
65
public:
65
    static Ref<VideoFullscreenInterfaceContext> create(VideoFullscreenManager& manager, uint64_t contextId)
66
    static Ref<VideoFullscreenInterfaceContext> create(VideoFullscreenManager& manager, PlaybackSessionContextIdentifier contextId)
66
    {
67
    {
67
        return adoptRef(*new VideoFullscreenInterfaceContext(manager, contextId));
68
        return adoptRef(*new VideoFullscreenInterfaceContext(manager, contextId));
68
    }
69
    }
Lines 94-103 private: a/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.h_sec4
94
    void hasVideoChanged(bool) override;
95
    void hasVideoChanged(bool) override;
95
    void videoDimensionsChanged(const WebCore::FloatSize&) override;
96
    void videoDimensionsChanged(const WebCore::FloatSize&) override;
96
97
97
    VideoFullscreenInterfaceContext(VideoFullscreenManager&, uint64_t contextId);
98
    VideoFullscreenInterfaceContext(VideoFullscreenManager&, PlaybackSessionContextIdentifier);
98
99
99
    VideoFullscreenManager* m_manager;
100
    VideoFullscreenManager* m_manager;
100
    uint64_t m_contextId;
101
    PlaybackSessionContextIdentifier m_contextId;
101
    std::unique_ptr<LayerHostingContext> m_layerHostingContext;
102
    std::unique_ptr<LayerHostingContext> m_layerHostingContext;
102
    AnimationType m_animationType { false };
103
    AnimationType m_animationType { false };
103
    bool m_targetIsFullscreen { false };
104
    bool m_targetIsFullscreen { false };
Lines 128-170 protected: a/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.h_sec5
128
    explicit VideoFullscreenManager(WebPage&, PlaybackSessionManager&);
129
    explicit VideoFullscreenManager(WebPage&, PlaybackSessionManager&);
129
130
130
    typedef std::tuple<RefPtr<WebCore::VideoFullscreenModelVideoElement>, RefPtr<VideoFullscreenInterfaceContext>> ModelInterfaceTuple;
131
    typedef std::tuple<RefPtr<WebCore::VideoFullscreenModelVideoElement>, RefPtr<VideoFullscreenInterfaceContext>> ModelInterfaceTuple;
131
    ModelInterfaceTuple createModelAndInterface(uint64_t contextId);
132
    ModelInterfaceTuple createModelAndInterface(PlaybackSessionContextIdentifier);
132
    ModelInterfaceTuple& ensureModelAndInterface(uint64_t contextId);
133
    ModelInterfaceTuple& ensureModelAndInterface(PlaybackSessionContextIdentifier);
133
    WebCore::VideoFullscreenModelVideoElement& ensureModel(uint64_t contextId);
134
    WebCore::VideoFullscreenModelVideoElement& ensureModel(PlaybackSessionContextIdentifier);
134
    VideoFullscreenInterfaceContext& ensureInterface(uint64_t contextId);
135
    VideoFullscreenInterfaceContext& ensureInterface(PlaybackSessionContextIdentifier);
135
    void removeContext(uint64_t contextId);
136
    void removeContext(PlaybackSessionContextIdentifier);
136
    void addClientForContext(uint64_t contextId);
137
    void addClientForContext(PlaybackSessionContextIdentifier);
137
    void removeClientForContext(uint64_t contextId);
138
    void removeClientForContext(PlaybackSessionContextIdentifier);
138
139
139
    // Interface to VideoFullscreenInterfaceContext
140
    // Interface to VideoFullscreenInterfaceContext
140
    void hasVideoChanged(uint64_t contextId, bool hasVideo);
141
    void hasVideoChanged(PlaybackSessionContextIdentifier, bool hasVideo);
141
    void videoDimensionsChanged(uint64_t contextId, const WebCore::FloatSize&);
142
    void videoDimensionsChanged(PlaybackSessionContextIdentifier, const WebCore::FloatSize&);
142
143
143
    // Messages from VideoFullscreenManagerProxy
144
    // Messages from VideoFullscreenManagerProxy
144
    void requestFullscreenMode(uint64_t contextId, WebCore::HTMLMediaElementEnums::VideoFullscreenMode, bool finishedWithMedia);
145
    void requestFullscreenMode(PlaybackSessionContextIdentifier, WebCore::HTMLMediaElementEnums::VideoFullscreenMode, bool finishedWithMedia);
145
    void requestUpdateInlineRect(uint64_t contextId);
146
    void requestUpdateInlineRect(PlaybackSessionContextIdentifier);
146
    void requestVideoContentLayer(uint64_t contextId);
147
    void requestVideoContentLayer(PlaybackSessionContextIdentifier);
147
    void returnVideoContentLayer(uint64_t contextId);
148
    void returnVideoContentLayer(PlaybackSessionContextIdentifier);
148
    void didSetupFullscreen(uint64_t contextId);
149
    void didSetupFullscreen(PlaybackSessionContextIdentifier);
149
    void willExitFullscreen(uint64_t contextId);
150
    void willExitFullscreen(PlaybackSessionContextIdentifier);
150
    void didExitFullscreen(uint64_t contextId);
151
    void didExitFullscreen(PlaybackSessionContextIdentifier);
151
    void didEnterFullscreen(uint64_t contextId);
152
    void didEnterFullscreen(PlaybackSessionContextIdentifier);
152
    void didCleanupFullscreen(uint64_t contextId);
153
    void didCleanupFullscreen(PlaybackSessionContextIdentifier);
153
    void setVideoLayerFrameFenced(uint64_t contextId, WebCore::FloatRect bounds, IPC::Attachment fencePort);
154
    void setVideoLayerFrameFenced(PlaybackSessionContextIdentifier, WebCore::FloatRect bounds, IPC::Attachment fencePort);
154
    void setVideoLayerGravityEnum(uint64_t contextId, unsigned gravity);
155
    void setVideoLayerGravityEnum(PlaybackSessionContextIdentifier, unsigned gravity);
155
    void fullscreenModeChanged(uint64_t contextId, WebCore::HTMLMediaElementEnums::VideoFullscreenMode);
156
    void fullscreenModeChanged(PlaybackSessionContextIdentifier, WebCore::HTMLMediaElementEnums::VideoFullscreenMode);
156
    void fullscreenMayReturnToInline(uint64_t contextId, bool isPageVisible);
157
    void fullscreenMayReturnToInline(PlaybackSessionContextIdentifier, bool isPageVisible);
157
    void requestRouteSharingPolicyAndContextUID(uint64_t contextId, Messages::VideoFullscreenManager::RequestRouteSharingPolicyAndContextUIDAsyncReply&&);
158
    void requestRouteSharingPolicyAndContextUID(PlaybackSessionContextIdentifier, Messages::VideoFullscreenManager::RequestRouteSharingPolicyAndContextUIDAsyncReply&&);
158
159
159
    WebPage* m_page;
160
    WebPage* m_page;
160
    Ref<PlaybackSessionManager> m_playbackSessionManager;
161
    Ref<PlaybackSessionManager> m_playbackSessionManager;
161
    HashMap<WebCore::HTMLVideoElement*, uint64_t> m_videoElements;
162
    HashMap<WebCore::HTMLVideoElement*, PlaybackSessionContextIdentifier> m_videoElements;
162
    HashMap<uint64_t, ModelInterfaceTuple> m_contextMap;
163
    HashMap<PlaybackSessionContextIdentifier, ModelInterfaceTuple> m_contextMap;
163
    uint64_t m_controlsManagerContextId { 0 };
164
    PlaybackSessionContextIdentifier m_controlsManagerContextId;
164
    HashMap<uint64_t, int> m_clientCounts;
165
    HashMap<PlaybackSessionContextIdentifier, int> m_clientCounts;
165
};
166
};
166
    
167
167
} // namespace WebKit
168
} // namespace WebKit
168
169
169
#endif // ENABLE(VIDEO_PRESENTATION_MODE)
170
#endif // ENABLE(VIDEO_PRESENTATION_MODE)
170
- a/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.messages.in -14 / +14 lines
Lines 22-40 a/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.messages.in_sec1
22
22
23
#if ENABLE(VIDEO_PRESENTATION_MODE)
23
#if ENABLE(VIDEO_PRESENTATION_MODE)
24
messages -> VideoFullscreenManager {
24
messages -> VideoFullscreenManager {
25
    RequestFullscreenMode(uint64_t contextId, WebCore::HTMLMediaElementEnums::VideoFullscreenMode videoFullscreenMode, bool finishedWithMedia)
25
    RequestFullscreenMode(WebKit::PlaybackSessionContextIdentifier contextId, WebCore::HTMLMediaElementEnums::VideoFullscreenMode videoFullscreenMode, bool finishedWithMedia)
26
    RequestUpdateInlineRect(uint64_t contextId)
26
    RequestUpdateInlineRect(WebKit::PlaybackSessionContextIdentifier contextId)
27
    RequestVideoContentLayer(uint64_t contextId)
27
    RequestVideoContentLayer(WebKit::PlaybackSessionContextIdentifier contextId)
28
    ReturnVideoContentLayer(uint64_t contextId)
28
    ReturnVideoContentLayer(WebKit::PlaybackSessionContextIdentifier contextId)
29
    DidSetupFullscreen(uint64_t contextId)
29
    DidSetupFullscreen(WebKit::PlaybackSessionContextIdentifier contextId)
30
    WillExitFullscreen(uint64_t contextId)
30
    WillExitFullscreen(WebKit::PlaybackSessionContextIdentifier contextId)
31
    DidExitFullscreen(uint64_t contextId)
31
    DidExitFullscreen(WebKit::PlaybackSessionContextIdentifier contextId)
32
    DidEnterFullscreen(uint64_t contextId)
32
    DidEnterFullscreen(WebKit::PlaybackSessionContextIdentifier contextId)
33
    DidCleanupFullscreen(uint64_t contextId)
33
    DidCleanupFullscreen(WebKit::PlaybackSessionContextIdentifier contextId)
34
    SetVideoLayerFrameFenced(uint64_t contextId, WebCore::FloatRect bounds, IPC::Attachment fencePort)
34
    SetVideoLayerFrameFenced(WebKit::PlaybackSessionContextIdentifier contextId, WebCore::FloatRect bounds, IPC::Attachment fencePort)
35
    SetVideoLayerGravityEnum(uint64_t contextId, unsigned gravity)
35
    SetVideoLayerGravityEnum(WebKit::PlaybackSessionContextIdentifier contextId, unsigned gravity)
36
    FullscreenModeChanged(uint64_t contextId, WebCore::HTMLMediaElementEnums::VideoFullscreenMode videoFullscreenMode)
36
    FullscreenModeChanged(WebKit::PlaybackSessionContextIdentifier contextId, WebCore::HTMLMediaElementEnums::VideoFullscreenMode videoFullscreenMode)
37
    FullscreenMayReturnToInline(uint64_t contextId, bool isPageVisible)
37
    FullscreenMayReturnToInline(WebKit::PlaybackSessionContextIdentifier contextId, bool isPageVisible)
38
    RequestRouteSharingPolicyAndContextUID(uint64_t contextId) -> (enum:uint8_t WebCore::RouteSharingPolicy routeSharingPolicy, String routingContextUID) Async
38
    RequestRouteSharingPolicyAndContextUID(WebKit::PlaybackSessionContextIdentifier contextId) -> (enum:uint8_t WebCore::RouteSharingPolicy routeSharingPolicy, String routingContextUID) Async
39
}
39
}
40
#endif
40
#endif
- a/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm -27 / +27 lines
Lines 82-88 static IntRect inlineVideoFrame(HTMLVideoElement& element) a/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm_sec1
82
82
83
#pragma mark - VideoFullscreenInterfaceContext
83
#pragma mark - VideoFullscreenInterfaceContext
84
84
85
VideoFullscreenInterfaceContext::VideoFullscreenInterfaceContext(VideoFullscreenManager& manager, uint64_t contextId)
85
VideoFullscreenInterfaceContext::VideoFullscreenInterfaceContext(VideoFullscreenManager& manager, PlaybackSessionContextIdentifier contextId)
86
    : m_manager(&manager)
86
    : m_manager(&manager)
87
    , m_contextId(contextId)
87
    , m_contextId(contextId)
88
{
88
{
Lines 147-153 void VideoFullscreenManager::invalidate() a/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm_sec2
147
    m_page = nullptr;
147
    m_page = nullptr;
148
}
148
}
149
149
150
VideoFullscreenManager::ModelInterfaceTuple VideoFullscreenManager::createModelAndInterface(uint64_t contextId)
150
VideoFullscreenManager::ModelInterfaceTuple VideoFullscreenManager::createModelAndInterface(PlaybackSessionContextIdentifier contextId)
151
{
151
{
152
    auto model = VideoFullscreenModelVideoElement::create();
152
    auto model = VideoFullscreenModelVideoElement::create();
153
    auto interface = VideoFullscreenInterfaceContext::create(*this, contextId);
153
    auto interface = VideoFullscreenInterfaceContext::create(*this, contextId);
Lines 159-165 VideoFullscreenManager::ModelInterfaceTuple VideoFullscreenManager::createModelA a/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm_sec3
159
    return std::make_tuple(WTFMove(model), WTFMove(interface));
159
    return std::make_tuple(WTFMove(model), WTFMove(interface));
160
}
160
}
161
161
162
VideoFullscreenManager::ModelInterfaceTuple& VideoFullscreenManager::ensureModelAndInterface(uint64_t contextId)
162
VideoFullscreenManager::ModelInterfaceTuple& VideoFullscreenManager::ensureModelAndInterface(PlaybackSessionContextIdentifier contextId)
163
{
163
{
164
    auto addResult = m_contextMap.add(contextId, ModelInterfaceTuple());
164
    auto addResult = m_contextMap.add(contextId, ModelInterfaceTuple());
165
    if (addResult.isNewEntry)
165
    if (addResult.isNewEntry)
Lines 167-183 VideoFullscreenManager::ModelInterfaceTuple& VideoFullscreenManager::ensureModel a/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm_sec4
167
    return addResult.iterator->value;
167
    return addResult.iterator->value;
168
}
168
}
169
169
170
WebCore::VideoFullscreenModelVideoElement& VideoFullscreenManager::ensureModel(uint64_t contextId)
170
WebCore::VideoFullscreenModelVideoElement& VideoFullscreenManager::ensureModel(PlaybackSessionContextIdentifier contextId)
171
{
171
{
172
    return *std::get<0>(ensureModelAndInterface(contextId));
172
    return *std::get<0>(ensureModelAndInterface(contextId));
173
}
173
}
174
174
175
VideoFullscreenInterfaceContext& VideoFullscreenManager::ensureInterface(uint64_t contextId)
175
VideoFullscreenInterfaceContext& VideoFullscreenManager::ensureInterface(PlaybackSessionContextIdentifier contextId)
176
{
176
{
177
    return *std::get<1>(ensureModelAndInterface(contextId));
177
    return *std::get<1>(ensureModelAndInterface(contextId));
178
}
178
}
179
179
180
void VideoFullscreenManager::removeContext(uint64_t contextId)
180
void VideoFullscreenManager::removeContext(PlaybackSessionContextIdentifier contextId)
181
{
181
{
182
    auto [model, interface] = ensureModelAndInterface(contextId);
182
    auto [model, interface] = ensureModelAndInterface(contextId);
183
183
Lines 191-204 void VideoFullscreenManager::removeContext(uint64_t contextId) a/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm_sec5
191
    m_contextMap.remove(contextId);
191
    m_contextMap.remove(contextId);
192
}
192
}
193
193
194
void VideoFullscreenManager::addClientForContext(uint64_t contextId)
194
void VideoFullscreenManager::addClientForContext(PlaybackSessionContextIdentifier contextId)
195
{
195
{
196
    auto addResult = m_clientCounts.add(contextId, 1);
196
    auto addResult = m_clientCounts.add(contextId, 1);
197
    if (!addResult.isNewEntry)
197
    if (!addResult.isNewEntry)
198
        addResult.iterator->value++;
198
        addResult.iterator->value++;
199
}
199
}
200
200
201
void VideoFullscreenManager::removeClientForContext(uint64_t contextId)
201
void VideoFullscreenManager::removeClientForContext(PlaybackSessionContextIdentifier contextId)
202
{
202
{
203
    ASSERT(m_clientCounts.contains(contextId));
203
    ASSERT(m_clientCounts.contains(contextId));
204
204
Lines 242-248 void VideoFullscreenManager::enterVideoFullscreenForVideoElement(HTMLVideoElemen a/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm_sec6
242
    ASSERT(standby || mode != HTMLMediaElementEnums::VideoFullscreenModeNone);
242
    ASSERT(standby || mode != HTMLMediaElementEnums::VideoFullscreenModeNone);
243
    LOG(Fullscreen, "VideoFullscreenManager::enterVideoFullscreenForVideoElement(%p)", this);
243
    LOG(Fullscreen, "VideoFullscreenManager::enterVideoFullscreenForVideoElement(%p)", this);
244
244
245
    uint64_t contextId = m_playbackSessionManager->contextIdForMediaElement(videoElement);
245
    auto contextId = m_playbackSessionManager->contextIdForMediaElement(videoElement);
246
    auto addResult = m_videoElements.add(&videoElement, contextId);
246
    auto addResult = m_videoElements.add(&videoElement, contextId);
247
    UNUSED_PARAM(addResult);
247
    UNUSED_PARAM(addResult);
248
    ASSERT(addResult.iterator->value == contextId);
248
    ASSERT(addResult.iterator->value == contextId);
Lines 294-300 void VideoFullscreenManager::exitVideoFullscreenForVideoElement(WebCore::HTMLVid a/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm_sec7
294
    ASSERT(m_page);
294
    ASSERT(m_page);
295
    ASSERT(m_videoElements.contains(&videoElement));
295
    ASSERT(m_videoElements.contains(&videoElement));
296
296
297
    uint64_t contextId = m_videoElements.get(&videoElement);
297
    auto contextId = m_videoElements.get(&videoElement);
298
    auto& interface = ensureInterface(contextId);
298
    auto& interface = ensureInterface(contextId);
299
    interface.setTargetIsFullscreen(false);
299
    interface.setTargetIsFullscreen(false);
300
    if (interface.animationState() != VideoFullscreenInterfaceContext::AnimationType::None)
300
    if (interface.animationState() != VideoFullscreenInterfaceContext::AnimationType::None)
Lines 311-317 void VideoFullscreenManager::exitVideoFullscreenToModeWithoutAnimation(WebCore:: a/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm_sec8
311
    ASSERT(m_page);
311
    ASSERT(m_page);
312
    ASSERT(m_videoElements.contains(&videoElement));
312
    ASSERT(m_videoElements.contains(&videoElement));
313
313
314
    uint64_t contextId = m_videoElements.get(&videoElement);
314
    auto contextId = m_videoElements.get(&videoElement);
315
    auto& interface = ensureInterface(contextId);
315
    auto& interface = ensureInterface(contextId);
316
316
317
    interface.setTargetIsFullscreen(false);
317
    interface.setTargetIsFullscreen(false);
Lines 321-333 void VideoFullscreenManager::exitVideoFullscreenToModeWithoutAnimation(WebCore:: a/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm_sec9
321
321
322
#pragma mark Interface to VideoFullscreenInterfaceContext:
322
#pragma mark Interface to VideoFullscreenInterfaceContext:
323
323
324
void VideoFullscreenManager::hasVideoChanged(uint64_t contextId, bool hasVideo)
324
void VideoFullscreenManager::hasVideoChanged(PlaybackSessionContextIdentifier contextId, bool hasVideo)
325
{
325
{
326
    if (m_page)
326
    if (m_page)
327
        m_page->send(Messages::VideoFullscreenManagerProxy::SetHasVideo(contextId, hasVideo));
327
        m_page->send(Messages::VideoFullscreenManagerProxy::SetHasVideo(contextId, hasVideo));
328
}
328
}
329
329
330
void VideoFullscreenManager::videoDimensionsChanged(uint64_t contextId, const FloatSize& videoDimensions)
330
void VideoFullscreenManager::videoDimensionsChanged(PlaybackSessionContextIdentifier contextId, const FloatSize& videoDimensions)
331
{
331
{
332
    if (m_page)
332
    if (m_page)
333
        m_page->send(Messages::VideoFullscreenManagerProxy::SetVideoDimensions(contextId, videoDimensions));
333
        m_page->send(Messages::VideoFullscreenManagerProxy::SetVideoDimensions(contextId, videoDimensions));
Lines 335-351 void VideoFullscreenManager::videoDimensionsChanged(uint64_t contextId, const Fl a/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm_sec10
335
335
336
#pragma mark Messages from VideoFullscreenManagerProxy:
336
#pragma mark Messages from VideoFullscreenManagerProxy:
337
337
338
void VideoFullscreenManager::requestFullscreenMode(uint64_t contextId, WebCore::HTMLMediaElementEnums::VideoFullscreenMode mode, bool finishedWithMedia)
338
void VideoFullscreenManager::requestFullscreenMode(PlaybackSessionContextIdentifier contextId, WebCore::HTMLMediaElementEnums::VideoFullscreenMode mode, bool finishedWithMedia)
339
{
339
{
340
    ensureModel(contextId).requestFullscreenMode(mode, finishedWithMedia);
340
    ensureModel(contextId).requestFullscreenMode(mode, finishedWithMedia);
341
}
341
}
342
342
343
void VideoFullscreenManager::fullscreenModeChanged(uint64_t contextId, WebCore::HTMLMediaElementEnums::VideoFullscreenMode videoFullscreenMode)
343
void VideoFullscreenManager::fullscreenModeChanged(PlaybackSessionContextIdentifier contextId, WebCore::HTMLMediaElementEnums::VideoFullscreenMode videoFullscreenMode)
344
{
344
{
345
    ensureModel(contextId).fullscreenModeChanged(videoFullscreenMode);
345
    ensureModel(contextId).fullscreenModeChanged(videoFullscreenMode);
346
}
346
}
347
347
348
void VideoFullscreenManager::requestUpdateInlineRect(uint64_t contextId)
348
void VideoFullscreenManager::requestUpdateInlineRect(PlaybackSessionContextIdentifier contextId)
349
{
349
{
350
    if (!m_page)
350
    if (!m_page)
351
        return;
351
        return;
Lines 355-361 void VideoFullscreenManager::requestUpdateInlineRect(uint64_t contextId) a/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm_sec11
355
    m_page->send(Messages::VideoFullscreenManagerProxy::SetInlineRect(contextId, inlineRect, inlineRect != IntRect(0, 0, 0, 0)));
355
    m_page->send(Messages::VideoFullscreenManagerProxy::SetInlineRect(contextId, inlineRect, inlineRect != IntRect(0, 0, 0, 0)));
356
}
356
}
357
357
358
void VideoFullscreenManager::requestVideoContentLayer(uint64_t contextId)
358
void VideoFullscreenManager::requestVideoContentLayer(PlaybackSessionContextIdentifier contextId)
359
{
359
{
360
    auto [model, interface] = ensureModelAndInterface(contextId);
360
    auto [model, interface] = ensureModelAndInterface(contextId);
361
361
Lines 369-375 void VideoFullscreenManager::requestVideoContentLayer(uint64_t contextId) a/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm_sec12
369
    });
369
    });
370
}
370
}
371
371
372
void VideoFullscreenManager::returnVideoContentLayer(uint64_t contextId)
372
void VideoFullscreenManager::returnVideoContentLayer(PlaybackSessionContextIdentifier contextId)
373
{
373
{
374
    RefPtr<VideoFullscreenModelVideoElement> model;
374
    RefPtr<VideoFullscreenModelVideoElement> model;
375
    RefPtr<VideoFullscreenInterfaceContext> interface;
375
    RefPtr<VideoFullscreenInterfaceContext> interface;
Lines 387-393 void VideoFullscreenManager::returnVideoContentLayer(uint64_t contextId) a/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm_sec13
387
    });
387
    });
388
}
388
}
389
389
390
void VideoFullscreenManager::didSetupFullscreen(uint64_t contextId)
390
void VideoFullscreenManager::didSetupFullscreen(PlaybackSessionContextIdentifier contextId)
391
{
391
{
392
    LOG(Fullscreen, "VideoFullscreenManager::didSetupFullscreen(%p, %x)", this, contextId);
392
    LOG(Fullscreen, "VideoFullscreenManager::didSetupFullscreen(%p, %x)", this, contextId);
393
393
Lines 411-417 void VideoFullscreenManager::didSetupFullscreen(uint64_t contextId) a/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm_sec14
411
#endif
411
#endif
412
}
412
}
413
413
414
void VideoFullscreenManager::willExitFullscreen(uint64_t contextId)
414
void VideoFullscreenManager::willExitFullscreen(PlaybackSessionContextIdentifier contextId)
415
{
415
{
416
    LOG(Fullscreen, "VideoFullscreenManager::willExitFullscreen(%p, %x)", this, contextId);
416
    LOG(Fullscreen, "VideoFullscreenManager::willExitFullscreen(%p, %x)", this, contextId);
417
417
Lines 428-434 void VideoFullscreenManager::willExitFullscreen(uint64_t contextId) a/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm_sec15
428
    });
428
    });
429
}
429
}
430
430
431
void VideoFullscreenManager::didEnterFullscreen(uint64_t contextId)
431
void VideoFullscreenManager::didEnterFullscreen(PlaybackSessionContextIdentifier contextId)
432
{
432
{
433
    LOG(Fullscreen, "VideoFullscreenManager::didEnterFullscreen(%p, %x)", this, contextId);
433
    LOG(Fullscreen, "VideoFullscreenManager::didEnterFullscreen(%p, %x)", this, contextId);
434
434
Lines 453-459 void VideoFullscreenManager::didEnterFullscreen(uint64_t contextId) a/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm_sec16
453
    });
453
    });
454
}
454
}
455
455
456
void VideoFullscreenManager::didExitFullscreen(uint64_t contextId)
456
void VideoFullscreenManager::didExitFullscreen(PlaybackSessionContextIdentifier contextId)
457
{
457
{
458
    LOG(Fullscreen, "VideoFullscreenManager::didExitFullscreen(%p, %x)", this, contextId);
458
    LOG(Fullscreen, "VideoFullscreenManager::didExitFullscreen(%p, %x)", this, contextId);
459
459
Lines 484-490 void VideoFullscreenManager::didExitFullscreen(uint64_t contextId) a/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm_sec17
484
#endif
484
#endif
485
}
485
}
486
    
486
    
487
void VideoFullscreenManager::didCleanupFullscreen(uint64_t contextId)
487
void VideoFullscreenManager::didCleanupFullscreen(PlaybackSessionContextIdentifier contextId)
488
{
488
{
489
    LOG(Fullscreen, "VideoFullscreenManager::didCleanupFullscreen(%p, %x)", this, contextId);
489
    LOG(Fullscreen, "VideoFullscreenManager::didCleanupFullscreen(%p, %x)", this, contextId);
490
490
Lines 519-530 void VideoFullscreenManager::didCleanupFullscreen(uint64_t contextId) a/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm_sec18
519
    });
519
    });
520
}
520
}
521
    
521
    
522
void VideoFullscreenManager::setVideoLayerGravityEnum(uint64_t contextId, unsigned gravity)
522
void VideoFullscreenManager::setVideoLayerGravityEnum(PlaybackSessionContextIdentifier contextId, unsigned gravity)
523
{
523
{
524
    ensureModel(contextId).setVideoLayerGravity((MediaPlayerEnums::VideoGravity)gravity);
524
    ensureModel(contextId).setVideoLayerGravity((MediaPlayerEnums::VideoGravity)gravity);
525
}
525
}
526
    
526
    
527
void VideoFullscreenManager::fullscreenMayReturnToInline(uint64_t contextId, bool isPageVisible)
527
void VideoFullscreenManager::fullscreenMayReturnToInline(PlaybackSessionContextIdentifier contextId, bool isPageVisible)
528
{
528
{
529
    if (!m_page)
529
    if (!m_page)
530
        return;
530
        return;
Lines 536-547 void VideoFullscreenManager::fullscreenMayReturnToInline(uint64_t contextId, boo a/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm_sec19
536
    m_page->send(Messages::VideoFullscreenManagerProxy::PreparedToReturnToInline(contextId, true, inlineVideoFrame(*model.videoElement())));
536
    m_page->send(Messages::VideoFullscreenManagerProxy::PreparedToReturnToInline(contextId, true, inlineVideoFrame(*model.videoElement())));
537
}
537
}
538
538
539
void VideoFullscreenManager::requestRouteSharingPolicyAndContextUID(uint64_t contextId, Messages::VideoFullscreenManager::RequestRouteSharingPolicyAndContextUID::AsyncReply&& reply)
539
void VideoFullscreenManager::requestRouteSharingPolicyAndContextUID(PlaybackSessionContextIdentifier contextId, Messages::VideoFullscreenManager::RequestRouteSharingPolicyAndContextUID::AsyncReply&& reply)
540
{
540
{
541
    ensureModel(contextId).requestRouteSharingPolicyAndContextUID(WTFMove(reply));
541
    ensureModel(contextId).requestRouteSharingPolicyAndContextUID(WTFMove(reply));
542
}
542
}
543
    
543
    
544
void VideoFullscreenManager::setVideoLayerFrameFenced(uint64_t contextId, WebCore::FloatRect bounds, IPC::Attachment fencePort)
544
void VideoFullscreenManager::setVideoLayerFrameFenced(PlaybackSessionContextIdentifier contextId, WebCore::FloatRect bounds, IPC::Attachment fencePort)
545
{
545
{
546
    LOG(Fullscreen, "VideoFullscreenManager::setVideoLayerFrameFenced(%p, %x)", this, contextId);
546
    LOG(Fullscreen, "VideoFullscreenManager::setVideoLayerFrameFenced(%p, %x)", this, contextId);
547
547

Return to Bug 212392