Changeset 205365 in webkit
- Timestamp:
- Sep 2, 2016 1:06:52 PM (8 years ago)
- Location:
- trunk/Source
- Files:
-
- 33 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r205360 r205365 1 2016-07-08 Jer Noble <jer.noble@apple.com> 2 3 Refactor WebPlaybackSessionModelMediaElement to be client based. 4 https://bugs.webkit.org/show_bug.cgi?id=159580 5 6 Reviewed by Eric Carlson. 7 8 Add client callback interfaces to both WebPlaybackSessionModel and WebVideoFullscreenModel, where each object 9 can have multiple clients, and so the object will both store current values and also notify those clients 10 when the values change. After this change, there is no need to have the models know about their associated 11 interfaces explicitly. 12 13 * platform/cocoa/WebPlaybackSessionInterface.h: 14 * platform/cocoa/WebPlaybackSessionModel.h: 15 (WebCore::WebPlaybackSessionModelClient::~WebPlaybackSessionModelClient): 16 (WebCore::WebPlaybackSessionModelClient::durationChanged): 17 (WebCore::WebPlaybackSessionModelClient::currentTimeChanged): 18 (WebCore::WebPlaybackSessionModelClient::bufferedTimeChanged): 19 (WebCore::WebPlaybackSessionModelClient::rateChanged): 20 (WebCore::WebPlaybackSessionModelClient::seekableRangesChanged): 21 (WebCore::WebPlaybackSessionModelClient::canPlayFastReverseChanged): 22 (WebCore::WebPlaybackSessionModelClient::audioMediaSelectionOptionsChanged): 23 (WebCore::WebPlaybackSessionModelClient::legibleMediaSelectionOptionsChanged): 24 (WebCore::WebPlaybackSessionModelClient::externalPlaybackChanged): 25 (WebCore::WebPlaybackSessionModelClient::wirelessVideoPlaybackDisabledChanged): 26 * platform/cocoa/WebPlaybackSessionModelMediaElement.h: 27 * platform/cocoa/WebPlaybackSessionModelMediaElement.mm: 28 (WebPlaybackSessionModelMediaElement::setMediaElement): 29 (WebPlaybackSessionModelMediaElement::updateForEventName): 30 (WebPlaybackSessionModelMediaElement::addClient): 31 (WebPlaybackSessionModelMediaElement::removeClient): 32 (WebPlaybackSessionModelMediaElement::updateLegibleOptions): 33 (WebPlaybackSessionModelMediaElement::observedEventNames): 34 (WebPlaybackSessionModelMediaElement::eventNameAll): 35 (WebPlaybackSessionModelMediaElement::audioMediaSelectionOptions): 36 (WebPlaybackSessionModelMediaElement::audioMediaSelectedIndex): 37 (WebPlaybackSessionModelMediaElement::legibleMediaSelectedIndex): 38 (WebPlaybackSessionModelMediaElement::externalPlaybackEnabled): 39 (WebPlaybackSessionModelMediaElement::externalPlaybackTargetType): 40 (WebPlaybackSessionModelMediaElement::externalPlaybackLocalizedDeviceName): 41 (WebPlaybackSessionModelMediaElement::wirelessVideoPlaybackDisabled): 42 (WebPlaybackSessionModelMediaElement::setWebPlaybackSessionInterface): Deleted. 43 * platform/cocoa/WebVideoFullscreenInterface.h: 44 * platform/cocoa/WebVideoFullscreenModel.h: 45 (WebCore::WebVideoFullscreenModelClient::~WebVideoFullscreenModelClient): 46 * platform/cocoa/WebVideoFullscreenModelVideoElement.h: 47 (WebCore::WebVideoFullscreenModelVideoElement::create): 48 (WebCore::WebVideoFullscreenModelVideoElement::playbackSessionModel): Deleted. 49 * platform/cocoa/WebVideoFullscreenModelVideoElement.mm: 50 (WebVideoFullscreenModelVideoElement::WebVideoFullscreenModelVideoElement): 51 (WebVideoFullscreenModelVideoElement::setVideoElement): 52 (WebVideoFullscreenModelVideoElement::updateForEventName): 53 (WebVideoFullscreenModelVideoElement::addClient): 54 (WebVideoFullscreenModelVideoElement::removeClient): 55 (WebVideoFullscreenModelVideoElement::setHasVideo): 56 (WebVideoFullscreenModelVideoElement::setVideoDimensions): 57 (WebVideoFullscreenModelVideoElement::setWebVideoFullscreenInterface): Deleted. 58 * platform/ios/WebAVPlayerController.h: 59 * platform/ios/WebAVPlayerController.mm: 60 (-[WebAVPlayerController resetState]): Deleted. 61 * platform/ios/WebPlaybackSessionInterfaceAVKit.h: 62 (WebCore::WebPlaybackSessionInterfaceAVKitClient::~WebPlaybackSessionInterfaceAVKitClient): Deleted. 63 * platform/ios/WebPlaybackSessionInterfaceAVKit.mm: 64 (WebCore::WebPlaybackSessionInterfaceAVKit::WebPlaybackSessionInterfaceAVKit): 65 (WebCore::WebPlaybackSessionInterfaceAVKit::~WebPlaybackSessionInterfaceAVKit): 66 (WebCore::WebPlaybackSessionInterfaceAVKit::resetMediaState): 67 (WebCore::WebPlaybackSessionInterfaceAVKit::durationChanged): 68 (WebCore::WebPlaybackSessionInterfaceAVKit::currentTimeChanged): 69 (WebCore::WebPlaybackSessionInterfaceAVKit::bufferedTimeChanged): 70 (WebCore::WebPlaybackSessionInterfaceAVKit::rateChanged): 71 (WebCore::WebPlaybackSessionInterfaceAVKit::seekableRangesChanged): 72 (WebCore::WebPlaybackSessionInterfaceAVKit::canPlayFastReverseChanged): 73 (WebCore::WebPlaybackSessionInterfaceAVKit::audioMediaSelectionOptionsChanged): 74 (WebCore::WebPlaybackSessionInterfaceAVKit::legibleMediaSelectionOptionsChanged): 75 (WebCore::WebPlaybackSessionInterfaceAVKit::externalPlaybackChanged): 76 (WebCore::WebPlaybackSessionInterfaceAVKit::wirelessVideoPlaybackDisabledChanged): 77 (WebCore::WebPlaybackSessionInterfaceAVKit::invalidate): 78 (WebCore::WebPlaybackSessionInterfaceAVKit::setWebPlaybackSessionModel): Deleted. 79 (WebCore::WebPlaybackSessionInterfaceAVKit::setDuration): Deleted. 80 (WebCore::WebPlaybackSessionInterfaceAVKit::setCurrentTime): Deleted. 81 (WebCore::WebPlaybackSessionInterfaceAVKit::setBufferedTime): Deleted. 82 (WebCore::WebPlaybackSessionInterfaceAVKit::setRate): Deleted. 83 (WebCore::WebPlaybackSessionInterfaceAVKit::setSeekableRanges): Deleted. 84 (WebCore::WebPlaybackSessionInterfaceAVKit::setCanPlayFastReverse): Deleted. 85 (WebCore::WebPlaybackSessionInterfaceAVKit::setAudioMediaSelectionOptions): Deleted. 86 (WebCore::WebPlaybackSessionInterfaceAVKit::setLegibleMediaSelectionOptions): Deleted. 87 (WebCore::WebPlaybackSessionInterfaceAVKit::setExternalPlayback): Deleted. 88 (WebCore::WebPlaybackSessionInterfaceAVKit::setWirelessVideoPlaybackDisabled): Deleted. 89 (WebCore::WebPlaybackSessionInterfaceAVKit::wirelessVideoPlaybackDisabled): Deleted. 90 * platform/ios/WebVideoFullscreenControllerAVKit.mm: 91 (WebVideoFullscreenControllerContext::didSetupFullscreen): 92 (WebVideoFullscreenControllerContext::didExitFullscreen): 93 (WebVideoFullscreenControllerContext::didCleanupFullscreen): 94 (WebVideoFullscreenControllerContext::durationChanged): 95 (WebVideoFullscreenControllerContext::currentTimeChanged): 96 (WebVideoFullscreenControllerContext::bufferedTimeChanged): 97 (WebVideoFullscreenControllerContext::rateChanged): 98 (WebVideoFullscreenControllerContext::hasVideoChanged): 99 (WebVideoFullscreenControllerContext::videoDimensionsChanged): 100 (WebVideoFullscreenControllerContext::seekableRangesChanged): 101 (WebVideoFullscreenControllerContext::canPlayFastReverseChanged): 102 (WebVideoFullscreenControllerContext::audioMediaSelectionOptionsChanged): 103 (WebVideoFullscreenControllerContext::legibleMediaSelectionOptionsChanged): 104 (WebVideoFullscreenControllerContext::externalPlaybackChanged): 105 (WebVideoFullscreenControllerContext::wirelessVideoPlaybackDisabledChanged): 106 (WebVideoFullscreenControllerContext::addClient): 107 (WebVideoFullscreenControllerContext::removeClient): 108 (WebVideoFullscreenControllerContext::requestFullscreenMode): 109 (WebVideoFullscreenControllerContext::setVideoLayerFrame): 110 (WebVideoFullscreenControllerContext::setVideoLayerGravity): 111 (WebVideoFullscreenControllerContext::fullscreenModeChanged): 112 (WebVideoFullscreenControllerContext::isVisible): 113 (WebVideoFullscreenControllerContext::hasVideo): 114 (WebVideoFullscreenControllerContext::videoDimensions): 115 (WebVideoFullscreenControllerContext::play): 116 (WebVideoFullscreenControllerContext::pause): 117 (WebVideoFullscreenControllerContext::togglePlayState): 118 (WebVideoFullscreenControllerContext::beginScrubbing): 119 (WebVideoFullscreenControllerContext::endScrubbing): 120 (WebVideoFullscreenControllerContext::seekToTime): 121 (WebVideoFullscreenControllerContext::fastSeek): 122 (WebVideoFullscreenControllerContext::beginScanningForward): 123 (WebVideoFullscreenControllerContext::beginScanningBackward): 124 (WebVideoFullscreenControllerContext::endScanning): 125 (WebVideoFullscreenControllerContext::selectAudioMediaOption): 126 (WebVideoFullscreenControllerContext::selectLegibleMediaOption): 127 (WebVideoFullscreenControllerContext::duration): 128 (WebVideoFullscreenControllerContext::currentTime): 129 (WebVideoFullscreenControllerContext::bufferedTime): 130 (WebVideoFullscreenControllerContext::isPlaying): 131 (WebVideoFullscreenControllerContext::playbackRate): 132 (WebVideoFullscreenControllerContext::seekableRanges): 133 (WebVideoFullscreenControllerContext::canPlayFastReverse): 134 (WebVideoFullscreenControllerContext::audioMediaSelectionOptions): 135 (WebVideoFullscreenControllerContext::audioMediaSelectedIndex): 136 (WebVideoFullscreenControllerContext::legibleMediaSelectionOptions): 137 (WebVideoFullscreenControllerContext::legibleMediaSelectedIndex): 138 (WebVideoFullscreenControllerContext::externalPlaybackEnabled): 139 (WebVideoFullscreenControllerContext::externalPlaybackTargetType): 140 (WebVideoFullscreenControllerContext::externalPlaybackLocalizedDeviceName): 141 (WebVideoFullscreenControllerContext::wirelessVideoPlaybackDisabled): 142 (WebVideoFullscreenControllerContext::setUpFullscreen): 143 (WebVideoFullscreenControllerContext::exitFullscreen): 144 (WebVideoFullscreenControllerContext::requestHideAndExitFullscreen): 145 (WebVideoFullscreenControllerContext::resetMediaState): Deleted. 146 (WebVideoFullscreenControllerContext::setDuration): Deleted. 147 (WebVideoFullscreenControllerContext::setCurrentTime): Deleted. 148 (WebVideoFullscreenControllerContext::setBufferedTime): Deleted. 149 (WebVideoFullscreenControllerContext::setRate): Deleted. 150 (WebVideoFullscreenControllerContext::setVideoDimensions): Deleted. 151 (WebVideoFullscreenControllerContext::setSeekableRanges): Deleted. 152 (WebVideoFullscreenControllerContext::setCanPlayFastReverse): Deleted. 153 (WebVideoFullscreenControllerContext::setAudioMediaSelectionOptions): Deleted. 154 (WebVideoFullscreenControllerContext::setLegibleMediaSelectionOptions): Deleted. 155 (WebVideoFullscreenControllerContext::setExternalPlayback): Deleted. 156 (WebVideoFullscreenControllerContext::setWirelessVideoPlaybackDisabled): Deleted. 157 (WebVideoFullscreenSessionModel::play): Deleted. 158 (WebVideoFullscreenSessionModel::pause): Deleted. 159 (WebVideoFullscreenSessionModel::togglePlayState): Deleted. 160 (WebVideoFullscreenSessionModel::beginScrubbing): Deleted. 161 (WebVideoFullscreenSessionModel::endScrubbing): Deleted. 162 (WebVideoFullscreenSessionModel::seekToTime): Deleted. 163 (WebVideoFullscreenSessionModel::fastSeek): Deleted. 164 (WebVideoFullscreenSessionModel::beginScanningForward): Deleted. 165 (WebVideoFullscreenSessionModel::beginScanningBackward): Deleted. 166 (WebVideoFullscreenSessionModel::endScanning): Deleted. 167 (WebVideoFullscreenSessionModel::selectAudioMediaOption): Deleted. 168 (WebVideoFullscreenSessionModel::selectLegibleMediaOption): Deleted. 169 * platform/ios/WebVideoFullscreenInterfaceAVKit.h: 170 * platform/ios/WebVideoFullscreenInterfaceAVKit.mm: 171 (WebVideoFullscreenInterfaceAVKit::~WebVideoFullscreenInterfaceAVKit): 172 (WebVideoFullscreenInterfaceAVKit::setWebVideoFullscreenModel): 173 (WebVideoFullscreenInterfaceAVKit::setWebVideoFullscreenChangeObserver): 174 (WebVideoFullscreenInterfaceAVKit::hasVideoChanged): 175 (WebVideoFullscreenInterfaceAVKit::videoDimensionsChanged): 176 (WebVideoFullscreenInterfaceAVKit::externalPlaybackChanged): 177 (WebVideoFullscreenInterfaceAVKit::resetMediaState): Deleted. 178 (WebVideoFullscreenInterfaceAVKit::setDuration): Deleted. 179 (WebVideoFullscreenInterfaceAVKit::setCurrentTime): Deleted. 180 (WebVideoFullscreenInterfaceAVKit::setBufferedTime): Deleted. 181 (WebVideoFullscreenInterfaceAVKit::setRate): Deleted. 182 (WebVideoFullscreenInterfaceAVKit::setVideoDimensions): Deleted. 183 (WebVideoFullscreenInterfaceAVKit::setSeekableRanges): Deleted. 184 (WebVideoFullscreenInterfaceAVKit::setCanPlayFastReverse): Deleted. 185 (WebVideoFullscreenInterfaceAVKit::setAudioMediaSelectionOptions): Deleted. 186 (WebVideoFullscreenInterfaceAVKit::setLegibleMediaSelectionOptions): Deleted. 187 (WebVideoFullscreenInterfaceAVKit::setExternalPlayback): Deleted. 188 (WebVideoFullscreenInterfaceAVKit::externalPlaybackEnabledChanged): Deleted. 189 (WebVideoFullscreenInterfaceAVKit::setWirelessVideoPlaybackDisabled): Deleted. 190 (WebVideoFullscreenInterfaceAVKit::wirelessVideoPlaybackDisabled): Deleted. 191 * platform/mac/WebPlaybackSessionInterfaceMac.h: 192 (WebCore::WebPlaybackSessionInterfaceMacClient::~WebPlaybackSessionInterfaceMacClient): Deleted. 193 * platform/mac/WebPlaybackSessionInterfaceMac.mm: 194 (WebCore::WebPlaybackSessionInterfaceMac::create): 195 (WebCore::WebPlaybackSessionInterfaceMac::WebPlaybackSessionInterfaceMac): 196 (WebCore::WebPlaybackSessionInterfaceMac::~WebPlaybackSessionInterfaceMac): 197 (WebCore::WebPlaybackSessionInterfaceMac::durationChanged): 198 (WebCore::WebPlaybackSessionInterfaceMac::currentTimeChanged): 199 (WebCore::WebPlaybackSessionInterfaceMac::rateChanged): 200 (WebCore::WebPlaybackSessionInterfaceMac::seekableRangesChanged): 201 (WebCore::WebPlaybackSessionInterfaceMac::audioMediaSelectionOptionsChanged): 202 (WebCore::WebPlaybackSessionInterfaceMac::legibleMediaSelectionOptionsChanged): 203 (WebCore::WebPlaybackSessionInterfaceMac::invalidate): 204 (WebCore::WebPlaybackSessionInterfaceMac::setWebPlaybackSessionModel): Deleted. 205 (WebCore::WebPlaybackSessionInterfaceMac::setClient): Deleted. 206 (WebCore::WebPlaybackSessionInterfaceMac::setDuration): Deleted. 207 (WebCore::WebPlaybackSessionInterfaceMac::setCurrentTime): Deleted. 208 (WebCore::WebPlaybackSessionInterfaceMac::setRate): Deleted. 209 (WebCore::WebPlaybackSessionInterfaceMac::setSeekableRanges): Deleted. 210 (WebCore::WebPlaybackSessionInterfaceMac::setAudioMediaSelectionOptions): Deleted. 211 (WebCore::WebPlaybackSessionInterfaceMac::setLegibleMediaSelectionOptions): Deleted. 212 * platform/mac/WebVideoFullscreenInterfaceMac.h: 213 * platform/mac/WebVideoFullscreenInterfaceMac.mm: 214 (WebCore::WebVideoFullscreenInterfaceMac::WebVideoFullscreenInterfaceMac): 215 (WebCore::WebVideoFullscreenInterfaceMac::~WebVideoFullscreenInterfaceMac): 216 (WebCore::WebVideoFullscreenInterfaceMac::setWebVideoFullscreenModel): 217 (WebCore::WebVideoFullscreenInterfaceMac::externalPlaybackChanged): 218 (WebCore::WebVideoFullscreenInterfaceMac::hasVideoChanged): 219 (WebCore::WebVideoFullscreenInterfaceMac::videoDimensionsChanged): 220 (WebCore::WebVideoFullscreenInterfaceMac::setDuration): Deleted. 221 (WebCore::WebVideoFullscreenInterfaceMac::setCurrentTime): Deleted. 222 (WebCore::WebVideoFullscreenInterfaceMac::setRate): Deleted. 223 (WebCore::WebVideoFullscreenInterfaceMac::setSeekableRanges): Deleted. 224 (WebCore::WebVideoFullscreenInterfaceMac::setAudioMediaSelectionOptions): Deleted. 225 (WebCore::WebVideoFullscreenInterfaceMac::setLegibleMediaSelectionOptions): Deleted. 226 (WebCore::WebVideoFullscreenInterfaceMac::setExternalPlayback): Deleted. 227 (WebCore::WebVideoFullscreenInterfaceMac::setVideoDimensions): Deleted. 228 1 229 2016-09-02 Chris Dumez <cdumez@apple.com> 2 230 -
trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionInterface.h
r199593 r205365 41 41 class WebPlaybackSessionInterface { 42 42 public: 43 enum ExternalPlaybackTargetType { TargetTypeNone, TargetTypeAirPlay, TargetTypeTVOut };44 45 43 virtual ~WebPlaybackSessionInterface() { }; 46 44 virtual void resetMediaState() = 0; 47 virtual void setDuration(double) = 0;48 virtual void setCurrentTime(double currentTime, double anchorTime) = 0;49 virtual void setBufferedTime(double) = 0;50 virtual void setRate(bool isPlaying, float playbackRate) = 0;51 virtual void setSeekableRanges(const TimeRanges&) = 0;52 virtual void setCanPlayFastReverse(bool) = 0;53 virtual void setAudioMediaSelectionOptions(const Vector<WTF::String>& options, uint64_t selectedIndex) = 0;54 virtual void setLegibleMediaSelectionOptions(const Vector<WTF::String>& options, uint64_t selectedIndex) = 0;55 virtual void setExternalPlayback(bool enabled, ExternalPlaybackTargetType, WTF::String localizedDeviceName) = 0;56 virtual void setWirelessVideoPlaybackDisabled(bool) = 0;57 45 }; 58 46 -
trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionModel.h
r200490 r205365 37 37 class TimeRanges; 38 38 39 class WebPlaybackSessionModelClient; 40 39 41 class WebPlaybackSessionModel { 40 42 public: 41 43 virtual ~WebPlaybackSessionModel() { }; 44 virtual void addClient(WebPlaybackSessionModelClient&) = 0; 45 virtual void removeClient(WebPlaybackSessionModelClient&) = 0; 46 42 47 virtual void play() = 0; 43 48 virtual void pause() = 0; … … 53 58 virtual void selectLegibleMediaOption(uint64_t index) = 0; 54 59 60 enum ExternalPlaybackTargetType { TargetTypeNone, TargetTypeAirPlay, TargetTypeTVOut }; 61 55 62 virtual double duration() const = 0; 56 63 virtual double currentTime() const = 0; … … 60 67 virtual Ref<TimeRanges> seekableRanges() const = 0; 61 68 virtual bool canPlayFastReverse() const = 0; 62 virtual Vector< WTF::String> audioMediaSelectionOptions() const = 0;69 virtual Vector<String> audioMediaSelectionOptions() const = 0; 63 70 virtual uint64_t audioMediaSelectedIndex() const = 0; 64 virtual Vector< WTF::String> legibleMediaSelectionOptions() const = 0;71 virtual Vector<String> legibleMediaSelectionOptions() const = 0; 65 72 virtual uint64_t legibleMediaSelectedIndex() const = 0; 66 73 virtual bool externalPlaybackEnabled() const = 0; 74 virtual ExternalPlaybackTargetType externalPlaybackTargetType() const = 0; 75 virtual String externalPlaybackLocalizedDeviceName() const = 0; 67 76 virtual bool wirelessVideoPlaybackDisabled() const = 0; 77 }; 78 79 class WebPlaybackSessionModelClient { 80 public: 81 virtual ~WebPlaybackSessionModelClient() { }; 82 virtual void durationChanged(double) { } 83 virtual void currentTimeChanged(double /* currentTime */, double /* anchorTime */) { } 84 virtual void bufferedTimeChanged(double) { } 85 virtual void rateChanged(bool /* isPlaying */, float /* playbackRate */) { } 86 virtual void seekableRangesChanged(const TimeRanges&) { } 87 virtual void canPlayFastReverseChanged(bool) { } 88 virtual void audioMediaSelectionOptionsChanged(const Vector<String>& /* options */, uint64_t /* selectedIndex */) { } 89 virtual void legibleMediaSelectionOptionsChanged(const Vector<String>& /* options */, uint64_t /* selectedIndex */) { } 90 virtual void externalPlaybackChanged(bool /* enabled */, WebPlaybackSessionModel::ExternalPlaybackTargetType, const String& /* localizedDeviceName */) { } 91 virtual void wirelessVideoPlaybackDisabledChanged(bool) { } 68 92 }; 69 93 -
trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionModelMediaElement.h
r204466 r205365 31 31 #include "HTMLMediaElementEnums.h" 32 32 #include "WebPlaybackSessionModel.h" 33 #include <wtf/HashSet.h> 33 34 #include <wtf/RefPtr.h> 34 35 #include <wtf/Vector.h> … … 47 48 } 48 49 WEBCORE_EXPORT virtual ~WebPlaybackSessionModelMediaElement(); 49 WEBCORE_EXPORT void setWebPlaybackSessionInterface(WebPlaybackSessionInterface*);50 50 WEBCORE_EXPORT void setMediaElement(HTMLMediaElement*); 51 51 WEBCORE_EXPORT HTMLMediaElement* mediaElement() const { return m_mediaElement.get(); } … … 55 55 bool operator==(const EventListener& rhs) const final { return static_cast<const WebCore::EventListener*>(this) == &rhs; } 56 56 57 WEBCORE_EXPORT void addClient(WebPlaybackSessionModelClient&); 58 WEBCORE_EXPORT void removeClient(WebPlaybackSessionModelClient&); 57 59 WEBCORE_EXPORT void play() final; 58 60 WEBCORE_EXPORT void pause() final; … … 80 82 uint64_t legibleMediaSelectedIndex() const final; 81 83 bool externalPlaybackEnabled() const final; 84 ExternalPlaybackTargetType externalPlaybackTargetType() const final; 85 String externalPlaybackLocalizedDeviceName() const final; 82 86 bool wirelessVideoPlaybackDisabled() const final; 83 87 … … 91 95 RefPtr<HTMLMediaElement> m_mediaElement; 92 96 bool m_isListening { false }; 93 WebPlaybackSessionInterface* m_playbackSessionInterface { nullptr };97 HashSet<WebPlaybackSessionModelClient*> m_clients; 94 98 Vector<RefPtr<TextTrack>> m_legibleTracksForMenu; 95 99 Vector<RefPtr<AudioTrack>> m_audioTracksForMenu; -
trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionModelMediaElement.mm
r204717 r205365 57 57 } 58 58 59 void WebPlaybackSessionModelMediaElement::setWebPlaybackSessionInterface(WebPlaybackSessionInterface* interface)60 {61 if (interface == m_playbackSessionInterface)62 return;63 64 m_playbackSessionInterface = interface;65 66 if (!m_playbackSessionInterface)67 return;68 69 m_playbackSessionInterface->resetMediaState();70 m_playbackSessionInterface->setDuration(duration());71 m_playbackSessionInterface->setCurrentTime(currentTime(), [[NSProcessInfo processInfo] systemUptime]);72 m_playbackSessionInterface->setBufferedTime(bufferedTime());73 m_playbackSessionInterface->setRate(isPlaying(), playbackRate());74 m_playbackSessionInterface->setSeekableRanges(seekableRanges());75 m_playbackSessionInterface->setCanPlayFastReverse(canPlayFastReverse());76 m_playbackSessionInterface->setWirelessVideoPlaybackDisabled(wirelessVideoPlaybackDisabled());77 updateLegibleOptions();78 }79 80 59 void WebPlaybackSessionModelMediaElement::setMediaElement(HTMLMediaElement* mediaElement) 81 60 { 82 61 if (m_mediaElement == mediaElement) 83 62 return; 84 85 if (m_playbackSessionInterface)86 m_playbackSessionInterface->resetMediaState();87 63 88 64 if (m_mediaElement && m_isListening) { … … 94 70 m_mediaElement = mediaElement; 95 71 96 if (!m_mediaElement) 97 return; 98 99 for (auto& eventName : observedEventNames()) 100 m_mediaElement->addEventListener(eventName, *this, false); 101 m_isListening = true; 72 if (m_mediaElement) { 73 for (auto& eventName : observedEventNames()) 74 m_mediaElement->addEventListener(eventName, *this, false); 75 m_isListening = true; 76 } 102 77 103 78 updateForEventName(eventNameAll()); 104 105 if (m_playbackSessionInterface)106 m_playbackSessionInterface->setWirelessVideoPlaybackDisabled(m_mediaElement->mediaSession().wirelessVideoPlaybackDisabled(*m_mediaElement));107 79 } 108 80 … … 114 86 void WebPlaybackSessionModelMediaElement::updateForEventName(const WTF::AtomicString& eventName) 115 87 { 116 if ( !m_mediaElement || !m_playbackSessionInterface)88 if (m_clients.isEmpty()) 117 89 return; 118 90 … … 121 93 if (all 122 94 || eventName == eventNames().durationchangeEvent) { 123 m_playbackSessionInterface->setDuration(m_mediaElement->duration()); 95 double duration = this->duration(); 96 for (auto client : m_clients) 97 client->durationChanged(duration); 124 98 // These is no standard event for minFastReverseRateChange; duration change is a reasonable proxy for it. 125 99 // It happens every time a new item becomes ready to play. 126 m_playbackSessionInterface->setCanPlayFastReverse(m_mediaElement->minFastReverseRate() < 0.0); 100 bool canPlayFastReverse = this->canPlayFastReverse(); 101 for (auto client : m_clients) 102 client->canPlayFastReverseChanged(canPlayFastReverse); 127 103 } 128 104 … … 130 106 || eventName == eventNames().pauseEvent 131 107 || eventName == eventNames().playEvent 132 || eventName == eventNames().ratechangeEvent) 133 m_playbackSessionInterface->setRate(!m_mediaElement->paused(), m_mediaElement->playbackRate()); 108 || eventName == eventNames().ratechangeEvent) { 109 bool isPlaying = this->isPlaying(); 110 float playbackRate = this->playbackRate(); 111 for (auto client : m_clients) 112 client->rateChanged(isPlaying, playbackRate); 113 } 134 114 135 115 if (all 136 116 || eventName == eventNames().timeupdateEvent) { 137 m_playbackSessionInterface->setCurrentTime(m_mediaElement->currentTime(), [[NSProcessInfo processInfo] systemUptime]); 138 m_playbackSessionInterface->setBufferedTime(m_mediaElement->maxBufferedTime()); 139 // FIXME: 130788 - find a better event to update seekable ranges from. 140 m_playbackSessionInterface->setSeekableRanges(m_mediaElement->seekable()); 117 auto currentTime = this->currentTime(); 118 auto anchorTime = [[NSProcessInfo processInfo] systemUptime]; 119 auto bufferedTime = this->bufferedTime(); 120 auto seekableRanges = this->seekableRanges(); 121 122 for (auto client : m_clients) { 123 client->currentTimeChanged(currentTime, anchorTime); 124 client->bufferedTimeChanged(bufferedTime); 125 // FIXME: 130788 - find a better event from which to update seekable ranges. 126 client->seekableRangesChanged(seekableRanges); 127 } 141 128 } 142 129 … … 148 135 if (all 149 136 || eventName == eventNames().webkitcurrentplaybacktargetiswirelesschangedEvent) { 150 bool enabled = m_mediaElement->webkitCurrentPlaybackTargetIsWireless(); 151 WebPlaybackSessionInterface::ExternalPlaybackTargetType targetType = WebPlaybackSessionInterface::TargetTypeNone; 152 String localizedDeviceName; 153 154 if (m_mediaElement->mediaControlsHost()) { 155 auto type = m_mediaElement->mediaControlsHost()->externalDeviceType(); 156 if (type == MediaControlsHost::DeviceType::Airplay) 157 targetType = WebPlaybackSessionInterface::TargetTypeAirPlay; 158 else if (type == MediaControlsHost::DeviceType::Tvout) 159 targetType = WebPlaybackSessionInterface::TargetTypeTVOut; 160 localizedDeviceName = m_mediaElement->mediaControlsHost()->externalDeviceDisplayName(); 137 bool enabled = externalPlaybackEnabled(); 138 ExternalPlaybackTargetType targetType = externalPlaybackTargetType(); 139 String localizedDeviceName = externalPlaybackLocalizedDeviceName(); 140 141 bool wirelessVideoPlaybackDisabled = this->wirelessVideoPlaybackDisabled(); 142 143 for (auto client : m_clients) { 144 client->externalPlaybackChanged(enabled, targetType, localizedDeviceName); 145 client->wirelessVideoPlaybackDisabledChanged(wirelessVideoPlaybackDisabled); 161 146 } 162 m_playbackSessionInterface->setExternalPlayback(enabled, targetType, localizedDeviceName); 163 m_playbackSessionInterface->setWirelessVideoPlaybackDisabled(m_mediaElement->mediaSession().wirelessVideoPlaybackDisabled(*m_mediaElement)); 164 } 147 } 148 } 149 void WebPlaybackSessionModelMediaElement::addClient(WebPlaybackSessionModelClient& client) 150 { 151 ASSERT(!m_clients.contains(&client)); 152 m_clients.add(&client); 153 } 154 155 void WebPlaybackSessionModelMediaElement::removeClient(WebPlaybackSessionModelClient& client) 156 { 157 ASSERT(m_clients.contains(&client)); 158 m_clients.remove(&client); 165 159 } 166 160 … … 280 274 m_audioTracksForMenu.clear(); 281 275 282 m_playbackSessionInterface->setAudioMediaSelectionOptions(audioMediaSelectionOptions(), audioMediaSelectedIndex()); 283 m_playbackSessionInterface->setLegibleMediaSelectionOptions(legibleMediaSelectionOptions(), legibleMediaSelectedIndex()); 284 } 285 286 const Vector<AtomicString>& WebPlaybackSessionModelMediaElement::observedEventNames() 287 { 288 static NeverDestroyed<Vector<AtomicString>> sEventNames; 289 290 if (!sEventNames.get().size()) { 291 sEventNames.get().append(eventNames().durationchangeEvent); 292 sEventNames.get().append(eventNames().pauseEvent); 293 sEventNames.get().append(eventNames().playEvent); 294 sEventNames.get().append(eventNames().ratechangeEvent); 295 sEventNames.get().append(eventNames().timeupdateEvent); 296 sEventNames.get().append(eventNames().addtrackEvent); 297 sEventNames.get().append(eventNames().removetrackEvent); 298 sEventNames.get().append(eventNames().webkitcurrentplaybacktargetiswirelesschangedEvent); 299 } 300 return sEventNames.get(); 276 auto audioOptions = audioMediaSelectionOptions(); 277 auto audioIndex = audioMediaSelectedIndex(); 278 auto legibleOptions = legibleMediaSelectionOptions(); 279 auto legibleIndex = legibleMediaSelectedIndex(); 280 281 for (auto client : m_clients) { 282 client->audioMediaSelectionOptionsChanged(audioOptions, audioIndex); 283 client->legibleMediaSelectionOptionsChanged(legibleOptions, legibleIndex); 284 } 285 } 286 287 const Vector<AtomicString>& WebPlaybackSessionModelMediaElement::observedEventNames() 288 { 289 // FIXME(157452): Remove the right-hand constructor notation once NeverDestroyed supports initializer_lists. 290 static NeverDestroyed<Vector<AtomicString>> names = Vector<AtomicString>({ 291 eventNames().durationchangeEvent, 292 eventNames().pauseEvent, 293 eventNames().playEvent, 294 eventNames().ratechangeEvent, 295 eventNames().timeupdateEvent, 296 eventNames().addtrackEvent, 297 eventNames().removetrackEvent, 298 eventNames().webkitcurrentplaybacktargetiswirelesschangedEvent, 299 }); 300 return names.get(); 301 301 } 302 302 303 303 const AtomicString& WebPlaybackSessionModelMediaElement::eventNameAll() 304 304 { 305 static NeverDestroyed<AtomicString> sEventNameAll = "allEvents";306 return sEventNameAll;305 static NeverDestroyed<AtomicString> eventNameAll("allEvents", AtomicString::ConstructFromLiteral); 306 return eventNameAll; 307 307 } 308 308 … … 342 342 } 343 343 344 Vector< WTF::String> WebPlaybackSessionModelMediaElement::audioMediaSelectionOptions() const344 Vector<String> WebPlaybackSessionModelMediaElement::audioMediaSelectionOptions() const 345 345 { 346 346 Vector<String> audioTrackDisplayNames; … … 351 351 auto& captionPreferences = m_mediaElement->document().page()->group().captionPreferences(); 352 352 353 audioTrackDisplayNames.reserveInitialCapacity(m_audioTracksForMenu.size()); 353 354 for (auto& audioTrack : m_audioTracksForMenu) 354 audioTrackDisplayNames. append(captionPreferences.displayNameForTrack(audioTrack.get()));355 audioTrackDisplayNames.uncheckedAppend(captionPreferences.displayNameForTrack(audioTrack.get())); 355 356 356 357 return audioTrackDisplayNames; … … 363 364 return index; 364 365 } 365 return 0;366 return std::numeric_limits<uint64_t>::max(); 366 367 } 367 368 … … 383 384 uint64_t WebPlaybackSessionModelMediaElement::legibleMediaSelectedIndex() const 384 385 { 385 uint64_t selectedIndex = 0;386 uint64_t selectedIndex = std::numeric_limits<uint64_t>::max(); 386 387 uint64_t offIndex = 0; 387 388 bool trackMenuItemSelected = false; 388 389 389 if (!m_mediaElement || !m_mediaElement->mediaControlsHost()) 390 auto host = m_mediaElement ? m_mediaElement->mediaControlsHost() : nullptr; 391 392 if (!host) 390 393 return selectedIndex; 391 394 392 AtomicString displayMode = m_mediaElement->mediaControlsHost()->captionDisplayMode();393 TextTrack* offItem = m_mediaElement->mediaControlsHost()->captionMenuOffItem();394 TextTrack* automaticItem = m_mediaElement->mediaControlsHost()->captionMenuAutomaticItem();395 AtomicString displayMode = host->captionDisplayMode(); 396 TextTrack* offItem = host->captionMenuOffItem(); 397 TextTrack* automaticItem = host->captionMenuAutomaticItem(); 395 398 396 399 for (size_t index = 0; index < m_legibleTracksForMenu.size(); index++) { … … 418 421 bool WebPlaybackSessionModelMediaElement::externalPlaybackEnabled() const 419 422 { 420 return m_mediaElement ? m_mediaElement->webkitCurrentPlaybackTargetIsWireless() : false; 423 return m_mediaElement && m_mediaElement->webkitCurrentPlaybackTargetIsWireless(); 424 } 425 426 WebPlaybackSessionModel::ExternalPlaybackTargetType WebPlaybackSessionModelMediaElement::externalPlaybackTargetType() const 427 { 428 if (!m_mediaElement || !m_mediaElement->mediaControlsHost()) 429 return TargetTypeNone; 430 431 switch (m_mediaElement->mediaControlsHost()->externalDeviceType()) { 432 default: 433 ASSERT_NOT_REACHED(); 434 return TargetTypeNone; 435 case MediaControlsHost::DeviceType::None: 436 return TargetTypeNone; 437 case MediaControlsHost::DeviceType::Airplay: 438 return TargetTypeAirPlay; 439 case MediaControlsHost::DeviceType::Tvout: 440 return TargetTypeTVOut; 441 } 442 } 443 444 String WebPlaybackSessionModelMediaElement::externalPlaybackLocalizedDeviceName() const 445 { 446 if (m_mediaElement && m_mediaElement->mediaControlsHost()) 447 return m_mediaElement->mediaControlsHost()->externalDeviceDisplayName(); 448 return emptyString(); 421 449 } 422 450 423 451 bool WebPlaybackSessionModelMediaElement::wirelessVideoPlaybackDisabled() const 424 452 { 425 return m_mediaElement ? m_mediaElement->mediaSession().wirelessVideoPlaybackDisabled(*m_mediaElement) : false;453 return m_mediaElement && m_mediaElement->mediaSession().wirelessVideoPlaybackDisabled(*m_mediaElement); 426 454 } 427 455 -
trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenInterface.h
r199593 r205365 37 37 class TimeRanges; 38 38 39 class WebVideoFullscreenInterface : public WebPlaybackSessionInterface{39 class WebVideoFullscreenInterface { 40 40 public: 41 41 virtual ~WebVideoFullscreenInterface() { }; 42 virtual void setVideoDimensions(bool hasVideo, float width, float height) = 0;43 42 }; 44 43 -
trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenModel.h
r200490 r205365 36 36 namespace WebCore { 37 37 38 class WebVideoFullscreenModelClient; 39 38 40 class WebVideoFullscreenModel { 39 41 public: 40 42 virtual ~WebVideoFullscreenModel() { }; 43 virtual void addClient(WebVideoFullscreenModelClient&) = 0; 44 virtual void removeClient(WebVideoFullscreenModelClient&)= 0; 45 41 46 virtual void requestFullscreenMode(HTMLMediaElementEnums::VideoFullscreenMode) = 0; 42 47 virtual void setVideoLayerFrame(FloatRect) = 0; … … 44 49 virtual void setVideoLayerGravity(VideoGravity) = 0; 45 50 virtual void fullscreenModeChanged(HTMLMediaElementEnums::VideoFullscreenMode) = 0; 51 46 52 virtual bool isVisible() const = 0; 53 virtual FloatSize videoDimensions() const = 0; 54 virtual bool hasVideo() const = 0; 55 }; 56 57 class WebVideoFullscreenModelClient { 58 public: 59 virtual ~WebVideoFullscreenModelClient() { } 60 virtual void hasVideoChanged(bool) = 0; 61 virtual void videoDimensionsChanged(const FloatSize&) = 0; 47 62 }; 48 63 -
trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenModelVideoElement.h
r201474 r205365 36 36 #include "WebVideoFullscreenModel.h" 37 37 #include <functional> 38 #include <wtf/HashSet.h> 38 39 #include <wtf/RefPtr.h> 39 40 #include <wtf/RetainPtr.h> … … 45 46 class TextTrack; 46 47 class WebPlaybackSessionModelMediaElement; 47 class WebVideoFullscreenInterface;48 48 49 49 class WebVideoFullscreenModelVideoElement : public WebVideoFullscreenModel, public EventListener { 50 50 public: 51 static RefPtr<WebVideoFullscreenModelVideoElement> create( WebPlaybackSessionModelMediaElement& playbackSessionModel)51 static RefPtr<WebVideoFullscreenModelVideoElement> create() 52 52 { 53 return adoptRef(*new WebVideoFullscreenModelVideoElement( playbackSessionModel));53 return adoptRef(*new WebVideoFullscreenModelVideoElement()); 54 54 } 55 55 WEBCORE_EXPORT virtual ~WebVideoFullscreenModelVideoElement(); 56 WEBCORE_EXPORT void setWebVideoFullscreenInterface(WebVideoFullscreenInterface*);57 56 WEBCORE_EXPORT void setVideoElement(HTMLVideoElement*); 58 57 WEBCORE_EXPORT HTMLVideoElement* videoElement() const { return m_videoElement.get(); } 59 58 WEBCORE_EXPORT void setVideoFullscreenLayer(PlatformLayer*, std::function<void()> completionHandler = [] { }); 60 59 WEBCORE_EXPORT void waitForPreparedForInlineThen(std::function<void()> completionHandler = [] { }); 61 WebPlaybackSessionModelMediaElement& playbackSessionModel() { return m_playbackSessionModel; }62 60 63 61 WEBCORE_EXPORT void handleEvent(WebCore::ScriptExecutionContext*, WebCore::Event*) override; … … 65 63 bool operator==(const EventListener& rhs) const override { return static_cast<const WebCore::EventListener*>(this) == &rhs; } 66 64 65 WEBCORE_EXPORT void addClient(WebVideoFullscreenModelClient&) override; 66 WEBCORE_EXPORT void removeClient(WebVideoFullscreenModelClient&) override; 67 67 WEBCORE_EXPORT void requestFullscreenMode(HTMLMediaElementEnums::VideoFullscreenMode) override; 68 68 WEBCORE_EXPORT void setVideoLayerFrame(FloatRect) override; … … 70 70 WEBCORE_EXPORT void fullscreenModeChanged(HTMLMediaElementEnums::VideoFullscreenMode) override; 71 71 WEBCORE_EXPORT bool isVisible() const override; 72 WEBCORE_EXPORT FloatSize videoDimensions() const override { return m_videoDimensions; } 73 WEBCORE_EXPORT bool hasVideo() const override { return m_hasVideo; } 74 72 75 73 76 protected: 74 WEBCORE_EXPORT WebVideoFullscreenModelVideoElement( WebPlaybackSessionModelMediaElement&);77 WEBCORE_EXPORT WebVideoFullscreenModelVideoElement(); 75 78 76 79 private: 80 void setHasVideo(bool); 81 void setVideoDimensions(const FloatSize&); 82 77 83 static const Vector<WTF::AtomicString>& observedEventNames(); 78 84 const WTF::AtomicString& eventNameAll(); 79 85 80 Ref<WebPlaybackSessionModelMediaElement> m_playbackSessionModel;81 86 RefPtr<HTMLVideoElement> m_videoElement; 82 87 RetainPtr<PlatformLayer> m_videoFullscreenLayer; 83 88 bool m_isListening { false }; 84 WebVideoFullscreenInterface* m_videoFullscreenInterface { nullptr }; 89 HashSet<WebVideoFullscreenModelClient*> m_clients; 90 bool m_hasVideo { false }; 91 FloatSize m_videoDimensions; 85 92 FloatRect m_videoFrame; 86 93 Vector<RefPtr<TextTrack>> m_legibleTracksForMenu; -
trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenModelVideoElement.mm
r204717 r205365 49 49 using namespace WebCore; 50 50 51 WebVideoFullscreenModelVideoElement::WebVideoFullscreenModelVideoElement( WebPlaybackSessionModelMediaElement& playbackSessionModel)51 WebVideoFullscreenModelVideoElement::WebVideoFullscreenModelVideoElement() 52 52 : EventListener(EventListener::CPPEventListenerType) 53 , m_playbackSessionModel(playbackSessionModel)54 53 { 55 54 } … … 57 56 WebVideoFullscreenModelVideoElement::~WebVideoFullscreenModelVideoElement() 58 57 { 59 }60 61 void WebVideoFullscreenModelVideoElement::setWebVideoFullscreenInterface(WebVideoFullscreenInterface* interface)62 {63 if (interface == m_videoFullscreenInterface)64 return;65 66 m_videoFullscreenInterface = interface;67 m_playbackSessionModel->setWebPlaybackSessionInterface(interface);68 69 if (m_videoFullscreenInterface && m_videoElement)70 m_videoFullscreenInterface->setVideoDimensions(true, m_videoElement->videoWidth(), m_videoElement->videoHeight());71 58 } 72 59 … … 87 74 m_videoElement = videoElement; 88 75 89 if (!m_videoElement) 90 return; 91 92 for (auto& eventName : observedEventNames()) 93 m_videoElement->addEventListener(eventName, *this, false); 94 m_isListening = true; 76 if (m_videoElement) { 77 for (auto& eventName : observedEventNames()) 78 m_videoElement->addEventListener(eventName, *this, false); 79 m_isListening = true; 80 } 95 81 96 82 updateForEventName(eventNameAll()); 97 98 if (m_videoFullscreenInterface)99 m_videoFullscreenInterface->setVideoDimensions(true, videoElement->videoWidth(), videoElement->videoHeight());100 83 } 101 84 … … 107 90 void WebVideoFullscreenModelVideoElement::updateForEventName(const WTF::AtomicString& eventName) 108 91 { 109 if ( !m_videoElement || !m_videoFullscreenInterface)92 if (m_clients.isEmpty()) 110 93 return; 111 94 … … 113 96 114 97 if (all 115 || eventName == eventNames().resizeEvent) 116 m_videoFullscreenInterface->setVideoDimensions(true, m_videoElement->videoWidth(), m_videoElement->videoHeight()); 98 || eventName == eventNames().resizeEvent) { 99 setHasVideo(m_videoElement); 100 setVideoDimensions(m_videoElement ? FloatSize(m_videoElement->videoWidth(), m_videoElement->videoHeight()) : FloatSize()); 101 } 117 102 } 118 103 … … 200 185 } 201 186 187 void WebVideoFullscreenModelVideoElement::addClient(WebVideoFullscreenModelClient& client) 188 { 189 ASSERT(!m_clients.contains(&client)); 190 m_clients.add(&client); 191 } 192 193 void WebVideoFullscreenModelVideoElement::removeClient(WebVideoFullscreenModelClient& client) 194 { 195 ASSERT(m_clients.contains(&client)); 196 m_clients.remove(&client); 197 } 198 202 199 bool WebVideoFullscreenModelVideoElement::isVisible() const 203 200 { … … 211 208 } 212 209 210 void WebVideoFullscreenModelVideoElement::setHasVideo(bool hasVideo) 211 { 212 if (hasVideo == m_hasVideo) 213 return; 214 215 m_hasVideo = hasVideo; 216 217 for (auto& client : m_clients) 218 client->hasVideoChanged(m_hasVideo); 219 } 220 221 void WebVideoFullscreenModelVideoElement::setVideoDimensions(const FloatSize& videoDimensions) 222 { 223 if (m_videoDimensions == videoDimensions) 224 return; 225 226 m_videoDimensions = videoDimensions; 227 228 for (auto& client : m_clients) 229 client->videoDimensionsChanged(m_videoDimensions); 230 } 231 213 232 #endif -
trunk/Source/WebCore/platform/ios/WebAVPlayerController.h
r199896 r205365 42 42 BOOL _pictureInPictureInterrupted; 43 43 } 44 45 - (void)resetState;46 44 47 45 @property (retain) AVPlayerController* playerControllerProxy; -
trunk/Source/WebCore/platform/ios/WebAVPlayerController.mm
r204466 r205365 75 75 } 76 76 77 - (void)resetState78 {79 self.contentDuration = 0;80 self.maxTime = 0;81 self.contentDurationWithinEndTimes = 0;82 self.loadedTimeRanges = @[];83 84 self.canPlay = NO;85 self.canPause = NO;86 self.canTogglePlayback = NO;87 self.hasEnabledAudio = NO;88 self.canSeek = NO;89 self.minTime = 0;90 self.status = AVPlayerControllerStatusUnknown;91 92 self.timing = nil;93 self.rate = 0;94 95 self.hasEnabledVideo = NO;96 self.contentDimensions = CGSizeMake(0, 0);97 98 self.seekableTimeRanges = [NSMutableArray array];99 100 self.canScanBackward = NO;101 102 self.audioMediaSelectionOptions = nil;103 self.currentAudioMediaSelectionOption = nil;104 105 self.legibleMediaSelectionOptions = nil;106 self.currentLegibleMediaSelectionOption = nil;107 }108 109 77 - (AVPlayer *)player 110 78 { -
trunk/Source/WebCore/platform/ios/WebPlaybackSessionInterfaceAVKit.h
r200490 r205365 34 34 #include "Timer.h" 35 35 #include "WebPlaybackSessionInterface.h" 36 #include "WebPlaybackSessionModel.h" 36 37 #include <functional> 37 38 #include <objc/objc.h> … … 55 56 class WebPlaybackSessionChangeObserver; 56 57 57 class WebPlaybackSessionInterfaceAVKitClient {58 public:59 virtual ~WebPlaybackSessionInterfaceAVKitClient() { }60 61 virtual void externalPlaybackEnabledChanged(bool) = 0;62 };63 64 58 class WEBCORE_EXPORT WebPlaybackSessionInterfaceAVKit 65 59 : public WebPlaybackSessionInterface 60 , public WebPlaybackSessionModelClient 66 61 , public RefCounted<WebPlaybackSessionInterfaceAVKit> { 67 62 68 63 public: 69 static Ref<WebPlaybackSessionInterfaceAVKit> create( )64 static Ref<WebPlaybackSessionInterfaceAVKit> create(WebPlaybackSessionModel& model) 70 65 { 71 return adoptRef(*new WebPlaybackSessionInterfaceAVKit( ));66 return adoptRef(*new WebPlaybackSessionInterfaceAVKit(model)); 72 67 } 73 68 virtual ~WebPlaybackSessionInterfaceAVKit(); 74 WEBCORE_EXPORT void setWebPlaybackSessionModel(WebPlaybackSessionModel*);75 69 WebPlaybackSessionModel* webPlaybackSessionModel() const { return m_playbackSessionModel; } 76 void setClient(WebPlaybackSessionInterfaceAVKitClient* client) { m_client = client; }77 70 71 // WebPlaybackSessionInterface 78 72 WEBCORE_EXPORT void resetMediaState() override; 79 WEBCORE_EXPORT void setDuration(double) override; 80 WEBCORE_EXPORT void setCurrentTime(double currentTime, double anchorTime) override; 81 WEBCORE_EXPORT void setBufferedTime(double) override; 82 WEBCORE_EXPORT void setRate(bool isPlaying, float playbackRate) override; 83 WEBCORE_EXPORT void setSeekableRanges(const TimeRanges&) override; 84 WEBCORE_EXPORT void setCanPlayFastReverse(bool) override; 85 WEBCORE_EXPORT void setAudioMediaSelectionOptions(const Vector<WTF::String>& options, uint64_t selectedIndex) override; 86 WEBCORE_EXPORT void setLegibleMediaSelectionOptions(const Vector<WTF::String>& options, uint64_t selectedIndex) override; 87 WEBCORE_EXPORT void setExternalPlayback(bool enabled, ExternalPlaybackTargetType, WTF::String localizedDeviceName) override; 88 WEBCORE_EXPORT void setWirelessVideoPlaybackDisabled(bool) override; 89 bool wirelessVideoPlaybackDisabled() const; 73 74 // WebPlaybackSessionModelClient 75 WEBCORE_EXPORT void durationChanged(double) override; 76 WEBCORE_EXPORT void currentTimeChanged(double currentTime, double anchorTime) override; 77 WEBCORE_EXPORT void bufferedTimeChanged(double) override; 78 WEBCORE_EXPORT void rateChanged(bool isPlaying, float playbackRate) override; 79 WEBCORE_EXPORT void seekableRangesChanged(const TimeRanges&) override; 80 WEBCORE_EXPORT void canPlayFastReverseChanged(bool) override; 81 WEBCORE_EXPORT void audioMediaSelectionOptionsChanged(const Vector<String>& options, uint64_t selectedIndex) override; 82 WEBCORE_EXPORT void legibleMediaSelectionOptionsChanged(const Vector<String>& options, uint64_t selectedIndex) override; 83 WEBCORE_EXPORT void externalPlaybackChanged(bool enabled, WebPlaybackSessionModel::ExternalPlaybackTargetType, const String& localizedDeviceName) override; 84 WEBCORE_EXPORT void wirelessVideoPlaybackDisabledChanged(bool) override; 90 85 91 86 WEBCORE_EXPORT virtual void invalidate(); … … 94 89 95 90 protected: 96 WEBCORE_EXPORT WebPlaybackSessionInterfaceAVKit( );91 WEBCORE_EXPORT WebPlaybackSessionInterfaceAVKit(WebPlaybackSessionModel&); 97 92 98 93 RetainPtr<WebAVPlayerController> m_playerController; 99 94 WebPlaybackSessionModel* m_playbackSessionModel { nullptr }; 100 WebPlaybackSessionInterfaceAVKitClient* m_client { nullptr};101 102 bool m_wirelessVideoPlaybackDisabled { true };103 95 }; 104 96 -
trunk/Source/WebCore/platform/ios/WebPlaybackSessionInterfaceAVKit.mm
r199701 r205365 48 48 namespace WebCore { 49 49 50 WebPlaybackSessionInterfaceAVKit::WebPlaybackSessionInterfaceAVKit( )50 WebPlaybackSessionInterfaceAVKit::WebPlaybackSessionInterfaceAVKit(WebPlaybackSessionModel& model) 51 51 : m_playerController(adoptNS([[WebAVPlayerController alloc] init])) 52 { 52 , m_playbackSessionModel(&model) 53 { 54 model.addClient(*this); 53 55 [m_playerController setPlaybackSessionInterface:this]; 56 [m_playerController setDelegate:&model]; 54 57 } 55 58 56 59 WebPlaybackSessionInterfaceAVKit::~WebPlaybackSessionInterfaceAVKit() 57 60 { 58 WebAVPlayerController* playerController = m_playerController.get(); 59 if (playerController && playerController.externalPlaybackActive) 60 setExternalPlayback(false, TargetTypeNone, ""); 61 [m_playerController setPlaybackSessionInterface:nullptr]; 62 [m_playerController setExternalPlaybackActive:false]; 63 64 invalidate(); 61 65 } 62 66 63 67 void WebPlaybackSessionInterfaceAVKit::resetMediaState() 64 68 { 65 [m_playerController resetState]; 66 } 67 68 void WebPlaybackSessionInterfaceAVKit::setWebPlaybackSessionModel(WebPlaybackSessionModel* model) 69 { 70 m_playbackSessionModel = model; 71 [m_playerController setDelegate:m_playbackSessionModel]; 72 } 73 74 void WebPlaybackSessionInterfaceAVKit::setDuration(double duration) 69 WebAVPlayerController* playerController = m_playerController.get(); 70 71 playerController.contentDuration = 0; 72 playerController.maxTime = 0; 73 playerController.contentDurationWithinEndTimes = 0; 74 playerController.loadedTimeRanges = @[]; 75 76 playerController.canPlay = NO; 77 playerController.canPause = NO; 78 playerController.canTogglePlayback = NO; 79 playerController.hasEnabledAudio = NO; 80 playerController.canSeek = NO; 81 playerController.minTime = 0; 82 playerController.status = AVPlayerControllerStatusUnknown; 83 84 playerController.timing = nil; 85 playerController.rate = 0; 86 87 playerController.seekableTimeRanges = [NSMutableArray array]; 88 89 playerController.canScanBackward = NO; 90 91 playerController.audioMediaSelectionOptions = nil; 92 playerController.currentAudioMediaSelectionOption = nil; 93 94 playerController.legibleMediaSelectionOptions = nil; 95 playerController.currentLegibleMediaSelectionOption = nil; 96 } 97 98 void WebPlaybackSessionInterfaceAVKit::durationChanged(double duration) 75 99 { 76 100 WebAVPlayerController* playerController = m_playerController.get(); … … 91 115 } 92 116 93 void WebPlaybackSessionInterfaceAVKit:: setCurrentTime(double currentTime, double anchorTime)117 void WebPlaybackSessionInterfaceAVKit::currentTimeChanged(double currentTime, double anchorTime) 94 118 { 95 119 NSTimeInterval anchorTimeStamp = ![m_playerController rate] ? NAN : anchorTime; … … 100 124 } 101 125 102 void WebPlaybackSessionInterfaceAVKit:: setBufferedTime(double bufferedTime)126 void WebPlaybackSessionInterfaceAVKit::bufferedTimeChanged(double bufferedTime) 103 127 { 104 128 WebAVPlayerController* playerController = m_playerController.get(); … … 112 136 } 113 137 114 void WebPlaybackSessionInterfaceAVKit:: setRate(bool isPlaying, float playbackRate)138 void WebPlaybackSessionInterfaceAVKit::rateChanged(bool isPlaying, float playbackRate) 115 139 { 116 140 [m_playerController setRate:isPlaying ? playbackRate : 0.]; 117 141 } 118 142 119 void WebPlaybackSessionInterfaceAVKit::se tSeekableRanges(const TimeRanges& timeRanges)143 void WebPlaybackSessionInterfaceAVKit::seekableRangesChanged(const TimeRanges& timeRanges) 120 144 { 121 145 RetainPtr<NSMutableArray> seekableRanges = adoptNS([[NSMutableArray alloc] init]); … … 133 157 } 134 158 135 void WebPlaybackSessionInterfaceAVKit:: setCanPlayFastReverse(bool canPlayFastReverse)159 void WebPlaybackSessionInterfaceAVKit::canPlayFastReverseChanged(bool canPlayFastReverse) 136 160 { 137 161 [m_playerController setCanScanBackward:canPlayFastReverse]; … … 149 173 } 150 174 151 void WebPlaybackSessionInterfaceAVKit:: setAudioMediaSelectionOptions(const Vector<String>& options, uint64_t selectedIndex)175 void WebPlaybackSessionInterfaceAVKit::audioMediaSelectionOptionsChanged(const Vector<String>& options, uint64_t selectedIndex) 152 176 { 153 177 RetainPtr<NSMutableArray> webOptions = mediaSelectionOptions(options); … … 157 181 } 158 182 159 void WebPlaybackSessionInterfaceAVKit:: setLegibleMediaSelectionOptions(const Vector<String>& options, uint64_t selectedIndex)183 void WebPlaybackSessionInterfaceAVKit::legibleMediaSelectionOptionsChanged(const Vector<String>& options, uint64_t selectedIndex) 160 184 { 161 185 RetainPtr<NSMutableArray> webOptions = mediaSelectionOptions(options); … … 165 189 } 166 190 167 void WebPlaybackSessionInterfaceAVKit:: setExternalPlayback(bool enabled, ExternalPlaybackTargetType targetType, StringlocalizedDeviceName)191 void WebPlaybackSessionInterfaceAVKit::externalPlaybackChanged(bool enabled, WebPlaybackSessionModel::ExternalPlaybackTargetType targetType, const String& localizedDeviceName) 168 192 { 169 193 AVPlayerControllerExternalPlaybackType externalPlaybackType = AVPlayerControllerExternalPlaybackTypeNone; 170 if (targetType == TargetTypeAirPlay)194 if (targetType == WebPlaybackSessionModel::TargetTypeAirPlay) 171 195 externalPlaybackType = AVPlayerControllerExternalPlaybackTypeAirPlay; 172 else if (targetType == TargetTypeTVOut)196 else if (targetType == WebPlaybackSessionModel::TargetTypeTVOut) 173 197 externalPlaybackType = AVPlayerControllerExternalPlaybackTypeTVOut; 174 198 … … 177 201 playerController.externalPlaybackType = externalPlaybackType; 178 202 playerController.externalPlaybackActive = enabled; 179 180 if (m_client) 181 m_client->externalPlaybackEnabledChanged(enabled); 182 } 183 184 void WebPlaybackSessionInterfaceAVKit::setWirelessVideoPlaybackDisabled(bool disabled) 203 } 204 205 void WebPlaybackSessionInterfaceAVKit::wirelessVideoPlaybackDisabledChanged(bool disabled) 185 206 { 186 207 [m_playerController setAllowsExternalPlayback:!disabled]; 187 208 } 188 209 189 bool WebPlaybackSessionInterfaceAVKit::wirelessVideoPlaybackDisabled() const190 {191 return [m_playerController allowsExternalPlayback];192 }193 194 210 void WebPlaybackSessionInterfaceAVKit::invalidate() 195 211 { 196 m_playbackSessionModel = nil; 212 if (!m_playbackSessionModel) 213 return; 214 215 [m_playerController setDelegate:nullptr]; 216 m_playbackSessionModel->removeClient(*this); 217 m_playbackSessionModel = nullptr; 197 218 } 198 219 -
trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm
r203303 r205365 92 92 93 93 class WebVideoFullscreenControllerContext; 94 class WebVideoFullscreenSessionModel;95 94 96 95 @interface WebVideoFullscreenController (delegate) … … 101 100 : private WebVideoFullscreenInterface 102 101 , private WebVideoFullscreenModel 102 , private WebVideoFullscreenModelClient 103 103 , private WebVideoFullscreenChangeObserver 104 , private WebPlaybackSessionModel 105 , private WebPlaybackSessionModelClient 104 106 , public ThreadSafeRefCounted<WebVideoFullscreenControllerContext> { 105 107 … … 115 117 void requestHideAndExitFullscreen(); 116 118 void invalidate(); 117 118 void play();119 void pause();120 void togglePlayState();121 void beginScrubbing();122 void endScrubbing();123 void seekToTime(double);124 void fastSeek(double time);125 void beginScanningForward();126 void beginScanningBackward();127 void endScanning();128 void selectAudioMediaOption(uint64_t);129 void selectLegibleMediaOption(uint64_t);130 119 131 120 private: … … 139 128 void fullscreenMayReturnToInline() override; 140 129 141 // WebVideoFullscreenInterface 142 void resetMediaState() override; 143 void setDuration(double) override; 144 void setCurrentTime(double currentTime, double anchorTime) override; 145 void setBufferedTime(double) override; 146 void setRate(bool isPlaying, float playbackRate) override; 147 void setVideoDimensions(bool hasVideo, float width, float height) override; 148 void setSeekableRanges(const TimeRanges&) override; 149 void setCanPlayFastReverse(bool) override; 150 void setAudioMediaSelectionOptions(const Vector<String>& options, uint64_t selectedIndex) override; 151 void setLegibleMediaSelectionOptions(const Vector<String>& options, uint64_t selectedIndex) override; 152 void setExternalPlayback(bool enabled, ExternalPlaybackTargetType, String localizedDeviceName) override; 153 void setWirelessVideoPlaybackDisabled(bool) override; 130 // WebVideoFullscreenModelClient 131 void hasVideoChanged(bool) override; 132 void videoDimensionsChanged(const FloatSize&) override; 133 134 // WebPlaybackSessionModel 135 void addClient(WebPlaybackSessionModelClient&) override; 136 void removeClient(WebPlaybackSessionModelClient&) override; 137 void play() override; 138 void pause() override; 139 void togglePlayState() override; 140 void beginScrubbing() override; 141 void endScrubbing() override; 142 void seekToTime(double) override; 143 void fastSeek(double time) override; 144 void beginScanningForward() override; 145 void beginScanningBackward() override; 146 void endScanning() override; 147 void selectAudioMediaOption(uint64_t) override; 148 void selectLegibleMediaOption(uint64_t) override; 149 double duration() const override; 150 double currentTime() const override; 151 double bufferedTime() const override; 152 bool isPlaying() const override; 153 float playbackRate() const override; 154 Ref<TimeRanges> seekableRanges() const override; 155 bool canPlayFastReverse() const override; 156 Vector<String> audioMediaSelectionOptions() const override; 157 uint64_t audioMediaSelectedIndex() const override; 158 Vector<String> legibleMediaSelectionOptions() const override; 159 uint64_t legibleMediaSelectedIndex() const override; 160 bool externalPlaybackEnabled() const override; 161 ExternalPlaybackTargetType externalPlaybackTargetType() const override; 162 String externalPlaybackLocalizedDeviceName() const override; 163 bool wirelessVideoPlaybackDisabled() const override; 164 165 // WebPlaybackSessionModelClient 166 void durationChanged(double) override; 167 void currentTimeChanged(double currentTime, double anchorTime) override; 168 void bufferedTimeChanged(double) override; 169 void rateChanged(bool isPlaying, float playbackRate) override; 170 void seekableRangesChanged(const TimeRanges&) override; 171 void canPlayFastReverseChanged(bool) override; 172 void audioMediaSelectionOptionsChanged(const Vector<String>& options, uint64_t selectedIndex) override; 173 void legibleMediaSelectionOptionsChanged(const Vector<String>& options, uint64_t selectedIndex) override; 174 void externalPlaybackChanged(bool enabled, WebPlaybackSessionModel::ExternalPlaybackTargetType, const String& localizedDeviceName) override; 175 void wirelessVideoPlaybackDisabledChanged(bool) override; 154 176 155 177 // WebVideoFullscreenModel 178 void addClient(WebVideoFullscreenModelClient&) override; 179 void removeClient(WebVideoFullscreenModelClient&) override; 156 180 void requestFullscreenMode(HTMLMediaElementEnums::VideoFullscreenMode) override; 157 181 void setVideoLayerFrame(FloatRect) override; … … 159 183 void fullscreenModeChanged(HTMLMediaElementEnums::VideoFullscreenMode) override; 160 184 bool isVisible() const override; 161 185 bool hasVideo() const override; 186 FloatSize videoDimensions() const override; 187 188 HashSet<WebPlaybackSessionModelClient*> m_playbackClients; 189 HashSet<WebVideoFullscreenModelClient*> m_fullscreenClients; 162 190 RefPtr<WebVideoFullscreenInterfaceAVKit> m_interface; 163 RefPtr<WebVideoFullscreenModelVideoElement> m_model; 191 RefPtr<WebVideoFullscreenModelVideoElement> m_fullscreenModel; 192 RefPtr<WebPlaybackSessionModelMediaElement> m_playbackModel; 164 193 RefPtr<HTMLVideoElement> m_videoElement; 165 194 RetainPtr<UIView> m_videoFullscreenView; 166 195 RetainPtr<WebVideoFullscreenController> m_controller; 167 RefPtr<WebVideoFullscreenSessionModel> m_sessionModel;168 196 }; 169 197 170 171 class WebVideoFullscreenSessionModel final: public RefCounted<WebVideoFullscreenSessionModel>, public WebCore::WebPlaybackSessionModel {172 public:173 static Ref<WebVideoFullscreenSessionModel> create(WebVideoFullscreenControllerContext& controller)174 {175 return adoptRef(*new WebVideoFullscreenSessionModel(controller));176 }177 virtual ~WebVideoFullscreenSessionModel() { }178 179 void invalidate() { m_controller = nullptr; }180 181 void setDuration(double duration) { m_duration = duration; }182 void setCurrentTime(double currentTime) { m_currentTime = currentTime; }183 void setBufferedTime(double bufferedTime) { m_bufferedTime = bufferedTime; }184 void setIsPlaying(bool isPlaying) { m_isPlaying = isPlaying; }185 void setPlaybackRate(float playbackRate) { m_playbackRate = playbackRate; }186 void setSeekableRanges(WebCore::TimeRanges& seekableRanges) { m_seekableRanges = seekableRanges; }187 void setCanPlayFastReverse(bool canPlayFastReverse) { m_canPlayFastReverse = canPlayFastReverse; }188 void setAudioMediaSelectionOptions(const Vector<WTF::String>& audioMediaSelectionOptions) { m_audioMediaSelectionOptions = audioMediaSelectionOptions; }189 void setAudioMediaSelectedIndex(uint64_t audioMediaSelectedIndex) { m_audioMediaSelectedIndex = audioMediaSelectedIndex; }190 void setLegibleMediaSelectionOptions(const Vector<WTF::String>& legibleMediaSelectionOptions) { m_legibleMediaSelectionOptions = legibleMediaSelectionOptions; }191 void setLegibleMediaSelectedIndex(uint64_t legibleMediaSelectedIndex) { m_legibleMediaSelectedIndex = legibleMediaSelectedIndex; }192 void setExternalPlaybackEnabled(bool externalPlaybackEnabled) { m_externalPlaybackEnabled = externalPlaybackEnabled; }193 void setWirelessVideoPlaybackDisabled(bool wirelessVideoPlaybackDisabled) { m_wirelessVideoPlaybackDisabled = wirelessVideoPlaybackDisabled; }194 195 private:196 WebVideoFullscreenSessionModel(WebVideoFullscreenControllerContext& controller)197 : m_controller(&controller)198 {199 }200 201 void play() final;202 void pause() final;203 void togglePlayState() final;204 void beginScrubbing() final;205 void endScrubbing() final;206 void seekToTime(double) final;207 void fastSeek(double time) final;208 void beginScanningForward() final;209 void beginScanningBackward() final;210 void endScanning() final;211 void selectAudioMediaOption(uint64_t) final;212 void selectLegibleMediaOption(uint64_t) final;213 214 double duration() const final { return m_duration; }215 double currentTime() const final { return m_currentTime; }216 double bufferedTime() const final { return m_bufferedTime; }217 bool isPlaying() const final { return m_isPlaying; }218 float playbackRate() const final { return m_playbackRate; }219 Ref<WebCore::TimeRanges> seekableRanges() const final { return m_seekableRanges.copyRef(); }220 bool canPlayFastReverse() const final { return m_canPlayFastReverse; }221 Vector<WTF::String> audioMediaSelectionOptions() const final { return m_audioMediaSelectionOptions; }222 uint64_t audioMediaSelectedIndex() const final { return m_audioMediaSelectedIndex; }223 Vector<WTF::String> legibleMediaSelectionOptions() const final { return m_legibleMediaSelectionOptions; }224 uint64_t legibleMediaSelectedIndex() const final { return m_legibleMediaSelectedIndex; }225 bool externalPlaybackEnabled() const final { return m_externalPlaybackEnabled; }226 bool wirelessVideoPlaybackDisabled() const final { return m_wirelessVideoPlaybackDisabled; }227 228 WebVideoFullscreenControllerContext* m_controller;229 double m_duration { 0 };230 double m_currentTime { 0 };231 double m_bufferedTime { 0 };232 bool m_isPlaying { false };233 float m_playbackRate { 0 };234 Ref<WebCore::TimeRanges> m_seekableRanges { WebCore::TimeRanges::create() };235 bool m_canPlayFastReverse { false };236 Vector<WTF::String> m_audioMediaSelectionOptions;237 uint64_t m_audioMediaSelectedIndex { 0 };238 Vector<WTF::String> m_legibleMediaSelectionOptions;239 uint64_t m_legibleMediaSelectedIndex { 0 };240 bool m_externalPlaybackEnabled { false };241 bool m_wirelessVideoPlaybackDisabled { false };242 };243 244 198 #pragma mark WebVideoFullscreenChangeObserver 245 199 … … 247 201 { 248 202 ASSERT(isUIThread()); 249 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this);250 203 RetainPtr<CALayer> videoFullscreenLayer = [m_videoFullscreenView layer]; 204 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 251 205 WebThreadRun([protectedThis, this, videoFullscreenLayer] { 252 206 [videoFullscreenLayer setBackgroundColor:cachedCGColor(WebCore::Color::transparent)]; 253 m_ model->setVideoFullscreenLayer(videoFullscreenLayer.get(), [protectedThis, this] {207 m_fullscreenModel->setVideoFullscreenLayer(videoFullscreenLayer.get(), [protectedThis, this] { 254 208 dispatch_async(dispatch_get_main_queue(), [protectedThis, this] { 255 209 m_interface->enterFullscreen(); … … 264 218 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 265 219 WebThreadRun([protectedThis, this] { 266 m_ model->setVideoFullscreenLayer(nil, [protectedThis, this] {220 m_fullscreenModel->setVideoFullscreenLayer(nil, [protectedThis, this] { 267 221 dispatch_async(dispatch_get_main_queue(), [protectedThis, this] { 268 222 m_interface->cleanupFullscreen(); … … 279 233 m_interface = nullptr; 280 234 m_videoFullscreenView = nil; 281 m_sessionModel->invalidate(); 282 m_sessionModel = nullptr; 283 284 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 285 WebThreadRun([protectedThis, this] { 286 m_model->setVideoFullscreenLayer(nil); 287 m_model->setWebVideoFullscreenInterface(nullptr); 288 m_model->setVideoElement(nullptr); 289 m_model->playbackSessionModel().setMediaElement(nullptr); 290 m_model = nullptr; 235 236 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 237 WebThreadRun([protectedThis, this] { 238 m_fullscreenModel->setVideoFullscreenLayer(nil); 239 m_fullscreenModel->setVideoElement(nullptr); 240 m_playbackModel->setMediaElement(nullptr); 241 m_fullscreenModel->removeClient(*this); 242 m_fullscreenModel = nullptr; 291 243 m_videoElement = nullptr; 292 244 … … 307 259 } 308 260 309 #pragma mark WebVideoFullscreenInterface 310 311 void WebVideoFullscreenControllerContext::resetMediaState() 312 { 313 ASSERT(WebThreadIsCurrent() || isMainThread()); 314 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 315 dispatch_async(dispatch_get_main_queue(), [protectedThis, this] { 316 if (m_interface) 317 m_interface->resetMediaState(); 318 }); 319 } 320 321 void WebVideoFullscreenControllerContext::setDuration(double duration) 322 { 323 ASSERT(WebThreadIsCurrent()); 324 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 325 dispatch_async(dispatch_get_main_queue(), [protectedThis, this, duration] { 326 if (m_interface) 327 m_interface->setDuration(duration); 328 }); 329 } 330 331 void WebVideoFullscreenControllerContext::setCurrentTime(double currentTime, double anchorTime) 332 { 333 ASSERT(WebThreadIsCurrent()); 334 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 335 dispatch_async(dispatch_get_main_queue(), [protectedThis, this, currentTime, anchorTime] { 336 if (m_interface) 337 m_interface->setCurrentTime(currentTime, anchorTime); 338 }); 339 } 340 341 void WebVideoFullscreenControllerContext::setBufferedTime(double bufferedTime) 342 { 343 ASSERT(WebThreadIsCurrent()); 344 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 345 dispatch_async(dispatch_get_main_queue(), [protectedThis, this, bufferedTime] { 346 if (m_interface) 347 m_interface->setBufferedTime(bufferedTime); 348 }); 349 } 350 351 void WebVideoFullscreenControllerContext::setRate(bool isPlaying, float playbackRate) 352 { 353 ASSERT(WebThreadIsCurrent()); 354 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 355 dispatch_async(dispatch_get_main_queue(), [protectedThis, this, isPlaying, playbackRate] { 356 if (m_interface) 357 m_interface->setRate(isPlaying, playbackRate); 358 }); 359 } 360 361 void WebVideoFullscreenControllerContext::setVideoDimensions(bool hasVideo, float width, float height) 362 { 363 if (WebThreadIsCurrent()) { 364 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 365 dispatch_async(dispatch_get_main_queue(), [protectedThis, this, hasVideo, width, height] { 366 if (m_interface) 367 m_interface->setVideoDimensions(hasVideo, width, height); 368 }); 369 return; 370 } 371 372 if (m_interface) 373 m_interface->setVideoDimensions(hasVideo, width, height); 374 } 375 376 void WebVideoFullscreenControllerContext::setSeekableRanges(const TimeRanges& timeRanges) 377 { 378 ASSERT(WebThreadIsCurrent()); 379 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 380 const PlatformTimeRanges& platformTimeRanges = timeRanges.ranges(); 381 dispatch_async(dispatch_get_main_queue(), [protectedThis, this, platformTimeRanges] { 382 if (m_interface) 383 m_interface->setSeekableRanges(TimeRanges::create(platformTimeRanges)); 384 }); 385 } 386 387 void WebVideoFullscreenControllerContext::setCanPlayFastReverse(bool canPlayFastReverse) 388 { 389 ASSERT(WebThreadIsCurrent()); 390 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 391 dispatch_async(dispatch_get_main_queue(), [protectedThis, this, canPlayFastReverse] { 392 if (m_interface) 393 m_interface->setCanPlayFastReverse(canPlayFastReverse); 394 }); 395 } 396 397 void WebVideoFullscreenControllerContext::setAudioMediaSelectionOptions(const Vector<String>& options, uint64_t selectedIndex) 398 { 399 ASSERT(WebThreadIsCurrent()); 400 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 401 402 RetainPtr<NSMutableArray> optionsArray = adoptNS([[NSMutableArray alloc] initWithCapacity:options.size()]); 403 for (auto& name : options) 404 [optionsArray addObject:name]; 405 406 dispatch_async(dispatch_get_main_queue(), [protectedThis, this, optionsArray, selectedIndex] { 407 Vector<String> options; 408 for (NSString *name : optionsArray.get()) 409 options.append(name); 410 411 if (m_interface) 412 m_interface->setAudioMediaSelectionOptions(options, selectedIndex); 413 }); 414 } 415 416 void WebVideoFullscreenControllerContext::setLegibleMediaSelectionOptions(const Vector<String>& options, uint64_t selectedIndex) 417 { 418 ASSERT(WebThreadIsCurrent()); 419 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 420 421 RetainPtr<NSMutableArray> optionsArray = adoptNS([[NSMutableArray alloc] initWithCapacity:options.size()]); 422 for (auto& name : options) 423 [optionsArray addObject:name]; 424 425 dispatch_async(dispatch_get_main_queue(), [protectedThis, this, optionsArray, selectedIndex] { 426 Vector<String> options; 427 for (NSString *name : optionsArray.get()) 428 options.append(name); 429 430 if (m_interface) 431 m_interface->setLegibleMediaSelectionOptions(options, selectedIndex); 432 }); 433 } 434 435 void WebVideoFullscreenControllerContext::setExternalPlayback(bool enabled, ExternalPlaybackTargetType type, String localizedDeviceName) 436 { 437 ASSERT(WebThreadIsCurrent()); 438 callOnMainThread([protectedThis = makeRef(*this), this, enabled, type, localizedDeviceName = localizedDeviceName.isolatedCopy()] { 439 if (m_interface) 440 m_interface->setExternalPlayback(enabled, type, localizedDeviceName); 441 }); 442 } 443 444 void WebVideoFullscreenControllerContext::setWirelessVideoPlaybackDisabled(bool disabled) 445 { 446 ASSERT(WebThreadIsCurrent()); 447 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 448 dispatch_async(dispatch_get_main_queue(), [protectedThis, this, disabled] { 449 if (m_interface) 450 m_interface->setWirelessVideoPlaybackDisabled(disabled); 451 }); 261 #pragma mark WebPlaybackSessionModelClient 262 263 void WebVideoFullscreenControllerContext::durationChanged(double duration) 264 { 265 if (WebThreadIsCurrent()) { 266 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 267 dispatch_async(dispatch_get_main_queue(), [protectedThis, duration] { 268 protectedThis->durationChanged(duration); 269 }); 270 return; 271 } 272 273 for (auto& client : m_playbackClients) 274 client->durationChanged(duration); 275 } 276 277 void WebVideoFullscreenControllerContext::currentTimeChanged(double currentTime, double anchorTime) 278 { 279 if (WebThreadIsCurrent()) { 280 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 281 dispatch_async(dispatch_get_main_queue(), [protectedThis, currentTime, anchorTime] { 282 protectedThis->currentTimeChanged(currentTime, anchorTime); 283 }); 284 return; 285 } 286 287 for (auto& client : m_playbackClients) 288 client->currentTimeChanged(currentTime, anchorTime); 289 } 290 291 void WebVideoFullscreenControllerContext::bufferedTimeChanged(double bufferedTime) 292 { 293 if (WebThreadIsCurrent()) { 294 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 295 dispatch_async(dispatch_get_main_queue(), [protectedThis, bufferedTime] { 296 protectedThis->bufferedTimeChanged(bufferedTime); 297 }); 298 return; 299 } 300 301 for (auto& client : m_playbackClients) 302 client->bufferedTimeChanged(bufferedTime); 303 } 304 305 void WebVideoFullscreenControllerContext::rateChanged(bool isPlaying, float playbackRate) 306 { 307 if (WebThreadIsCurrent()) { 308 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 309 dispatch_async(dispatch_get_main_queue(), [protectedThis, isPlaying, playbackRate] { 310 protectedThis->rateChanged(isPlaying, playbackRate); 311 }); 312 return; 313 } 314 315 for (auto& client : m_playbackClients) 316 client->rateChanged(isPlaying, playbackRate); 317 } 318 319 void WebVideoFullscreenControllerContext::hasVideoChanged(bool hasVideo) 320 { 321 if (WebThreadIsCurrent()) { 322 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 323 dispatch_async(dispatch_get_main_queue(), [protectedThis, hasVideo] { 324 protectedThis->hasVideoChanged(hasVideo); 325 }); 326 return; 327 } 328 329 for (auto& client : m_fullscreenClients) 330 client->hasVideoChanged(hasVideo); 331 } 332 333 void WebVideoFullscreenControllerContext::videoDimensionsChanged(const FloatSize& videoDimensions) 334 { 335 if (WebThreadIsCurrent()) { 336 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 337 dispatch_async(dispatch_get_main_queue(), [protectedThis, videoDimensions = videoDimensions] { 338 protectedThis->videoDimensionsChanged(videoDimensions); 339 }); 340 return; 341 } 342 343 for (auto& client : m_fullscreenClients) 344 client->videoDimensionsChanged(videoDimensions); 345 } 346 347 void WebVideoFullscreenControllerContext::seekableRangesChanged(const TimeRanges& timeRanges) 348 { 349 if (WebThreadIsCurrent()) { 350 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 351 dispatch_async(dispatch_get_main_queue(), [protectedThis, platformTimeRanges = timeRanges.ranges()] { 352 protectedThis->seekableRangesChanged(TimeRanges::create(platformTimeRanges)); 353 }); 354 return; 355 } 356 357 for (auto &client : m_playbackClients) 358 client->seekableRangesChanged(timeRanges); 359 } 360 361 void WebVideoFullscreenControllerContext::canPlayFastReverseChanged(bool canPlayFastReverse) 362 { 363 if (WebThreadIsCurrent()) { 364 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 365 dispatch_async(dispatch_get_main_queue(), [protectedThis, canPlayFastReverse] { 366 protectedThis->canPlayFastReverseChanged(canPlayFastReverse); 367 }); 368 return; 369 } 370 371 for (auto &client : m_playbackClients) 372 client->canPlayFastReverseChanged(canPlayFastReverse); 373 } 374 375 void WebVideoFullscreenControllerContext::audioMediaSelectionOptionsChanged(const Vector<String>& options, uint64_t selectedIndex) 376 { 377 if (WebThreadIsCurrent()) { 378 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 379 dispatch_async(dispatch_get_main_queue(), [protectedThis, options = options, selectedIndex] { 380 protectedThis->audioMediaSelectionOptionsChanged(options, selectedIndex); 381 }); 382 return; 383 } 384 385 for (auto& client : m_playbackClients) 386 client->audioMediaSelectionOptionsChanged(options, selectedIndex); 387 } 388 389 void WebVideoFullscreenControllerContext::legibleMediaSelectionOptionsChanged(const Vector<String>& options, uint64_t selectedIndex) 390 { 391 if (WebThreadIsCurrent()) { 392 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 393 dispatch_async(dispatch_get_main_queue(), [protectedThis, options = options, selectedIndex] { 394 protectedThis->legibleMediaSelectionOptionsChanged(options, selectedIndex); 395 }); 396 return; 397 } 398 399 for (auto& client : m_playbackClients) 400 client->legibleMediaSelectionOptionsChanged(options, selectedIndex); 401 } 402 403 void WebVideoFullscreenControllerContext::externalPlaybackChanged(bool enabled, WebPlaybackSessionModel::ExternalPlaybackTargetType type, const String& localizedDeviceName) 404 { 405 if (WebThreadIsCurrent()) { 406 callOnMainThread([protectedThis = makeRef(*this), this, enabled, type, localizedDeviceName = localizedDeviceName.isolatedCopy()] { 407 for (auto& client : m_playbackClients) 408 client->externalPlaybackChanged(enabled, type, localizedDeviceName); 409 }); 410 return; 411 } 412 413 for (auto& client : m_playbackClients) 414 client->externalPlaybackChanged(enabled, type, localizedDeviceName); 415 } 416 417 void WebVideoFullscreenControllerContext::wirelessVideoPlaybackDisabledChanged(bool disabled) 418 { 419 if (WebThreadIsCurrent()) { 420 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 421 dispatch_async(dispatch_get_main_queue(), [protectedThis, disabled] { 422 protectedThis->wirelessVideoPlaybackDisabledChanged(disabled); 423 }); 424 return; 425 } 426 427 for (auto& client : m_playbackClients) 428 client->wirelessVideoPlaybackDisabledChanged(disabled); 452 429 } 453 430 454 431 #pragma mark WebVideoFullscreenModel 455 432 433 void WebVideoFullscreenControllerContext::addClient(WebVideoFullscreenModelClient& client) 434 { 435 ASSERT(!m_fullscreenClients.contains(&client)); 436 m_fullscreenClients.add(&client); 437 } 438 439 void WebVideoFullscreenControllerContext::removeClient(WebVideoFullscreenModelClient& client) 440 { 441 ASSERT(m_fullscreenClients.contains(&client)); 442 m_fullscreenClients.remove(&client); 443 } 444 456 445 void WebVideoFullscreenControllerContext::requestFullscreenMode(HTMLMediaElementEnums::VideoFullscreenMode mode) 457 446 { … … 459 448 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 460 449 WebThreadRun([protectedThis, this, mode] { 461 if (m_ model)462 m_ model->requestFullscreenMode(mode);450 if (m_fullscreenModel) 451 m_fullscreenModel->requestFullscreenMode(mode); 463 452 }); 464 453 } … … 480 469 [videoFullscreenLayer setSublayerTransform:CATransform3DIdentity]; 481 470 482 if (m_ model)483 m_ model->setVideoLayerFrame(frame);471 if (m_fullscreenModel) 472 m_fullscreenModel->setVideoLayerFrame(frame); 484 473 [CATransaction commit]; 485 474 }); … … 492 481 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 493 482 WebThreadRun([protectedThis, this, videoGravity] { 494 if (m_ model)495 m_ model->setVideoLayerGravity(videoGravity);483 if (m_fullscreenModel) 484 m_fullscreenModel->setVideoLayerGravity(videoGravity); 496 485 }); 497 486 } … … 502 491 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 503 492 WebThreadRun([protectedThis, this, mode] { 504 if (m_ model)505 m_ model->fullscreenModeChanged(mode);493 if (m_fullscreenModel) 494 m_fullscreenModel->fullscreenModeChanged(mode); 506 495 }); 507 496 } … … 510 499 { 511 500 ASSERT(isUIThread()); 512 return m_model ? m_model->isVisible() : false; 513 } 514 515 #pragma mark - WebPlaybackSessionModelContext 501 return m_fullscreenModel ? m_fullscreenModel->isVisible() : false; 502 } 503 504 bool WebVideoFullscreenControllerContext::hasVideo() const 505 { 506 ASSERT(isUIThread()); 507 return m_fullscreenModel ? m_fullscreenModel->hasVideo() : false; 508 } 509 510 FloatSize WebVideoFullscreenControllerContext::videoDimensions() const 511 { 512 ASSERT(isUIThread()); 513 return m_fullscreenModel ? m_fullscreenModel->videoDimensions() : FloatSize(); 514 } 515 516 #pragma mark - WebPlaybackSessionModel 517 518 void WebVideoFullscreenControllerContext::addClient(WebPlaybackSessionModelClient& client) 519 { 520 ASSERT(!m_playbackClients.contains(&client)); 521 m_playbackClients.add(&client); 522 } 523 524 void WebVideoFullscreenControllerContext::removeClient(WebPlaybackSessionModelClient& client) 525 { 526 ASSERT(m_playbackClients.contains(&client)); 527 m_playbackClients.remove(&client); 528 } 516 529 517 530 void WebVideoFullscreenControllerContext::play() … … 520 533 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 521 534 WebThreadRun([protectedThis, this] { 522 if (m_ model)523 m_ model->playbackSessionModel().play();535 if (m_playbackModel) 536 m_playbackModel->play(); 524 537 }); 525 538 } … … 530 543 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 531 544 WebThreadRun([protectedThis, this] { 532 if (m_ model)533 m_ model->playbackSessionModel().pause();545 if (m_playbackModel) 546 m_playbackModel->pause(); 534 547 }); 535 548 } … … 540 553 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 541 554 WebThreadRun([protectedThis, this] { 542 if (m_ model)543 m_ model->playbackSessionModel().togglePlayState();555 if (m_playbackModel) 556 m_playbackModel->togglePlayState(); 544 557 }); 545 558 } … … 550 563 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 551 564 WebThreadRun([protectedThis, this] { 552 if (m_ model)553 m_ model->playbackSessionModel().beginScrubbing();565 if (m_playbackModel) 566 m_playbackModel->beginScrubbing(); 554 567 }); 555 568 } … … 560 573 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 561 574 WebThreadRun([protectedThis, this] { 562 if (m_ model)563 m_ model->playbackSessionModel().endScrubbing();575 if (m_playbackModel) 576 m_playbackModel->endScrubbing(); 564 577 }); 565 578 } … … 570 583 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 571 584 WebThreadRun([protectedThis, this, time] { 572 if (m_ model)573 m_ model->playbackSessionModel().seekToTime(time);585 if (m_playbackModel) 586 m_playbackModel->seekToTime(time); 574 587 }); 575 588 } … … 580 593 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 581 594 WebThreadRun([protectedThis, this, time] { 582 if (m_ model)583 m_ model->playbackSessionModel().fastSeek(time);595 if (m_playbackModel) 596 m_playbackModel->fastSeek(time); 584 597 }); 585 598 } … … 590 603 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 591 604 WebThreadRun([protectedThis, this] { 592 if (m_ model)593 m_ model->playbackSessionModel().beginScanningForward();605 if (m_playbackModel) 606 m_playbackModel->beginScanningForward(); 594 607 }); 595 608 } … … 600 613 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 601 614 WebThreadRun([protectedThis, this] { 602 if (m_ model)603 m_ model->playbackSessionModel().beginScanningBackward();615 if (m_playbackModel) 616 m_playbackModel->beginScanningBackward(); 604 617 }); 605 618 } … … 610 623 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 611 624 WebThreadRun([protectedThis, this] { 612 if (m_ model)613 m_ model->playbackSessionModel().endScanning();625 if (m_playbackModel) 626 m_playbackModel->endScanning(); 614 627 }); 615 628 } … … 620 633 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 621 634 WebThreadRun([protectedThis, this, index] { 622 if (m_ model)623 m_ model->playbackSessionModel().selectAudioMediaOption(index);635 if (m_playbackModel) 636 m_playbackModel->selectAudioMediaOption(index); 624 637 }); 625 638 } … … 630 643 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 631 644 WebThreadRun([protectedThis, this, index] { 632 if (m_model) 633 m_model->playbackSessionModel().selectLegibleMediaOption(index); 634 }); 645 if (m_playbackModel) 646 m_playbackModel->selectLegibleMediaOption(index); 647 }); 648 } 649 650 double WebVideoFullscreenControllerContext::duration() const 651 { 652 ASSERT(isUIThread()); 653 return m_playbackModel ? m_playbackModel->duration() : 0; 654 } 655 656 double WebVideoFullscreenControllerContext::currentTime() const 657 { 658 ASSERT(isUIThread()); 659 return m_playbackModel ? m_playbackModel->currentTime() : 0; 660 } 661 662 double WebVideoFullscreenControllerContext::bufferedTime() const 663 { 664 ASSERT(isUIThread()); 665 return m_playbackModel ? m_playbackModel->bufferedTime() : 0; 666 } 667 668 bool WebVideoFullscreenControllerContext::isPlaying() const 669 { 670 ASSERT(isUIThread()); 671 return m_playbackModel ? m_playbackModel->isPlaying() : false; 672 } 673 674 float WebVideoFullscreenControllerContext::playbackRate() const 675 { 676 ASSERT(isUIThread()); 677 return m_playbackModel ? m_playbackModel->playbackRate() : 0; 678 } 679 680 Ref<TimeRanges> WebVideoFullscreenControllerContext::seekableRanges() const 681 { 682 ASSERT(isUIThread()); 683 return m_playbackModel ? m_playbackModel->seekableRanges() : TimeRanges::create(); 684 } 685 686 bool WebVideoFullscreenControllerContext::canPlayFastReverse() const 687 { 688 ASSERT(isUIThread()); 689 return m_playbackModel ? m_playbackModel->canPlayFastReverse() : false; 690 } 691 692 Vector<String> WebVideoFullscreenControllerContext::audioMediaSelectionOptions() const 693 { 694 ASSERT(isUIThread()); 695 return m_playbackModel ? m_playbackModel->audioMediaSelectionOptions() : Vector<String>(); 696 } 697 698 uint64_t WebVideoFullscreenControllerContext::audioMediaSelectedIndex() const 699 { 700 ASSERT(isUIThread()); 701 return m_playbackModel ? m_playbackModel->audioMediaSelectedIndex() : -1; 702 } 703 704 Vector<String> WebVideoFullscreenControllerContext::legibleMediaSelectionOptions() const 705 { 706 ASSERT(isUIThread()); 707 return m_playbackModel ? m_playbackModel->legibleMediaSelectionOptions() : Vector<String>(); 708 } 709 710 uint64_t WebVideoFullscreenControllerContext::legibleMediaSelectedIndex() const 711 { 712 ASSERT(isUIThread()); 713 return m_playbackModel ? m_playbackModel->legibleMediaSelectedIndex() : -1; 714 } 715 716 bool WebVideoFullscreenControllerContext::externalPlaybackEnabled() const 717 { 718 ASSERT(isUIThread()); 719 return m_playbackModel ? m_playbackModel->externalPlaybackEnabled() : false; 720 } 721 722 WebPlaybackSessionModel::ExternalPlaybackTargetType WebVideoFullscreenControllerContext::externalPlaybackTargetType() const 723 { 724 ASSERT(isUIThread()); 725 return m_playbackModel ? m_playbackModel->externalPlaybackTargetType() : TargetTypeNone; 726 } 727 728 String WebVideoFullscreenControllerContext::externalPlaybackLocalizedDeviceName() const 729 { 730 ASSERT(isUIThread()); 731 return m_playbackModel ? m_playbackModel->externalPlaybackLocalizedDeviceName() : String(); 732 } 733 734 bool WebVideoFullscreenControllerContext::wirelessVideoPlaybackDisabled() const 735 { 736 ASSERT(isUIThread()); 737 return m_playbackModel ? m_playbackModel->wirelessVideoPlaybackDisabled() : true; 635 738 } 636 739 … … 642 745 RetainPtr<UIView> viewRef = view; 643 746 m_videoElement = &videoElement; 644 645 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 646 dispatch_async(dispatch_get_main_queue(), [protectedThis, this, viewRef, mode] { 747 m_playbackModel = WebPlaybackSessionModelMediaElement::create(); 748 m_playbackModel->addClient(*this); 749 m_playbackModel->setMediaElement(m_videoElement.get()); 750 751 m_fullscreenModel = WebVideoFullscreenModelVideoElement::create(); 752 m_fullscreenModel->addClient(*this); 753 m_fullscreenModel->setVideoElement(m_videoElement.get()); 754 755 bool allowsPictureInPicture = m_videoElement->mediaSession().allowsPictureInPicture(*m_videoElement.get()); 756 757 IntRect videoElementClientRect = elementRectInWindow(m_videoElement.get()); 758 FloatRect videoLayerFrame = FloatRect(FloatPoint(), videoElementClientRect.size()); 759 m_fullscreenModel->setVideoLayerFrame(videoLayerFrame); 760 761 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 762 dispatch_async(dispatch_get_main_queue(), [protectedThis, this, videoElementClientRect, viewRef, mode, allowsPictureInPicture] { 647 763 ASSERT(isUIThread()); 648 764 649 Ref<WebPlaybackSessionInterfaceAVKit> sessionInterface = WebPlaybackSessionInterfaceAVKit::create( );765 Ref<WebPlaybackSessionInterfaceAVKit> sessionInterface = WebPlaybackSessionInterfaceAVKit::create(*this); 650 766 m_interface = WebVideoFullscreenInterfaceAVKit::create(sessionInterface.get()); 651 652 m_sessionModel = WebVideoFullscreenSessionModel::create(*this); 653 sessionInterface->setWebPlaybackSessionModel(m_sessionModel.get()); 654 767 m_interface->setWebVideoFullscreenChangeObserver(this); 655 768 m_interface->setWebVideoFullscreenModel(this); 656 769 m_interface->setWebVideoFullscreenChangeObserver(this); … … 658 771 m_videoFullscreenView = adoptNS([[getUIViewClass() alloc] init]); 659 772 660 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 661 WebThreadRun([protectedThis, this, viewRef, mode] { 662 m_model = WebVideoFullscreenModelVideoElement::create(WebPlaybackSessionModelMediaElement::create().get()); 663 m_model->setWebVideoFullscreenInterface(this); 664 m_model->playbackSessionModel().setMediaElement(m_videoElement.get()); 665 m_model->setVideoElement(m_videoElement.get()); 666 667 IntRect videoElementClientRect = elementRectInWindow(m_videoElement.get()); 668 FloatRect videoLayerFrame = FloatRect(FloatPoint(), videoElementClientRect.size()); 669 m_model->setVideoLayerFrame(videoLayerFrame); 670 671 bool allowsPictureInPicture = m_videoElement->mediaSession().allowsPictureInPicture(*m_videoElement.get()); 672 dispatch_async(dispatch_get_main_queue(), [protectedThis, this, videoElementClientRect, viewRef, mode, allowsPictureInPicture] { 673 m_interface->setupFullscreen(*m_videoFullscreenView.get(), videoElementClientRect, viewRef.get(), mode, allowsPictureInPicture); 674 }); 675 }); 773 m_interface->setupFullscreen(*m_videoFullscreenView.get(), videoElementClientRect, viewRef.get(), mode, allowsPictureInPicture); 676 774 }); 677 775 } … … 693 791 m_interface->requestHideAndExitFullscreen(); 694 792 } 695 696 #pragma mark WebPlaybackSessionModel697 698 void WebVideoFullscreenSessionModel::play()699 {700 if (m_controller)701 m_controller->play();702 }703 704 void WebVideoFullscreenSessionModel::pause()705 {706 if (m_controller)707 m_controller->pause();708 }709 710 void WebVideoFullscreenSessionModel::togglePlayState()711 {712 if (m_controller)713 m_controller->togglePlayState();714 }715 716 void WebVideoFullscreenSessionModel::beginScrubbing()717 {718 if (m_controller)719 m_controller->beginScrubbing();720 }721 722 void WebVideoFullscreenSessionModel::endScrubbing()723 {724 if (m_controller)725 m_controller->endScrubbing();726 }727 728 void WebVideoFullscreenSessionModel::seekToTime(double time)729 {730 if (m_controller)731 m_controller->seekToTime(time);732 }733 734 void WebVideoFullscreenSessionModel::fastSeek(double time)735 {736 if (m_controller)737 m_controller->fastSeek(time);738 }739 740 void WebVideoFullscreenSessionModel::beginScanningForward()741 {742 if (m_controller)743 m_controller->beginScanningForward();744 }745 746 void WebVideoFullscreenSessionModel::beginScanningBackward()747 {748 if (m_controller)749 m_controller->beginScanningBackward();750 }751 752 void WebVideoFullscreenSessionModel::endScanning()753 {754 if (m_controller)755 m_controller->endScanning();756 }757 758 void WebVideoFullscreenSessionModel::selectAudioMediaOption(uint64_t optionId)759 {760 if (m_controller)761 m_controller->selectAudioMediaOption(optionId);762 }763 764 void WebVideoFullscreenSessionModel::selectLegibleMediaOption(uint64_t optionId)765 {766 if (m_controller)767 m_controller->selectLegibleMediaOption(optionId);768 }769 770 793 771 794 @implementation WebVideoFullscreenController { -
trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.h
r200490 r205365 36 36 #include "WebPlaybackSessionInterfaceAVKit.h" 37 37 #include "WebVideoFullscreenInterface.h" 38 #include "WebVideoFullscreenModel.h" 38 39 #include <functional> 39 40 #include <objc/objc.h> … … 58 59 namespace WebCore { 59 60 class IntRect; 61 class FloatSize; 60 62 class WebVideoFullscreenModel; 61 63 class WebVideoFullscreenChangeObserver; … … 63 65 class WEBCORE_EXPORT WebVideoFullscreenInterfaceAVKit final 64 66 : public WebVideoFullscreenInterface 65 , public WebPlaybackSessionInterfaceAVKitClient 67 , public WebVideoFullscreenModelClient 68 , public WebPlaybackSessionModelClient 66 69 , public RefCounted<WebVideoFullscreenInterfaceAVKit> { 67 70 … … 73 76 WebPlaybackSessionModel* webPlaybackSessionModel() const { return m_playbackSessionInterface->webPlaybackSessionModel(); } 74 77 75 WEBCORE_EXPORT void resetMediaState() final; 76 WEBCORE_EXPORT void setDuration(double) final; 77 WEBCORE_EXPORT void setCurrentTime(double currentTime, double anchorTime) final; 78 WEBCORE_EXPORT void setBufferedTime(double) final; 79 WEBCORE_EXPORT void setRate(bool isPlaying, float playbackRate) final; 80 WEBCORE_EXPORT void setVideoDimensions(bool hasVideo, float width, float height) final; 81 WEBCORE_EXPORT void setSeekableRanges(const TimeRanges&) final; 82 WEBCORE_EXPORT void setCanPlayFastReverse(bool) final; 83 WEBCORE_EXPORT void setAudioMediaSelectionOptions(const Vector<WTF::String>& options, uint64_t selectedIndex) final; 84 WEBCORE_EXPORT void setLegibleMediaSelectionOptions(const Vector<WTF::String>& options, uint64_t selectedIndex) final; 85 WEBCORE_EXPORT void setExternalPlayback(bool enabled, ExternalPlaybackTargetType, WTF::String localizedDeviceName) final; 86 WEBCORE_EXPORT void setWirelessVideoPlaybackDisabled(bool) final; 78 // WebVideoFullscreenModelClient 79 WEBCORE_EXPORT void hasVideoChanged(bool) final; 80 WEBCORE_EXPORT void videoDimensionsChanged(const FloatSize&) final; 81 82 // WebPlaybackSessionModelClient 83 WEBCORE_EXPORT void externalPlaybackChanged(bool enabled, WebPlaybackSessionModel::ExternalPlaybackTargetType, const String& localizedDeviceName) final; 84 87 85 WEBCORE_EXPORT virtual void setupFullscreen(UIView&, const IntRect& initialRect, UIView *, HTMLMediaElementEnums::VideoFullscreenMode, bool allowsPictureInPicturePlayback); 88 86 WEBCORE_EXPORT virtual void enterFullscreen(); … … 128 126 void enterFullscreenStandard(); 129 127 void watchdogTimerFired(); 130 void externalPlaybackEnabledChanged(bool) final;131 128 WebAVPlayerController *playerController() const; 132 129 -
trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm
r204492 r205365 504 504 WebAVPlayerController* playerController = this->playerController(); 505 505 if (playerController && playerController.externalPlaybackActive) 506 setExternalPlayback(false, TargetTypeNone, ""); 506 externalPlaybackChanged(false, WebPlaybackSessionModel::TargetTypeNone, ""); 507 if (m_videoFullscreenModel) 508 m_videoFullscreenModel->removeClient(*this); 507 509 } 508 510 … … 512 514 } 513 515 514 void WebVideoFullscreenInterfaceAVKit::resetMediaState()515 {516 m_playbackSessionInterface->resetMediaState();517 }518 519 516 void WebVideoFullscreenInterfaceAVKit::setWebVideoFullscreenModel(WebVideoFullscreenModel* model) 520 517 { 518 if (m_videoFullscreenModel) 519 m_videoFullscreenModel->removeClient(*this); 520 521 521 m_videoFullscreenModel = model; 522 523 if (m_videoFullscreenModel) 524 m_videoFullscreenModel->addClient(*this); 525 526 hasVideoChanged(m_videoFullscreenModel ? m_videoFullscreenModel->hasVideo() : false); 527 videoDimensionsChanged(m_videoFullscreenModel ? m_videoFullscreenModel->videoDimensions() : FloatSize()); 522 528 } 523 529 … … 527 533 } 528 534 529 void WebVideoFullscreenInterfaceAVKit::setDuration(double duration) 530 { 531 m_playbackSessionInterface->setDuration(duration); 532 } 533 534 void WebVideoFullscreenInterfaceAVKit::setCurrentTime(double currentTime, double anchorTime) 535 { 536 m_playbackSessionInterface->setCurrentTime(currentTime, anchorTime); 537 } 538 539 void WebVideoFullscreenInterfaceAVKit::setBufferedTime(double bufferedTime) 540 { 541 m_playbackSessionInterface->setBufferedTime(bufferedTime); 542 } 543 544 void WebVideoFullscreenInterfaceAVKit::setRate(bool isPlaying, float playbackRate) 545 { 546 m_playbackSessionInterface->setRate(isPlaying, playbackRate); 547 } 548 549 void WebVideoFullscreenInterfaceAVKit::setVideoDimensions(bool hasVideo, float width, float height) 535 void WebVideoFullscreenInterfaceAVKit::hasVideoChanged(bool hasVideo) 536 { 537 [playerController() setHasEnabledVideo:hasVideo]; 538 } 539 540 void WebVideoFullscreenInterfaceAVKit::videoDimensionsChanged(const FloatSize& videoDimensions) 550 541 { 551 542 WebAVPlayerLayer *playerLayer = (WebAVPlayerLayer *)[m_playerLayerView playerLayer]; 552 543 553 [playerLayer setVideoDimensions:CGSizeMake(width, height)]; 554 [playerController() setHasEnabledVideo:hasVideo]; 555 [playerController() setContentDimensions:CGSizeMake(width, height)]; 544 [playerLayer setVideoDimensions:videoDimensions]; 545 [playerController() setContentDimensions:videoDimensions]; 556 546 [m_playerLayerView setNeedsLayout]; 557 547 … … 562 552 } 563 553 564 void WebVideoFullscreenInterfaceAVKit::setSeekableRanges(const TimeRanges& timeRanges) 565 { 566 m_playbackSessionInterface->setSeekableRanges(timeRanges); 567 } 568 569 void WebVideoFullscreenInterfaceAVKit::setCanPlayFastReverse(bool canPlayFastReverse) 570 { 571 m_playbackSessionInterface->setCanPlayFastReverse(canPlayFastReverse); 572 } 573 574 void WebVideoFullscreenInterfaceAVKit::setAudioMediaSelectionOptions(const Vector<String>& options, uint64_t selectedIndex) 575 { 576 m_playbackSessionInterface->setAudioMediaSelectionOptions(options, selectedIndex); 577 } 578 579 void WebVideoFullscreenInterfaceAVKit::setLegibleMediaSelectionOptions(const Vector<String>& options, uint64_t selectedIndex) 580 { 581 m_playbackSessionInterface->setLegibleMediaSelectionOptions(options, selectedIndex); 582 } 583 584 void WebVideoFullscreenInterfaceAVKit::setExternalPlayback(bool enabled, ExternalPlaybackTargetType targetType, String localizedDeviceName) 585 { 586 m_playbackSessionInterface->setExternalPlayback(enabled, targetType, localizedDeviceName); 587 } 588 589 void WebVideoFullscreenInterfaceAVKit::externalPlaybackEnabledChanged(bool enabled) 554 void WebVideoFullscreenInterfaceAVKit::externalPlaybackChanged(bool enabled, WebPlaybackSessionModel::ExternalPlaybackTargetType, const String&) 590 555 { 591 556 [m_playerLayerView setHidden:enabled]; 592 }593 594 void WebVideoFullscreenInterfaceAVKit::setWirelessVideoPlaybackDisabled(bool disabled)595 {596 m_playbackSessionInterface->setWirelessVideoPlaybackDisabled(disabled);597 }598 599 bool WebVideoFullscreenInterfaceAVKit::wirelessVideoPlaybackDisabled() const600 {601 return m_playbackSessionInterface->wirelessVideoPlaybackDisabled();602 557 } 603 558 -
trunk/Source/WebCore/platform/mac/WebPlaybackSessionInterfaceMac.h
r202908 r205365 31 31 #include "HTMLMediaElementEnums.h" 32 32 #include "WebPlaybackSessionInterface.h" 33 #include "WebPlaybackSessionModel.h" 33 34 #include <wtf/RefCounted.h> 34 35 #include <wtf/RetainPtr.h> … … 41 42 class WebPlaybackSessionModel; 42 43 43 class WebPlaybackSessionInterfaceMacClient {44 public:45 virtual ~WebPlaybackSessionInterfaceMacClient() { }46 47 virtual void rateChanged(bool isPlaying, float playbackRate) = 0;48 };49 50 44 class WEBCORE_EXPORT WebPlaybackSessionInterfaceMac final 51 45 : public WebPlaybackSessionInterface 46 , public WebPlaybackSessionModelClient 52 47 , public RefCounted<WebPlaybackSessionInterfaceMac> { 53 48 public: 54 static Ref<WebPlaybackSessionInterfaceMac> create() 55 { 56 return adoptRef(*new WebPlaybackSessionInterfaceMac()); 57 } 49 static Ref<WebPlaybackSessionInterfaceMac> create(WebPlaybackSessionModel&); 58 50 virtual ~WebPlaybackSessionInterfaceMac(); 59 51 WebPlaybackSessionModel* webPlaybackSessionModel() const { return m_playbackSessionModel; } 60 WEBCORE_EXPORT void setWebPlaybackSessionModel(WebPlaybackSessionModel*);61 WebPlaybackSessionInterfaceMacClient* client() const { return m_client; }62 void setClient(WebPlaybackSessionInterfaceMacClient*);63 52 53 // WebPlaybackSessionInterface 64 54 WEBCORE_EXPORT void resetMediaState() final { } 65 WEBCORE_EXPORT void setDuration(double) final; 66 WEBCORE_EXPORT void setCurrentTime(double /*currentTime*/, double /*anchorTime*/) final; 67 WEBCORE_EXPORT void setBufferedTime(double) final { } 68 WEBCORE_EXPORT void setRate(bool /*isPlaying*/, float /*playbackRate*/) final; 69 WEBCORE_EXPORT void setSeekableRanges(const TimeRanges&) final; 70 WEBCORE_EXPORT void setCanPlayFastReverse(bool) final { } 71 WEBCORE_EXPORT void setAudioMediaSelectionOptions(const Vector<String>& /*options*/, uint64_t /*selectedIndex*/) final; 72 WEBCORE_EXPORT void setLegibleMediaSelectionOptions(const Vector<String>& /*options*/, uint64_t /*selectedIndex*/) final; 73 WEBCORE_EXPORT void setExternalPlayback(bool, ExternalPlaybackTargetType, String) final { } 74 WEBCORE_EXPORT void setWirelessVideoPlaybackDisabled(bool) final { } 55 56 // WebPlaybackSessionModelClient 57 WEBCORE_EXPORT void durationChanged(double) final; 58 WEBCORE_EXPORT void currentTimeChanged(double /*currentTime*/, double /*anchorTime*/) final; 59 WEBCORE_EXPORT void rateChanged(bool /*isPlaying*/, float /*playbackRate*/) final; 60 WEBCORE_EXPORT void seekableRangesChanged(const TimeRanges&) final; 61 WEBCORE_EXPORT void audioMediaSelectionOptionsChanged(const Vector<String>& /*options*/, uint64_t /*selectedIndex*/) final; 62 WEBCORE_EXPORT void legibleMediaSelectionOptionsChanged(const Vector<String>& /*options*/, uint64_t /*selectedIndex*/) final; 75 63 WEBCORE_EXPORT void invalidate(); 76 64 WEBCORE_EXPORT void ensureControlsManager(); … … 79 67 80 68 private: 69 WebPlaybackSessionInterfaceMac(WebPlaybackSessionModel&); 81 70 WebPlaybackSessionModel* m_playbackSessionModel { nullptr }; 82 WebPlaybackControlsManager *m_playbackControlsManager; 83 WebPlaybackSessionInterfaceMacClient* m_client { nullptr }; 71 WebPlaybackControlsManager *m_playbackControlsManager { nullptr }; 84 72 }; 85 73 -
trunk/Source/WebCore/platform/mac/WebPlaybackSessionInterfaceMac.mm
r202908 r205365 46 46 namespace WebCore { 47 47 48 WebPlaybackSessionInterfaceMac::~WebPlaybackSessionInterfaceMac() 48 Ref<WebPlaybackSessionInterfaceMac> WebPlaybackSessionInterfaceMac::create(WebPlaybackSessionModel& model) 49 { 50 auto interface = adoptRef(*new WebPlaybackSessionInterfaceMac(model)); 51 model.addClient(interface); 52 return interface; 53 } 54 55 WebPlaybackSessionInterfaceMac::WebPlaybackSessionInterfaceMac(WebPlaybackSessionModel& model) 56 : m_playbackSessionModel(&model) 49 57 { 50 58 } 51 59 52 void WebPlaybackSessionInterfaceMac::setWebPlaybackSessionModel(WebPlaybackSessionModel* model)60 WebPlaybackSessionInterfaceMac::~WebPlaybackSessionInterfaceMac() 53 61 { 54 m_playbackSessionModel = model;62 invalidate(); 55 63 } 56 64 57 void WebPlaybackSessionInterfaceMac::setClient(WebPlaybackSessionInterfaceMacClient* client) 58 { 59 m_client = client; 60 61 if (m_client && m_playbackSessionModel) 62 m_client->rateChanged(m_playbackSessionModel->isPlaying(), m_playbackSessionModel->playbackRate()); 63 } 64 65 void WebPlaybackSessionInterfaceMac::setDuration(double duration) 65 void WebPlaybackSessionInterfaceMac::durationChanged(double duration) 66 66 { 67 67 WebPlaybackControlsManager* controlsManager = playBackControlsManager(); … … 74 74 } 75 75 76 void WebPlaybackSessionInterfaceMac:: setCurrentTime(double currentTime, double anchorTime)76 void WebPlaybackSessionInterfaceMac::currentTimeChanged(double currentTime, double anchorTime) 77 77 { 78 78 WebPlaybackControlsManager* controlsManager = playBackControlsManager(); … … 85 85 } 86 86 87 void WebPlaybackSessionInterfaceMac:: setRate(bool isPlaying, float playbackRate)87 void WebPlaybackSessionInterfaceMac::rateChanged(bool isPlaying, float playbackRate) 88 88 { 89 89 WebPlaybackControlsManager* controlsManager = playBackControlsManager(); 90 90 [controlsManager setRate:isPlaying ? playbackRate : 0.]; 91 91 [controlsManager setPlaying:isPlaying]; 92 93 if (m_client)94 m_client->rateChanged(isPlaying, playbackRate);95 92 } 96 93 … … 108 105 } 109 106 110 void WebPlaybackSessionInterfaceMac::se tSeekableRanges(const TimeRanges& timeRanges)107 void WebPlaybackSessionInterfaceMac::seekableRangesChanged(const TimeRanges& timeRanges) 111 108 { 112 WebPlaybackControlsManager* controlsManager = playBackControlsManager(); 113 [controlsManager setSeekableTimeRanges:timeRangesToArray(timeRanges).get()]; 109 [playBackControlsManager() setSeekableTimeRanges:timeRangesToArray(timeRanges).get()]; 114 110 } 115 111 116 void WebPlaybackSessionInterfaceMac:: setAudioMediaSelectionOptions(const Vector<WTF::String>& options, uint64_t selectedIndex)112 void WebPlaybackSessionInterfaceMac::audioMediaSelectionOptionsChanged(const Vector<WTF::String>& options, uint64_t selectedIndex) 117 113 { 118 WebPlaybackControlsManager* controlsManager = playBackControlsManager(); 119 [controlsManager setAudioMediaSelectionOptions:options withSelectedIndex:static_cast<NSUInteger>(selectedIndex)]; 114 [playBackControlsManager() setAudioMediaSelectionOptions:options withSelectedIndex:static_cast<NSUInteger>(selectedIndex)]; 120 115 } 121 116 122 void WebPlaybackSessionInterfaceMac:: setLegibleMediaSelectionOptions(const Vector<WTF::String>& options, uint64_t selectedIndex)117 void WebPlaybackSessionInterfaceMac::legibleMediaSelectionOptionsChanged(const Vector<WTF::String>& options, uint64_t selectedIndex) 123 118 { 124 WebPlaybackControlsManager* controlsManager = playBackControlsManager(); 125 [controlsManager setLegibleMediaSelectionOptions:options withSelectedIndex:static_cast<NSUInteger>(selectedIndex)]; 119 [playBackControlsManager() setLegibleMediaSelectionOptions:options withSelectedIndex:static_cast<NSUInteger>(selectedIndex)]; 126 120 } 127 121 128 122 void WebPlaybackSessionInterfaceMac::invalidate() 129 123 { 124 if (!m_playbackSessionModel) 125 return; 126 127 m_playbackSessionModel->removeClient(*this); 128 m_playbackSessionModel = nullptr; 130 129 } 131 130 -
trunk/Source/WebCore/platform/mac/WebVideoFullscreenInterfaceMac.h
r202274 r205365 31 31 #include "HTMLMediaElementEnums.h" 32 32 #include "WebPlaybackSessionInterfaceMac.h" 33 #include "WebPlaybackSessionModel.h" 33 34 #include "WebVideoFullscreenInterface.h" 35 #include "WebVideoFullscreenModel.h" 34 36 #include <wtf/RefCounted.h> 35 37 #include <wtf/RetainPtr.h> … … 41 43 namespace WebCore { 42 44 class IntRect; 45 class FloatSize; 43 46 class WebPlaybackSessionInterfaceMac; 44 47 class WebVideoFullscreenChangeObserver; 45 class WebVideoFullscreenModel;46 48 47 49 class WEBCORE_EXPORT WebVideoFullscreenInterfaceMac 48 50 : public WebVideoFullscreenInterface 49 , private WebPlaybackSessionInterfaceMacClient 51 , public WebVideoFullscreenModelClient 52 , private WebPlaybackSessionModelClient 50 53 , public RefCounted<WebVideoFullscreenInterfaceMac> { 51 54 … … 62 65 WEBCORE_EXPORT void setWebVideoFullscreenChangeObserver(WebVideoFullscreenChangeObserver*); 63 66 64 WEBCORE_EXPORT void resetMediaState() override { } 65 WEBCORE_EXPORT void setDuration(double) override; 66 WEBCORE_EXPORT void setCurrentTime(double /*currentTime*/, double /*anchorTime*/) override; 67 WEBCORE_EXPORT void setBufferedTime(double) override { } 68 WEBCORE_EXPORT void setRate(bool /*isPlaying*/, float /*playbackRate*/) override; 69 WEBCORE_EXPORT void setVideoDimensions(bool hasVideo, float width, float height) final; 70 WEBCORE_EXPORT void setSeekableRanges(const TimeRanges&) override; 71 WEBCORE_EXPORT void setCanPlayFastReverse(bool) override { } 72 WEBCORE_EXPORT void setAudioMediaSelectionOptions(const Vector<String>& /*options*/, uint64_t /*selectedIndex*/) override; 73 WEBCORE_EXPORT void setLegibleMediaSelectionOptions(const Vector<String>& /*options*/, uint64_t /*selectedIndex*/) override; 74 WEBCORE_EXPORT void setExternalPlayback(bool enabled, ExternalPlaybackTargetType, String localizedDeviceName) override; 75 WEBCORE_EXPORT void setWirelessVideoPlaybackDisabled(bool) override { } 67 // WebPlaybackSessionModelClient 68 WEBCORE_EXPORT void rateChanged(bool isPlaying, float playbackRate) override; 69 WEBCORE_EXPORT void externalPlaybackChanged(bool enabled, WebPlaybackSessionModel::ExternalPlaybackTargetType, const String& localizedDeviceName) override; 70 71 // WebVideoFullscreenModelClient 72 WEBCORE_EXPORT void hasVideoChanged(bool) final; 73 WEBCORE_EXPORT void videoDimensionsChanged(const FloatSize&) final; 76 74 77 75 WEBCORE_EXPORT void setupFullscreen(NSView& layerHostedView, const IntRect& initialRect, NSWindow *parentWindow, HTMLMediaElementEnums::VideoFullscreenMode, bool allowsPictureInPicturePlayback); … … 96 94 void applicationDidBecomeActive() { } 97 95 98 void rateChanged(bool isPlaying, float playbackRate) override;99 100 96 WEBCORE_EXPORT WebVideoFullscreenInterfaceMacObjC *videoFullscreenInterfaceObjC(); 101 97 -
trunk/Source/WebCore/platform/mac/WebVideoFullscreenInterfaceMac.mm
r204088 r205365 352 352 : m_playbackSessionInterface(playbackSessionInterface) 353 353 { 354 m_playbackSessionInterface->setClient(this); 354 ASSERT(m_playbackSessionInterface->webPlaybackSessionModel()); 355 m_playbackSessionInterface->webPlaybackSessionModel()->addClient(*this); 355 356 } 356 357 357 358 WebVideoFullscreenInterfaceMac::~WebVideoFullscreenInterfaceMac() 358 359 { 359 if (m_playbackSessionInterface->client() == this) 360 m_playbackSessionInterface->setClient(nullptr); 360 if (m_playbackSessionInterface->webPlaybackSessionModel()) 361 m_playbackSessionInterface->webPlaybackSessionModel()->removeClient(*this); 362 if (m_videoFullscreenModel) 363 m_videoFullscreenModel->removeClient(*this); 361 364 } 362 365 363 366 void WebVideoFullscreenInterfaceMac::setWebVideoFullscreenModel(WebVideoFullscreenModel* model) 364 367 { 368 if (m_videoFullscreenModel) 369 m_videoFullscreenModel->removeClient(*this); 365 370 m_videoFullscreenModel = model; 371 if (m_videoFullscreenModel) 372 m_videoFullscreenModel->addClient(*this); 366 373 } 367 374 … … 393 400 } 394 401 395 void WebVideoFullscreenInterfaceMac::setDuration(double duration)396 {397 m_playbackSessionInterface->setDuration(duration);398 }399 400 void WebVideoFullscreenInterfaceMac::setCurrentTime(double currentTime, double anchorTime)401 {402 m_playbackSessionInterface->setCurrentTime(currentTime, anchorTime);403 }404 405 void WebVideoFullscreenInterfaceMac::setRate(bool isPlaying, float playbackRate)406 {407 m_playbackSessionInterface->setRate(isPlaying, playbackRate);408 }409 410 402 void WebVideoFullscreenInterfaceMac::rateChanged(bool isPlaying, float playbackRate) 411 403 { 412 404 [videoFullscreenInterfaceObjC() updateIsPlaying:isPlaying newPlaybackRate:playbackRate]; 413 }414 415 void WebVideoFullscreenInterfaceMac::setSeekableRanges(const TimeRanges& timeRanges)416 {417 m_playbackSessionInterface->setSeekableRanges(timeRanges);418 }419 420 void WebVideoFullscreenInterfaceMac::setAudioMediaSelectionOptions(const Vector<WTF::String>& options, uint64_t selectedIndex)421 {422 m_playbackSessionInterface->setAudioMediaSelectionOptions(options, selectedIndex);423 }424 425 void WebVideoFullscreenInterfaceMac::setLegibleMediaSelectionOptions(const Vector<WTF::String>& options, uint64_t selectedIndex)426 {427 m_playbackSessionInterface->setLegibleMediaSelectionOptions(options, selectedIndex);428 405 } 429 406 … … 546 523 } 547 524 548 void WebVideoFullscreenInterfaceMac:: setExternalPlayback(bool enabled, ExternalPlaybackTargetType, String)549 { 550 LOG(Fullscreen, "WebVideoFullscreenInterfaceMac:: setExternalPlayback(%p), enabled:%s", this, boolString(enabled));525 void WebVideoFullscreenInterfaceMac::externalPlaybackChanged(bool enabled, WebPlaybackSessionModel::ExternalPlaybackTargetType, const String&) 526 { 527 LOG(Fullscreen, "WebVideoFullscreenInterfaceMac::externalPlaybackChanged(%p), enabled:%s", this, boolString(enabled)); 551 528 552 529 if (enabled && m_mode == HTMLMediaElementEnums::VideoFullscreenModePictureInPicture) … … 554 531 } 555 532 556 void WebVideoFullscreenInterfaceMac:: setVideoDimensions(bool hasVideo, float width, float height)557 { 558 LOG(Fullscreen, "WebVideoFullscreenInterfaceMac:: setVideoDimensions(%p), hasVideo:%s, width:%.0f, height:%.0f", this, boolString(hasVideo), width, height);559 560 if (!hasVideo) {533 void WebVideoFullscreenInterfaceMac::hasVideoChanged(bool hasVideo) 534 { 535 LOG(Fullscreen, "WebVideoFullscreenInterfaceMac::hasVideoChanged(%p):%s", this, boolString(hasVideo)); 536 537 if (!hasVideo) 561 538 exitFullscreenWithoutAnimationToMode(HTMLMediaElementEnums::VideoFullscreenModeNone); 562 return; 563 } 539 } 540 541 void WebVideoFullscreenInterfaceMac::videoDimensionsChanged(const FloatSize& videoDimensions) 542 { 543 LOG(Fullscreen, "WebVideoFullscreenInterfaceMac::videoDimensionsChanged(%p), width:%.0f, height:%.0f", this, videoDimensions.width(), videoDimensions.height()); 564 544 565 545 // Width and height can be zero when we are transitioning from one video to another. Ignore zero values. 566 if ( width && height)567 [m_webVideoFullscreenInterfaceObjC setVideoDimensions: NSMakeSize(width, height)];546 if (!videoDimensions.isZero()) 547 [m_webVideoFullscreenInterfaceObjC setVideoDimensions:videoDimensions]; 568 548 } 569 549 -
trunk/Source/WebKit/mac/ChangeLog
r205333 r205365 1 2016-07-08 Jer Noble <jer.noble@apple.com> 2 3 Refactor WebPlaybackSessionModelMediaElement to be client based. 4 https://bugs.webkit.org/show_bug.cgi?id=159580 5 6 Reviewed by Eric Carlson. 7 8 No longer necessary to tell the models and interfaces about each other. 9 10 * WebView/WebView.mm: 11 (-[WebView _setUpPlaybackControlsManagerForMediaElement:]): 12 (-[WebView _clearPlaybackControlsManager]): 13 1 14 2016-09-01 Dan Bernstein <mitz@apple.com> 2 15 -
trunk/Source/WebKit/mac/WebView/WebView.mm
r205282 r205365 8637 8637 8638 8638 if (!_private->playbackSessionInterface) 8639 _private->playbackSessionInterface = WebPlaybackSessionInterfaceMac::create(); 8640 8641 _private->playbackSessionInterface->setWebPlaybackSessionModel(_private->playbackSessionModel.get()); 8642 _private->playbackSessionModel->setWebPlaybackSessionInterface(_private->playbackSessionInterface.get()); 8639 _private->playbackSessionInterface = WebPlaybackSessionInterfaceMac::create(*_private->playbackSessionModel); 8640 8643 8641 [self updateWebViewAdditions]; 8644 8642 } … … 8650 8648 8651 8649 _private->playbackSessionModel->setMediaElement(nullptr); 8652 _private->playbackSessionModel->setWebPlaybackSessionInterface(nullptr); 8653 _private->playbackSessionInterface->setWebPlaybackSessionModel(nullptr); 8650 _private->playbackSessionInterface->invalidate(); 8654 8651 8655 8652 _private->playbackSessionModel = nullptr; -
trunk/Source/WebKit2/ChangeLog
r205342 r205365 1 2016-07-08 Jer Noble <jer.noble@apple.com> 2 3 Refactor WebPlaybackSessionModelMediaElement to be client based. 4 https://bugs.webkit.org/show_bug.cgi?id=159580 5 6 Reviewed by Eric Carlson. 7 8 Adopt the changes made in the WebPlaybackSessionModel,Interface and WebVideoFullscreenModel,Interface 9 in the WebPlaybackSessionManager,Proxy classes. 10 11 * UIProcess/API/Cocoa/WKWebView.mm: 12 (-[WKWebView _initializeWithConfiguration:]): Deleted. 13 * UIProcess/Cocoa/WebPlaybackSessionManagerProxy.h: 14 * UIProcess/Cocoa/WebPlaybackSessionManagerProxy.mm: 15 (WebKit::WebPlaybackSessionModelContext::addClient): 16 (WebKit::WebPlaybackSessionModelContext::removeClient): 17 (WebKit::WebPlaybackSessionModelContext::setDuration): 18 (WebKit::WebPlaybackSessionModelContext::setCurrentTime): 19 (WebKit::WebPlaybackSessionModelContext::setBufferedTime): 20 (WebKit::WebPlaybackSessionModelContext::setRate): 21 (WebKit::WebPlaybackSessionModelContext::setSeekableRanges): 22 (WebKit::WebPlaybackSessionModelContext::setCanPlayFastReverse): 23 (WebKit::WebPlaybackSessionModelContext::setAudioMediaSelectionOptions): 24 (WebKit::WebPlaybackSessionModelContext::setLegibleMediaSelectionOptions): 25 (WebKit::WebPlaybackSessionModelContext::setExternalPlayback): 26 (WebKit::WebPlaybackSessionModelContext::setWirelessVideoPlaybackDisabled): 27 (WebKit::WebPlaybackSessionManagerProxy::createModelAndInterface): 28 (WebKit::WebPlaybackSessionManagerProxy::removeClientForContext): 29 (WebKit::WebPlaybackSessionManagerProxy::setCurrentTime): 30 (WebKit::WebPlaybackSessionManagerProxy::setBufferedTime): 31 (WebKit::WebPlaybackSessionManagerProxy::setSeekableRangesVector): 32 (WebKit::WebPlaybackSessionManagerProxy::setCanPlayFastReverse): 33 (WebKit::WebPlaybackSessionManagerProxy::setAudioMediaSelectionOptions): 34 (WebKit::WebPlaybackSessionManagerProxy::setLegibleMediaSelectionOptions): 35 (WebKit::WebPlaybackSessionManagerProxy::setExternalPlaybackProperties): 36 (WebKit::WebPlaybackSessionManagerProxy::setWirelessVideoPlaybackDisabled): 37 (WebKit::WebPlaybackSessionManagerProxy::setDuration): 38 (WebKit::WebPlaybackSessionManagerProxy::setRate): 39 * UIProcess/Cocoa/WebVideoFullscreenManagerProxy.h: 40 * UIProcess/Cocoa/WebVideoFullscreenManagerProxy.messages.in: 41 * UIProcess/Cocoa/WebVideoFullscreenManagerProxy.mm: 42 (WebKit::WebVideoFullscreenModelContext::addClient): 43 (WebKit::WebVideoFullscreenModelContext::removeClient): 44 (WebKit::WebVideoFullscreenManagerProxy::setHasVideo): 45 (WebKit::WebVideoFullscreenManagerProxy::setVideoDimensions): 46 * WebProcess/cocoa/WebPlaybackSessionManager.h: 47 * WebProcess/cocoa/WebPlaybackSessionManager.mm: 48 (WebKit::WebPlaybackSessionInterfaceContext::durationChanged): 49 (WebKit::WebPlaybackSessionInterfaceContext::currentTimeChanged): 50 (WebKit::WebPlaybackSessionInterfaceContext::bufferedTimeChanged): 51 (WebKit::WebPlaybackSessionInterfaceContext::rateChanged): 52 (WebKit::WebPlaybackSessionInterfaceContext::seekableRangesChanged): 53 (WebKit::WebPlaybackSessionInterfaceContext::canPlayFastReverseChanged): 54 (WebKit::WebPlaybackSessionInterfaceContext::audioMediaSelectionOptionsChanged): 55 (WebKit::WebPlaybackSessionInterfaceContext::legibleMediaSelectionOptionsChanged): 56 (WebKit::WebPlaybackSessionInterfaceContext::externalPlaybackChanged): 57 (WebKit::WebPlaybackSessionInterfaceContext::wirelessVideoPlaybackDisabledChanged): 58 (WebKit::WebPlaybackSessionManager::~WebPlaybackSessionManager): 59 (WebKit::WebPlaybackSessionManager::createModelAndInterface): 60 (WebKit::WebPlaybackSessionManager::removeContext): 61 (WebKit::WebPlaybackSessionManager::durationChanged): 62 (WebKit::WebPlaybackSessionManager::currentTimeChanged): 63 (WebKit::WebPlaybackSessionManager::bufferedTimeChanged): 64 (WebKit::WebPlaybackSessionManager::rateChanged): 65 (WebKit::WebPlaybackSessionManager::seekableRangesChanged): 66 (WebKit::WebPlaybackSessionManager::canPlayFastReverseChanged): 67 (WebKit::WebPlaybackSessionManager::audioMediaSelectionOptionsChanged): 68 (WebKit::WebPlaybackSessionManager::legibleMediaSelectionOptionsChanged): 69 (WebKit::WebPlaybackSessionManager::externalPlaybackChanged): 70 (WebKit::WebPlaybackSessionManager::wirelessVideoPlaybackDisabledChanged): 71 (WebKit::WebPlaybackSessionInterfaceContext::setDuration): Deleted. 72 (WebKit::WebPlaybackSessionInterfaceContext::setCurrentTime): Deleted. 73 (WebKit::WebPlaybackSessionInterfaceContext::setBufferedTime): Deleted. 74 (WebKit::WebPlaybackSessionInterfaceContext::setRate): Deleted. 75 (WebKit::WebPlaybackSessionInterfaceContext::setSeekableRanges): Deleted. 76 (WebKit::WebPlaybackSessionInterfaceContext::setCanPlayFastReverse): Deleted. 77 (WebKit::WebPlaybackSessionInterfaceContext::setAudioMediaSelectionOptions): Deleted. 78 (WebKit::WebPlaybackSessionInterfaceContext::setLegibleMediaSelectionOptions): Deleted. 79 (WebKit::WebPlaybackSessionInterfaceContext::setExternalPlayback): Deleted. 80 (WebKit::WebPlaybackSessionInterfaceContext::setWirelessVideoPlaybackDisabled): Deleted. 81 (WebKit::WebPlaybackSessionManager::setDuration): Deleted. 82 (WebKit::WebPlaybackSessionManager::setCurrentTime): Deleted. 83 (WebKit::WebPlaybackSessionManager::setBufferedTime): Deleted. 84 (WebKit::WebPlaybackSessionManager::setRate): Deleted. 85 (WebKit::WebPlaybackSessionManager::setSeekableRanges): Deleted. 86 (WebKit::WebPlaybackSessionManager::setCanPlayFastReverse): Deleted. 87 (WebKit::WebPlaybackSessionManager::setAudioMediaSelectionOptions): Deleted. 88 (WebKit::WebPlaybackSessionManager::setLegibleMediaSelectionOptions): Deleted. 89 (WebKit::WebPlaybackSessionManager::setExternalPlayback): Deleted. 90 (WebKit::WebPlaybackSessionManager::setWirelessVideoPlaybackDisabled): Deleted. 91 * WebProcess/cocoa/WebVideoFullscreenManager.h: 92 (WebKit::WebVideoFullscreenInterfaceContext::create): 93 * WebProcess/cocoa/WebVideoFullscreenManager.mm: 94 (WebKit::WebVideoFullscreenInterfaceContext::WebVideoFullscreenInterfaceContext): 95 (WebKit::WebVideoFullscreenInterfaceContext::hasVideoChanged): 96 (WebKit::WebVideoFullscreenInterfaceContext::videoDimensionsChanged): 97 (WebKit::WebVideoFullscreenManager::~WebVideoFullscreenManager): 98 (WebKit::WebVideoFullscreenManager::createModelAndInterface): 99 (WebKit::WebVideoFullscreenManager::removeContext): 100 (WebKit::WebVideoFullscreenManager::hasVideoChanged): 101 (WebKit::WebVideoFullscreenManager::videoDimensionsChanged): 102 (WebKit::WebVideoFullscreenInterfaceContext::resetMediaState): Deleted. 103 (WebKit::WebVideoFullscreenInterfaceContext::setDuration): Deleted. 104 (WebKit::WebVideoFullscreenInterfaceContext::setCurrentTime): Deleted. 105 (WebKit::WebVideoFullscreenInterfaceContext::setBufferedTime): Deleted. 106 (WebKit::WebVideoFullscreenInterfaceContext::setRate): Deleted. 107 (WebKit::WebVideoFullscreenInterfaceContext::setVideoDimensions): Deleted. 108 (WebKit::WebVideoFullscreenInterfaceContext::setSeekableRanges): Deleted. 109 (WebKit::WebVideoFullscreenInterfaceContext::setCanPlayFastReverse): Deleted. 110 (WebKit::WebVideoFullscreenInterfaceContext::setAudioMediaSelectionOptions): Deleted. 111 (WebKit::WebVideoFullscreenInterfaceContext::setLegibleMediaSelectionOptions): Deleted. 112 (WebKit::WebVideoFullscreenInterfaceContext::setExternalPlayback): Deleted. 113 (WebKit::WebVideoFullscreenInterfaceContext::setWirelessVideoPlaybackDisabled): Deleted. 114 (WebKit::WebVideoFullscreenManager::setVideoDimensions): Deleted. 115 1 116 2016-09-02 Zan Dobersek <zdobersek@igalia.com> 2 117 -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
r204728 r205365 545 545 546 546 _navigationState = std::make_unique<WebKit::NavigationState>(self); 547 _page->setNavigationClient(_navigationState->createNavigationClient());548 549 547 _uiDelegate = std::make_unique<WebKit::UIDelegate>(self); 550 548 _page->setFindClient(std::make_unique<WebKit::FindClient>(self)); -
trunk/Source/WebKit2/UIProcess/Cocoa/WebPlaybackSessionManagerProxy.h
r204668 r205365 34 34 #include <WebCore/WebPlaybackSessionModel.h> 35 35 #include <wtf/HashMap.h> 36 #include <wtf/HashSet.h> 36 37 #include <wtf/RefCounted.h> 37 38 #include <wtf/RefPtr.h> … … 64 65 void invalidate() { m_manager = nullptr; } 65 66 66 void setDuration(double duration) { m_duration = duration; } 67 void setCurrentTime(double currentTime) { m_currentTime = currentTime; } 68 void setBufferedTime(double bufferedTime) { m_bufferedTime = bufferedTime; } 69 void setIsPlaying(bool isPlaying) { m_isPlaying = isPlaying; } 70 void setPlaybackRate(float playbackRate) { m_playbackRate = playbackRate; } 71 void setSeekableRanges(WebCore::TimeRanges& seekableRanges) { m_seekableRanges = seekableRanges; } 72 void setCanPlayFastReverse(bool canPlayFastReverse) { m_canPlayFastReverse = canPlayFastReverse; } 73 void setAudioMediaSelectionOptions(const Vector<WTF::String>& audioMediaSelectionOptions) { m_audioMediaSelectionOptions = audioMediaSelectionOptions; } 74 void setAudioMediaSelectedIndex(uint64_t audioMediaSelectedIndex) { m_audioMediaSelectedIndex = audioMediaSelectedIndex; } 75 void setLegibleMediaSelectionOptions(const Vector<WTF::String>& legibleMediaSelectionOptions) { m_legibleMediaSelectionOptions = legibleMediaSelectionOptions; } 76 void setLegibleMediaSelectedIndex(uint64_t legibleMediaSelectedIndex) { m_legibleMediaSelectedIndex = legibleMediaSelectedIndex; } 77 void setExternalPlaybackEnabled(bool externalPlaybackEnabled) { m_externalPlaybackEnabled = externalPlaybackEnabled; } 78 void setWirelessVideoPlaybackDisabled(bool wirelessVideoPlaybackDisabled) { m_wirelessVideoPlaybackDisabled = wirelessVideoPlaybackDisabled; } 67 // WebPlaybackSessionModel 68 void addClient(WebCore::WebPlaybackSessionModelClient&) final; 69 void removeClient(WebCore::WebPlaybackSessionModelClient&)final; 70 71 void setDuration(double); 72 void setCurrentTime(double); 73 void setBufferedTime(double); 74 void setRate(bool isPlaying, float playbackRate); 75 void setSeekableRanges(WebCore::TimeRanges&); 76 void setCanPlayFastReverse(bool); 77 void setAudioMediaSelectionOptions(const Vector<WTF::String>& options, uint64_t index); 78 void setLegibleMediaSelectionOptions(const Vector<WTF::String>& options, uint64_t index); 79 void setExternalPlayback(bool, WebPlaybackSessionModel::ExternalPlaybackTargetType, const String&); 80 void setWirelessVideoPlaybackDisabled(bool); 79 81 80 82 private: … … 113 115 uint64_t legibleMediaSelectedIndex() const final { return m_legibleMediaSelectedIndex; } 114 116 bool externalPlaybackEnabled() const final { return m_externalPlaybackEnabled; } 117 WebPlaybackSessionModel::ExternalPlaybackTargetType externalPlaybackTargetType() const final { return m_externalPlaybackTargetType; } 118 String externalPlaybackLocalizedDeviceName() const final { return m_externalPlaybackLocalizedDeviceName; } 115 119 bool wirelessVideoPlaybackDisabled() const final { return m_wirelessVideoPlaybackDisabled; } 116 120 117 121 WebPlaybackSessionManagerProxy* m_manager; 118 122 uint64_t m_contextId; 123 HashSet<WebCore::WebPlaybackSessionModelClient*> m_clients; 119 124 double m_duration { 0 }; 120 125 double m_currentTime { 0 }; … … 129 134 uint64_t m_legibleMediaSelectedIndex { 0 }; 130 135 bool m_externalPlaybackEnabled { false }; 136 WebPlaybackSessionModel::ExternalPlaybackTargetType m_externalPlaybackTargetType { WebPlaybackSessionModel::TargetTypeNone }; 137 String m_externalPlaybackLocalizedDeviceName; 131 138 bool m_wirelessVideoPlaybackDisabled { false }; 132 139 }; -
trunk/Source/WebKit2/UIProcess/Cocoa/WebPlaybackSessionManagerProxy.mm
r200490 r205365 41 41 #pragma mark - WebPlaybackSessionModelContext 42 42 43 void WebPlaybackSessionModelContext::addClient(WebPlaybackSessionModelClient& client) 44 { 45 ASSERT(!m_clients.contains(&client)); 46 m_clients.add(&client); 47 } 48 49 void WebPlaybackSessionModelContext::removeClient(WebPlaybackSessionModelClient& client) 50 { 51 ASSERT(m_clients.contains(&client)); 52 m_clients.remove(&client); 53 } 54 43 55 void WebPlaybackSessionModelContext::play() 44 56 { … … 111 123 if (m_manager) 112 124 m_manager->selectLegibleMediaOption(m_contextId, optionId); 125 } 126 127 void WebPlaybackSessionModelContext::setDuration(double duration) 128 { 129 m_duration = duration; 130 for (auto* client : m_clients) 131 client->durationChanged(duration); 132 } 133 134 void WebPlaybackSessionModelContext::setCurrentTime(double currentTime) 135 { 136 m_currentTime = currentTime; 137 auto anchorTime = [[NSProcessInfo processInfo] systemUptime]; 138 139 for (auto* client : m_clients) 140 client->currentTimeChanged(currentTime, anchorTime); 141 } 142 143 void WebPlaybackSessionModelContext::setBufferedTime(double bufferedTime) 144 { 145 m_bufferedTime = bufferedTime; 146 for (auto* client : m_clients) 147 client->bufferedTimeChanged(bufferedTime); 148 } 149 150 void WebPlaybackSessionModelContext::setRate(bool isPlaying, float playbackRate) 151 { 152 m_isPlaying = isPlaying; 153 m_playbackRate = playbackRate; 154 for (auto* client : m_clients) 155 client->rateChanged(isPlaying, playbackRate); 156 } 157 158 void WebPlaybackSessionModelContext::setSeekableRanges(WebCore::TimeRanges& seekableRanges) 159 { 160 m_seekableRanges = seekableRanges; 161 for (auto* client : m_clients) 162 client->seekableRangesChanged(seekableRanges); 163 } 164 165 void WebPlaybackSessionModelContext::setCanPlayFastReverse(bool canPlayFastReverse) 166 { 167 m_canPlayFastReverse = canPlayFastReverse; 168 for (auto* client : m_clients) 169 client->canPlayFastReverseChanged(canPlayFastReverse); 170 } 171 172 void WebPlaybackSessionModelContext::setAudioMediaSelectionOptions(const Vector<WTF::String>& audioMediaSelectionOptions, uint64_t audioMediaSelectedIndex) 173 { 174 m_audioMediaSelectionOptions = audioMediaSelectionOptions; 175 m_audioMediaSelectedIndex = audioMediaSelectedIndex; 176 for (auto* client : m_clients) 177 client->audioMediaSelectionOptionsChanged(audioMediaSelectionOptions, audioMediaSelectedIndex); 178 } 179 180 void WebPlaybackSessionModelContext::setLegibleMediaSelectionOptions(const Vector<WTF::String>& legibleMediaSelectionOptions, uint64_t legibleMediaSelectedIndex) 181 { 182 m_legibleMediaSelectionOptions = legibleMediaSelectionOptions; 183 m_legibleMediaSelectedIndex = legibleMediaSelectedIndex; 184 185 for (auto* client : m_clients) 186 client->legibleMediaSelectionOptionsChanged(legibleMediaSelectionOptions, legibleMediaSelectedIndex); 187 } 188 189 void WebPlaybackSessionModelContext::setExternalPlayback(bool enabled, WebPlaybackSessionModel::ExternalPlaybackTargetType type, const String& localizedName) 190 { 191 m_externalPlaybackEnabled = enabled; 192 m_externalPlaybackTargetType = type; 193 m_externalPlaybackLocalizedDeviceName = localizedName; 194 195 for (auto* client : m_clients) 196 client->externalPlaybackChanged(enabled, type, localizedName); 197 } 198 199 void WebPlaybackSessionModelContext::setWirelessVideoPlaybackDisabled(bool wirelessVideoPlaybackDisabled) 200 { 201 m_wirelessVideoPlaybackDisabled = wirelessVideoPlaybackDisabled; 202 for (auto* client : m_clients) 203 client->wirelessVideoPlaybackDisabledChanged(wirelessVideoPlaybackDisabled); 113 204 } 114 205 … … 153 244 { 154 245 Ref<WebPlaybackSessionModelContext> model = WebPlaybackSessionModelContext::create(*this, contextId); 155 Ref<PlatformWebPlaybackSessionInterface> interface = PlatformWebPlaybackSessionInterface::create(); 156 157 interface->setWebPlaybackSessionModel(&model.get()); 246 Ref<PlatformWebPlaybackSessionInterface> interface = PlatformWebPlaybackSessionInterface::create(model); 158 247 159 248 return std::make_tuple(WTFMove(model), WTFMove(interface)); … … 195 284 if (clientCount <= 0) { 196 285 m_clientCounts.remove(contextId); 286 287 RefPtr<WebPlaybackSessionModelContext> model; 288 RefPtr<PlatformWebPlaybackSessionInterface> interface; 289 std::tie(model, interface) = ensureModelAndInterface(contextId); 290 interface->invalidate(); 197 291 m_contextMap.remove(contextId); 198 292 return; … … 242 336 void WebPlaybackSessionManagerProxy::setCurrentTime(uint64_t contextId, double currentTime, double hostTime) 243 337 { 244 RefPtr<WebPlaybackSessionModelContext> model; 245 RefPtr<PlatformWebPlaybackSessionInterface> interface; 246 std::tie(model, interface) = ensureModelAndInterface(contextId); 247 model->setCurrentTime(currentTime); 248 interface->setCurrentTime(currentTime, hostTime); 338 ensureModel(contextId).setCurrentTime(currentTime); 249 339 } 250 340 251 341 void WebPlaybackSessionManagerProxy::setBufferedTime(uint64_t contextId, double bufferedTime) 252 342 { 253 RefPtr<WebPlaybackSessionModelContext> model; 254 RefPtr<PlatformWebPlaybackSessionInterface> interface; 255 std::tie(model, interface) = ensureModelAndInterface(contextId); 256 model->setBufferedTime(bufferedTime); 257 interface->setBufferedTime(bufferedTime); 343 ensureModel(contextId).setBufferedTime(bufferedTime); 258 344 } 259 345 … … 268 354 } 269 355 270 RefPtr<WebPlaybackSessionModelContext> model; 271 RefPtr<PlatformWebPlaybackSessionInterface> interface; 272 std::tie(model, interface) = ensureModelAndInterface(contextId); 273 model->setSeekableRanges(timeRanges); 274 interface->setSeekableRanges(timeRanges); 356 ensureModel(contextId).setSeekableRanges(timeRanges); 275 357 } 276 358 277 359 void WebPlaybackSessionManagerProxy::setCanPlayFastReverse(uint64_t contextId, bool value) 278 360 { 279 RefPtr<WebPlaybackSessionModelContext> model; 280 RefPtr<PlatformWebPlaybackSessionInterface> interface; 281 std::tie(model, interface) = ensureModelAndInterface(contextId); 282 model->setCanPlayFastReverse(value); 283 interface->setCanPlayFastReverse(value); 361 ensureModel(contextId).setCanPlayFastReverse(value); 284 362 } 285 363 286 364 void WebPlaybackSessionManagerProxy::setAudioMediaSelectionOptions(uint64_t contextId, Vector<String> options, uint64_t selectedIndex) 287 365 { 288 RefPtr<WebPlaybackSessionModelContext> model; 289 RefPtr<PlatformWebPlaybackSessionInterface> interface; 290 std::tie(model, interface) = ensureModelAndInterface(contextId); 291 model->setAudioMediaSelectionOptions(options); 292 model->setAudioMediaSelectedIndex(selectedIndex); 293 interface->setAudioMediaSelectionOptions(options, selectedIndex); 366 ensureModel(contextId).setAudioMediaSelectionOptions(options, selectedIndex); 294 367 } 295 368 296 369 void WebPlaybackSessionManagerProxy::setLegibleMediaSelectionOptions(uint64_t contextId, Vector<String> options, uint64_t selectedIndex) 297 370 { 298 RefPtr<WebPlaybackSessionModelContext> model; 299 RefPtr<PlatformWebPlaybackSessionInterface> interface; 300 std::tie(model, interface) = ensureModelAndInterface(contextId); 301 model->setLegibleMediaSelectionOptions(options); 302 model->setLegibleMediaSelectedIndex(selectedIndex); 303 interface->setLegibleMediaSelectionOptions(options, selectedIndex); 371 ensureModel(contextId).setLegibleMediaSelectionOptions(options, selectedIndex); 304 372 } 305 373 306 374 void WebPlaybackSessionManagerProxy::setExternalPlaybackProperties(uint64_t contextId, bool enabled, uint32_t targetType, String localizedDeviceName) 307 375 { 308 WebPlaybackSessionInterface::ExternalPlaybackTargetType type = static_cast<WebPlaybackSessionInterface::ExternalPlaybackTargetType>(targetType); 309 ASSERT(type == WebPlaybackSessionInterface::TargetTypeAirPlay || type == WebPlaybackSessionInterface::TargetTypeTVOut || type == WebPlaybackSessionInterface::TargetTypeNone); 310 311 RefPtr<WebPlaybackSessionModelContext> model; 312 RefPtr<PlatformWebPlaybackSessionInterface> interface; 313 std::tie(model, interface) = ensureModelAndInterface(contextId); 314 model->setExternalPlaybackEnabled(enabled); 315 interface->setExternalPlayback(enabled, type, localizedDeviceName); 376 WebPlaybackSessionModel::ExternalPlaybackTargetType type = static_cast<WebPlaybackSessionModel::ExternalPlaybackTargetType>(targetType); 377 ASSERT(type == WebPlaybackSessionModel::TargetTypeAirPlay || type == WebPlaybackSessionModel::TargetTypeTVOut || type == WebPlaybackSessionModel::TargetTypeNone); 378 379 ensureModel(contextId).setExternalPlayback(enabled, type, localizedDeviceName); 316 380 } 317 381 318 382 void WebPlaybackSessionManagerProxy::setWirelessVideoPlaybackDisabled(uint64_t contextId, bool disabled) 319 383 { 320 RefPtr<WebPlaybackSessionModelContext> model; 321 RefPtr<PlatformWebPlaybackSessionInterface> interface; 322 std::tie(model, interface) = ensureModelAndInterface(contextId); 323 model->setWirelessVideoPlaybackDisabled(disabled); 324 interface->setWirelessVideoPlaybackDisabled(disabled); 384 ensureModel(contextId).setWirelessVideoPlaybackDisabled(disabled); 325 385 } 326 386 327 387 void WebPlaybackSessionManagerProxy::setDuration(uint64_t contextId, double duration) 328 388 { 329 RefPtr<WebPlaybackSessionModelContext> model; 330 RefPtr<PlatformWebPlaybackSessionInterface> interface; 331 std::tie(model, interface) = ensureModelAndInterface(contextId); 332 model->setDuration(duration); 333 interface->setDuration(duration); 389 ensureModel(contextId).setDuration(duration); 334 390 } 335 391 336 392 void WebPlaybackSessionManagerProxy::setRate(uint64_t contextId, bool isPlaying, double rate) 337 393 { 338 RefPtr<WebPlaybackSessionModelContext> model; 339 RefPtr<PlatformWebPlaybackSessionInterface> interface; 340 std::tie(model, interface) = ensureModelAndInterface(contextId); 341 model->setIsPlaying(isPlaying); 342 model->setPlaybackRate(rate); 343 interface->setRate(isPlaying, rate); 394 ensureModel(contextId).setRate(isPlaying, rate); 344 395 } 345 396 -
trunk/Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.h
r204668 r205365 35 35 #include <WebCore/WebVideoFullscreenModel.h> 36 36 #include <wtf/HashMap.h> 37 #include <wtf/HashSet.h> 37 38 #include <wtf/RefCounted.h> 38 39 #include <wtf/RefPtr.h> … … 57 58 class WebVideoFullscreenManagerProxy; 58 59 59 class WebVideoFullscreenModelContext final: public RefCounted<WebVideoFullscreenModelContext>, public WebCore::WebVideoFullscreenModel, public WebCore::WebVideoFullscreenChangeObserver { 60 class WebVideoFullscreenModelContext final 61 : public RefCounted<WebVideoFullscreenModelContext> 62 , public WebCore::WebVideoFullscreenModel 63 , public WebCore::WebVideoFullscreenChangeObserver { 60 64 public: 61 65 static Ref<WebVideoFullscreenModelContext> create(WebVideoFullscreenManagerProxy& manager, WebPlaybackSessionModelContext& playbackSessionModel, uint64_t contextId) … … 74 78 75 79 // WebVideoFullscreenModel 80 void addClient(WebCore::WebVideoFullscreenModelClient&) override; 81 void removeClient(WebCore::WebVideoFullscreenModelClient&) override; 76 82 void requestFullscreenMode(WebCore::HTMLMediaElementEnums::VideoFullscreenMode) override; 77 83 void setVideoLayerFrame(WebCore::FloatRect) override; … … 79 85 void fullscreenModeChanged(WebCore::HTMLMediaElementEnums::VideoFullscreenMode) override; 80 86 bool isVisible() const override; 87 bool hasVideo() const override { return m_hasVideo; } 88 WebCore::FloatSize videoDimensions() const override { return m_videoDimensions; } 81 89 82 90 // WebVideoFullscreenChangeObserver … … 91 99 uint64_t m_contextId; 92 100 RetainPtr<PlatformView *> m_layerHostView; 101 HashSet<WebCore::WebVideoFullscreenModelClient*> m_clients; 102 WebCore::FloatSize m_videoDimensions; 103 bool m_hasVideo { false }; 93 104 }; 94 105 … … 126 137 // Messages from WebVideoFullscreenManager 127 138 void setupFullscreenWithID(uint64_t contextId, uint32_t videoLayerID, const WebCore::IntRect& initialRect, float hostingScaleFactor, WebCore::HTMLMediaElementEnums::VideoFullscreenMode, bool allowsPictureInPicture); 128 void setVideoDimensions(uint64_t contextId, bool hasVideo, unsigned width, unsigned height); 139 void setHasVideo(uint64_t contextId, bool); 140 void setVideoDimensions(uint64_t contextId, const WebCore::FloatSize&); 129 141 void enterFullscreen(uint64_t contextId); 130 142 void exitFullscreen(uint64_t contextId, WebCore::IntRect finalRect); -
trunk/Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.messages.in
r199919 r205365 23 23 #if (PLATFORM(IOS) && HAVE(AVKIT)) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)) 24 24 messages -> WebVideoFullscreenManagerProxy { 25 SetVideoDimensions(uint64_t contextId, bool hasVideo, unsigned width, unsigned height) 25 SetHasVideo(uint64_t contextId, bool hasVideo) 26 SetVideoDimensions(uint64_t contextId, WebCore::FloatSize videoDimensions) 26 27 SetupFullscreenWithID(uint64_t contextId, uint32_t videoLayerID, WebCore::IntRect initialRect, float hostingScaleFactor, WebCore::HTMLMediaElementEnums::VideoFullscreenMode videoFullscreenMode, bool allowsPictureInPicture) 27 28 EnterFullscreen(uint64_t contextId) -
trunk/Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.mm
r200595 r205365 125 125 } 126 126 127 void WebVideoFullscreenModelContext::addClient(WebVideoFullscreenModelClient& client) 128 { 129 ASSERT(!m_clients.contains(&client)); 130 m_clients.add(&client); 131 } 132 133 void WebVideoFullscreenModelContext::removeClient(WebVideoFullscreenModelClient& client) 134 { 135 ASSERT(m_clients.contains(&client)); 136 m_clients.remove(&client); 137 } 138 127 139 void WebVideoFullscreenModelContext::requestFullscreenMode(HTMLMediaElementEnums::VideoFullscreenMode mode) 128 140 { … … 359 371 } 360 372 361 void WebVideoFullscreenManagerProxy::setVideoDimensions(uint64_t contextId, bool hasVideo, unsigned width, unsigned height) 362 { 363 ensureInterface(contextId).setVideoDimensions(hasVideo, width, height); 373 void WebVideoFullscreenManagerProxy::setHasVideo(uint64_t contextId, bool hasVideo) 374 { 375 ensureInterface(contextId).hasVideoChanged(hasVideo); 376 } 377 378 void WebVideoFullscreenManagerProxy::setVideoDimensions(uint64_t contextId, const FloatSize& videoDimensions) 379 { 380 ensureInterface(contextId).videoDimensionsChanged(videoDimensions); 364 381 } 365 382 -
trunk/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.h
r204668 r205365 55 55 class WebPlaybackSessionManager; 56 56 57 class WebPlaybackSessionInterfaceContext final : public RefCounted<WebPlaybackSessionInterfaceContext>, public WebCore::WebPlaybackSessionInterface { 57 class WebPlaybackSessionInterfaceContext final 58 : public RefCounted<WebPlaybackSessionInterfaceContext> 59 , public WebCore::WebPlaybackSessionInterface 60 , public WebCore::WebPlaybackSessionModelClient { 58 61 public: 59 62 static Ref<WebPlaybackSessionInterfaceContext> create(WebPlaybackSessionManager& manager, uint64_t contextId) … … 70 73 // WebPlaybackSessionInterface 71 74 void resetMediaState() final; 72 void setDuration(double) final; 73 void setCurrentTime(double currentTime, double anchorTime) final; 74 void setBufferedTime(double) final; 75 void setRate(bool isPlaying, float playbackRate) final; 76 void setSeekableRanges(const WebCore::TimeRanges&) final; 77 void setCanPlayFastReverse(bool value) final; 78 void setAudioMediaSelectionOptions(const Vector<WTF::String>& options, uint64_t selectedIndex) final; 79 void setLegibleMediaSelectionOptions(const Vector<WTF::String>& options, uint64_t selectedIndex) final; 80 void setExternalPlayback(bool enabled, ExternalPlaybackTargetType, WTF::String localizedDeviceName) final; 81 void setWirelessVideoPlaybackDisabled(bool) final; 75 76 // WebPlaybackModelClient 77 void durationChanged(double) final; 78 void currentTimeChanged(double currentTime, double anchorTime) final; 79 void bufferedTimeChanged(double) final; 80 void rateChanged(bool isPlaying, float playbackRate) final; 81 void seekableRangesChanged(const WebCore::TimeRanges&) final; 82 void canPlayFastReverseChanged(bool value) final; 83 void audioMediaSelectionOptionsChanged(const Vector<String>& options, uint64_t selectedIndex) final; 84 void legibleMediaSelectionOptionsChanged(const Vector<String>& options, uint64_t selectedIndex) final; 85 void externalPlaybackChanged(bool enabled, WebCore::WebPlaybackSessionModel::ExternalPlaybackTargetType, const String& localizedDeviceName) final; 86 void wirelessVideoPlaybackDisabledChanged(bool) final; 82 87 83 88 WebPlaybackSessionInterfaceContext(WebPlaybackSessionManager&, uint64_t contextId); … … 115 120 // Interface to WebPlaybackSessionInterfaceContext 116 121 void resetMediaState(uint64_t contextId); 117 void setDuration(uint64_t contextId, double);118 void setCurrentTime(uint64_t contextId, double currentTime, double anchorTime);119 void setBufferedTime(uint64_t contextId, double bufferedTime);120 void setRate(uint64_t contextId, bool isPlaying, float playbackRate);121 void se tSeekableRanges(uint64_t contextId, const WebCore::TimeRanges&);122 void setCanPlayFastReverse(uint64_t contextId, bool value);123 void setAudioMediaSelectionOptions(uint64_t contextId, const Vector<String>& options, uint64_t selectedIndex);124 void setLegibleMediaSelectionOptions(uint64_t contextId, const Vector<String>& options, uint64_t selectedIndex);125 void setExternalPlayback(uint64_t contextId, bool enabled, WebCore::WebPlaybackSessionInterface::ExternalPlaybackTargetType, String localizedDeviceName);126 void setWirelessVideoPlaybackDisabled(uint64_t contextId, bool);122 void durationChanged(uint64_t contextId, double); 123 void currentTimeChanged(uint64_t contextId, double currentTime, double anchorTime); 124 void bufferedTimeChanged(uint64_t contextId, double bufferedTime); 125 void rateChanged(uint64_t contextId, bool isPlaying, float playbackRate); 126 void seekableRangesChanged(uint64_t contextId, const WebCore::TimeRanges&); 127 void canPlayFastReverseChanged(uint64_t contextId, bool value); 128 void audioMediaSelectionOptionsChanged(uint64_t contextId, const Vector<String>& options, uint64_t selectedIndex); 129 void legibleMediaSelectionOptionsChanged(uint64_t contextId, const Vector<String>& options, uint64_t selectedIndex); 130 void externalPlaybackChanged(uint64_t contextId, bool enabled, WebCore::WebPlaybackSessionModel::ExternalPlaybackTargetType, String localizedDeviceName); 131 void wirelessVideoPlaybackDisabledChanged(uint64_t contextId, bool); 127 132 128 133 // Messages from WebPlaybackSessionManagerProxy -
trunk/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.mm
r203338 r205365 73 73 } 74 74 75 void WebPlaybackSessionInterfaceContext:: setDuration(double duration)76 { 77 if (m_manager) 78 m_manager-> setDuration(m_contextId, duration);79 } 80 81 void WebPlaybackSessionInterfaceContext:: setCurrentTime(double currentTime, double anchorTime)82 { 83 if (m_manager) 84 m_manager-> setCurrentTime(m_contextId, currentTime, anchorTime);85 } 86 87 void WebPlaybackSessionInterfaceContext:: setBufferedTime(double bufferedTime)88 { 89 if (m_manager) 90 m_manager-> setBufferedTime(m_contextId, bufferedTime);91 } 92 93 void WebPlaybackSessionInterfaceContext:: setRate(bool isPlaying, float playbackRate)94 { 95 if (m_manager) 96 m_manager-> setRate(m_contextId, isPlaying, playbackRate);97 } 98 99 void WebPlaybackSessionInterfaceContext::se tSeekableRanges(const WebCore::TimeRanges& ranges)100 { 101 if (m_manager) 102 m_manager->se tSeekableRanges(m_contextId, ranges);103 } 104 105 void WebPlaybackSessionInterfaceContext:: setCanPlayFastReverse(bool value)106 { 107 if (m_manager) 108 m_manager-> setCanPlayFastReverse(m_contextId, value);109 } 110 111 void WebPlaybackSessionInterfaceContext:: setAudioMediaSelectionOptions(const Vector<WTF::String>& options, uint64_t selectedIndex)112 { 113 if (m_manager) 114 m_manager-> setAudioMediaSelectionOptions(m_contextId, options, selectedIndex);115 } 116 117 void WebPlaybackSessionInterfaceContext:: setLegibleMediaSelectionOptions(const Vector<WTF::String>& options, uint64_t selectedIndex)118 { 119 if (m_manager) 120 m_manager-> setLegibleMediaSelectionOptions(m_contextId, options, selectedIndex);121 } 122 123 void WebPlaybackSessionInterfaceContext:: setExternalPlayback(bool enabled, ExternalPlaybackTargetType type, WTF::StringlocalizedDeviceName)124 { 125 if (m_manager) 126 m_manager-> setExternalPlayback(m_contextId, enabled, type, localizedDeviceName);127 } 128 129 void WebPlaybackSessionInterfaceContext:: setWirelessVideoPlaybackDisabled(bool disabled)130 { 131 if (m_manager) 132 m_manager-> setWirelessVideoPlaybackDisabled(m_contextId, disabled);75 void WebPlaybackSessionInterfaceContext::durationChanged(double duration) 76 { 77 if (m_manager) 78 m_manager->durationChanged(m_contextId, duration); 79 } 80 81 void WebPlaybackSessionInterfaceContext::currentTimeChanged(double currentTime, double anchorTime) 82 { 83 if (m_manager) 84 m_manager->currentTimeChanged(m_contextId, currentTime, anchorTime); 85 } 86 87 void WebPlaybackSessionInterfaceContext::bufferedTimeChanged(double bufferedTime) 88 { 89 if (m_manager) 90 m_manager->bufferedTimeChanged(m_contextId, bufferedTime); 91 } 92 93 void WebPlaybackSessionInterfaceContext::rateChanged(bool isPlaying, float playbackRate) 94 { 95 if (m_manager) 96 m_manager->rateChanged(m_contextId, isPlaying, playbackRate); 97 } 98 99 void WebPlaybackSessionInterfaceContext::seekableRangesChanged(const WebCore::TimeRanges& ranges) 100 { 101 if (m_manager) 102 m_manager->seekableRangesChanged(m_contextId, ranges); 103 } 104 105 void WebPlaybackSessionInterfaceContext::canPlayFastReverseChanged(bool value) 106 { 107 if (m_manager) 108 m_manager->canPlayFastReverseChanged(m_contextId, value); 109 } 110 111 void WebPlaybackSessionInterfaceContext::audioMediaSelectionOptionsChanged(const Vector<String>& options, uint64_t selectedIndex) 112 { 113 if (m_manager) 114 m_manager->audioMediaSelectionOptionsChanged(m_contextId, options, selectedIndex); 115 } 116 117 void WebPlaybackSessionInterfaceContext::legibleMediaSelectionOptionsChanged(const Vector<String>& options, uint64_t selectedIndex) 118 { 119 if (m_manager) 120 m_manager->legibleMediaSelectionOptionsChanged(m_contextId, options, selectedIndex); 121 } 122 123 void WebPlaybackSessionInterfaceContext::externalPlaybackChanged(bool enabled, WebPlaybackSessionModel::ExternalPlaybackTargetType type, const String& localizedDeviceName) 124 { 125 if (m_manager) 126 m_manager->externalPlaybackChanged(m_contextId, enabled, type, localizedDeviceName); 127 } 128 129 void WebPlaybackSessionInterfaceContext::wirelessVideoPlaybackDisabledChanged(bool disabled) 130 { 131 if (m_manager) 132 m_manager->wirelessVideoPlaybackDisabledChanged(m_contextId, disabled); 133 133 } 134 134 … … 152 152 RefPtr<WebPlaybackSessionInterfaceContext> interface; 153 153 std::tie(model, interface) = tuple; 154 155 model->setWebPlaybackSessionInterface(nullptr); 154 model->removeClient(*interface); 156 155 model->setMediaElement(nullptr); 157 156 … … 170 169 RefPtr<WebPlaybackSessionModelMediaElement> model = WebPlaybackSessionModelMediaElement::create(); 171 170 RefPtr<WebPlaybackSessionInterfaceContext> interface = WebPlaybackSessionInterfaceContext::create(*this, contextId); 172 173 model->setWebPlaybackSessionInterface(interface.get()); 171 model->addClient(*interface); 174 172 175 173 return std::make_tuple(WTFMove(model), WTFMove(interface)); … … 202 200 RefPtr<HTMLMediaElement> mediaElement = model->mediaElement(); 203 201 model->setMediaElement(nullptr); 204 model-> setWebPlaybackSessionInterface(nullptr);202 model->removeClient(*interface); 205 203 interface->invalidate(); 206 204 m_mediaElements.remove(mediaElement.get()); … … 285 283 } 286 284 287 void WebPlaybackSessionManager:: setDuration(uint64_t contextId, double duration)285 void WebPlaybackSessionManager::durationChanged(uint64_t contextId, double duration) 288 286 { 289 287 m_page->send(Messages::WebPlaybackSessionManagerProxy::SetDuration(contextId, duration), m_page->pageID()); 290 288 } 291 289 292 void WebPlaybackSessionManager:: setCurrentTime(uint64_t contextId, double currentTime, double anchorTime)290 void WebPlaybackSessionManager::currentTimeChanged(uint64_t contextId, double currentTime, double anchorTime) 293 291 { 294 292 m_page->send(Messages::WebPlaybackSessionManagerProxy::SetCurrentTime(contextId, currentTime, anchorTime), m_page->pageID()); 295 293 } 296 294 297 void WebPlaybackSessionManager:: setBufferedTime(uint64_t contextId, double bufferedTime)295 void WebPlaybackSessionManager::bufferedTimeChanged(uint64_t contextId, double bufferedTime) 298 296 { 299 297 m_page->send(Messages::WebPlaybackSessionManagerProxy::SetBufferedTime(contextId, bufferedTime), m_page->pageID()); 300 298 } 301 299 302 void WebPlaybackSessionManager:: setRate(uint64_t contextId, bool isPlaying, float playbackRate)300 void WebPlaybackSessionManager::rateChanged(uint64_t contextId, bool isPlaying, float playbackRate) 303 301 { 304 302 m_page->send(Messages::WebPlaybackSessionManagerProxy::SetRate(contextId, isPlaying, playbackRate), m_page->pageID()); 305 303 } 306 304 307 void WebPlaybackSessionManager::se tSeekableRanges(uint64_t contextId, const WebCore::TimeRanges& timeRanges)305 void WebPlaybackSessionManager::seekableRangesChanged(uint64_t contextId, const WebCore::TimeRanges& timeRanges) 308 306 { 309 307 Vector<std::pair<double, double>> rangesVector; … … 319 317 } 320 318 321 void WebPlaybackSessionManager:: setCanPlayFastReverse(uint64_t contextId, bool value)319 void WebPlaybackSessionManager::canPlayFastReverseChanged(uint64_t contextId, bool value) 322 320 { 323 321 m_page->send(Messages::WebPlaybackSessionManagerProxy::SetCanPlayFastReverse(contextId, value), m_page->pageID()); 324 322 } 325 323 326 void WebPlaybackSessionManager:: setAudioMediaSelectionOptions(uint64_t contextId, const Vector<String>& options, uint64_t selectedIndex)324 void WebPlaybackSessionManager::audioMediaSelectionOptionsChanged(uint64_t contextId, const Vector<String>& options, uint64_t selectedIndex) 327 325 { 328 326 m_page->send(Messages::WebPlaybackSessionManagerProxy::SetAudioMediaSelectionOptions(contextId, options, selectedIndex), m_page->pageID()); 329 327 } 330 328 331 void WebPlaybackSessionManager:: setLegibleMediaSelectionOptions(uint64_t contextId, const Vector<String>& options, uint64_t selectedIndex)329 void WebPlaybackSessionManager::legibleMediaSelectionOptionsChanged(uint64_t contextId, const Vector<String>& options, uint64_t selectedIndex) 332 330 { 333 331 m_page->send(Messages::WebPlaybackSessionManagerProxy::SetLegibleMediaSelectionOptions(contextId, options, selectedIndex), m_page->pageID()); 334 332 } 335 333 336 void WebPlaybackSessionManager:: setExternalPlayback(uint64_t contextId, bool enabled, WebPlaybackSessionInterface::ExternalPlaybackTargetType targetType, String localizedDeviceName)334 void WebPlaybackSessionManager::externalPlaybackChanged(uint64_t contextId, bool enabled, WebPlaybackSessionModel::ExternalPlaybackTargetType targetType, String localizedDeviceName) 337 335 { 338 336 m_page->send(Messages::WebPlaybackSessionManagerProxy::SetExternalPlaybackProperties(contextId, enabled, static_cast<uint32_t>(targetType), localizedDeviceName), m_page->pageID()); 339 337 } 340 338 341 void WebPlaybackSessionManager:: setWirelessVideoPlaybackDisabled(uint64_t contextId, bool disabled)339 void WebPlaybackSessionManager::wirelessVideoPlaybackDisabledChanged(uint64_t contextId, bool disabled) 342 340 { 343 341 m_page->send(Messages::WebPlaybackSessionManagerProxy::SetWirelessVideoPlaybackDisabled(contextId, disabled)); -
trunk/Source/WebKit2/WebProcess/cocoa/WebVideoFullscreenManager.h
r204668 r205365 46 46 47 47 namespace WebCore { 48 class FloatSize; 48 49 class Node; 49 50 } … … 57 58 class WebVideoFullscreenManager; 58 59 59 class WebVideoFullscreenInterfaceContext : public RefCounted<WebVideoFullscreenInterfaceContext>, public WebCore::WebVideoFullscreenInterface { 60 class WebVideoFullscreenInterfaceContext 61 : public RefCounted<WebVideoFullscreenInterfaceContext> 62 , public WebCore::WebVideoFullscreenInterface 63 , public WebCore::WebVideoFullscreenModelClient { 60 64 public: 61 static Ref<WebVideoFullscreenInterfaceContext> create(WebVideoFullscreenManager& manager, WebPlaybackSessionInterfaceContext& playbackSessionInterface,uint64_t contextId)65 static Ref<WebVideoFullscreenInterfaceContext> create(WebVideoFullscreenManager& manager, uint64_t contextId) 62 66 { 63 return adoptRef(*new WebVideoFullscreenInterfaceContext(manager, playbackSessionInterface,contextId));67 return adoptRef(*new WebVideoFullscreenInterfaceContext(manager, contextId)); 64 68 } 65 69 virtual ~WebVideoFullscreenInterfaceContext(); … … 83 87 84 88 private: 85 // WebPlaybackSessionInterface 86 void resetMediaState() override; 87 void setDuration(double) override; 88 void setCurrentTime(double currentTime, double anchorTime) override; 89 void setBufferedTime(double) override; 90 void setRate(bool isPlaying, float playbackRate) override; 91 void setSeekableRanges(const WebCore::TimeRanges&) override; 92 void setCanPlayFastReverse(bool value) override; 93 void setAudioMediaSelectionOptions(const Vector<WTF::String>& options, uint64_t selectedIndex) override; 94 void setLegibleMediaSelectionOptions(const Vector<WTF::String>& options, uint64_t selectedIndex) override; 95 void setExternalPlayback(bool enabled, ExternalPlaybackTargetType, WTF::String localizedDeviceName) override; 96 void setWirelessVideoPlaybackDisabled(bool) override; 89 // WebVideoFullscreenModelClient 90 void hasVideoChanged(bool) override; 91 void videoDimensionsChanged(const WebCore::FloatSize&) override; 97 92 98 // WebVideoFullscreenInterface 99 void setVideoDimensions(bool hasVideo, float width, float height) override; 100 101 WebVideoFullscreenInterfaceContext(WebVideoFullscreenManager&, WebPlaybackSessionInterfaceContext&, uint64_t contextId); 93 WebVideoFullscreenInterfaceContext(WebVideoFullscreenManager&, uint64_t contextId); 102 94 103 95 WebVideoFullscreenManager* m_manager; 104 Ref<WebPlaybackSessionInterfaceContext> m_playbackSessionInterface;105 96 uint64_t m_contextId; 106 97 std::unique_ptr<LayerHostingContext> m_layerHostingContext; … … 139 130 140 131 // Interface to WebVideoFullscreenInterfaceContext 141 void setVideoDimensions(uint64_t contextId, bool hasVideo, float width, float height); 132 void hasVideoChanged(uint64_t contextId, bool hasVideo); 133 void videoDimensionsChanged(uint64_t contextId, const WebCore::FloatSize&); 142 134 143 135 // Messages from WebVideoFullscreenManagerProxy -
trunk/Source/WebKit2/WebProcess/cocoa/WebVideoFullscreenManager.mm
r202274 r205365 67 67 #pragma mark - WebVideoFullscreenInterfaceContext 68 68 69 WebVideoFullscreenInterfaceContext::WebVideoFullscreenInterfaceContext(WebVideoFullscreenManager& manager, WebPlaybackSessionInterfaceContext& playbackSessionInterface,uint64_t contextId)69 WebVideoFullscreenInterfaceContext::WebVideoFullscreenInterfaceContext(WebVideoFullscreenManager& manager, uint64_t contextId) 70 70 : m_manager(&manager) 71 , m_playbackSessionInterface(playbackSessionInterface)72 71 , m_contextId(contextId) 73 72 { … … 83 82 } 84 83 85 void WebVideoFullscreenInterfaceContext::resetMediaState() 86 { 87 m_playbackSessionInterface->resetMediaState(); 88 } 89 90 void WebVideoFullscreenInterfaceContext::setDuration(double duration) 91 { 92 m_playbackSessionInterface->setDuration(duration); 93 } 94 95 void WebVideoFullscreenInterfaceContext::setCurrentTime(double currentTime, double anchorTime) 96 { 97 m_playbackSessionInterface->setCurrentTime(currentTime, anchorTime); 98 } 99 100 void WebVideoFullscreenInterfaceContext::setBufferedTime(double bufferedTime) 101 { 102 m_playbackSessionInterface->setBufferedTime(bufferedTime); 103 } 104 105 void WebVideoFullscreenInterfaceContext::setRate(bool isPlaying, float playbackRate) 106 { 107 m_playbackSessionInterface->setRate(isPlaying, playbackRate); 108 } 109 110 void WebVideoFullscreenInterfaceContext::setVideoDimensions(bool hasVideo, float width, float height) 84 void WebVideoFullscreenInterfaceContext::hasVideoChanged(bool hasVideo) 111 85 { 112 86 if (m_manager) 113 m_manager->setVideoDimensions(m_contextId, hasVideo, width, height); 114 } 115 116 void WebVideoFullscreenInterfaceContext::setSeekableRanges(const WebCore::TimeRanges& ranges) 117 { 118 m_playbackSessionInterface->setSeekableRanges(ranges); 119 } 120 121 void WebVideoFullscreenInterfaceContext::setCanPlayFastReverse(bool value) 122 { 123 m_playbackSessionInterface->setCanPlayFastReverse(value); 124 } 125 126 void WebVideoFullscreenInterfaceContext::setAudioMediaSelectionOptions(const Vector<WTF::String>& options, uint64_t selectedIndex) 127 { 128 m_playbackSessionInterface->setAudioMediaSelectionOptions(options, selectedIndex); 129 } 130 131 void WebVideoFullscreenInterfaceContext::setLegibleMediaSelectionOptions(const Vector<WTF::String>& options, uint64_t selectedIndex) 132 { 133 m_playbackSessionInterface->setLegibleMediaSelectionOptions(options, selectedIndex); 134 } 135 136 void WebVideoFullscreenInterfaceContext::setExternalPlayback(bool enabled, ExternalPlaybackTargetType type, WTF::String localizedDeviceName) 137 { 138 m_playbackSessionInterface->setExternalPlayback(enabled, type, localizedDeviceName); 139 } 140 141 void WebVideoFullscreenInterfaceContext::setWirelessVideoPlaybackDisabled(bool disabled) 142 { 143 m_playbackSessionInterface->setWirelessVideoPlaybackDisabled(disabled); 87 m_manager->hasVideoChanged(m_contextId, hasVideo); 88 } 89 90 void WebVideoFullscreenInterfaceContext::videoDimensionsChanged(const FloatSize& videoDimensions) 91 { 92 if (m_manager) 93 m_manager->videoDimensionsChanged(m_contextId, videoDimensions); 144 94 } 145 95 … … 165 115 std::tie(model, interface) = tuple; 166 116 167 model->setWebVideoFullscreenInterface(nullptr);168 117 model->setVideoElement(nullptr); 118 model->removeClient(*interface); 169 119 170 120 interface->invalidate(); … … 180 130 WebVideoFullscreenManager::ModelInterfaceTuple WebVideoFullscreenManager::createModelAndInterface(uint64_t contextId) 181 131 { 182 auto& playbackSessionModel = m_playbackSessionManager->ensureModel(contextId); 183 RefPtr<WebVideoFullscreenModelVideoElement> model = WebVideoFullscreenModelVideoElement::create(playbackSessionModel); 184 auto& playbackSessionInterface = m_playbackSessionManager->ensureInterface(contextId); 185 RefPtr<WebVideoFullscreenInterfaceContext> interface = WebVideoFullscreenInterfaceContext::create(*this, playbackSessionInterface, contextId); 132 RefPtr<WebVideoFullscreenModelVideoElement> model = WebVideoFullscreenModelVideoElement::create(); 133 RefPtr<WebVideoFullscreenInterfaceContext> interface = WebVideoFullscreenInterfaceContext::create(*this, contextId); 186 134 m_playbackSessionManager->addClientForContext(contextId); 187 135 188 136 interface->setLayerHostingContext(LayerHostingContext::createForExternalHostingProcess()); 189 model-> setWebVideoFullscreenInterface(interface.get());137 model->addClient(*interface); 190 138 191 139 return std::make_tuple(WTFMove(model), WTFMove(interface)); … … 220 168 RefPtr<HTMLVideoElement> videoElement = model->videoElement(); 221 169 model->setVideoElement(nullptr); 222 model-> setWebVideoFullscreenInterface(nullptr);170 model->removeClient(*interface); 223 171 interface->invalidate(); 224 172 m_videoElements.remove(videoElement.get()); … … 332 280 #pragma mark Interface to WebVideoFullscreenInterfaceContext: 333 281 334 void WebVideoFullscreenManager::setVideoDimensions(uint64_t contextId, bool hasVideo, float width, float height) 335 { 336 m_page->send(Messages::WebVideoFullscreenManagerProxy::SetVideoDimensions(contextId, hasVideo, width, height), m_page->pageID()); 282 void WebVideoFullscreenManager::hasVideoChanged(uint64_t contextId, bool hasVideo) 283 { 284 m_page->send(Messages::WebVideoFullscreenManagerProxy::SetHasVideo(contextId, hasVideo), m_page->pageID()); 285 } 286 287 void WebVideoFullscreenManager::videoDimensionsChanged(uint64_t contextId, const FloatSize& videoDimensions) 288 { 289 m_page->send(Messages::WebVideoFullscreenManagerProxy::SetVideoDimensions(contextId, videoDimensions), m_page->pageID()); 337 290 } 338 291
Note: See TracChangeset
for help on using the changeset viewer.