[iOS] Refactor AirPlay monitoring code
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Oct 2014 00:22:49 +0000 (00:22 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Oct 2014 00:22:49 +0000 (00:22 +0000)
commit289dd1c2e0ab08d38d865815b6ec1a8c2001a512
treed6a35cc48575e06326fad1a872bc8721eacfbadf
parent77ad754549c9922f3e0ebd97f8e6a3f53e562bce
[iOS] Refactor AirPlay monitoring code
https://bugs.webkit.org/show_bug.cgi?id=137645
<rdar://problem/18444817>

Reviewed by Jer Noble.

Refactor AirPlay route change monitoring code:
+ Have MediaSessionManager register/unregister for route changes depending on the state of
    all sessions so it does the right thing when there is more than one media element.
+ Make HTMLMediaElement unregister with MediaSession as soon as the media player is cleared
    because there can be no wireless playback without a player.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::~HTMLMediaElement): Call mediaSession->setHasPlaybackTargetAvailabilityListeners
    when there are target availability changed listeners.
(WebCore::HTMLMediaElement::clearMediaPlayer): Ditto.
(WebCore::HTMLMediaElement::wirelessRoutesAvailableDidChange): New, media session client method.
* html/HTMLMediaElement.h:

* html/HTMLMediaSession.cpp:
(WebCore::HTMLMediaSession::HTMLMediaSession): Initialize m_hasPlaybackTargetAvailabilityListeners.
(WebCore::HTMLMediaSession::setHasPlaybackTargetAvailabilityListeners): Remember whether or not
    the client has a target availability listener and tell the media session manager to reconfigure
    itself instead of telling it to start or stop listening for route changes so it does the
    right thing when there is more than one media element.
* html/HTMLMediaSession.h:
(WebCore::HTMLMediaSession::requiresPlaybackTargetRouteMonitoring): Return true when the client
    has a target availability listener, false otherwise.

* platform/audio/MediaSession.cpp:
(WebCore::MediaSession::wirelessRoutesAvailableDidChange): Inform the client that routes have changed.
* platform/audio/MediaSession.h:
(WebCore::MediaSession::requiresPlaybackTargetRouteMonitoring):
(WebCore::MediaSessionClient::wirelessRoutesAvailableDidChange):

* platform/audio/MediaSessionManager.cpp:
(WebCore::MediaSessionManager::wirelessRoutesAvailableChanged): Implement it.
* platform/audio/MediaSessionManager.h:
(WebCore::MediaSessionManager::configureWireLessTargetMonitoring):
(WebCore::MediaSessionManager::hasWirelessTargetsAvailable):
(WebCore::MediaSessionManager::sessions):
(WebCore::MediaSessionManager::startMonitoringAirPlayRoutes): Deleted.
(WebCore::MediaSessionManager::stopMonitoringAirPlayRoutes): Deleted.

* platform/audio/ios/MediaSessionManagerIOS.h:
* platform/audio/ios/MediaSessionManagerIOS.mm:
(WebCore::MediaSessionManageriOS::configureWireLessTargetMonitoring): Start or stop monitoring
    for route changes depending on client state.
(WebCore::MediaSessionManageriOS::startMonitoringAirPlayRoutes): Deleted.
(WebCore::MediaSessionManageriOS::stopMonitoringAirPlayRoutes): Deleted.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@174666 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/html/HTMLMediaSession.cpp
Source/WebCore/html/HTMLMediaSession.h
Source/WebCore/platform/audio/MediaSession.cpp
Source/WebCore/platform/audio/MediaSession.h
Source/WebCore/platform/audio/MediaSessionManager.cpp
Source/WebCore/platform/audio/MediaSessionManager.h
Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h
Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm