Changeset 205365 in webkit


Ignore:
Timestamp:
Sep 2, 2016 1:06:52 PM (8 years ago)
Author:
jer.noble@apple.com
Message:

Refactor WebPlaybackSessionModelMediaElement to be client based.
https://bugs.webkit.org/show_bug.cgi?id=159580

Reviewed by Eric Carlson.

Source/WebCore:

Add client callback interfaces to both WebPlaybackSessionModel and WebVideoFullscreenModel, where each object
can have multiple clients, and so the object will both store current values and also notify those clients
when the values change. After this change, there is no need to have the models know about their associated
interfaces explicitly.

  • platform/cocoa/WebPlaybackSessionInterface.h:
  • platform/cocoa/WebPlaybackSessionModel.h:

(WebCore::WebPlaybackSessionModelClient::~WebPlaybackSessionModelClient):
(WebCore::WebPlaybackSessionModelClient::durationChanged):
(WebCore::WebPlaybackSessionModelClient::currentTimeChanged):
(WebCore::WebPlaybackSessionModelClient::bufferedTimeChanged):
(WebCore::WebPlaybackSessionModelClient::rateChanged):
(WebCore::WebPlaybackSessionModelClient::seekableRangesChanged):
(WebCore::WebPlaybackSessionModelClient::canPlayFastReverseChanged):
(WebCore::WebPlaybackSessionModelClient::audioMediaSelectionOptionsChanged):
(WebCore::WebPlaybackSessionModelClient::legibleMediaSelectionOptionsChanged):
(WebCore::WebPlaybackSessionModelClient::externalPlaybackChanged):
(WebCore::WebPlaybackSessionModelClient::wirelessVideoPlaybackDisabledChanged):

  • platform/cocoa/WebPlaybackSessionModelMediaElement.h:
  • platform/cocoa/WebPlaybackSessionModelMediaElement.mm:

(WebPlaybackSessionModelMediaElement::setMediaElement):
(WebPlaybackSessionModelMediaElement::updateForEventName):
(WebPlaybackSessionModelMediaElement::addClient):
(WebPlaybackSessionModelMediaElement::removeClient):
(WebPlaybackSessionModelMediaElement::updateLegibleOptions):
(WebPlaybackSessionModelMediaElement::observedEventNames):
(WebPlaybackSessionModelMediaElement::eventNameAll):
(WebPlaybackSessionModelMediaElement::audioMediaSelectionOptions):
(WebPlaybackSessionModelMediaElement::audioMediaSelectedIndex):
(WebPlaybackSessionModelMediaElement::legibleMediaSelectedIndex):
(WebPlaybackSessionModelMediaElement::externalPlaybackEnabled):
(WebPlaybackSessionModelMediaElement::externalPlaybackTargetType):
(WebPlaybackSessionModelMediaElement::externalPlaybackLocalizedDeviceName):
(WebPlaybackSessionModelMediaElement::wirelessVideoPlaybackDisabled):
(WebPlaybackSessionModelMediaElement::setWebPlaybackSessionInterface): Deleted.

  • platform/cocoa/WebVideoFullscreenInterface.h:
  • platform/cocoa/WebVideoFullscreenModel.h:

(WebCore::WebVideoFullscreenModelClient::~WebVideoFullscreenModelClient):

  • platform/cocoa/WebVideoFullscreenModelVideoElement.h:

(WebCore::WebVideoFullscreenModelVideoElement::create):
(WebCore::WebVideoFullscreenModelVideoElement::playbackSessionModel): Deleted.

  • platform/cocoa/WebVideoFullscreenModelVideoElement.mm:

(WebVideoFullscreenModelVideoElement::WebVideoFullscreenModelVideoElement):
(WebVideoFullscreenModelVideoElement::setVideoElement):
(WebVideoFullscreenModelVideoElement::updateForEventName):
(WebVideoFullscreenModelVideoElement::addClient):
(WebVideoFullscreenModelVideoElement::removeClient):
(WebVideoFullscreenModelVideoElement::setHasVideo):
(WebVideoFullscreenModelVideoElement::setVideoDimensions):
(WebVideoFullscreenModelVideoElement::setWebVideoFullscreenInterface): Deleted.

  • platform/ios/WebAVPlayerController.h:
  • platform/ios/WebAVPlayerController.mm:

(-[WebAVPlayerController resetState]): Deleted.

  • platform/ios/WebPlaybackSessionInterfaceAVKit.h:

(WebCore::WebPlaybackSessionInterfaceAVKitClient::~WebPlaybackSessionInterfaceAVKitClient): Deleted.

  • platform/ios/WebPlaybackSessionInterfaceAVKit.mm:

(WebCore::WebPlaybackSessionInterfaceAVKit::WebPlaybackSessionInterfaceAVKit):
(WebCore::WebPlaybackSessionInterfaceAVKit::~WebPlaybackSessionInterfaceAVKit):
(WebCore::WebPlaybackSessionInterfaceAVKit::resetMediaState):
(WebCore::WebPlaybackSessionInterfaceAVKit::durationChanged):
(WebCore::WebPlaybackSessionInterfaceAVKit::currentTimeChanged):
(WebCore::WebPlaybackSessionInterfaceAVKit::bufferedTimeChanged):
(WebCore::WebPlaybackSessionInterfaceAVKit::rateChanged):
(WebCore::WebPlaybackSessionInterfaceAVKit::seekableRangesChanged):
(WebCore::WebPlaybackSessionInterfaceAVKit::canPlayFastReverseChanged):
(WebCore::WebPlaybackSessionInterfaceAVKit::audioMediaSelectionOptionsChanged):
(WebCore::WebPlaybackSessionInterfaceAVKit::legibleMediaSelectionOptionsChanged):
(WebCore::WebPlaybackSessionInterfaceAVKit::externalPlaybackChanged):
(WebCore::WebPlaybackSessionInterfaceAVKit::wirelessVideoPlaybackDisabledChanged):
(WebCore::WebPlaybackSessionInterfaceAVKit::invalidate):
(WebCore::WebPlaybackSessionInterfaceAVKit::setWebPlaybackSessionModel): Deleted.
(WebCore::WebPlaybackSessionInterfaceAVKit::setDuration): Deleted.
(WebCore::WebPlaybackSessionInterfaceAVKit::setCurrentTime): Deleted.
(WebCore::WebPlaybackSessionInterfaceAVKit::setBufferedTime): Deleted.
(WebCore::WebPlaybackSessionInterfaceAVKit::setRate): Deleted.
(WebCore::WebPlaybackSessionInterfaceAVKit::setSeekableRanges): Deleted.
(WebCore::WebPlaybackSessionInterfaceAVKit::setCanPlayFastReverse): Deleted.
(WebCore::WebPlaybackSessionInterfaceAVKit::setAudioMediaSelectionOptions): Deleted.
(WebCore::WebPlaybackSessionInterfaceAVKit::setLegibleMediaSelectionOptions): Deleted.
(WebCore::WebPlaybackSessionInterfaceAVKit::setExternalPlayback): Deleted.
(WebCore::WebPlaybackSessionInterfaceAVKit::setWirelessVideoPlaybackDisabled): Deleted.
(WebCore::WebPlaybackSessionInterfaceAVKit::wirelessVideoPlaybackDisabled): Deleted.

  • platform/ios/WebVideoFullscreenControllerAVKit.mm:

(WebVideoFullscreenControllerContext::didSetupFullscreen):
(WebVideoFullscreenControllerContext::didExitFullscreen):
(WebVideoFullscreenControllerContext::didCleanupFullscreen):
(WebVideoFullscreenControllerContext::durationChanged):
(WebVideoFullscreenControllerContext::currentTimeChanged):
(WebVideoFullscreenControllerContext::bufferedTimeChanged):
(WebVideoFullscreenControllerContext::rateChanged):
(WebVideoFullscreenControllerContext::hasVideoChanged):
(WebVideoFullscreenControllerContext::videoDimensionsChanged):
(WebVideoFullscreenControllerContext::seekableRangesChanged):
(WebVideoFullscreenControllerContext::canPlayFastReverseChanged):
(WebVideoFullscreenControllerContext::audioMediaSelectionOptionsChanged):
(WebVideoFullscreenControllerContext::legibleMediaSelectionOptionsChanged):
(WebVideoFullscreenControllerContext::externalPlaybackChanged):
(WebVideoFullscreenControllerContext::wirelessVideoPlaybackDisabledChanged):
(WebVideoFullscreenControllerContext::addClient):
(WebVideoFullscreenControllerContext::removeClient):
(WebVideoFullscreenControllerContext::requestFullscreenMode):
(WebVideoFullscreenControllerContext::setVideoLayerFrame):
(WebVideoFullscreenControllerContext::setVideoLayerGravity):
(WebVideoFullscreenControllerContext::fullscreenModeChanged):
(WebVideoFullscreenControllerContext::isVisible):
(WebVideoFullscreenControllerContext::hasVideo):
(WebVideoFullscreenControllerContext::videoDimensions):
(WebVideoFullscreenControllerContext::play):
(WebVideoFullscreenControllerContext::pause):
(WebVideoFullscreenControllerContext::togglePlayState):
(WebVideoFullscreenControllerContext::beginScrubbing):
(WebVideoFullscreenControllerContext::endScrubbing):
(WebVideoFullscreenControllerContext::seekToTime):
(WebVideoFullscreenControllerContext::fastSeek):
(WebVideoFullscreenControllerContext::beginScanningForward):
(WebVideoFullscreenControllerContext::beginScanningBackward):
(WebVideoFullscreenControllerContext::endScanning):
(WebVideoFullscreenControllerContext::selectAudioMediaOption):
(WebVideoFullscreenControllerContext::selectLegibleMediaOption):
(WebVideoFullscreenControllerContext::duration):
(WebVideoFullscreenControllerContext::currentTime):
(WebVideoFullscreenControllerContext::bufferedTime):
(WebVideoFullscreenControllerContext::isPlaying):
(WebVideoFullscreenControllerContext::playbackRate):
(WebVideoFullscreenControllerContext::seekableRanges):
(WebVideoFullscreenControllerContext::canPlayFastReverse):
(WebVideoFullscreenControllerContext::audioMediaSelectionOptions):
(WebVideoFullscreenControllerContext::audioMediaSelectedIndex):
(WebVideoFullscreenControllerContext::legibleMediaSelectionOptions):
(WebVideoFullscreenControllerContext::legibleMediaSelectedIndex):
(WebVideoFullscreenControllerContext::externalPlaybackEnabled):
(WebVideoFullscreenControllerContext::externalPlaybackTargetType):
(WebVideoFullscreenControllerContext::externalPlaybackLocalizedDeviceName):
(WebVideoFullscreenControllerContext::wirelessVideoPlaybackDisabled):
(WebVideoFullscreenControllerContext::setUpFullscreen):
(WebVideoFullscreenControllerContext::exitFullscreen):
(WebVideoFullscreenControllerContext::requestHideAndExitFullscreen):
(WebVideoFullscreenControllerContext::resetMediaState): Deleted.
(WebVideoFullscreenControllerContext::setDuration): Deleted.
(WebVideoFullscreenControllerContext::setCurrentTime): Deleted.
(WebVideoFullscreenControllerContext::setBufferedTime): Deleted.
(WebVideoFullscreenControllerContext::setRate): Deleted.
(WebVideoFullscreenControllerContext::setVideoDimensions): Deleted.
(WebVideoFullscreenControllerContext::setSeekableRanges): Deleted.
(WebVideoFullscreenControllerContext::setCanPlayFastReverse): Deleted.
(WebVideoFullscreenControllerContext::setAudioMediaSelectionOptions): Deleted.
(WebVideoFullscreenControllerContext::setLegibleMediaSelectionOptions): Deleted.
(WebVideoFullscreenControllerContext::setExternalPlayback): Deleted.
(WebVideoFullscreenControllerContext::setWirelessVideoPlaybackDisabled): Deleted.
(WebVideoFullscreenSessionModel::play): Deleted.
(WebVideoFullscreenSessionModel::pause): Deleted.
(WebVideoFullscreenSessionModel::togglePlayState): Deleted.
(WebVideoFullscreenSessionModel::beginScrubbing): Deleted.
(WebVideoFullscreenSessionModel::endScrubbing): Deleted.
(WebVideoFullscreenSessionModel::seekToTime): Deleted.
(WebVideoFullscreenSessionModel::fastSeek): Deleted.
(WebVideoFullscreenSessionModel::beginScanningForward): Deleted.
(WebVideoFullscreenSessionModel::beginScanningBackward): Deleted.
(WebVideoFullscreenSessionModel::endScanning): Deleted.
(WebVideoFullscreenSessionModel::selectAudioMediaOption): Deleted.
(WebVideoFullscreenSessionModel::selectLegibleMediaOption): Deleted.

  • platform/ios/WebVideoFullscreenInterfaceAVKit.h:
  • platform/ios/WebVideoFullscreenInterfaceAVKit.mm:

(WebVideoFullscreenInterfaceAVKit::~WebVideoFullscreenInterfaceAVKit):
(WebVideoFullscreenInterfaceAVKit::setWebVideoFullscreenModel):
(WebVideoFullscreenInterfaceAVKit::setWebVideoFullscreenChangeObserver):
(WebVideoFullscreenInterfaceAVKit::hasVideoChanged):
(WebVideoFullscreenInterfaceAVKit::videoDimensionsChanged):
(WebVideoFullscreenInterfaceAVKit::externalPlaybackChanged):
(WebVideoFullscreenInterfaceAVKit::resetMediaState): Deleted.
(WebVideoFullscreenInterfaceAVKit::setDuration): Deleted.
(WebVideoFullscreenInterfaceAVKit::setCurrentTime): Deleted.
(WebVideoFullscreenInterfaceAVKit::setBufferedTime): Deleted.
(WebVideoFullscreenInterfaceAVKit::setRate): Deleted.
(WebVideoFullscreenInterfaceAVKit::setVideoDimensions): Deleted.
(WebVideoFullscreenInterfaceAVKit::setSeekableRanges): Deleted.
(WebVideoFullscreenInterfaceAVKit::setCanPlayFastReverse): Deleted.
(WebVideoFullscreenInterfaceAVKit::setAudioMediaSelectionOptions): Deleted.
(WebVideoFullscreenInterfaceAVKit::setLegibleMediaSelectionOptions): Deleted.
(WebVideoFullscreenInterfaceAVKit::setExternalPlayback): Deleted.
(WebVideoFullscreenInterfaceAVKit::externalPlaybackEnabledChanged): Deleted.
(WebVideoFullscreenInterfaceAVKit::setWirelessVideoPlaybackDisabled): Deleted.
(WebVideoFullscreenInterfaceAVKit::wirelessVideoPlaybackDisabled): Deleted.

  • platform/mac/WebPlaybackSessionInterfaceMac.h:

(WebCore::WebPlaybackSessionInterfaceMacClient::~WebPlaybackSessionInterfaceMacClient): Deleted.

  • platform/mac/WebPlaybackSessionInterfaceMac.mm:

(WebCore::WebPlaybackSessionInterfaceMac::create):
(WebCore::WebPlaybackSessionInterfaceMac::WebPlaybackSessionInterfaceMac):
(WebCore::WebPlaybackSessionInterfaceMac::~WebPlaybackSessionInterfaceMac):
(WebCore::WebPlaybackSessionInterfaceMac::durationChanged):
(WebCore::WebPlaybackSessionInterfaceMac::currentTimeChanged):
(WebCore::WebPlaybackSessionInterfaceMac::rateChanged):
(WebCore::WebPlaybackSessionInterfaceMac::seekableRangesChanged):
(WebCore::WebPlaybackSessionInterfaceMac::audioMediaSelectionOptionsChanged):
(WebCore::WebPlaybackSessionInterfaceMac::legibleMediaSelectionOptionsChanged):
(WebCore::WebPlaybackSessionInterfaceMac::invalidate):
(WebCore::WebPlaybackSessionInterfaceMac::setWebPlaybackSessionModel): Deleted.
(WebCore::WebPlaybackSessionInterfaceMac::setClient): Deleted.
(WebCore::WebPlaybackSessionInterfaceMac::setDuration): Deleted.
(WebCore::WebPlaybackSessionInterfaceMac::setCurrentTime): Deleted.
(WebCore::WebPlaybackSessionInterfaceMac::setRate): Deleted.
(WebCore::WebPlaybackSessionInterfaceMac::setSeekableRanges): Deleted.
(WebCore::WebPlaybackSessionInterfaceMac::setAudioMediaSelectionOptions): Deleted.
(WebCore::WebPlaybackSessionInterfaceMac::setLegibleMediaSelectionOptions): Deleted.

  • platform/mac/WebVideoFullscreenInterfaceMac.h:
  • platform/mac/WebVideoFullscreenInterfaceMac.mm:

(WebCore::WebVideoFullscreenInterfaceMac::WebVideoFullscreenInterfaceMac):
(WebCore::WebVideoFullscreenInterfaceMac::~WebVideoFullscreenInterfaceMac):
(WebCore::WebVideoFullscreenInterfaceMac::setWebVideoFullscreenModel):
(WebCore::WebVideoFullscreenInterfaceMac::externalPlaybackChanged):
(WebCore::WebVideoFullscreenInterfaceMac::hasVideoChanged):
(WebCore::WebVideoFullscreenInterfaceMac::videoDimensionsChanged):
(WebCore::WebVideoFullscreenInterfaceMac::setDuration): Deleted.
(WebCore::WebVideoFullscreenInterfaceMac::setCurrentTime): Deleted.
(WebCore::WebVideoFullscreenInterfaceMac::setRate): Deleted.
(WebCore::WebVideoFullscreenInterfaceMac::setSeekableRanges): Deleted.
(WebCore::WebVideoFullscreenInterfaceMac::setAudioMediaSelectionOptions): Deleted.
(WebCore::WebVideoFullscreenInterfaceMac::setLegibleMediaSelectionOptions): Deleted.
(WebCore::WebVideoFullscreenInterfaceMac::setExternalPlayback): Deleted.
(WebCore::WebVideoFullscreenInterfaceMac::setVideoDimensions): Deleted.

Source/WebKit/mac:

No longer necessary to tell the models and interfaces about each other.

  • WebView/WebView.mm:

(-[WebView _setUpPlaybackControlsManagerForMediaElement:]):
(-[WebView _clearPlaybackControlsManager]):

Source/WebKit2:

Adopt the changes made in the WebPlaybackSessionModel,Interface and WebVideoFullscreenModel,Interface
in the WebPlaybackSessionManager,Proxy classes.

  • UIProcess/API/Cocoa/WKWebView.mm:

(-[WKWebView _initializeWithConfiguration:]): Deleted.

  • UIProcess/Cocoa/WebPlaybackSessionManagerProxy.h:
  • UIProcess/Cocoa/WebPlaybackSessionManagerProxy.mm:

(WebKit::WebPlaybackSessionModelContext::addClient):
(WebKit::WebPlaybackSessionModelContext::removeClient):
(WebKit::WebPlaybackSessionModelContext::setDuration):
(WebKit::WebPlaybackSessionModelContext::setCurrentTime):
(WebKit::WebPlaybackSessionModelContext::setBufferedTime):
(WebKit::WebPlaybackSessionModelContext::setRate):
(WebKit::WebPlaybackSessionModelContext::setSeekableRanges):
(WebKit::WebPlaybackSessionModelContext::setCanPlayFastReverse):
(WebKit::WebPlaybackSessionModelContext::setAudioMediaSelectionOptions):
(WebKit::WebPlaybackSessionModelContext::setLegibleMediaSelectionOptions):
(WebKit::WebPlaybackSessionModelContext::setExternalPlayback):
(WebKit::WebPlaybackSessionModelContext::setWirelessVideoPlaybackDisabled):
(WebKit::WebPlaybackSessionManagerProxy::createModelAndInterface):
(WebKit::WebPlaybackSessionManagerProxy::removeClientForContext):
(WebKit::WebPlaybackSessionManagerProxy::setCurrentTime):
(WebKit::WebPlaybackSessionManagerProxy::setBufferedTime):
(WebKit::WebPlaybackSessionManagerProxy::setSeekableRangesVector):
(WebKit::WebPlaybackSessionManagerProxy::setCanPlayFastReverse):
(WebKit::WebPlaybackSessionManagerProxy::setAudioMediaSelectionOptions):
(WebKit::WebPlaybackSessionManagerProxy::setLegibleMediaSelectionOptions):
(WebKit::WebPlaybackSessionManagerProxy::setExternalPlaybackProperties):
(WebKit::WebPlaybackSessionManagerProxy::setWirelessVideoPlaybackDisabled):
(WebKit::WebPlaybackSessionManagerProxy::setDuration):
(WebKit::WebPlaybackSessionManagerProxy::setRate):

  • UIProcess/Cocoa/WebVideoFullscreenManagerProxy.h:
  • UIProcess/Cocoa/WebVideoFullscreenManagerProxy.messages.in:
  • UIProcess/Cocoa/WebVideoFullscreenManagerProxy.mm:

(WebKit::WebVideoFullscreenModelContext::addClient):
(WebKit::WebVideoFullscreenModelContext::removeClient):
(WebKit::WebVideoFullscreenManagerProxy::setHasVideo):
(WebKit::WebVideoFullscreenManagerProxy::setVideoDimensions):

  • WebProcess/cocoa/WebPlaybackSessionManager.h:
  • WebProcess/cocoa/WebPlaybackSessionManager.mm:

(WebKit::WebPlaybackSessionInterfaceContext::durationChanged):
(WebKit::WebPlaybackSessionInterfaceContext::currentTimeChanged):
(WebKit::WebPlaybackSessionInterfaceContext::bufferedTimeChanged):
(WebKit::WebPlaybackSessionInterfaceContext::rateChanged):
(WebKit::WebPlaybackSessionInterfaceContext::seekableRangesChanged):
(WebKit::WebPlaybackSessionInterfaceContext::canPlayFastReverseChanged):
(WebKit::WebPlaybackSessionInterfaceContext::audioMediaSelectionOptionsChanged):
(WebKit::WebPlaybackSessionInterfaceContext::legibleMediaSelectionOptionsChanged):
(WebKit::WebPlaybackSessionInterfaceContext::externalPlaybackChanged):
(WebKit::WebPlaybackSessionInterfaceContext::wirelessVideoPlaybackDisabledChanged):
(WebKit::WebPlaybackSessionManager::~WebPlaybackSessionManager):
(WebKit::WebPlaybackSessionManager::createModelAndInterface):
(WebKit::WebPlaybackSessionManager::removeContext):
(WebKit::WebPlaybackSessionManager::durationChanged):
(WebKit::WebPlaybackSessionManager::currentTimeChanged):
(WebKit::WebPlaybackSessionManager::bufferedTimeChanged):
(WebKit::WebPlaybackSessionManager::rateChanged):
(WebKit::WebPlaybackSessionManager::seekableRangesChanged):
(WebKit::WebPlaybackSessionManager::canPlayFastReverseChanged):
(WebKit::WebPlaybackSessionManager::audioMediaSelectionOptionsChanged):
(WebKit::WebPlaybackSessionManager::legibleMediaSelectionOptionsChanged):
(WebKit::WebPlaybackSessionManager::externalPlaybackChanged):
(WebKit::WebPlaybackSessionManager::wirelessVideoPlaybackDisabledChanged):
(WebKit::WebPlaybackSessionInterfaceContext::setDuration): Deleted.
(WebKit::WebPlaybackSessionInterfaceContext::setCurrentTime): Deleted.
(WebKit::WebPlaybackSessionInterfaceContext::setBufferedTime): Deleted.
(WebKit::WebPlaybackSessionInterfaceContext::setRate): Deleted.
(WebKit::WebPlaybackSessionInterfaceContext::setSeekableRanges): Deleted.
(WebKit::WebPlaybackSessionInterfaceContext::setCanPlayFastReverse): Deleted.
(WebKit::WebPlaybackSessionInterfaceContext::setAudioMediaSelectionOptions): Deleted.
(WebKit::WebPlaybackSessionInterfaceContext::setLegibleMediaSelectionOptions): Deleted.
(WebKit::WebPlaybackSessionInterfaceContext::setExternalPlayback): Deleted.
(WebKit::WebPlaybackSessionInterfaceContext::setWirelessVideoPlaybackDisabled): Deleted.
(WebKit::WebPlaybackSessionManager::setDuration): Deleted.
(WebKit::WebPlaybackSessionManager::setCurrentTime): Deleted.
(WebKit::WebPlaybackSessionManager::setBufferedTime): Deleted.
(WebKit::WebPlaybackSessionManager::setRate): Deleted.
(WebKit::WebPlaybackSessionManager::setSeekableRanges): Deleted.
(WebKit::WebPlaybackSessionManager::setCanPlayFastReverse): Deleted.
(WebKit::WebPlaybackSessionManager::setAudioMediaSelectionOptions): Deleted.
(WebKit::WebPlaybackSessionManager::setLegibleMediaSelectionOptions): Deleted.
(WebKit::WebPlaybackSessionManager::setExternalPlayback): Deleted.
(WebKit::WebPlaybackSessionManager::setWirelessVideoPlaybackDisabled): Deleted.

  • WebProcess/cocoa/WebVideoFullscreenManager.h:

(WebKit::WebVideoFullscreenInterfaceContext::create):

  • WebProcess/cocoa/WebVideoFullscreenManager.mm:

(WebKit::WebVideoFullscreenInterfaceContext::WebVideoFullscreenInterfaceContext):
(WebKit::WebVideoFullscreenInterfaceContext::hasVideoChanged):
(WebKit::WebVideoFullscreenInterfaceContext::videoDimensionsChanged):
(WebKit::WebVideoFullscreenManager::~WebVideoFullscreenManager):
(WebKit::WebVideoFullscreenManager::createModelAndInterface):
(WebKit::WebVideoFullscreenManager::removeContext):
(WebKit::WebVideoFullscreenManager::hasVideoChanged):
(WebKit::WebVideoFullscreenManager::videoDimensionsChanged):
(WebKit::WebVideoFullscreenInterfaceContext::resetMediaState): Deleted.
(WebKit::WebVideoFullscreenInterfaceContext::setDuration): Deleted.
(WebKit::WebVideoFullscreenInterfaceContext::setCurrentTime): Deleted.
(WebKit::WebVideoFullscreenInterfaceContext::setBufferedTime): Deleted.
(WebKit::WebVideoFullscreenInterfaceContext::setRate): Deleted.
(WebKit::WebVideoFullscreenInterfaceContext::setVideoDimensions): Deleted.
(WebKit::WebVideoFullscreenInterfaceContext::setSeekableRanges): Deleted.
(WebKit::WebVideoFullscreenInterfaceContext::setCanPlayFastReverse): Deleted.
(WebKit::WebVideoFullscreenInterfaceContext::setAudioMediaSelectionOptions): Deleted.
(WebKit::WebVideoFullscreenInterfaceContext::setLegibleMediaSelectionOptions): Deleted.
(WebKit::WebVideoFullscreenInterfaceContext::setExternalPlayback): Deleted.
(WebKit::WebVideoFullscreenInterfaceContext::setWirelessVideoPlaybackDisabled): Deleted.
(WebKit::WebVideoFullscreenManager::setVideoDimensions): Deleted.

Location:
trunk/Source
Files:
33 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r205360 r205365  
     12016-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
    12292016-09-02  Chris Dumez  <cdumez@apple.com>
    2230
  • trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionInterface.h

    r199593 r205365  
    4141class WebPlaybackSessionInterface {
    4242public:
    43     enum ExternalPlaybackTargetType { TargetTypeNone, TargetTypeAirPlay, TargetTypeTVOut };
    44 
    4543    virtual ~WebPlaybackSessionInterface() { };
    4644    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;
    5745};
    5846
  • trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionModel.h

    r200490 r205365  
    3737class TimeRanges;
    3838
     39class WebPlaybackSessionModelClient;
     40
    3941class WebPlaybackSessionModel {
    4042public:
    4143    virtual ~WebPlaybackSessionModel() { };
     44    virtual void addClient(WebPlaybackSessionModelClient&) = 0;
     45    virtual void removeClient(WebPlaybackSessionModelClient&) = 0;
     46
    4247    virtual void play() = 0;
    4348    virtual void pause() = 0;
     
    5358    virtual void selectLegibleMediaOption(uint64_t index) = 0;
    5459
     60    enum ExternalPlaybackTargetType { TargetTypeNone, TargetTypeAirPlay, TargetTypeTVOut };
     61
    5562    virtual double duration() const = 0;
    5663    virtual double currentTime() const = 0;
     
    6067    virtual Ref<TimeRanges> seekableRanges() const = 0;
    6168    virtual bool canPlayFastReverse() const = 0;
    62     virtual Vector<WTF::String> audioMediaSelectionOptions() const = 0;
     69    virtual Vector<String> audioMediaSelectionOptions() const = 0;
    6370    virtual uint64_t audioMediaSelectedIndex() const = 0;
    64     virtual Vector<WTF::String> legibleMediaSelectionOptions() const = 0;
     71    virtual Vector<String> legibleMediaSelectionOptions() const = 0;
    6572    virtual uint64_t legibleMediaSelectedIndex() const = 0;
    6673    virtual bool externalPlaybackEnabled() const = 0;
     74    virtual ExternalPlaybackTargetType externalPlaybackTargetType() const = 0;
     75    virtual String externalPlaybackLocalizedDeviceName() const = 0;
    6776    virtual bool wirelessVideoPlaybackDisabled() const = 0;
     77};
     78
     79class WebPlaybackSessionModelClient {
     80public:
     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) { }
    6892};
    6993
  • trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionModelMediaElement.h

    r204466 r205365  
    3131#include "HTMLMediaElementEnums.h"
    3232#include "WebPlaybackSessionModel.h"
     33#include <wtf/HashSet.h>
    3334#include <wtf/RefPtr.h>
    3435#include <wtf/Vector.h>
     
    4748    }
    4849    WEBCORE_EXPORT virtual ~WebPlaybackSessionModelMediaElement();
    49     WEBCORE_EXPORT void setWebPlaybackSessionInterface(WebPlaybackSessionInterface*);
    5050    WEBCORE_EXPORT void setMediaElement(HTMLMediaElement*);
    5151    WEBCORE_EXPORT HTMLMediaElement* mediaElement() const { return m_mediaElement.get(); }
     
    5555    bool operator==(const EventListener& rhs) const final { return static_cast<const WebCore::EventListener*>(this) == &rhs; }
    5656
     57    WEBCORE_EXPORT void addClient(WebPlaybackSessionModelClient&);
     58    WEBCORE_EXPORT void removeClient(WebPlaybackSessionModelClient&);
    5759    WEBCORE_EXPORT void play() final;
    5860    WEBCORE_EXPORT void pause() final;
     
    8082    uint64_t legibleMediaSelectedIndex() const final;
    8183    bool externalPlaybackEnabled() const final;
     84    ExternalPlaybackTargetType externalPlaybackTargetType() const final;
     85    String externalPlaybackLocalizedDeviceName() const final;
    8286    bool wirelessVideoPlaybackDisabled() const final;
    8387
     
    9195    RefPtr<HTMLMediaElement> m_mediaElement;
    9296    bool m_isListening { false };
    93     WebPlaybackSessionInterface* m_playbackSessionInterface { nullptr };
     97    HashSet<WebPlaybackSessionModelClient*> m_clients;
    9498    Vector<RefPtr<TextTrack>> m_legibleTracksForMenu;
    9599    Vector<RefPtr<AudioTrack>> m_audioTracksForMenu;
  • trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionModelMediaElement.mm

    r204717 r205365  
    5757}
    5858
    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 
    8059void WebPlaybackSessionModelMediaElement::setMediaElement(HTMLMediaElement* mediaElement)
    8160{
    8261    if (m_mediaElement == mediaElement)
    8362        return;
    84 
    85     if (m_playbackSessionInterface)
    86         m_playbackSessionInterface->resetMediaState();
    8763
    8864    if (m_mediaElement && m_isListening) {
     
    9470    m_mediaElement = mediaElement;
    9571
    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    }
    10277
    10378    updateForEventName(eventNameAll());
    104 
    105     if (m_playbackSessionInterface)
    106         m_playbackSessionInterface->setWirelessVideoPlaybackDisabled(m_mediaElement->mediaSession().wirelessVideoPlaybackDisabled(*m_mediaElement));
    10779}
    10880
     
    11486void WebPlaybackSessionModelMediaElement::updateForEventName(const WTF::AtomicString& eventName)
    11587{
    116     if (!m_mediaElement || !m_playbackSessionInterface)
     88    if (m_clients.isEmpty())
    11789        return;
    11890
     
    12193    if (all
    12294        || 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);
    12498        // These is no standard event for minFastReverseRateChange; duration change is a reasonable proxy for it.
    12599        // 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);
    127103    }
    128104
     
    130106        || eventName == eventNames().pauseEvent
    131107        || 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    }
    134114
    135115    if (all
    136116        || 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        }
    141128    }
    142129
     
    148135    if (all
    149136        || 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);
    161146        }
    162         m_playbackSessionInterface->setExternalPlayback(enabled, targetType, localizedDeviceName);
    163         m_playbackSessionInterface->setWirelessVideoPlaybackDisabled(m_mediaElement->mediaSession().wirelessVideoPlaybackDisabled(*m_mediaElement));
    164     }
     147    }
     148}
     149void WebPlaybackSessionModelMediaElement::addClient(WebPlaybackSessionModelClient& client)
     150{
     151    ASSERT(!m_clients.contains(&client));
     152    m_clients.add(&client);
     153}
     154
     155void WebPlaybackSessionModelMediaElement::removeClient(WebPlaybackSessionModelClient& client)
     156{
     157    ASSERT(m_clients.contains(&client));
     158    m_clients.remove(&client);
    165159}
    166160
     
    280274        m_audioTracksForMenu.clear();
    281275
    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
     287const 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();
    301301}
    302302
    303303const AtomicString&  WebPlaybackSessionModelMediaElement::eventNameAll()
    304304{
    305     static NeverDestroyed<AtomicString> sEventNameAll = "allEvents";
    306     return sEventNameAll;
     305    static NeverDestroyed<AtomicString> eventNameAll("allEvents", AtomicString::ConstructFromLiteral);
     306    return eventNameAll;
    307307}
    308308
     
    342342}
    343343
    344 Vector<WTF::String> WebPlaybackSessionModelMediaElement::audioMediaSelectionOptions() const
     344Vector<String> WebPlaybackSessionModelMediaElement::audioMediaSelectionOptions() const
    345345{
    346346    Vector<String> audioTrackDisplayNames;
     
    351351    auto& captionPreferences = m_mediaElement->document().page()->group().captionPreferences();
    352352
     353    audioTrackDisplayNames.reserveInitialCapacity(m_audioTracksForMenu.size());
    353354    for (auto& audioTrack : m_audioTracksForMenu)
    354         audioTrackDisplayNames.append(captionPreferences.displayNameForTrack(audioTrack.get()));
     355        audioTrackDisplayNames.uncheckedAppend(captionPreferences.displayNameForTrack(audioTrack.get()));
    355356
    356357    return audioTrackDisplayNames;
     
    363364            return index;
    364365    }
    365     return 0;
     366    return std::numeric_limits<uint64_t>::max();
    366367}
    367368
     
    383384uint64_t WebPlaybackSessionModelMediaElement::legibleMediaSelectedIndex() const
    384385{
    385     uint64_t selectedIndex = 0;
     386    uint64_t selectedIndex = std::numeric_limits<uint64_t>::max();
    386387    uint64_t offIndex = 0;
    387388    bool trackMenuItemSelected = false;
    388389
    389     if (!m_mediaElement || !m_mediaElement->mediaControlsHost())
     390    auto host = m_mediaElement ? m_mediaElement->mediaControlsHost() : nullptr;
     391
     392    if (!host)
    390393        return selectedIndex;
    391394
    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();
    395398
    396399    for (size_t index = 0; index < m_legibleTracksForMenu.size(); index++) {
     
    418421bool WebPlaybackSessionModelMediaElement::externalPlaybackEnabled() const
    419422{
    420     return m_mediaElement ? m_mediaElement->webkitCurrentPlaybackTargetIsWireless() : false;
     423    return m_mediaElement && m_mediaElement->webkitCurrentPlaybackTargetIsWireless();
     424}
     425
     426WebPlaybackSessionModel::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
     444String WebPlaybackSessionModelMediaElement::externalPlaybackLocalizedDeviceName() const
     445{
     446    if (m_mediaElement && m_mediaElement->mediaControlsHost())
     447        return m_mediaElement->mediaControlsHost()->externalDeviceDisplayName();
     448    return emptyString();
    421449}
    422450
    423451bool WebPlaybackSessionModelMediaElement::wirelessVideoPlaybackDisabled() const
    424452{
    425     return m_mediaElement ? m_mediaElement->mediaSession().wirelessVideoPlaybackDisabled(*m_mediaElement) : false;
     453    return m_mediaElement && m_mediaElement->mediaSession().wirelessVideoPlaybackDisabled(*m_mediaElement);
    426454}
    427455
  • trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenInterface.h

    r199593 r205365  
    3737class TimeRanges;
    3838
    39 class WebVideoFullscreenInterface : public WebPlaybackSessionInterface {
     39class WebVideoFullscreenInterface {
    4040public:
    4141    virtual ~WebVideoFullscreenInterface() { };
    42     virtual void setVideoDimensions(bool hasVideo, float width, float height) = 0;
    4342};
    4443
  • trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenModel.h

    r200490 r205365  
    3636namespace WebCore {
    3737
     38class WebVideoFullscreenModelClient;
     39
    3840class WebVideoFullscreenModel {
    3941public:
    4042    virtual ~WebVideoFullscreenModel() { };
     43    virtual void addClient(WebVideoFullscreenModelClient&) = 0;
     44    virtual void removeClient(WebVideoFullscreenModelClient&)= 0;
     45
    4146    virtual void requestFullscreenMode(HTMLMediaElementEnums::VideoFullscreenMode) = 0;
    4247    virtual void setVideoLayerFrame(FloatRect) = 0;
     
    4449    virtual void setVideoLayerGravity(VideoGravity) = 0;
    4550    virtual void fullscreenModeChanged(HTMLMediaElementEnums::VideoFullscreenMode) = 0;
     51
    4652    virtual bool isVisible() const = 0;
     53    virtual FloatSize videoDimensions() const = 0;
     54    virtual bool hasVideo() const = 0;
     55};
     56
     57class WebVideoFullscreenModelClient {
     58public:
     59    virtual ~WebVideoFullscreenModelClient() { }
     60    virtual void hasVideoChanged(bool) = 0;
     61    virtual void videoDimensionsChanged(const FloatSize&) = 0;
    4762};
    4863
  • trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenModelVideoElement.h

    r201474 r205365  
    3636#include "WebVideoFullscreenModel.h"
    3737#include <functional>
     38#include <wtf/HashSet.h>
    3839#include <wtf/RefPtr.h>
    3940#include <wtf/RetainPtr.h>
     
    4546class TextTrack;
    4647class WebPlaybackSessionModelMediaElement;
    47 class WebVideoFullscreenInterface;
    4848
    4949class WebVideoFullscreenModelVideoElement : public WebVideoFullscreenModel, public EventListener {
    5050public:
    51     static RefPtr<WebVideoFullscreenModelVideoElement> create(WebPlaybackSessionModelMediaElement& playbackSessionModel)
     51    static RefPtr<WebVideoFullscreenModelVideoElement> create()
    5252    {
    53         return adoptRef(*new WebVideoFullscreenModelVideoElement(playbackSessionModel));
     53        return adoptRef(*new WebVideoFullscreenModelVideoElement());
    5454    }
    5555    WEBCORE_EXPORT virtual ~WebVideoFullscreenModelVideoElement();
    56     WEBCORE_EXPORT void setWebVideoFullscreenInterface(WebVideoFullscreenInterface*);
    5756    WEBCORE_EXPORT void setVideoElement(HTMLVideoElement*);
    5857    WEBCORE_EXPORT HTMLVideoElement* videoElement() const { return m_videoElement.get(); }
    5958    WEBCORE_EXPORT void setVideoFullscreenLayer(PlatformLayer*, std::function<void()> completionHandler = [] { });
    6059    WEBCORE_EXPORT void waitForPreparedForInlineThen(std::function<void()> completionHandler = [] { });
    61     WebPlaybackSessionModelMediaElement& playbackSessionModel() { return m_playbackSessionModel; }
    6260   
    6361    WEBCORE_EXPORT void handleEvent(WebCore::ScriptExecutionContext*, WebCore::Event*) override;
     
    6563    bool operator==(const EventListener& rhs) const override { return static_cast<const WebCore::EventListener*>(this) == &rhs; }
    6664
     65    WEBCORE_EXPORT void addClient(WebVideoFullscreenModelClient&) override;
     66    WEBCORE_EXPORT void removeClient(WebVideoFullscreenModelClient&) override;
    6767    WEBCORE_EXPORT void requestFullscreenMode(HTMLMediaElementEnums::VideoFullscreenMode) override;
    6868    WEBCORE_EXPORT void setVideoLayerFrame(FloatRect) override;
     
    7070    WEBCORE_EXPORT void fullscreenModeChanged(HTMLMediaElementEnums::VideoFullscreenMode) override;
    7171    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
    7275
    7376protected:
    74     WEBCORE_EXPORT WebVideoFullscreenModelVideoElement(WebPlaybackSessionModelMediaElement&);
     77    WEBCORE_EXPORT WebVideoFullscreenModelVideoElement();
    7578
    7679private:
     80    void setHasVideo(bool);
     81    void setVideoDimensions(const FloatSize&);
     82
    7783    static const Vector<WTF::AtomicString>& observedEventNames();
    7884    const WTF::AtomicString& eventNameAll();
    7985
    80     Ref<WebPlaybackSessionModelMediaElement> m_playbackSessionModel;
    8186    RefPtr<HTMLVideoElement> m_videoElement;
    8287    RetainPtr<PlatformLayer> m_videoFullscreenLayer;
    8388    bool m_isListening { false };
    84     WebVideoFullscreenInterface* m_videoFullscreenInterface { nullptr };
     89    HashSet<WebVideoFullscreenModelClient*> m_clients;
     90    bool m_hasVideo { false };
     91    FloatSize m_videoDimensions;
    8592    FloatRect m_videoFrame;
    8693    Vector<RefPtr<TextTrack>> m_legibleTracksForMenu;
  • trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenModelVideoElement.mm

    r204717 r205365  
    4949using namespace WebCore;
    5050
    51 WebVideoFullscreenModelVideoElement::WebVideoFullscreenModelVideoElement(WebPlaybackSessionModelMediaElement& playbackSessionModel)
     51WebVideoFullscreenModelVideoElement::WebVideoFullscreenModelVideoElement()
    5252    : EventListener(EventListener::CPPEventListenerType)
    53     , m_playbackSessionModel(playbackSessionModel)
    5453{
    5554}
     
    5756WebVideoFullscreenModelVideoElement::~WebVideoFullscreenModelVideoElement()
    5857{
    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());
    7158}
    7259
     
    8774    m_videoElement = videoElement;
    8875
    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    }
    9581
    9682    updateForEventName(eventNameAll());
    97 
    98     if (m_videoFullscreenInterface)
    99         m_videoFullscreenInterface->setVideoDimensions(true, videoElement->videoWidth(), videoElement->videoHeight());
    10083}
    10184
     
    10790void WebVideoFullscreenModelVideoElement::updateForEventName(const WTF::AtomicString& eventName)
    10891{
    109     if (!m_videoElement || !m_videoFullscreenInterface)
     92    if (m_clients.isEmpty())
    11093        return;
    11194   
     
    11396
    11497    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    }
    117102}
    118103
     
    200185}
    201186
     187void WebVideoFullscreenModelVideoElement::addClient(WebVideoFullscreenModelClient& client)
     188{
     189    ASSERT(!m_clients.contains(&client));
     190    m_clients.add(&client);
     191}
     192
     193void WebVideoFullscreenModelVideoElement::removeClient(WebVideoFullscreenModelClient& client)
     194{
     195    ASSERT(m_clients.contains(&client));
     196    m_clients.remove(&client);
     197}
     198
    202199bool WebVideoFullscreenModelVideoElement::isVisible() const
    203200{
     
    211208}
    212209
     210void 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
     221void 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
    213232#endif
  • trunk/Source/WebCore/platform/ios/WebAVPlayerController.h

    r199896 r205365  
    4242    BOOL _pictureInPictureInterrupted;
    4343}
    44 
    45 - (void)resetState;
    4644
    4745@property (retain) AVPlayerController* playerControllerProxy;
  • trunk/Source/WebCore/platform/ios/WebAVPlayerController.mm

    r204466 r205365  
    7575}
    7676
    77 - (void)resetState
    78 {
    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 
    10977- (AVPlayer *)player
    11078{
  • trunk/Source/WebCore/platform/ios/WebPlaybackSessionInterfaceAVKit.h

    r200490 r205365  
    3434#include "Timer.h"
    3535#include "WebPlaybackSessionInterface.h"
     36#include "WebPlaybackSessionModel.h"
    3637#include <functional>
    3738#include <objc/objc.h>
     
    5556class WebPlaybackSessionChangeObserver;
    5657
    57 class WebPlaybackSessionInterfaceAVKitClient {
    58 public:
    59     virtual ~WebPlaybackSessionInterfaceAVKitClient() { }
    60 
    61     virtual void externalPlaybackEnabledChanged(bool) = 0;
    62 };
    63 
    6458class WEBCORE_EXPORT WebPlaybackSessionInterfaceAVKit
    6559    : public WebPlaybackSessionInterface
     60    , public WebPlaybackSessionModelClient
    6661    , public RefCounted<WebPlaybackSessionInterfaceAVKit> {
    6762
    6863public:
    69     static Ref<WebPlaybackSessionInterfaceAVKit> create()
     64    static Ref<WebPlaybackSessionInterfaceAVKit> create(WebPlaybackSessionModel& model)
    7065    {
    71         return adoptRef(*new WebPlaybackSessionInterfaceAVKit());
     66        return adoptRef(*new WebPlaybackSessionInterfaceAVKit(model));
    7267    }
    7368    virtual ~WebPlaybackSessionInterfaceAVKit();
    74     WEBCORE_EXPORT void setWebPlaybackSessionModel(WebPlaybackSessionModel*);
    7569    WebPlaybackSessionModel* webPlaybackSessionModel() const { return m_playbackSessionModel; }
    76     void setClient(WebPlaybackSessionInterfaceAVKitClient* client) { m_client = client; }
    7770
     71    // WebPlaybackSessionInterface
    7872    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;
    9085
    9186    WEBCORE_EXPORT virtual void invalidate();
     
    9489
    9590protected:
    96     WEBCORE_EXPORT WebPlaybackSessionInterfaceAVKit();
     91    WEBCORE_EXPORT WebPlaybackSessionInterfaceAVKit(WebPlaybackSessionModel&);
    9792
    9893    RetainPtr<WebAVPlayerController> m_playerController;
    9994    WebPlaybackSessionModel* m_playbackSessionModel { nullptr };
    100     WebPlaybackSessionInterfaceAVKitClient* m_client { nullptr};
    101 
    102     bool m_wirelessVideoPlaybackDisabled { true };
    10395};
    10496
  • trunk/Source/WebCore/platform/ios/WebPlaybackSessionInterfaceAVKit.mm

    r199701 r205365  
    4848namespace WebCore {
    4949
    50 WebPlaybackSessionInterfaceAVKit::WebPlaybackSessionInterfaceAVKit()
     50WebPlaybackSessionInterfaceAVKit::WebPlaybackSessionInterfaceAVKit(WebPlaybackSessionModel& model)
    5151    : m_playerController(adoptNS([[WebAVPlayerController alloc] init]))
    52 {
     52    , m_playbackSessionModel(&model)
     53{
     54    model.addClient(*this);
    5355    [m_playerController setPlaybackSessionInterface:this];
     56    [m_playerController setDelegate:&model];
    5457}
    5558
    5659WebPlaybackSessionInterfaceAVKit::~WebPlaybackSessionInterfaceAVKit()
    5760{
    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();
    6165}
    6266
    6367void WebPlaybackSessionInterfaceAVKit::resetMediaState()
    6468{
    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
     98void WebPlaybackSessionInterfaceAVKit::durationChanged(double duration)
    7599{
    76100    WebAVPlayerController* playerController = m_playerController.get();
     
    91115}
    92116
    93 void WebPlaybackSessionInterfaceAVKit::setCurrentTime(double currentTime, double anchorTime)
     117void WebPlaybackSessionInterfaceAVKit::currentTimeChanged(double currentTime, double anchorTime)
    94118{
    95119    NSTimeInterval anchorTimeStamp = ![m_playerController rate] ? NAN : anchorTime;
     
    100124}
    101125
    102 void WebPlaybackSessionInterfaceAVKit::setBufferedTime(double bufferedTime)
     126void WebPlaybackSessionInterfaceAVKit::bufferedTimeChanged(double bufferedTime)
    103127{
    104128    WebAVPlayerController* playerController = m_playerController.get();
     
    112136}
    113137
    114 void WebPlaybackSessionInterfaceAVKit::setRate(bool isPlaying, float playbackRate)
     138void WebPlaybackSessionInterfaceAVKit::rateChanged(bool isPlaying, float playbackRate)
    115139{
    116140    [m_playerController setRate:isPlaying ? playbackRate : 0.];
    117141}
    118142
    119 void WebPlaybackSessionInterfaceAVKit::setSeekableRanges(const TimeRanges& timeRanges)
     143void WebPlaybackSessionInterfaceAVKit::seekableRangesChanged(const TimeRanges& timeRanges)
    120144{
    121145    RetainPtr<NSMutableArray> seekableRanges = adoptNS([[NSMutableArray alloc] init]);
     
    133157}
    134158
    135 void WebPlaybackSessionInterfaceAVKit::setCanPlayFastReverse(bool canPlayFastReverse)
     159void WebPlaybackSessionInterfaceAVKit::canPlayFastReverseChanged(bool canPlayFastReverse)
    136160{
    137161    [m_playerController setCanScanBackward:canPlayFastReverse];
     
    149173}
    150174
    151 void WebPlaybackSessionInterfaceAVKit::setAudioMediaSelectionOptions(const Vector<String>& options, uint64_t selectedIndex)
     175void WebPlaybackSessionInterfaceAVKit::audioMediaSelectionOptionsChanged(const Vector<String>& options, uint64_t selectedIndex)
    152176{
    153177    RetainPtr<NSMutableArray> webOptions = mediaSelectionOptions(options);
     
    157181}
    158182
    159 void WebPlaybackSessionInterfaceAVKit::setLegibleMediaSelectionOptions(const Vector<String>& options, uint64_t selectedIndex)
     183void WebPlaybackSessionInterfaceAVKit::legibleMediaSelectionOptionsChanged(const Vector<String>& options, uint64_t selectedIndex)
    160184{
    161185    RetainPtr<NSMutableArray> webOptions = mediaSelectionOptions(options);
     
    165189}
    166190
    167 void WebPlaybackSessionInterfaceAVKit::setExternalPlayback(bool enabled, ExternalPlaybackTargetType targetType, String localizedDeviceName)
     191void WebPlaybackSessionInterfaceAVKit::externalPlaybackChanged(bool enabled, WebPlaybackSessionModel::ExternalPlaybackTargetType targetType, const String& localizedDeviceName)
    168192{
    169193    AVPlayerControllerExternalPlaybackType externalPlaybackType = AVPlayerControllerExternalPlaybackTypeNone;
    170     if (targetType == TargetTypeAirPlay)
     194    if (targetType == WebPlaybackSessionModel::TargetTypeAirPlay)
    171195        externalPlaybackType = AVPlayerControllerExternalPlaybackTypeAirPlay;
    172     else if (targetType == TargetTypeTVOut)
     196    else if (targetType == WebPlaybackSessionModel::TargetTypeTVOut)
    173197        externalPlaybackType = AVPlayerControllerExternalPlaybackTypeTVOut;
    174198
     
    177201    playerController.externalPlaybackType = externalPlaybackType;
    178202    playerController.externalPlaybackActive = enabled;
    179 
    180     if (m_client)
    181         m_client->externalPlaybackEnabledChanged(enabled);
    182 }
    183 
    184 void WebPlaybackSessionInterfaceAVKit::setWirelessVideoPlaybackDisabled(bool disabled)
     203}
     204
     205void WebPlaybackSessionInterfaceAVKit::wirelessVideoPlaybackDisabledChanged(bool disabled)
    185206{
    186207    [m_playerController setAllowsExternalPlayback:!disabled];
    187208}
    188209
    189 bool WebPlaybackSessionInterfaceAVKit::wirelessVideoPlaybackDisabled() const
    190 {
    191     return [m_playerController allowsExternalPlayback];
    192 }
    193 
    194210void WebPlaybackSessionInterfaceAVKit::invalidate()
    195211{
    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;
    197218}
    198219
  • trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm

    r203303 r205365  
    9292
    9393class WebVideoFullscreenControllerContext;
    94 class WebVideoFullscreenSessionModel;
    9594
    9695@interface WebVideoFullscreenController (delegate)
     
    101100    : private WebVideoFullscreenInterface
    102101    , private WebVideoFullscreenModel
     102    , private WebVideoFullscreenModelClient
    103103    , private WebVideoFullscreenChangeObserver
     104    , private WebPlaybackSessionModel
     105    , private WebPlaybackSessionModelClient
    104106    , public ThreadSafeRefCounted<WebVideoFullscreenControllerContext> {
    105107
     
    115117    void requestHideAndExitFullscreen();
    116118    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);
    130119
    131120private:
     
    139128    void fullscreenMayReturnToInline() override;
    140129
    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;
    154176
    155177    // WebVideoFullscreenModel
     178    void addClient(WebVideoFullscreenModelClient&) override;
     179    void removeClient(WebVideoFullscreenModelClient&) override;
    156180    void requestFullscreenMode(HTMLMediaElementEnums::VideoFullscreenMode) override;
    157181    void setVideoLayerFrame(FloatRect) override;
     
    159183    void fullscreenModeChanged(HTMLMediaElementEnums::VideoFullscreenMode) override;
    160184    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;
    162190    RefPtr<WebVideoFullscreenInterfaceAVKit> m_interface;
    163     RefPtr<WebVideoFullscreenModelVideoElement> m_model;
     191    RefPtr<WebVideoFullscreenModelVideoElement> m_fullscreenModel;
     192    RefPtr<WebPlaybackSessionModelMediaElement> m_playbackModel;
    164193    RefPtr<HTMLVideoElement> m_videoElement;
    165194    RetainPtr<UIView> m_videoFullscreenView;
    166195    RetainPtr<WebVideoFullscreenController> m_controller;
    167     RefPtr<WebVideoFullscreenSessionModel> m_sessionModel;
    168196};
    169197
    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 
    244198#pragma mark WebVideoFullscreenChangeObserver
    245199
     
    247201{
    248202    ASSERT(isUIThread());
    249     RefPtr<WebVideoFullscreenControllerContext> protectedThis(this);
    250203    RetainPtr<CALayer> videoFullscreenLayer = [m_videoFullscreenView layer];
     204    RefPtr<WebVideoFullscreenControllerContext> protectedThis(this);
    251205    WebThreadRun([protectedThis, this, videoFullscreenLayer] {
    252206        [videoFullscreenLayer setBackgroundColor:cachedCGColor(WebCore::Color::transparent)];
    253         m_model->setVideoFullscreenLayer(videoFullscreenLayer.get(), [protectedThis, this] {
     207        m_fullscreenModel->setVideoFullscreenLayer(videoFullscreenLayer.get(), [protectedThis, this] {
    254208            dispatch_async(dispatch_get_main_queue(), [protectedThis, this] {
    255209                m_interface->enterFullscreen();
     
    264218    RefPtr<WebVideoFullscreenControllerContext> protectedThis(this);
    265219    WebThreadRun([protectedThis, this] {
    266         m_model->setVideoFullscreenLayer(nil, [protectedThis, this] {
     220        m_fullscreenModel->setVideoFullscreenLayer(nil, [protectedThis, this] {
    267221            dispatch_async(dispatch_get_main_queue(), [protectedThis, this] {
    268222                m_interface->cleanupFullscreen();
     
    279233    m_interface = nullptr;
    280234    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;
    291243        m_videoElement = nullptr;
    292244
     
    307259}
    308260
    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
     263void 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
     277void 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
     291void 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
     305void 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
     319void 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
     333void 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
     347void 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
     361void 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
     375void 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
     389void 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
     403void 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
     417void 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);
    452429}
    453430
    454431#pragma mark WebVideoFullscreenModel
    455432
     433void WebVideoFullscreenControllerContext::addClient(WebVideoFullscreenModelClient& client)
     434{
     435    ASSERT(!m_fullscreenClients.contains(&client));
     436    m_fullscreenClients.add(&client);
     437}
     438
     439void WebVideoFullscreenControllerContext::removeClient(WebVideoFullscreenModelClient& client)
     440{
     441    ASSERT(m_fullscreenClients.contains(&client));
     442    m_fullscreenClients.remove(&client);
     443}
     444
    456445void WebVideoFullscreenControllerContext::requestFullscreenMode(HTMLMediaElementEnums::VideoFullscreenMode mode)
    457446{
     
    459448    RefPtr<WebVideoFullscreenControllerContext> protectedThis(this);
    460449    WebThreadRun([protectedThis, this, mode] {
    461         if (m_model)
    462             m_model->requestFullscreenMode(mode);
     450        if (m_fullscreenModel)
     451            m_fullscreenModel->requestFullscreenMode(mode);
    463452    });
    464453}
     
    480469            [videoFullscreenLayer setSublayerTransform:CATransform3DIdentity];
    481470           
    482             if (m_model)
    483                 m_model->setVideoLayerFrame(frame);
     471            if (m_fullscreenModel)
     472                m_fullscreenModel->setVideoLayerFrame(frame);
    484473            [CATransaction commit];
    485474        });
     
    492481    RefPtr<WebVideoFullscreenControllerContext> protectedThis(this);
    493482    WebThreadRun([protectedThis, this, videoGravity] {
    494         if (m_model)
    495             m_model->setVideoLayerGravity(videoGravity);
     483        if (m_fullscreenModel)
     484            m_fullscreenModel->setVideoLayerGravity(videoGravity);
    496485    });
    497486}
     
    502491    RefPtr<WebVideoFullscreenControllerContext> protectedThis(this);
    503492    WebThreadRun([protectedThis, this, mode] {
    504         if (m_model)
    505             m_model->fullscreenModeChanged(mode);
     493        if (m_fullscreenModel)
     494            m_fullscreenModel->fullscreenModeChanged(mode);
    506495    });
    507496}
     
    510499{
    511500    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
     504bool WebVideoFullscreenControllerContext::hasVideo() const
     505{
     506    ASSERT(isUIThread());
     507    return m_fullscreenModel ? m_fullscreenModel->hasVideo() : false;
     508}
     509
     510FloatSize WebVideoFullscreenControllerContext::videoDimensions() const
     511{
     512    ASSERT(isUIThread());
     513    return m_fullscreenModel ? m_fullscreenModel->videoDimensions() : FloatSize();
     514}
     515
     516#pragma mark - WebPlaybackSessionModel
     517
     518void WebVideoFullscreenControllerContext::addClient(WebPlaybackSessionModelClient& client)
     519{
     520    ASSERT(!m_playbackClients.contains(&client));
     521    m_playbackClients.add(&client);
     522}
     523
     524void WebVideoFullscreenControllerContext::removeClient(WebPlaybackSessionModelClient& client)
     525{
     526    ASSERT(m_playbackClients.contains(&client));
     527    m_playbackClients.remove(&client);
     528}
    516529
    517530void WebVideoFullscreenControllerContext::play()
     
    520533    RefPtr<WebVideoFullscreenControllerContext> protectedThis(this);
    521534    WebThreadRun([protectedThis, this] {
    522         if (m_model)
    523             m_model->playbackSessionModel().play();
     535        if (m_playbackModel)
     536            m_playbackModel->play();
    524537    });
    525538}
     
    530543    RefPtr<WebVideoFullscreenControllerContext> protectedThis(this);
    531544    WebThreadRun([protectedThis, this] {
    532         if (m_model)
    533             m_model->playbackSessionModel().pause();
     545        if (m_playbackModel)
     546            m_playbackModel->pause();
    534547    });
    535548}
     
    540553    RefPtr<WebVideoFullscreenControllerContext> protectedThis(this);
    541554    WebThreadRun([protectedThis, this] {
    542         if (m_model)
    543             m_model->playbackSessionModel().togglePlayState();
     555        if (m_playbackModel)
     556            m_playbackModel->togglePlayState();
    544557    });
    545558}
     
    550563    RefPtr<WebVideoFullscreenControllerContext> protectedThis(this);
    551564    WebThreadRun([protectedThis, this] {
    552         if (m_model)
    553             m_model->playbackSessionModel().beginScrubbing();
     565        if (m_playbackModel)
     566            m_playbackModel->beginScrubbing();
    554567    });
    555568}
     
    560573    RefPtr<WebVideoFullscreenControllerContext> protectedThis(this);
    561574    WebThreadRun([protectedThis, this] {
    562         if (m_model)
    563             m_model->playbackSessionModel().endScrubbing();
     575        if (m_playbackModel)
     576            m_playbackModel->endScrubbing();
    564577    });
    565578}
     
    570583    RefPtr<WebVideoFullscreenControllerContext> protectedThis(this);
    571584    WebThreadRun([protectedThis, this, time] {
    572         if (m_model)
    573             m_model->playbackSessionModel().seekToTime(time);
     585        if (m_playbackModel)
     586            m_playbackModel->seekToTime(time);
    574587    });
    575588}
     
    580593    RefPtr<WebVideoFullscreenControllerContext> protectedThis(this);
    581594    WebThreadRun([protectedThis, this, time] {
    582         if (m_model)
    583             m_model->playbackSessionModel().fastSeek(time);
     595        if (m_playbackModel)
     596            m_playbackModel->fastSeek(time);
    584597    });
    585598}
     
    590603    RefPtr<WebVideoFullscreenControllerContext> protectedThis(this);
    591604    WebThreadRun([protectedThis, this] {
    592         if (m_model)
    593             m_model->playbackSessionModel().beginScanningForward();
     605        if (m_playbackModel)
     606            m_playbackModel->beginScanningForward();
    594607    });
    595608}
     
    600613    RefPtr<WebVideoFullscreenControllerContext> protectedThis(this);
    601614    WebThreadRun([protectedThis, this] {
    602         if (m_model)
    603             m_model->playbackSessionModel().beginScanningBackward();
     615        if (m_playbackModel)
     616            m_playbackModel->beginScanningBackward();
    604617    });
    605618}
     
    610623    RefPtr<WebVideoFullscreenControllerContext> protectedThis(this);
    611624    WebThreadRun([protectedThis, this] {
    612         if (m_model)
    613             m_model->playbackSessionModel().endScanning();
     625        if (m_playbackModel)
     626            m_playbackModel->endScanning();
    614627    });
    615628}
     
    620633    RefPtr<WebVideoFullscreenControllerContext> protectedThis(this);
    621634    WebThreadRun([protectedThis, this, index] {
    622         if (m_model)
    623             m_model->playbackSessionModel().selectAudioMediaOption(index);
     635        if (m_playbackModel)
     636            m_playbackModel->selectAudioMediaOption(index);
    624637    });
    625638}
     
    630643    RefPtr<WebVideoFullscreenControllerContext> protectedThis(this);
    631644    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
     650double WebVideoFullscreenControllerContext::duration() const
     651{
     652    ASSERT(isUIThread());
     653    return m_playbackModel ? m_playbackModel->duration() : 0;
     654}
     655
     656double WebVideoFullscreenControllerContext::currentTime() const
     657{
     658    ASSERT(isUIThread());
     659    return m_playbackModel ? m_playbackModel->currentTime() : 0;
     660}
     661
     662double WebVideoFullscreenControllerContext::bufferedTime() const
     663{
     664    ASSERT(isUIThread());
     665    return m_playbackModel ? m_playbackModel->bufferedTime() : 0;
     666}
     667
     668bool WebVideoFullscreenControllerContext::isPlaying() const
     669{
     670    ASSERT(isUIThread());
     671    return m_playbackModel ? m_playbackModel->isPlaying() : false;
     672}
     673
     674float WebVideoFullscreenControllerContext::playbackRate() const
     675{
     676    ASSERT(isUIThread());
     677    return m_playbackModel ? m_playbackModel->playbackRate() : 0;
     678}
     679
     680Ref<TimeRanges> WebVideoFullscreenControllerContext::seekableRanges() const
     681{
     682    ASSERT(isUIThread());
     683    return m_playbackModel ? m_playbackModel->seekableRanges() : TimeRanges::create();
     684}
     685
     686bool WebVideoFullscreenControllerContext::canPlayFastReverse() const
     687{
     688    ASSERT(isUIThread());
     689    return m_playbackModel ? m_playbackModel->canPlayFastReverse() : false;
     690}
     691
     692Vector<String> WebVideoFullscreenControllerContext::audioMediaSelectionOptions() const
     693{
     694    ASSERT(isUIThread());
     695    return m_playbackModel ? m_playbackModel->audioMediaSelectionOptions() : Vector<String>();
     696}
     697
     698uint64_t WebVideoFullscreenControllerContext::audioMediaSelectedIndex() const
     699{
     700    ASSERT(isUIThread());
     701    return m_playbackModel ? m_playbackModel->audioMediaSelectedIndex() : -1;
     702}
     703
     704Vector<String> WebVideoFullscreenControllerContext::legibleMediaSelectionOptions() const
     705{
     706    ASSERT(isUIThread());
     707    return m_playbackModel ? m_playbackModel->legibleMediaSelectionOptions() : Vector<String>();
     708}
     709
     710uint64_t WebVideoFullscreenControllerContext::legibleMediaSelectedIndex() const
     711{
     712    ASSERT(isUIThread());
     713    return m_playbackModel ? m_playbackModel->legibleMediaSelectedIndex() : -1;
     714}
     715
     716bool WebVideoFullscreenControllerContext::externalPlaybackEnabled() const
     717{
     718    ASSERT(isUIThread());
     719    return m_playbackModel ? m_playbackModel->externalPlaybackEnabled() : false;
     720}
     721
     722WebPlaybackSessionModel::ExternalPlaybackTargetType WebVideoFullscreenControllerContext::externalPlaybackTargetType() const
     723{
     724    ASSERT(isUIThread());
     725    return m_playbackModel ? m_playbackModel->externalPlaybackTargetType() : TargetTypeNone;
     726}
     727
     728String WebVideoFullscreenControllerContext::externalPlaybackLocalizedDeviceName() const
     729{
     730    ASSERT(isUIThread());
     731    return m_playbackModel ? m_playbackModel->externalPlaybackLocalizedDeviceName() : String();
     732}
     733
     734bool WebVideoFullscreenControllerContext::wirelessVideoPlaybackDisabled() const
     735{
     736    ASSERT(isUIThread());
     737    return m_playbackModel ? m_playbackModel->wirelessVideoPlaybackDisabled() : true;
    635738}
    636739
     
    642745    RetainPtr<UIView> viewRef = view;
    643746    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] {
    647763        ASSERT(isUIThread());
    648764
    649         Ref<WebPlaybackSessionInterfaceAVKit> sessionInterface = WebPlaybackSessionInterfaceAVKit::create();
     765        Ref<WebPlaybackSessionInterfaceAVKit> sessionInterface = WebPlaybackSessionInterfaceAVKit::create(*this);
    650766        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);
    655768        m_interface->setWebVideoFullscreenModel(this);
    656769        m_interface->setWebVideoFullscreenChangeObserver(this);
     
    658771        m_videoFullscreenView = adoptNS([[getUIViewClass() alloc] init]);
    659772       
    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);
    676774    });
    677775}
     
    693791    m_interface->requestHideAndExitFullscreen();
    694792}
    695 
    696 #pragma mark WebPlaybackSessionModel
    697 
    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 
    770793
    771794@implementation WebVideoFullscreenController {
  • trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.h

    r200490 r205365  
    3636#include "WebPlaybackSessionInterfaceAVKit.h"
    3737#include "WebVideoFullscreenInterface.h"
     38#include "WebVideoFullscreenModel.h"
    3839#include <functional>
    3940#include <objc/objc.h>
     
    5859namespace WebCore {
    5960class IntRect;
     61class FloatSize;
    6062class WebVideoFullscreenModel;
    6163class WebVideoFullscreenChangeObserver;
     
    6365class WEBCORE_EXPORT WebVideoFullscreenInterfaceAVKit final
    6466    : public WebVideoFullscreenInterface
    65     , public WebPlaybackSessionInterfaceAVKitClient
     67    , public WebVideoFullscreenModelClient
     68    , public WebPlaybackSessionModelClient
    6669    , public RefCounted<WebVideoFullscreenInterfaceAVKit> {
    6770
     
    7376    WebPlaybackSessionModel* webPlaybackSessionModel() const { return m_playbackSessionInterface->webPlaybackSessionModel(); }
    7477
    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
    8785    WEBCORE_EXPORT virtual void setupFullscreen(UIView&, const IntRect& initialRect, UIView *, HTMLMediaElementEnums::VideoFullscreenMode, bool allowsPictureInPicturePlayback);
    8886    WEBCORE_EXPORT virtual void enterFullscreen();
     
    128126    void enterFullscreenStandard();
    129127    void watchdogTimerFired();
    130     void externalPlaybackEnabledChanged(bool) final;
    131128    WebAVPlayerController *playerController() const;
    132129
  • trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm

    r204492 r205365  
    504504    WebAVPlayerController* playerController = this->playerController();
    505505    if (playerController && playerController.externalPlaybackActive)
    506         setExternalPlayback(false, TargetTypeNone, "");
     506        externalPlaybackChanged(false, WebPlaybackSessionModel::TargetTypeNone, "");
     507    if (m_videoFullscreenModel)
     508        m_videoFullscreenModel->removeClient(*this);
    507509}
    508510
     
    512514}
    513515
    514 void WebVideoFullscreenInterfaceAVKit::resetMediaState()
    515 {
    516     m_playbackSessionInterface->resetMediaState();
    517 }
    518 
    519516void WebVideoFullscreenInterfaceAVKit::setWebVideoFullscreenModel(WebVideoFullscreenModel* model)
    520517{
     518    if (m_videoFullscreenModel)
     519        m_videoFullscreenModel->removeClient(*this);
     520
    521521    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());
    522528}
    523529
     
    527533}
    528534
    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)
     535void WebVideoFullscreenInterfaceAVKit::hasVideoChanged(bool hasVideo)
     536{
     537    [playerController() setHasEnabledVideo:hasVideo];
     538}
     539
     540void WebVideoFullscreenInterfaceAVKit::videoDimensionsChanged(const FloatSize& videoDimensions)
    550541{
    551542    WebAVPlayerLayer *playerLayer = (WebAVPlayerLayer *)[m_playerLayerView playerLayer];
    552543
    553     [playerLayer setVideoDimensions:CGSizeMake(width, height)];
    554     [playerController() setHasEnabledVideo:hasVideo];
    555     [playerController() setContentDimensions:CGSizeMake(width, height)];
     544    [playerLayer setVideoDimensions:videoDimensions];
     545    [playerController() setContentDimensions:videoDimensions];
    556546    [m_playerLayerView setNeedsLayout];
    557547
     
    562552}
    563553
    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)
     554void WebVideoFullscreenInterfaceAVKit::externalPlaybackChanged(bool enabled, WebPlaybackSessionModel::ExternalPlaybackTargetType, const String&)
    590555{
    591556    [m_playerLayerView setHidden:enabled];
    592 }
    593 
    594 void WebVideoFullscreenInterfaceAVKit::setWirelessVideoPlaybackDisabled(bool disabled)
    595 {
    596     m_playbackSessionInterface->setWirelessVideoPlaybackDisabled(disabled);
    597 }
    598 
    599 bool WebVideoFullscreenInterfaceAVKit::wirelessVideoPlaybackDisabled() const
    600 {
    601     return m_playbackSessionInterface->wirelessVideoPlaybackDisabled();
    602557}
    603558
  • trunk/Source/WebCore/platform/mac/WebPlaybackSessionInterfaceMac.h

    r202908 r205365  
    3131#include "HTMLMediaElementEnums.h"
    3232#include "WebPlaybackSessionInterface.h"
     33#include "WebPlaybackSessionModel.h"
    3334#include <wtf/RefCounted.h>
    3435#include <wtf/RetainPtr.h>
     
    4142class WebPlaybackSessionModel;
    4243
    43 class WebPlaybackSessionInterfaceMacClient {
    44 public:
    45     virtual ~WebPlaybackSessionInterfaceMacClient() { }
    46 
    47     virtual void rateChanged(bool isPlaying, float playbackRate) = 0;
    48 };
    49 
    5044class WEBCORE_EXPORT WebPlaybackSessionInterfaceMac final
    5145    : public WebPlaybackSessionInterface
     46    , public WebPlaybackSessionModelClient
    5247    , public RefCounted<WebPlaybackSessionInterfaceMac> {
    5348public:
    54     static Ref<WebPlaybackSessionInterfaceMac> create()
    55     {
    56         return adoptRef(*new WebPlaybackSessionInterfaceMac());
    57     }
     49    static Ref<WebPlaybackSessionInterfaceMac> create(WebPlaybackSessionModel&);
    5850    virtual ~WebPlaybackSessionInterfaceMac();
    5951    WebPlaybackSessionModel* webPlaybackSessionModel() const { return m_playbackSessionModel; }
    60     WEBCORE_EXPORT void setWebPlaybackSessionModel(WebPlaybackSessionModel*);
    61     WebPlaybackSessionInterfaceMacClient* client() const { return m_client; }
    62     void setClient(WebPlaybackSessionInterfaceMacClient*);
    6352
     53    // WebPlaybackSessionInterface
    6454    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;
    7563    WEBCORE_EXPORT void invalidate();
    7664    WEBCORE_EXPORT void ensureControlsManager();
     
    7967
    8068private:
     69    WebPlaybackSessionInterfaceMac(WebPlaybackSessionModel&);
    8170    WebPlaybackSessionModel* m_playbackSessionModel { nullptr };
    82     WebPlaybackControlsManager *m_playbackControlsManager;
    83     WebPlaybackSessionInterfaceMacClient* m_client { nullptr };
     71    WebPlaybackControlsManager *m_playbackControlsManager  { nullptr };
    8472};
    8573
  • trunk/Source/WebCore/platform/mac/WebPlaybackSessionInterfaceMac.mm

    r202908 r205365  
    4646namespace WebCore {
    4747
    48 WebPlaybackSessionInterfaceMac::~WebPlaybackSessionInterfaceMac()
     48Ref<WebPlaybackSessionInterfaceMac> WebPlaybackSessionInterfaceMac::create(WebPlaybackSessionModel& model)
     49{
     50    auto interface = adoptRef(*new WebPlaybackSessionInterfaceMac(model));
     51    model.addClient(interface);
     52    return interface;
     53}
     54
     55WebPlaybackSessionInterfaceMac::WebPlaybackSessionInterfaceMac(WebPlaybackSessionModel& model)
     56    : m_playbackSessionModel(&model)
    4957{
    5058}
    5159
    52 void WebPlaybackSessionInterfaceMac::setWebPlaybackSessionModel(WebPlaybackSessionModel* model)
     60WebPlaybackSessionInterfaceMac::~WebPlaybackSessionInterfaceMac()
    5361{
    54     m_playbackSessionModel = model;
     62    invalidate();
    5563}
    5664
    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)
     65void WebPlaybackSessionInterfaceMac::durationChanged(double duration)
    6666{
    6767    WebPlaybackControlsManager* controlsManager = playBackControlsManager();
     
    7474}
    7575
    76 void WebPlaybackSessionInterfaceMac::setCurrentTime(double currentTime, double anchorTime)
     76void WebPlaybackSessionInterfaceMac::currentTimeChanged(double currentTime, double anchorTime)
    7777{
    7878    WebPlaybackControlsManager* controlsManager = playBackControlsManager();
     
    8585}
    8686
    87 void WebPlaybackSessionInterfaceMac::setRate(bool isPlaying, float playbackRate)
     87void WebPlaybackSessionInterfaceMac::rateChanged(bool isPlaying, float playbackRate)
    8888{
    8989    WebPlaybackControlsManager* controlsManager = playBackControlsManager();
    9090    [controlsManager setRate:isPlaying ? playbackRate : 0.];
    9191    [controlsManager setPlaying:isPlaying];
    92 
    93     if (m_client)
    94         m_client->rateChanged(isPlaying, playbackRate);
    9592}
    9693
     
    108105}
    109106
    110 void WebPlaybackSessionInterfaceMac::setSeekableRanges(const TimeRanges& timeRanges)
     107void WebPlaybackSessionInterfaceMac::seekableRangesChanged(const TimeRanges& timeRanges)
    111108{
    112     WebPlaybackControlsManager* controlsManager = playBackControlsManager();
    113     [controlsManager setSeekableTimeRanges:timeRangesToArray(timeRanges).get()];
     109    [playBackControlsManager() setSeekableTimeRanges:timeRangesToArray(timeRanges).get()];
    114110}
    115111
    116 void WebPlaybackSessionInterfaceMac::setAudioMediaSelectionOptions(const Vector<WTF::String>& options, uint64_t selectedIndex)
     112void WebPlaybackSessionInterfaceMac::audioMediaSelectionOptionsChanged(const Vector<WTF::String>& options, uint64_t selectedIndex)
    117113{
    118     WebPlaybackControlsManager* controlsManager = playBackControlsManager();
    119     [controlsManager setAudioMediaSelectionOptions:options withSelectedIndex:static_cast<NSUInteger>(selectedIndex)];
     114    [playBackControlsManager() setAudioMediaSelectionOptions:options withSelectedIndex:static_cast<NSUInteger>(selectedIndex)];
    120115}
    121116
    122 void WebPlaybackSessionInterfaceMac::setLegibleMediaSelectionOptions(const Vector<WTF::String>& options, uint64_t selectedIndex)
     117void WebPlaybackSessionInterfaceMac::legibleMediaSelectionOptionsChanged(const Vector<WTF::String>& options, uint64_t selectedIndex)
    123118{
    124     WebPlaybackControlsManager* controlsManager = playBackControlsManager();
    125     [controlsManager setLegibleMediaSelectionOptions:options withSelectedIndex:static_cast<NSUInteger>(selectedIndex)];
     119    [playBackControlsManager() setLegibleMediaSelectionOptions:options withSelectedIndex:static_cast<NSUInteger>(selectedIndex)];
    126120}
    127121
    128122void WebPlaybackSessionInterfaceMac::invalidate()
    129123{
     124    if (!m_playbackSessionModel)
     125        return;
     126
     127    m_playbackSessionModel->removeClient(*this);
     128    m_playbackSessionModel = nullptr;
    130129}
    131130
  • trunk/Source/WebCore/platform/mac/WebVideoFullscreenInterfaceMac.h

    r202274 r205365  
    3131#include "HTMLMediaElementEnums.h"
    3232#include "WebPlaybackSessionInterfaceMac.h"
     33#include "WebPlaybackSessionModel.h"
    3334#include "WebVideoFullscreenInterface.h"
     35#include "WebVideoFullscreenModel.h"
    3436#include <wtf/RefCounted.h>
    3537#include <wtf/RetainPtr.h>
     
    4143namespace WebCore {
    4244class IntRect;
     45class FloatSize;
    4346class WebPlaybackSessionInterfaceMac;
    4447class WebVideoFullscreenChangeObserver;
    45 class WebVideoFullscreenModel;
    4648
    4749class WEBCORE_EXPORT WebVideoFullscreenInterfaceMac
    4850    : public WebVideoFullscreenInterface
    49     , private WebPlaybackSessionInterfaceMacClient
     51    , public WebVideoFullscreenModelClient
     52    , private WebPlaybackSessionModelClient
    5053    , public RefCounted<WebVideoFullscreenInterfaceMac> {
    5154
     
    6265    WEBCORE_EXPORT void setWebVideoFullscreenChangeObserver(WebVideoFullscreenChangeObserver*);
    6366
    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;
    7674
    7775    WEBCORE_EXPORT void setupFullscreen(NSView& layerHostedView, const IntRect& initialRect, NSWindow *parentWindow, HTMLMediaElementEnums::VideoFullscreenMode, bool allowsPictureInPicturePlayback);
     
    9694    void applicationDidBecomeActive() { }
    9795
    98     void rateChanged(bool isPlaying, float playbackRate) override;
    99 
    10096    WEBCORE_EXPORT WebVideoFullscreenInterfaceMacObjC *videoFullscreenInterfaceObjC();
    10197
  • trunk/Source/WebCore/platform/mac/WebVideoFullscreenInterfaceMac.mm

    r204088 r205365  
    352352    : m_playbackSessionInterface(playbackSessionInterface)
    353353{
    354     m_playbackSessionInterface->setClient(this);
     354    ASSERT(m_playbackSessionInterface->webPlaybackSessionModel());
     355    m_playbackSessionInterface->webPlaybackSessionModel()->addClient(*this);
    355356}
    356357
    357358WebVideoFullscreenInterfaceMac::~WebVideoFullscreenInterfaceMac()
    358359{
    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);
    361364}
    362365
    363366void WebVideoFullscreenInterfaceMac::setWebVideoFullscreenModel(WebVideoFullscreenModel* model)
    364367{
     368    if (m_videoFullscreenModel)
     369        m_videoFullscreenModel->removeClient(*this);
    365370    m_videoFullscreenModel = model;
     371    if (m_videoFullscreenModel)
     372        m_videoFullscreenModel->addClient(*this);
    366373}
    367374
     
    393400}
    394401
    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 
    410402void WebVideoFullscreenInterfaceMac::rateChanged(bool isPlaying, float playbackRate)
    411403{
    412404    [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);
    428405}
    429406
     
    546523}
    547524
    548 void WebVideoFullscreenInterfaceMac::setExternalPlayback(bool enabled, ExternalPlaybackTargetType, String)
    549 {
    550     LOG(Fullscreen, "WebVideoFullscreenInterfaceMac::setExternalPlayback(%p), enabled:%s", this, boolString(enabled));
     525void WebVideoFullscreenInterfaceMac::externalPlaybackChanged(bool enabled, WebPlaybackSessionModel::ExternalPlaybackTargetType, const String&)
     526{
     527    LOG(Fullscreen, "WebVideoFullscreenInterfaceMac::externalPlaybackChanged(%p), enabled:%s", this, boolString(enabled));
    551528
    552529    if (enabled && m_mode == HTMLMediaElementEnums::VideoFullscreenModePictureInPicture)
     
    554531}
    555532
    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) {
     533void WebVideoFullscreenInterfaceMac::hasVideoChanged(bool hasVideo)
     534{
     535    LOG(Fullscreen, "WebVideoFullscreenInterfaceMac::hasVideoChanged(%p):%s", this, boolString(hasVideo));
     536
     537    if (!hasVideo)
    561538        exitFullscreenWithoutAnimationToMode(HTMLMediaElementEnums::VideoFullscreenModeNone);
    562         return;
    563     }
     539}
     540
     541void WebVideoFullscreenInterfaceMac::videoDimensionsChanged(const FloatSize& videoDimensions)
     542{
     543    LOG(Fullscreen, "WebVideoFullscreenInterfaceMac::videoDimensionsChanged(%p), width:%.0f, height:%.0f", this, videoDimensions.width(), videoDimensions.height());
    564544
    565545    // 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];
    568548}
    569549
  • trunk/Source/WebKit/mac/ChangeLog

    r205333 r205365  
     12016-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
    1142016-09-01  Dan Bernstein  <mitz@apple.com>
    215
  • trunk/Source/WebKit/mac/WebView/WebView.mm

    r205282 r205365  
    86378637
    86388638    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
    86438641    [self updateWebViewAdditions];
    86448642}
     
    86508648
    86518649    _private->playbackSessionModel->setMediaElement(nullptr);
    8652     _private->playbackSessionModel->setWebPlaybackSessionInterface(nullptr);
    8653     _private->playbackSessionInterface->setWebPlaybackSessionModel(nullptr);
     8650    _private->playbackSessionInterface->invalidate();
    86548651
    86558652    _private->playbackSessionModel = nullptr;
  • trunk/Source/WebKit2/ChangeLog

    r205342 r205365  
     12016-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
    11162016-09-02  Zan Dobersek  <zdobersek@igalia.com>
    2117
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm

    r204728 r205365  
    545545
    546546    _navigationState = std::make_unique<WebKit::NavigationState>(self);
    547     _page->setNavigationClient(_navigationState->createNavigationClient());
    548 
    549547    _uiDelegate = std::make_unique<WebKit::UIDelegate>(self);
    550548    _page->setFindClient(std::make_unique<WebKit::FindClient>(self));
  • trunk/Source/WebKit2/UIProcess/Cocoa/WebPlaybackSessionManagerProxy.h

    r204668 r205365  
    3434#include <WebCore/WebPlaybackSessionModel.h>
    3535#include <wtf/HashMap.h>
     36#include <wtf/HashSet.h>
    3637#include <wtf/RefCounted.h>
    3738#include <wtf/RefPtr.h>
     
    6465    void invalidate() { m_manager = nullptr; }
    6566
    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);
    7981
    8082private:
     
    113115    uint64_t legibleMediaSelectedIndex() const final { return m_legibleMediaSelectedIndex; }
    114116    bool externalPlaybackEnabled() const final { return m_externalPlaybackEnabled; }
     117    WebPlaybackSessionModel::ExternalPlaybackTargetType externalPlaybackTargetType() const final { return m_externalPlaybackTargetType; }
     118    String externalPlaybackLocalizedDeviceName() const final { return m_externalPlaybackLocalizedDeviceName; }
    115119    bool wirelessVideoPlaybackDisabled() const final { return m_wirelessVideoPlaybackDisabled; }
    116120
    117121    WebPlaybackSessionManagerProxy* m_manager;
    118122    uint64_t m_contextId;
     123    HashSet<WebCore::WebPlaybackSessionModelClient*> m_clients;
    119124    double m_duration { 0 };
    120125    double m_currentTime { 0 };
     
    129134    uint64_t m_legibleMediaSelectedIndex { 0 };
    130135    bool m_externalPlaybackEnabled { false };
     136    WebPlaybackSessionModel::ExternalPlaybackTargetType m_externalPlaybackTargetType { WebPlaybackSessionModel::TargetTypeNone };
     137    String m_externalPlaybackLocalizedDeviceName;
    131138    bool m_wirelessVideoPlaybackDisabled { false };
    132139};
  • trunk/Source/WebKit2/UIProcess/Cocoa/WebPlaybackSessionManagerProxy.mm

    r200490 r205365  
    4141#pragma mark - WebPlaybackSessionModelContext
    4242
     43void WebPlaybackSessionModelContext::addClient(WebPlaybackSessionModelClient& client)
     44{
     45    ASSERT(!m_clients.contains(&client));
     46    m_clients.add(&client);
     47}
     48
     49void WebPlaybackSessionModelContext::removeClient(WebPlaybackSessionModelClient& client)
     50{
     51    ASSERT(m_clients.contains(&client));
     52    m_clients.remove(&client);
     53}
     54
    4355void WebPlaybackSessionModelContext::play()
    4456{
     
    111123    if (m_manager)
    112124        m_manager->selectLegibleMediaOption(m_contextId, optionId);
     125}
     126
     127void WebPlaybackSessionModelContext::setDuration(double duration)
     128{
     129    m_duration = duration;
     130    for (auto* client : m_clients)
     131        client->durationChanged(duration);
     132}
     133
     134void 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
     143void WebPlaybackSessionModelContext::setBufferedTime(double bufferedTime)
     144{
     145    m_bufferedTime = bufferedTime;
     146    for (auto* client : m_clients)
     147        client->bufferedTimeChanged(bufferedTime);
     148}
     149
     150void 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
     158void WebPlaybackSessionModelContext::setSeekableRanges(WebCore::TimeRanges& seekableRanges)
     159{
     160    m_seekableRanges = seekableRanges;
     161    for (auto* client : m_clients)
     162        client->seekableRangesChanged(seekableRanges);
     163}
     164
     165void WebPlaybackSessionModelContext::setCanPlayFastReverse(bool canPlayFastReverse)
     166{
     167    m_canPlayFastReverse = canPlayFastReverse;
     168    for (auto* client : m_clients)
     169        client->canPlayFastReverseChanged(canPlayFastReverse);
     170}
     171
     172void 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
     180void 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
     189void 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
     199void WebPlaybackSessionModelContext::setWirelessVideoPlaybackDisabled(bool wirelessVideoPlaybackDisabled)
     200{
     201    m_wirelessVideoPlaybackDisabled = wirelessVideoPlaybackDisabled;
     202    for (auto* client : m_clients)
     203        client->wirelessVideoPlaybackDisabledChanged(wirelessVideoPlaybackDisabled);
    113204}
    114205
     
    153244{
    154245    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);
    158247
    159248    return std::make_tuple(WTFMove(model), WTFMove(interface));
     
    195284    if (clientCount <= 0) {
    196285        m_clientCounts.remove(contextId);
     286
     287        RefPtr<WebPlaybackSessionModelContext> model;
     288        RefPtr<PlatformWebPlaybackSessionInterface> interface;
     289        std::tie(model, interface) = ensureModelAndInterface(contextId);
     290        interface->invalidate();
    197291        m_contextMap.remove(contextId);
    198292        return;
     
    242336void WebPlaybackSessionManagerProxy::setCurrentTime(uint64_t contextId, double currentTime, double hostTime)
    243337{
    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);
    249339}
    250340
    251341void WebPlaybackSessionManagerProxy::setBufferedTime(uint64_t contextId, double bufferedTime)
    252342{
    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);
    258344}
    259345
     
    268354    }
    269355
    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);
    275357}
    276358
    277359void WebPlaybackSessionManagerProxy::setCanPlayFastReverse(uint64_t contextId, bool value)
    278360{
    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);
    284362}
    285363
    286364void WebPlaybackSessionManagerProxy::setAudioMediaSelectionOptions(uint64_t contextId, Vector<String> options, uint64_t selectedIndex)
    287365{
    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);
    294367}
    295368
    296369void WebPlaybackSessionManagerProxy::setLegibleMediaSelectionOptions(uint64_t contextId, Vector<String> options, uint64_t selectedIndex)
    297370{
    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);
    304372}
    305373
    306374void WebPlaybackSessionManagerProxy::setExternalPlaybackProperties(uint64_t contextId, bool enabled, uint32_t targetType, String localizedDeviceName)
    307375{
    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);
    316380}
    317381
    318382void WebPlaybackSessionManagerProxy::setWirelessVideoPlaybackDisabled(uint64_t contextId, bool disabled)
    319383{
    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);
    325385}
    326386
    327387void WebPlaybackSessionManagerProxy::setDuration(uint64_t contextId, double duration)
    328388{
    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);
    334390}
    335391
    336392void WebPlaybackSessionManagerProxy::setRate(uint64_t contextId, bool isPlaying, double rate)
    337393{
    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);
    344395}
    345396
  • trunk/Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.h

    r204668 r205365  
    3535#include <WebCore/WebVideoFullscreenModel.h>
    3636#include <wtf/HashMap.h>
     37#include <wtf/HashSet.h>
    3738#include <wtf/RefCounted.h>
    3839#include <wtf/RefPtr.h>
     
    5758class WebVideoFullscreenManagerProxy;
    5859
    59 class WebVideoFullscreenModelContext final: public RefCounted<WebVideoFullscreenModelContext>, public WebCore::WebVideoFullscreenModel, public WebCore::WebVideoFullscreenChangeObserver  {
     60class WebVideoFullscreenModelContext final
     61    : public RefCounted<WebVideoFullscreenModelContext>
     62    , public WebCore::WebVideoFullscreenModel
     63    , public WebCore::WebVideoFullscreenChangeObserver  {
    6064public:
    6165    static Ref<WebVideoFullscreenModelContext> create(WebVideoFullscreenManagerProxy& manager, WebPlaybackSessionModelContext& playbackSessionModel, uint64_t contextId)
     
    7478
    7579    // WebVideoFullscreenModel
     80    void addClient(WebCore::WebVideoFullscreenModelClient&) override;
     81    void removeClient(WebCore::WebVideoFullscreenModelClient&) override;
    7682    void requestFullscreenMode(WebCore::HTMLMediaElementEnums::VideoFullscreenMode) override;
    7783    void setVideoLayerFrame(WebCore::FloatRect) override;
     
    7985    void fullscreenModeChanged(WebCore::HTMLMediaElementEnums::VideoFullscreenMode) override;
    8086    bool isVisible() const override;
     87    bool hasVideo() const override { return m_hasVideo; }
     88    WebCore::FloatSize videoDimensions() const override { return m_videoDimensions; }
    8189
    8290    // WebVideoFullscreenChangeObserver
     
    9199    uint64_t m_contextId;
    92100    RetainPtr<PlatformView *> m_layerHostView;
     101    HashSet<WebCore::WebVideoFullscreenModelClient*> m_clients;
     102    WebCore::FloatSize m_videoDimensions;
     103    bool m_hasVideo { false };
    93104};
    94105
     
    126137    // Messages from WebVideoFullscreenManager
    127138    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&);
    129141    void enterFullscreen(uint64_t contextId);
    130142    void exitFullscreen(uint64_t contextId, WebCore::IntRect finalRect);
  • trunk/Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.messages.in

    r199919 r205365  
    2323#if (PLATFORM(IOS) && HAVE(AVKIT)) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
    2424messages -> 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)
    2627    SetupFullscreenWithID(uint64_t contextId, uint32_t videoLayerID, WebCore::IntRect initialRect, float hostingScaleFactor, WebCore::HTMLMediaElementEnums::VideoFullscreenMode videoFullscreenMode, bool allowsPictureInPicture)
    2728    EnterFullscreen(uint64_t contextId)
  • trunk/Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.mm

    r200595 r205365  
    125125}
    126126
     127void WebVideoFullscreenModelContext::addClient(WebVideoFullscreenModelClient& client)
     128{
     129    ASSERT(!m_clients.contains(&client));
     130    m_clients.add(&client);
     131}
     132
     133void WebVideoFullscreenModelContext::removeClient(WebVideoFullscreenModelClient& client)
     134{
     135    ASSERT(m_clients.contains(&client));
     136    m_clients.remove(&client);
     137}
     138
    127139void WebVideoFullscreenModelContext::requestFullscreenMode(HTMLMediaElementEnums::VideoFullscreenMode mode)
    128140{
     
    359371}
    360372
    361 void WebVideoFullscreenManagerProxy::setVideoDimensions(uint64_t contextId, bool hasVideo, unsigned width, unsigned height)
    362 {
    363     ensureInterface(contextId).setVideoDimensions(hasVideo, width, height);
     373void WebVideoFullscreenManagerProxy::setHasVideo(uint64_t contextId, bool hasVideo)
     374{
     375    ensureInterface(contextId).hasVideoChanged(hasVideo);
     376}
     377
     378void WebVideoFullscreenManagerProxy::setVideoDimensions(uint64_t contextId, const FloatSize& videoDimensions)
     379{
     380    ensureInterface(contextId).videoDimensionsChanged(videoDimensions);
    364381}
    365382
  • trunk/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.h

    r204668 r205365  
    5555class WebPlaybackSessionManager;
    5656
    57 class WebPlaybackSessionInterfaceContext final : public RefCounted<WebPlaybackSessionInterfaceContext>, public WebCore::WebPlaybackSessionInterface {
     57class WebPlaybackSessionInterfaceContext final
     58    : public RefCounted<WebPlaybackSessionInterfaceContext>
     59    , public WebCore::WebPlaybackSessionInterface
     60    , public WebCore::WebPlaybackSessionModelClient {
    5861public:
    5962    static Ref<WebPlaybackSessionInterfaceContext> create(WebPlaybackSessionManager& manager, uint64_t contextId)
     
    7073    // WebPlaybackSessionInterface
    7174    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;
    8287
    8388    WebPlaybackSessionInterfaceContext(WebPlaybackSessionManager&, uint64_t contextId);
     
    115120    // Interface to WebPlaybackSessionInterfaceContext
    116121    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 setSeekableRanges(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);
    127132
    128133    // Messages from WebPlaybackSessionManagerProxy
  • trunk/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.mm

    r203338 r205365  
    7373}
    7474
    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::setSeekableRanges(const WebCore::TimeRanges& ranges)
    100 {
    101     if (m_manager)
    102         m_manager->setSeekableRanges(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::String localizedDeviceName)
    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);
     75void WebPlaybackSessionInterfaceContext::durationChanged(double duration)
     76{
     77    if (m_manager)
     78        m_manager->durationChanged(m_contextId, duration);
     79}
     80
     81void WebPlaybackSessionInterfaceContext::currentTimeChanged(double currentTime, double anchorTime)
     82{
     83    if (m_manager)
     84        m_manager->currentTimeChanged(m_contextId, currentTime, anchorTime);
     85}
     86
     87void WebPlaybackSessionInterfaceContext::bufferedTimeChanged(double bufferedTime)
     88{
     89    if (m_manager)
     90        m_manager->bufferedTimeChanged(m_contextId, bufferedTime);
     91}
     92
     93void WebPlaybackSessionInterfaceContext::rateChanged(bool isPlaying, float playbackRate)
     94{
     95    if (m_manager)
     96        m_manager->rateChanged(m_contextId, isPlaying, playbackRate);
     97}
     98
     99void WebPlaybackSessionInterfaceContext::seekableRangesChanged(const WebCore::TimeRanges& ranges)
     100{
     101    if (m_manager)
     102        m_manager->seekableRangesChanged(m_contextId, ranges);
     103}
     104
     105void WebPlaybackSessionInterfaceContext::canPlayFastReverseChanged(bool value)
     106{
     107    if (m_manager)
     108        m_manager->canPlayFastReverseChanged(m_contextId, value);
     109}
     110
     111void WebPlaybackSessionInterfaceContext::audioMediaSelectionOptionsChanged(const Vector<String>& options, uint64_t selectedIndex)
     112{
     113    if (m_manager)
     114        m_manager->audioMediaSelectionOptionsChanged(m_contextId, options, selectedIndex);
     115}
     116
     117void WebPlaybackSessionInterfaceContext::legibleMediaSelectionOptionsChanged(const Vector<String>& options, uint64_t selectedIndex)
     118{
     119    if (m_manager)
     120        m_manager->legibleMediaSelectionOptionsChanged(m_contextId, options, selectedIndex);
     121}
     122
     123void 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
     129void WebPlaybackSessionInterfaceContext::wirelessVideoPlaybackDisabledChanged(bool disabled)
     130{
     131    if (m_manager)
     132        m_manager->wirelessVideoPlaybackDisabledChanged(m_contextId, disabled);
    133133}
    134134
     
    152152        RefPtr<WebPlaybackSessionInterfaceContext> interface;
    153153        std::tie(model, interface) = tuple;
    154 
    155         model->setWebPlaybackSessionInterface(nullptr);
     154        model->removeClient(*interface);
    156155        model->setMediaElement(nullptr);
    157156
     
    170169    RefPtr<WebPlaybackSessionModelMediaElement> model = WebPlaybackSessionModelMediaElement::create();
    171170    RefPtr<WebPlaybackSessionInterfaceContext> interface = WebPlaybackSessionInterfaceContext::create(*this, contextId);
    172 
    173     model->setWebPlaybackSessionInterface(interface.get());
     171    model->addClient(*interface);
    174172
    175173    return std::make_tuple(WTFMove(model), WTFMove(interface));
     
    202200    RefPtr<HTMLMediaElement> mediaElement = model->mediaElement();
    203201    model->setMediaElement(nullptr);
    204     model->setWebPlaybackSessionInterface(nullptr);
     202    model->removeClient(*interface);
    205203    interface->invalidate();
    206204    m_mediaElements.remove(mediaElement.get());
     
    285283}
    286284
    287 void WebPlaybackSessionManager::setDuration(uint64_t contextId, double duration)
     285void WebPlaybackSessionManager::durationChanged(uint64_t contextId, double duration)
    288286{
    289287    m_page->send(Messages::WebPlaybackSessionManagerProxy::SetDuration(contextId, duration), m_page->pageID());
    290288}
    291289
    292 void WebPlaybackSessionManager::setCurrentTime(uint64_t contextId, double currentTime, double anchorTime)
     290void WebPlaybackSessionManager::currentTimeChanged(uint64_t contextId, double currentTime, double anchorTime)
    293291{
    294292    m_page->send(Messages::WebPlaybackSessionManagerProxy::SetCurrentTime(contextId, currentTime, anchorTime), m_page->pageID());
    295293}
    296294
    297 void WebPlaybackSessionManager::setBufferedTime(uint64_t contextId, double bufferedTime)
     295void WebPlaybackSessionManager::bufferedTimeChanged(uint64_t contextId, double bufferedTime)
    298296{
    299297    m_page->send(Messages::WebPlaybackSessionManagerProxy::SetBufferedTime(contextId, bufferedTime), m_page->pageID());
    300298}
    301299
    302 void WebPlaybackSessionManager::setRate(uint64_t contextId, bool isPlaying, float playbackRate)
     300void WebPlaybackSessionManager::rateChanged(uint64_t contextId, bool isPlaying, float playbackRate)
    303301{
    304302    m_page->send(Messages::WebPlaybackSessionManagerProxy::SetRate(contextId, isPlaying, playbackRate), m_page->pageID());
    305303}
    306304
    307 void WebPlaybackSessionManager::setSeekableRanges(uint64_t contextId, const WebCore::TimeRanges& timeRanges)
     305void WebPlaybackSessionManager::seekableRangesChanged(uint64_t contextId, const WebCore::TimeRanges& timeRanges)
    308306{
    309307    Vector<std::pair<double, double>> rangesVector;
     
    319317}
    320318
    321 void WebPlaybackSessionManager::setCanPlayFastReverse(uint64_t contextId, bool value)
     319void WebPlaybackSessionManager::canPlayFastReverseChanged(uint64_t contextId, bool value)
    322320{
    323321    m_page->send(Messages::WebPlaybackSessionManagerProxy::SetCanPlayFastReverse(contextId, value), m_page->pageID());
    324322}
    325323
    326 void WebPlaybackSessionManager::setAudioMediaSelectionOptions(uint64_t contextId, const Vector<String>& options, uint64_t selectedIndex)
     324void WebPlaybackSessionManager::audioMediaSelectionOptionsChanged(uint64_t contextId, const Vector<String>& options, uint64_t selectedIndex)
    327325{
    328326    m_page->send(Messages::WebPlaybackSessionManagerProxy::SetAudioMediaSelectionOptions(contextId, options, selectedIndex), m_page->pageID());
    329327}
    330328
    331 void WebPlaybackSessionManager::setLegibleMediaSelectionOptions(uint64_t contextId, const Vector<String>& options, uint64_t selectedIndex)
     329void WebPlaybackSessionManager::legibleMediaSelectionOptionsChanged(uint64_t contextId, const Vector<String>& options, uint64_t selectedIndex)
    332330{
    333331    m_page->send(Messages::WebPlaybackSessionManagerProxy::SetLegibleMediaSelectionOptions(contextId, options, selectedIndex), m_page->pageID());
    334332}
    335333
    336 void WebPlaybackSessionManager::setExternalPlayback(uint64_t contextId, bool enabled, WebPlaybackSessionInterface::ExternalPlaybackTargetType targetType, String localizedDeviceName)
     334void WebPlaybackSessionManager::externalPlaybackChanged(uint64_t contextId, bool enabled, WebPlaybackSessionModel::ExternalPlaybackTargetType targetType, String localizedDeviceName)
    337335{
    338336    m_page->send(Messages::WebPlaybackSessionManagerProxy::SetExternalPlaybackProperties(contextId, enabled, static_cast<uint32_t>(targetType), localizedDeviceName), m_page->pageID());
    339337}
    340338
    341 void WebPlaybackSessionManager::setWirelessVideoPlaybackDisabled(uint64_t contextId, bool disabled)
     339void WebPlaybackSessionManager::wirelessVideoPlaybackDisabledChanged(uint64_t contextId, bool disabled)
    342340{
    343341    m_page->send(Messages::WebPlaybackSessionManagerProxy::SetWirelessVideoPlaybackDisabled(contextId, disabled));
  • trunk/Source/WebKit2/WebProcess/cocoa/WebVideoFullscreenManager.h

    r204668 r205365  
    4646
    4747namespace WebCore {
     48class FloatSize;
    4849class Node;
    4950}
     
    5758class WebVideoFullscreenManager;
    5859
    59 class WebVideoFullscreenInterfaceContext : public RefCounted<WebVideoFullscreenInterfaceContext>, public WebCore::WebVideoFullscreenInterface {
     60class WebVideoFullscreenInterfaceContext
     61    : public RefCounted<WebVideoFullscreenInterfaceContext>
     62    , public WebCore::WebVideoFullscreenInterface
     63    , public WebCore::WebVideoFullscreenModelClient {
    6064public:
    61     static Ref<WebVideoFullscreenInterfaceContext> create(WebVideoFullscreenManager& manager, WebPlaybackSessionInterfaceContext& playbackSessionInterface, uint64_t contextId)
     65    static Ref<WebVideoFullscreenInterfaceContext> create(WebVideoFullscreenManager& manager, uint64_t contextId)
    6266    {
    63         return adoptRef(*new WebVideoFullscreenInterfaceContext(manager, playbackSessionInterface, contextId));
     67        return adoptRef(*new WebVideoFullscreenInterfaceContext(manager, contextId));
    6468    }
    6569    virtual ~WebVideoFullscreenInterfaceContext();
     
    8387
    8488private:
    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;
    9792
    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);
    10294
    10395    WebVideoFullscreenManager* m_manager;
    104     Ref<WebPlaybackSessionInterfaceContext> m_playbackSessionInterface;
    10596    uint64_t m_contextId;
    10697    std::unique_ptr<LayerHostingContext> m_layerHostingContext;
     
    139130
    140131    // 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&);
    142134
    143135    // Messages from WebVideoFullscreenManagerProxy
  • trunk/Source/WebKit2/WebProcess/cocoa/WebVideoFullscreenManager.mm

    r202274 r205365  
    6767#pragma mark - WebVideoFullscreenInterfaceContext
    6868
    69 WebVideoFullscreenInterfaceContext::WebVideoFullscreenInterfaceContext(WebVideoFullscreenManager& manager, WebPlaybackSessionInterfaceContext& playbackSessionInterface, uint64_t contextId)
     69WebVideoFullscreenInterfaceContext::WebVideoFullscreenInterfaceContext(WebVideoFullscreenManager& manager, uint64_t contextId)
    7070    : m_manager(&manager)
    71     , m_playbackSessionInterface(playbackSessionInterface)
    7271    , m_contextId(contextId)
    7372{
     
    8382}
    8483
    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)
     84void WebVideoFullscreenInterfaceContext::hasVideoChanged(bool hasVideo)
    11185{
    11286    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
     90void WebVideoFullscreenInterfaceContext::videoDimensionsChanged(const FloatSize& videoDimensions)
     91{
     92    if (m_manager)
     93        m_manager->videoDimensionsChanged(m_contextId, videoDimensions);
    14494}
    14595
     
    165115        std::tie(model, interface) = tuple;
    166116
    167         model->setWebVideoFullscreenInterface(nullptr);
    168117        model->setVideoElement(nullptr);
     118        model->removeClient(*interface);
    169119
    170120        interface->invalidate();
     
    180130WebVideoFullscreenManager::ModelInterfaceTuple WebVideoFullscreenManager::createModelAndInterface(uint64_t contextId)
    181131{
    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);
    186134    m_playbackSessionManager->addClientForContext(contextId);
    187135
    188136    interface->setLayerHostingContext(LayerHostingContext::createForExternalHostingProcess());
    189     model->setWebVideoFullscreenInterface(interface.get());
     137    model->addClient(*interface);
    190138
    191139    return std::make_tuple(WTFMove(model), WTFMove(interface));
     
    220168    RefPtr<HTMLVideoElement> videoElement = model->videoElement();
    221169    model->setVideoElement(nullptr);
    222     model->setWebVideoFullscreenInterface(nullptr);
     170    model->removeClient(*interface);
    223171    interface->invalidate();
    224172    m_videoElements.remove(videoElement.get());
     
    332280#pragma mark Interface to WebVideoFullscreenInterfaceContext:
    333281
    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());
     282void WebVideoFullscreenManager::hasVideoChanged(uint64_t contextId, bool hasVideo)
     283{
     284    m_page->send(Messages::WebVideoFullscreenManagerProxy::SetHasVideo(contextId, hasVideo), m_page->pageID());
     285}
     286
     287void WebVideoFullscreenManager::videoDimensionsChanged(uint64_t contextId, const FloatSize& videoDimensions)
     288{
     289    m_page->send(Messages::WebVideoFullscreenManagerProxy::SetVideoDimensions(contextId, videoDimensions), m_page->pageID());
    337290}
    338291
Note: See TracChangeset for help on using the changeset viewer.