Title: [184966] trunk/Source/WebCore
Revision
184966
Author
commit-qu...@webkit.org
Date
2015-05-28 16:03:34 -0700 (Thu, 28 May 2015)

Log Message

Rename HTMLMediaSession to MediaElementSession to reserve "media session" for the Media Session API.
https://bugs.webkit.org/show_bug.cgi?id=145440

Patch by Matt Rajca <mra...@apple.com> on 2015-05-28
Reviewed by Eric Carlson.

* CMakeLists.txt:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::HTMLMediaElement):
(WebCore::HTMLMediaElement::loadInternal):
(WebCore::HTMLMediaElement::loadResource):
(WebCore::HTMLMediaElement::suspend):
(WebCore::HTMLMediaElement::resume):
(WebCore::HTMLMediaElement::removeBehaviorsRestrictionsAfterFirstUserGesture):
(WebCore::HTMLMediaElement::mediaState):
* html/HTMLMediaElement.h:
(WebCore::HTMLMediaElement::mediaSession):
* html/MediaElementSession.cpp: Renamed from Source/WebCore/html/HTMLMediaSession.cpp.
(WebCore::restrictionName):
(WebCore::MediaElementSession::MediaElementSession):
(WebCore::MediaElementSession::registerWithDocument):
(WebCore::MediaElementSession::unregisterWithDocument):
(WebCore::MediaElementSession::addBehaviorRestriction):
(WebCore::MediaElementSession::removeBehaviorRestriction):
(WebCore::MediaElementSession::playbackPermitted):
(WebCore::MediaElementSession::dataLoadingPermitted):
(WebCore::MediaElementSession::fullscreenPermitted):
(WebCore::MediaElementSession::pageAllowsDataLoading):
(WebCore::MediaElementSession::pageAllowsPlaybackAfterResuming):
(WebCore::MediaElementSession::showPlaybackTargetPicker):
(WebCore::MediaElementSession::hasWirelessPlaybackTargets):
(WebCore::MediaElementSession::wirelessVideoPlaybackDisabled):
(WebCore::MediaElementSession::setWirelessVideoPlaybackDisabled):
(WebCore::MediaElementSession::setHasPlaybackTargetAvailabilityListeners):
(WebCore::MediaElementSession::setPlaybackTarget):
(WebCore::MediaElementSession::targetAvailabilityChangedTimerFired):
(WebCore::MediaElementSession::externalOutputDeviceAvailableDidChange):
(WebCore::MediaElementSession::canPlayToWirelessPlaybackTarget):
(WebCore::MediaElementSession::isPlayingToWirelessPlaybackTarget):
(WebCore::MediaElementSession::setShouldPlayToPlaybackTarget):
(WebCore::MediaElementSession::mediaStateDidChange):
(WebCore::MediaElementSession::effectivePreloadForElement):
(WebCore::MediaElementSession::requiresFullscreenForVideoPlayback):
(WebCore::MediaElementSession::mediaEngineUpdated):
(WebCore::MediaElementSession::allowsAlternateFullscreen):
(WebCore::MediaElementSession::maximumMediaSourceBufferSize):
* html/MediaElementSession.h: Renamed from Source/WebCore/html/HTMLMediaSession.h.
* testing/Internals.cpp:
(WebCore::Internals::setMediaElementRestrictions):
(WebCore::Internals::setAudioContextRestrictions):

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/CMakeLists.txt (184965 => 184966)


--- trunk/Source/WebCore/CMakeLists.txt	2015-05-28 22:41:19 UTC (rev 184965)
+++ trunk/Source/WebCore/CMakeLists.txt	2015-05-28 23:03:34 UTC (rev 184966)
@@ -1636,7 +1636,6 @@
     html/HTMLMapElement.cpp
     html/HTMLMarqueeElement.cpp
     html/HTMLMediaElement.cpp
-    html/HTMLMediaSession.cpp
     html/HTMLMenuElement.cpp
     html/HTMLMetaElement.cpp
     html/HTMLMeterElement.cpp
@@ -1688,6 +1687,7 @@
     html/LinkRelAttribute.cpp
     html/MediaController.cpp
     html/MediaDocument.cpp
+    html/MediaElementSession.cpp
     html/MediaFragmentURIParser.cpp
     html/MonthInputType.cpp
     html/NumberInputType.cpp

Modified: trunk/Source/WebCore/ChangeLog (184965 => 184966)


--- trunk/Source/WebCore/ChangeLog	2015-05-28 22:41:19 UTC (rev 184965)
+++ trunk/Source/WebCore/ChangeLog	2015-05-28 23:03:34 UTC (rev 184966)
@@ -1,3 +1,58 @@
+2015-05-28  Matt Rajca  <mra...@apple.com>
+
+        Rename HTMLMediaSession to MediaElementSession to reserve "media session" for the Media Session API.
+        https://bugs.webkit.org/show_bug.cgi?id=145440
+
+        Reviewed by Eric Carlson.
+
+        * CMakeLists.txt:
+        * WebCore.vcxproj/WebCore.vcxproj:
+        * WebCore.vcxproj/WebCore.vcxproj.filters:
+        * WebCore.xcodeproj/project.pbxproj:
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::HTMLMediaElement):
+        (WebCore::HTMLMediaElement::loadInternal):
+        (WebCore::HTMLMediaElement::loadResource):
+        (WebCore::HTMLMediaElement::suspend):
+        (WebCore::HTMLMediaElement::resume):
+        (WebCore::HTMLMediaElement::removeBehaviorsRestrictionsAfterFirstUserGesture):
+        (WebCore::HTMLMediaElement::mediaState):
+        * html/HTMLMediaElement.h:
+        (WebCore::HTMLMediaElement::mediaSession):
+        * html/MediaElementSession.cpp: Renamed from Source/WebCore/html/HTMLMediaSession.cpp.
+        (WebCore::restrictionName):
+        (WebCore::MediaElementSession::MediaElementSession):
+        (WebCore::MediaElementSession::registerWithDocument):
+        (WebCore::MediaElementSession::unregisterWithDocument):
+        (WebCore::MediaElementSession::addBehaviorRestriction):
+        (WebCore::MediaElementSession::removeBehaviorRestriction):
+        (WebCore::MediaElementSession::playbackPermitted):
+        (WebCore::MediaElementSession::dataLoadingPermitted):
+        (WebCore::MediaElementSession::fullscreenPermitted):
+        (WebCore::MediaElementSession::pageAllowsDataLoading):
+        (WebCore::MediaElementSession::pageAllowsPlaybackAfterResuming):
+        (WebCore::MediaElementSession::showPlaybackTargetPicker):
+        (WebCore::MediaElementSession::hasWirelessPlaybackTargets):
+        (WebCore::MediaElementSession::wirelessVideoPlaybackDisabled):
+        (WebCore::MediaElementSession::setWirelessVideoPlaybackDisabled):
+        (WebCore::MediaElementSession::setHasPlaybackTargetAvailabilityListeners):
+        (WebCore::MediaElementSession::setPlaybackTarget):
+        (WebCore::MediaElementSession::targetAvailabilityChangedTimerFired):
+        (WebCore::MediaElementSession::externalOutputDeviceAvailableDidChange):
+        (WebCore::MediaElementSession::canPlayToWirelessPlaybackTarget):
+        (WebCore::MediaElementSession::isPlayingToWirelessPlaybackTarget):
+        (WebCore::MediaElementSession::setShouldPlayToPlaybackTarget):
+        (WebCore::MediaElementSession::mediaStateDidChange):
+        (WebCore::MediaElementSession::effectivePreloadForElement):
+        (WebCore::MediaElementSession::requiresFullscreenForVideoPlayback):
+        (WebCore::MediaElementSession::mediaEngineUpdated):
+        (WebCore::MediaElementSession::allowsAlternateFullscreen):
+        (WebCore::MediaElementSession::maximumMediaSourceBufferSize):
+        * html/MediaElementSession.h: Renamed from Source/WebCore/html/HTMLMediaSession.h.
+        * testing/Internals.cpp:
+        (WebCore::Internals::setMediaElementRestrictions):
+        (WebCore::Internals::setAudioContextRestrictions):
+
 2015-05-28  Myles C. Maxfield  <mmaxfi...@apple.com>
 
         Crash under ICU with ASAN during editing/selection/move-by-word-visually-crash-test-5.html

Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj (184965 => 184966)


--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj	2015-05-28 22:41:19 UTC (rev 184965)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj	2015-05-28 23:03:34 UTC (rev 184966)
@@ -15098,7 +15098,7 @@
     <ClCompile Include="..\html\DOMSettableTokenList.cpp" />
     <ClCompile Include="..\html\DOMTokenList.cpp" />
     <ClCompile Include="..\html\DOMURL.cpp" />
-    <ClCompile Include="..\html\HTMLMediaSession.cpp" />
+    <ClCompile Include="..\html\MediaElementSession.cpp" />
     <ClCompile Include="..\html\EmailInputType.cpp" />
     <ClCompile Include="..\html\PublicURLManager.cpp" />
     <ClCompile Include="..\fileapi\File.cpp" />

Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters (184965 => 184966)


--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters	2015-05-28 22:41:19 UTC (rev 184965)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters	2015-05-28 23:03:34 UTC (rev 184966)
@@ -7030,7 +7030,7 @@
     <ClCompile Include="..\Modules\gamepad\GamepadEvent.cpp">
       <Filter>Modules\gamepad</Filter>
     </ClCompile>
-    <ClCompile Include="..\html\HTMLMediaSession.cpp">
+    <ClCompile Include="..\html\MediaElementSession.cpp">
       <Filter>html</Filter>
     </ClCompile>
     <ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\HTTPHeaderNames.cpp">

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (184965 => 184966)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2015-05-28 22:41:19 UTC (rev 184965)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2015-05-28 23:03:34 UTC (rev 184966)
@@ -351,8 +351,8 @@
 		07F876841AD580F900905849 /* MediaPlaybackTargetContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 07F876831AD4A94500905849 /* MediaPlaybackTargetContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		07F944161864D046005D31CB /* MediaSessionManager.h in Headers */ = {isa = PBXBuildFile; fileRef = CDAE8C081746B95700532D78 /* MediaSessionManager.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		07FBDE2C18FED178001A7CFF /* JSDataCueCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07FBDE2B18FED178001A7CFF /* JSDataCueCustom.cpp */; };
-		07FE99DC18807A7D00256648 /* HTMLMediaSession.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07FE99DA18807A7D00256648 /* HTMLMediaSession.cpp */; };
-		07FE99DD18807A7D00256648 /* HTMLMediaSession.h in Headers */ = {isa = PBXBuildFile; fileRef = 07FE99DB18807A7D00256648 /* HTMLMediaSession.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		07FE99DC18807A7D00256648 /* MediaElementSession.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07FE99DA18807A7D00256648 /* MediaElementSession.cpp */; };
+		07FE99DD18807A7D00256648 /* MediaElementSession.h in Headers */ = {isa = PBXBuildFile; fileRef = 07FE99DB18807A7D00256648 /* MediaElementSession.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		07FFDE68181AED420072D409 /* MediaStreamTrackPrivate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07FFDE66181AED420072D409 /* MediaStreamTrackPrivate.cpp */; };
 		07FFDE69181AED420072D409 /* MediaStreamTrackPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 07FFDE67181AED420072D409 /* MediaStreamTrackPrivate.h */; };
 		0806E57A12893045007CED32 /* SVGMatrix.h in Headers */ = {isa = PBXBuildFile; fileRef = 0806E57912893045007CED32 /* SVGMatrix.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -7403,8 +7403,8 @@
 		07F0B97B1AC5DB4600E535D9 /* AVFoundationSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AVFoundationSPI.h; sourceTree = "<group>"; };
 		07F876831AD4A94500905849 /* MediaPlaybackTargetContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaPlaybackTargetContext.h; sourceTree = "<group>"; };
 		07FBDE2B18FED178001A7CFF /* JSDataCueCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDataCueCustom.cpp; sourceTree = "<group>"; };
-		07FE99DA18807A7D00256648 /* HTMLMediaSession.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLMediaSession.cpp; sourceTree = "<group>"; };
-		07FE99DB18807A7D00256648 /* HTMLMediaSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLMediaSession.h; sourceTree = "<group>"; };
+		07FE99DA18807A7D00256648 /* MediaElementSession.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaElementSession.cpp; sourceTree = "<group>"; };
+		07FE99DB18807A7D00256648 /* MediaElementSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaElementSession.h; sourceTree = "<group>"; };
 		07FFDE66181AED420072D409 /* MediaStreamTrackPrivate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaStreamTrackPrivate.cpp; sourceTree = "<group>"; };
 		07FFDE67181AED420072D409 /* MediaStreamTrackPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaStreamTrackPrivate.h; sourceTree = "<group>"; };
 		0806E57912893045007CED32 /* SVGMatrix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGMatrix.h; sourceTree = "<group>"; };
@@ -18156,8 +18156,6 @@
 				E44613930CD6331000FADA75 /* HTMLMediaElement.h */,
 				E44613940CD6331000FADA75 /* HTMLMediaElement.idl */,
 				CD5209E51B0BD9E10077184E /* HTMLMediaElementEnums.h */,
-				07FE99DA18807A7D00256648 /* HTMLMediaSession.cpp */,
-				07FE99DB18807A7D00256648 /* HTMLMediaSession.h */,
 				A8EA79EC0A1916DF00A8EF5F /* HTMLMenuElement.cpp */,
 				A8EA79E80A1916DF00A8EF5F /* HTMLMenuElement.h */,
 				1AE2AE430A1D269E00B42B25 /* HTMLMenuElement.idl */,
@@ -18296,6 +18294,8 @@
 				CDF65CC9145B43A700C4C7AA /* MediaControllerInterface.h */,
 				97205AB31239291000B17380 /* MediaDocument.cpp */,
 				97205AB41239291000B17380 /* MediaDocument.h */,
+				07FE99DA18807A7D00256648 /* MediaElementSession.cpp */,
+				07FE99DB18807A7D00256648 /* MediaElementSession.h */,
 				E446139B0CD6331000FADA75 /* MediaError.h */,
 				E446139C0CD6331000FADA75 /* MediaError.idl */,
 				07A6D1E91491137700051D0C /* MediaFragmentURIParser.cpp */,
@@ -24895,7 +24895,6 @@
 				A8EA7CAB0A192B9C00A8EF5F /* HTMLMarqueeElement.h in Headers */,
 				E44613A50CD6331000FADA75 /* HTMLMediaElement.h in Headers */,
 				0779BF0E18453168000B6AE7 /* HTMLMediaElementMediaStream.h in Headers */,
-				07FE99DD18807A7D00256648 /* HTMLMediaSession.h in Headers */,
 				A8EA79F40A1916DF00A8EF5F /* HTMLMenuElement.h in Headers */,
 				2BE8E2C712A589EC00FAD550 /* HTMLMetaCharsetParser.h in Headers */,
 				A871DC240A15205700B12A68 /* HTMLMetaElement.h in Headers */,
@@ -25774,6 +25773,7 @@
 				5EA725D31ACABD4700EAD17B /* MediaDevices.h in Headers */,
 				97205AB81239291000B17380 /* MediaDocument.h in Headers */,
 				FD6F252D13F5EF0E0065165F /* MediaElementAudioSourceNode.h in Headers */,
+				07FE99DD18807A7D00256648 /* MediaElementSession.h in Headers */,
 				E44613AD0CD6331000FADA75 /* MediaError.h in Headers */,
 				4E1959220A39DABA00220FE5 /* MediaFeatureNames.h in Headers */,
 				07A6D1EC1491137700051D0C /* MediaFragmentURIParser.h in Headers */,
@@ -28402,7 +28402,6 @@
 				A8EA7CAC0A192B9C00A8EF5F /* HTMLMarqueeElement.cpp in Sources */,
 				E44613A40CD6331000FADA75 /* HTMLMediaElement.cpp in Sources */,
 				0779BF0D18453168000B6AE7 /* HTMLMediaElementMediaStream.cpp in Sources */,
-				07FE99DC18807A7D00256648 /* HTMLMediaSession.cpp in Sources */,
 				A8EA79F80A1916DF00A8EF5F /* HTMLMenuElement.cpp in Sources */,
 				2BE8E2C912A58A0100FAD550 /* HTMLMetaCharsetParser.cpp in Sources */,
 				A871DC270A15205700B12A68 /* HTMLMetaElement.cpp in Sources */,
@@ -29355,6 +29354,7 @@
 				5EA725D21ACABD4700EAD17B /* MediaDevices.cpp in Sources */,
 				97205AB71239291000B17380 /* MediaDocument.cpp in Sources */,
 				FD6F252C13F5EF0E0065165F /* MediaElementAudioSourceNode.cpp in Sources */,
+				07FE99DC18807A7D00256648 /* MediaElementSession.cpp in Sources */,
 				4E1959210A39DABA00220FE5 /* MediaFeatureNames.cpp in Sources */,
 				07A6D1EB1491137700051D0C /* MediaFragmentURIParser.cpp in Sources */,
 				CDB859F7160D48A400E5B07F /* MediaKeyEvent.cpp in Sources */,

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (184965 => 184966)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2015-05-28 22:41:19 UTC (rev 184965)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2015-05-28 23:03:34 UTC (rev 184966)
@@ -351,7 +351,7 @@
 #if ENABLE(WEB_AUDIO)
     , m_audioSourceNode(0)
 #endif
-    , m_mediaSession(std::make_unique<HTMLMediaSession>(*this))
+    , m_mediaSession(std::make_unique<MediaElementSession>(*this))
     , m_reportedExtraMemoryCost(0)
 #if ENABLE(MEDIA_STREAM)
     , m_mediaStreamSrcObject(nullptr)
@@ -360,36 +360,36 @@
     LOG(Media, "HTMLMediaElement::HTMLMediaElement(%p)", this);
     setHasCustomStyleResolveCallbacks();
 
-    m_mediaSession->addBehaviorRestriction(HTMLMediaSession::RequireUserGestureForFullscreen);
-    m_mediaSession->addBehaviorRestriction(HTMLMediaSession::RequirePageConsentToLoadMedia);
+    m_mediaSession->addBehaviorRestriction(MediaElementSession::RequireUserGestureForFullscreen);
+    m_mediaSession->addBehaviorRestriction(MediaElementSession::RequirePageConsentToLoadMedia);
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
-    m_mediaSession->addBehaviorRestriction(HTMLMediaSession::RequireUserGestureToAutoplayToExternalDevice);
+    m_mediaSession->addBehaviorRestriction(MediaElementSession::RequireUserGestureToAutoplayToExternalDevice);
 #endif
 
     // FIXME: We should clean up and look to better merge the iOS and non-iOS code below.
     Settings* settings = document.settings();
 #if !PLATFORM(IOS)
     if (settings && settings->requiresUserGestureForMediaPlayback()) {
-        m_mediaSession->addBehaviorRestriction(HTMLMediaSession::RequireUserGestureForRateChange);
-        m_mediaSession->addBehaviorRestriction(HTMLMediaSession::RequireUserGestureForLoad);
+        m_mediaSession->addBehaviorRestriction(MediaElementSession::RequireUserGestureForRateChange);
+        m_mediaSession->addBehaviorRestriction(MediaElementSession::RequireUserGestureForLoad);
     }
 #else
     m_sendProgressEvents = false;
     if (!settings || settings->requiresUserGestureForMediaPlayback()) {
         // Allow autoplay in a MediaDocument that is not in an iframe.
         if (document.ownerElement() || !document.isMediaDocument())
-            m_mediaSession->addBehaviorRestriction(HTMLMediaSession::RequireUserGestureForRateChange);
+            m_mediaSession->addBehaviorRestriction(MediaElementSession::RequireUserGestureForRateChange);
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
-        m_mediaSession->addBehaviorRestriction(HTMLMediaSession::RequireUserGestureToShowPlaybackTargetPicker);
+        m_mediaSession->addBehaviorRestriction(MediaElementSession::RequireUserGestureToShowPlaybackTargetPicker);
 #endif
     } else {
         // Relax RequireUserGestureForFullscreen when requiresUserGestureForMediaPlayback is not set:
-        m_mediaSession->removeBehaviorRestriction(HTMLMediaSession::RequireUserGestureForFullscreen);
+        m_mediaSession->removeBehaviorRestriction(MediaElementSession::RequireUserGestureForFullscreen);
     }
 #endif // !PLATFORM(IOS)
 
     if (settings && settings->audioPlaybackRequiresUserGesture())
-        m_mediaSession->addBehaviorRestriction(HTMLMediaSession::RequireUserGestureForAudioRateChange);
+        m_mediaSession->addBehaviorRestriction(MediaElementSession::RequireUserGestureForAudioRateChange);
 
 #if ENABLE(VIDEO_TRACK)
     if (document.page())
@@ -1021,7 +1021,7 @@
     // Once the page has allowed an element to load media, it is free to load at will. This allows a 
     // playlist that starts in a foreground tab to continue automatically if the tab is subsequently 
     // put into the background.
-    m_mediaSession->removeBehaviorRestriction(HTMLMediaSession::RequirePageConsentToLoadMedia);
+    m_mediaSession->removeBehaviorRestriction(MediaElementSession::RequirePageConsentToLoadMedia);
 
 #if ENABLE(VIDEO_TRACK)
     if (hasMediaControls())
@@ -1200,7 +1200,7 @@
 
 #if ENABLE(MEDIA_STREAM)
     if (MediaStreamRegistry::registry().lookup(url.string()))
-        m_mediaSession->removeBehaviorRestriction(HTMLMediaSession::RequireUserGestureForRateChange);
+        m_mediaSession->removeBehaviorRestriction(MediaElementSession::RequireUserGestureForRateChange);
 #endif
 
     if (m_sendProgressEvents) 
@@ -4835,7 +4835,7 @@
     {
         case PageCache:
             stop();
-            m_mediaSession->addBehaviorRestriction(HTMLMediaSession::RequirePageConsentToResumeMedia);
+            m_mediaSession->addBehaviorRestriction(MediaElementSession::RequirePageConsentToResumeMedia);
             break;
         case DocumentWillBePaused:
         case _javascript_DebuggerPaused:
@@ -4857,7 +4857,7 @@
     else
         setPausedInternal(false);
 
-    m_mediaSession->removeBehaviorRestriction(HTMLMediaSession::RequirePageConsentToResumeMedia);
+    m_mediaSession->removeBehaviorRestriction(MediaElementSession::RequirePageConsentToResumeMedia);
 
     if (m_error && m_error->code() == MediaError::MEDIA_ERR_ABORTED) {
         // Restart the load if it was aborted in the middle by moving the document to the page cache.
@@ -5962,15 +5962,15 @@
 
 void HTMLMediaElement::removeBehaviorsRestrictionsAfterFirstUserGesture()
 {
-    HTMLMediaSession::BehaviorRestrictions restrictionsToRemove = HTMLMediaSession::RequireUserGestureForLoad
+    MediaElementSession::BehaviorRestrictions restrictionsToRemove = MediaElementSession::RequireUserGestureForLoad
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
-        | HTMLMediaSession::RequireUserGestureToShowPlaybackTargetPicker
-        | HTMLMediaSession::RequireUserGestureToAutoplayToExternalDevice
+        | MediaElementSession::RequireUserGestureToShowPlaybackTargetPicker
+        | MediaElementSession::RequireUserGestureToAutoplayToExternalDevice
 #endif
-        | HTMLMediaSession::RequireUserGestureForLoad
-        | HTMLMediaSession::RequireUserGestureForRateChange
-        | HTMLMediaSession::RequireUserGestureForAudioRateChange
-        | HTMLMediaSession::RequireUserGestureForFullscreen;
+        | MediaElementSession::RequireUserGestureForLoad
+        | MediaElementSession::RequireUserGestureForRateChange
+        | MediaElementSession::RequireUserGestureForAudioRateChange
+        | MediaElementSession::RequireUserGestureForFullscreen;
     m_mediaSession->removeBehaviorRestriction(restrictionsToRemove);
 }
 
@@ -6295,7 +6295,7 @@
     if (!m_mediaSession->wirelessVideoPlaybackDisabled(*this) && m_hasPlaybackTargetAvailabilityListeners && m_player->canPlayToWirelessPlaybackTarget())
         state |= RequiresPlaybackTargetMonitoring;
 
-    bool requireUserGesture = m_mediaSession->hasBehaviorRestriction(HTMLMediaSession::RequireUserGestureToAutoplayToExternalDevice);
+    bool requireUserGesture = m_mediaSession->hasBehaviorRestriction(MediaElementSession::RequireUserGestureToAutoplayToExternalDevice);
     if (hasActiveVideo && (!requireUserGesture || (hasAudio && !loop())))
         state |= ExternalDeviceAutoPlayCandidate;
 #endif

Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (184965 => 184966)


--- trunk/Source/WebCore/html/HTMLMediaElement.h	2015-05-28 22:41:19 UTC (rev 184965)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h	2015-05-28 23:03:34 UTC (rev 184966)
@@ -32,9 +32,9 @@
 #include "GenericEventQueue.h"
 #include "GenericTaskQueue.h"
 #include "HTMLMediaElementEnums.h"
-#include "HTMLMediaSession.h"
 #include "MediaCanStartListener.h"
 #include "MediaControllerInterface.h"
+#include "MediaElementSession.h"
 #include "MediaProducer.h"
 #include "PageThrottler.h"
 
@@ -416,7 +416,7 @@
 #endif
 
     MediaPlayerEnums::Preload preloadValue() const { return m_preload; }
-    HTMLMediaSession& mediaSession() const { return *m_mediaSession; }
+    MediaElementSession& mediaSession() const { return *m_mediaSession; }
 
 #if ENABLE(MEDIA_CONTROLS_SCRIPT)
     void pageScaleFactorChanged();
@@ -894,7 +894,7 @@
     RefPtr<PlatformTextTrackMenuInterface> m_platformMenu;
 #endif
 
-    std::unique_ptr<HTMLMediaSession> m_mediaSession;
+    std::unique_ptr<MediaElementSession> m_mediaSession;
     PageActivityAssertionToken m_activityToken;
     size_t m_reportedExtraMemoryCost;
 

Deleted: trunk/Source/WebCore/html/HTMLMediaSession.cpp (184965 => 184966)


--- trunk/Source/WebCore/html/HTMLMediaSession.cpp	2015-05-28 22:41:19 UTC (rev 184965)
+++ trunk/Source/WebCore/html/HTMLMediaSession.cpp	2015-05-28 23:03:34 UTC (rev 184966)
@@ -1,422 +0,0 @@
-/*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if ENABLE(VIDEO)
-
-#include "HTMLMediaSession.h"
-
-#include "Chrome.h"
-#include "ChromeClient.h"
-#include "Document.h"
-#include "Frame.h"
-#include "FrameView.h"
-#include "HTMLMediaElement.h"
-#include "HTMLNames.h"
-#include "HTMLVideoElement.h"
-#include "Logging.h"
-#include "MediaSessionManager.h"
-#include "Page.h"
-#include "ScriptController.h"
-#include "SourceBuffer.h"
-
-#if PLATFORM(IOS)
-#include "AudioSession.h"
-#include "RuntimeApplicationChecksIOS.h"
-#endif
-
-namespace WebCore {
-
-#if !LOG_DISABLED
-static String restrictionName(HTMLMediaSession::BehaviorRestrictions restriction)
-{
-    StringBuilder restrictionBuilder;
-#define CASE(restrictionType) \
-    if (restriction & HTMLMediaSession::restrictionType) { \
-        if (!restrictionBuilder.isEmpty()) \
-            restrictionBuilder.append(", "); \
-        restrictionBuilder.append(#restrictionType); \
-    } \
-
-    CASE(NoRestrictions);
-    CASE(RequireUserGestureForLoad);
-    CASE(RequireUserGestureForRateChange);
-    CASE(RequireUserGestureForAudioRateChange);
-    CASE(RequireUserGestureForFullscreen);
-    CASE(RequirePageConsentToLoadMedia);
-    CASE(RequirePageConsentToResumeMedia);
-#if ENABLE(WIRELESS_PLAYBACK_TARGET)
-    CASE(RequireUserGestureToShowPlaybackTargetPicker);
-    CASE(WirelessVideoPlaybackDisabled);
-#endif
-    CASE(RequireUserGestureForAudioRateChange);
-
-    return restrictionBuilder.toString();
-}
-#endif
-
-HTMLMediaSession::HTMLMediaSession(MediaSessionClient& client)
-    : MediaSession(client)
-    , m_restrictions(NoRestrictions)
-#if ENABLE(WIRELESS_PLAYBACK_TARGET)
-    , m_targetAvailabilityChangedTimer(*this, &HTMLMediaSession::targetAvailabilityChangedTimerFired)
-#endif
-{
-}
-
-void HTMLMediaSession::registerWithDocument(const HTMLMediaElement& element)
-{
-#if ENABLE(WIRELESS_PLAYBACK_TARGET)
-    element.document().addPlaybackTargetPickerClient(*this);
-#else
-    UNUSED_PARAM(element);
-#endif
-}
-
-void HTMLMediaSession::unregisterWithDocument(const HTMLMediaElement& element)
-{
-#if ENABLE(WIRELESS_PLAYBACK_TARGET)
-    element.document().removePlaybackTargetPickerClient(*this);
-#else
-    UNUSED_PARAM(element);
-#endif
-}
-
-void HTMLMediaSession::addBehaviorRestriction(BehaviorRestrictions restriction)
-{
-    LOG(Media, "HTMLMediaSession::addBehaviorRestriction - adding %s", restrictionName(restriction).utf8().data());
-    m_restrictions |= restriction;
-}
-
-void HTMLMediaSession::removeBehaviorRestriction(BehaviorRestrictions restriction)
-{
-    LOG(Media, "HTMLMediaSession::removeBehaviorRestriction - removing %s", restrictionName(restriction).utf8().data());
-    m_restrictions &= ~restriction;
-}
-
-bool HTMLMediaSession::playbackPermitted(const HTMLMediaElement& element) const
-{
-    if (m_restrictions & RequireUserGestureForRateChange && !ScriptController::processingUserGesture()) {
-        LOG(Media, "HTMLMediaSession::playbackPermitted - returning FALSE");
-        return false;
-    }
-
-    if (m_restrictions & RequireUserGestureForAudioRateChange && element.hasAudio() && !ScriptController::processingUserGesture()) {
-        LOG(Media, "HTMLMediaSession::playbackPermitted - returning FALSE");
-        return false;
-    }
-
-    return true;
-}
-
-bool HTMLMediaSession::dataLoadingPermitted(const HTMLMediaElement&) const
-{
-    if (m_restrictions & RequireUserGestureForLoad && !ScriptController::processingUserGesture()) {
-        LOG(Media, "HTMLMediaSession::dataLoadingPermitted - returning FALSE");
-        return false;
-    }
-
-    return true;
-}
-
-bool HTMLMediaSession::fullscreenPermitted(const HTMLMediaElement&) const
-{
-    if (m_restrictions & RequireUserGestureForFullscreen && !ScriptController::processingUserGesture()) {
-        LOG(Media, "HTMLMediaSession::fullscreenPermitted - returning FALSE");
-        return false;
-    }
-
-    return true;
-}
-
-bool HTMLMediaSession::pageAllowsDataLoading(const HTMLMediaElement& element) const
-{
-    Page* page = element.document().page();
-    if (m_restrictions & RequirePageConsentToLoadMedia && page && !page->canStartMedia()) {
-        LOG(Media, "HTMLMediaSession::pageAllowsDataLoading - returning FALSE");
-        return false;
-    }
-
-    return true;
-}
-
-bool HTMLMediaSession::pageAllowsPlaybackAfterResuming(const HTMLMediaElement& element) const
-{
-    Page* page = element.document().page();
-    if (m_restrictions & RequirePageConsentToResumeMedia && page && !page->canStartMedia()) {
-        LOG(Media, "HTMLMediaSession::pageAllowsPlaybackAfterResuming - returning FALSE");
-        return false;
-    }
-
-    return true;
-}
-
-#if ENABLE(WIRELESS_PLAYBACK_TARGET)
-void HTMLMediaSession::showPlaybackTargetPicker(const HTMLMediaElement& element)
-{
-    LOG(Media, "HTMLMediaSession::showPlaybackTargetPicker");
-
-    if (m_restrictions & RequireUserGestureToShowPlaybackTargetPicker && !ScriptController::processingUserGesture()) {
-        LOG(Media, "HTMLMediaSession::showPlaybackTargetPicker - returning early because of permissions");
-        return;
-    }
-
-    if (!element.document().page()) {
-        LOG(Media, "HTMLMediaSession::showingPlaybackTargetPickerPermitted - returning early because page is NULL");
-        return;
-    }
-
-#if !PLATFORM(IOS)
-    if (!element.hasVideo()) {
-        LOG(Media, "HTMLMediaSession::showPlaybackTargetPicker - returning early because element has no video");
-        return;
-    }
-#endif
-
-    element.document().showPlaybackTargetPicker(*this, is<HTMLVideoElement>(element));
-}
-
-bool HTMLMediaSession::hasWirelessPlaybackTargets(const HTMLMediaElement&) const
-{
-#if PLATFORM(IOS)
-    // FIXME: consolidate Mac and iOS implementations
-    m_hasPlaybackTargets = MediaSessionManager::sharedManager().hasWirelessTargetsAvailable();
-#endif
-
-    LOG(Media, "HTMLMediaSession::hasWirelessPlaybackTargets - returning %s", m_hasPlaybackTargets ? "TRUE" : "FALSE");
-
-    return m_hasPlaybackTargets;
-}
-
-bool HTMLMediaSession::wirelessVideoPlaybackDisabled(const HTMLMediaElement& element) const
-{
-    Settings* settings = element.document().settings();
-    if (!settings || !settings->allowsAirPlayForMediaPlayback()) {
-        LOG(Media, "HTMLMediaSession::wirelessVideoPlaybackDisabled - returning TRUE because of settings");
-        return true;
-    }
-
-    if (element.fastHasAttribute(HTMLNames::webkitwirelessvideoplaybackdisabledAttr)) {
-        LOG(Media, "HTMLMediaSession::wirelessVideoPlaybackDisabled - returning TRUE because of attribute");
-        return true;
-    }
-
-#if PLATFORM(IOS)
-    String legacyAirplayAttributeValue = element.fastGetAttribute(HTMLNames::webkitairplayAttr);
-    if (equalIgnoringCase(legacyAirplayAttributeValue, "deny")) {
-        LOG(Media, "HTMLMediaSession::wirelessVideoPlaybackDisabled - returning TRUE because of legacy attribute");
-        return true;
-    }
-    if (equalIgnoringCase(legacyAirplayAttributeValue, "allow")) {
-        LOG(Media, "HTMLMediaSession::wirelessVideoPlaybackDisabled - returning FALSE because of legacy attribute");
-        return false;
-    }
-#endif
-
-    MediaPlayer* player = element.player();
-    if (!player)
-        return true;
-
-    bool disabled = player->wirelessVideoPlaybackDisabled();
-    LOG(Media, "HTMLMediaSession::wirelessVideoPlaybackDisabled - returning %s because media engine says so", disabled ? "TRUE" : "FALSE");
-    
-    return disabled;
-}
-
-void HTMLMediaSession::setWirelessVideoPlaybackDisabled(const HTMLMediaElement& element, bool disabled)
-{
-    if (disabled)
-        addBehaviorRestriction(WirelessVideoPlaybackDisabled);
-    else
-        removeBehaviorRestriction(WirelessVideoPlaybackDisabled);
-
-    MediaPlayer* player = element.player();
-    if (!player)
-        return;
-
-    LOG(Media, "HTMLMediaSession::setWirelessVideoPlaybackDisabled - disabled %s", disabled ? "TRUE" : "FALSE");
-    player->setWirelessVideoPlaybackDisabled(disabled);
-}
-
-void HTMLMediaSession::setHasPlaybackTargetAvailabilityListeners(const HTMLMediaElement& element, bool hasListeners)
-{
-    LOG(Media, "HTMLMediaSession::setHasPlaybackTargetAvailabilityListeners - hasListeners %s", hasListeners ? "TRUE" : "FALSE");
-
-#if PLATFORM(IOS)
-    UNUSED_PARAM(element);
-    m_hasPlaybackTargetAvailabilityListeners = hasListeners;
-    MediaSessionManager::sharedManager().configureWireLessTargetMonitoring();
-#else
-    UNUSED_PARAM(hasListeners);
-    element.document().playbackTargetPickerClientStateDidChange(*this, element.mediaState());
-#endif
-}
-
-void HTMLMediaSession::setPlaybackTarget(Ref<MediaPlaybackTarget>&& device)
-{
-    m_playbackTarget = WTF::move(device);
-    client().setWirelessPlaybackTarget(*m_playbackTarget.copyRef());
-}
-
-void HTMLMediaSession::targetAvailabilityChangedTimerFired()
-{
-    client().wirelessRoutesAvailableDidChange();
-}
-
-void HTMLMediaSession::externalOutputDeviceAvailableDidChange(bool hasTargets)
-{
-    if (m_hasPlaybackTargets == hasTargets)
-        return;
-
-    LOG(Media, "HTMLMediaSession::externalOutputDeviceAvailableDidChange(%p) - hasTargets %s", this, hasTargets ? "TRUE" : "FALSE");
-
-    m_hasPlaybackTargets = hasTargets;
-    m_targetAvailabilityChangedTimer.startOneShot(0);
-}
-
-bool HTMLMediaSession::canPlayToWirelessPlaybackTarget() const
-{
-    if (!m_playbackTarget || !m_playbackTarget->hasActiveRoute())
-        return false;
-
-    return client().canPlayToWirelessPlaybackTarget();
-}
-
-bool HTMLMediaSession::isPlayingToWirelessPlaybackTarget() const
-{
-    if (!m_playbackTarget || !m_playbackTarget->hasActiveRoute())
-        return false;
-
-    return client().isPlayingToWirelessPlaybackTarget();
-}
-
-void HTMLMediaSession::setShouldPlayToPlaybackTarget(bool shouldPlay)
-{
-    LOG(Media, "HTMLMediaSession::setShouldPlayToPlaybackTarget - shouldPlay %s", shouldPlay ? "TRUE" : "FALSE");
-    m_shouldPlayToPlaybackTarget = shouldPlay;
-    client().setShouldPlayToPlaybackTarget(shouldPlay);
-}
-
-void HTMLMediaSession::mediaStateDidChange(const HTMLMediaElement& element, MediaProducer::MediaStateFlags state)
-{
-    element.document().playbackTargetPickerClientStateDidChange(*this, state);
-}
-#endif
-
-MediaPlayer::Preload HTMLMediaSession::effectivePreloadForElement(const HTMLMediaElement& element) const
-{
-    MediaSessionManager::SessionRestrictions restrictions = MediaSessionManager::sharedManager().restrictions(mediaType());
-    MediaPlayer::Preload preload = element.preloadValue();
-
-    if ((restrictions & MediaSessionManager::MetadataPreloadingNotPermitted) == MediaSessionManager::MetadataPreloadingNotPermitted)
-        return MediaPlayer::None;
-
-    if ((restrictions & MediaSessionManager::AutoPreloadingNotPermitted) == MediaSessionManager::AutoPreloadingNotPermitted) {
-        if (preload > MediaPlayer::MetaData)
-            return MediaPlayer::MetaData;
-    }
-
-    return preload;
-}
-
-bool HTMLMediaSession::requiresFullscreenForVideoPlayback(const HTMLMediaElement& element) const
-{
-    if (!MediaSessionManager::sharedManager().sessionRestrictsInlineVideoPlayback(*this))
-        return false;
-
-    Settings* settings = element.document().settings();
-    if (!settings || !settings->allowsInlineMediaPlayback())
-        return true;
-
-    if (element.fastHasAttribute(HTMLNames::webkit_playsinlineAttr))
-        return false;
-
-#if PLATFORM(IOS)
-    if (applicationIsDumpRenderTree())
-        return false;
-#endif
-
-    return true;
-}
-
-void HTMLMediaSession::mediaEngineUpdated(const HTMLMediaElement& element)
-{
-    LOG(Media, "HTMLMediaSession::mediaEngineUpdated");
-
-#if ENABLE(WIRELESS_PLAYBACK_TARGET)
-    if (m_restrictions & WirelessVideoPlaybackDisabled)
-        setWirelessVideoPlaybackDisabled(element, true);
-    if (m_playbackTarget)
-        client().setWirelessPlaybackTarget(*m_playbackTarget.copyRef());
-    if (m_shouldPlayToPlaybackTarget)
-        client().setShouldPlayToPlaybackTarget(true);
-#else
-    UNUSED_PARAM(element);
-#endif
-    
-}
-
-bool HTMLMediaSession::allowsAlternateFullscreen(const HTMLMediaElement& element) const
-{
-    Settings* settings = element.document().settings();
-    return settings && settings->allowsAlternateFullscreen();
-}
-
-#if ENABLE(MEDIA_SOURCE)
-const unsigned fiveMinutesOf1080PVideo = 290 * 1024 * 1024; // 290 MB is approximately 5 minutes of 8Mbps (1080p) content.
-const unsigned fiveMinutesStereoAudio = 14 * 1024 * 1024; // 14 MB is approximately 5 minutes of 384kbps content.
-
-size_t HTMLMediaSession::maximumMediaSourceBufferSize(const SourceBuffer& buffer) const
-{
-    // A good quality 1080p video uses 8,000 kbps and stereo audio uses 384 kbps, so assume 95% for video and 5% for audio.
-    const float bufferBudgetPercentageForVideo = .95;
-    const float bufferBudgetPercentageForAudio = .05;
-
-    size_t maximum;
-    Settings* settings = buffer.document().settings();
-    if (settings)
-        maximum = settings->maximumSourceBufferSize();
-    else
-        maximum = fiveMinutesOf1080PVideo + fiveMinutesStereoAudio;
-
-    // Allow a SourceBuffer to buffer as though it is audio-only even if it doesn't have any active tracks (yet).
-    size_t bufferSize = static_cast<size_t>(maximum * bufferBudgetPercentageForAudio);
-    if (buffer.hasVideo())
-        bufferSize += static_cast<size_t>(maximum * bufferBudgetPercentageForVideo);
-
-    // FIXME: we might want to modify this algorithm to:
-    // - decrease the maximum size for background tabs
-    // - decrease the maximum size allowed for inactive elements when a process has more than one
-    //   element, eg. so a page with many elements which are played one at a time doesn't keep
-    //   everything buffered after an element has finished playing.
-
-    return bufferSize;
-}
-#endif
-
-}
-
-#endif // ENABLE(VIDEO)

Deleted: trunk/Source/WebCore/html/HTMLMediaSession.h (184965 => 184966)


--- trunk/Source/WebCore/html/HTMLMediaSession.h	2015-05-28 22:41:19 UTC (rev 184965)
+++ trunk/Source/WebCore/html/HTMLMediaSession.h	2015-05-28 23:03:34 UTC (rev 184966)
@@ -1,134 +0,0 @@
-/*
- * Copyright (C) 2014-2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef HTMLMediaSession_h
-#define HTMLMediaSession_h
-
-#if ENABLE(VIDEO)
-
-#include "MediaPlayer.h"
-#include "MediaSession.h"
-#include "Timer.h"
-
-namespace WebCore {
-
-class Document;
-class HTMLMediaElement;
-class SourceBuffer;
-
-class HTMLMediaSession final : public MediaSession {
-    WTF_MAKE_FAST_ALLOCATED;
-public:
-    explicit HTMLMediaSession(MediaSessionClient&);
-    virtual ~HTMLMediaSession() { }
-
-    void registerWithDocument(const HTMLMediaElement&);
-    void unregisterWithDocument(const HTMLMediaElement&);
-
-    bool playbackPermitted(const HTMLMediaElement&) const;
-    bool dataLoadingPermitted(const HTMLMediaElement&) const;
-    bool fullscreenPermitted(const HTMLMediaElement&) const;
-    bool pageAllowsDataLoading(const HTMLMediaElement&) const;
-    bool pageAllowsPlaybackAfterResuming(const HTMLMediaElement&) const;
-
-#if ENABLE(WIRELESS_PLAYBACK_TARGET)
-    void showPlaybackTargetPicker(const HTMLMediaElement&);
-    bool hasWirelessPlaybackTargets(const HTMLMediaElement&) const;
-
-    bool wirelessVideoPlaybackDisabled(const HTMLMediaElement&) const;
-    void setWirelessVideoPlaybackDisabled(const HTMLMediaElement&, bool);
-
-    void setHasPlaybackTargetAvailabilityListeners(const HTMLMediaElement&, bool);
-
-    virtual bool canPlayToWirelessPlaybackTarget() const override;
-    virtual bool isPlayingToWirelessPlaybackTarget() const override;
-
-    void mediaStateDidChange(const HTMLMediaElement&, MediaProducer::MediaStateFlags);
-#endif
-
-    bool requiresFullscreenForVideoPlayback(const HTMLMediaElement&) const;
-    WEBCORE_EXPORT bool allowsAlternateFullscreen(const HTMLMediaElement&) const;
-    MediaPlayer::Preload effectivePreloadForElement(const HTMLMediaElement&) const;
-
-    void mediaEngineUpdated(const HTMLMediaElement&);
-
-    // Restrictions to modify default behaviors.
-    enum BehaviorRestrictionFlags {
-        NoRestrictions = 0,
-        RequireUserGestureForLoad = 1 << 0,
-        RequireUserGestureForRateChange = 1 << 1,
-        RequireUserGestureForFullscreen = 1 << 2,
-        RequirePageConsentToLoadMedia = 1 << 3,
-        RequirePageConsentToResumeMedia = 1 << 4,
-        RequireUserGestureForAudioRateChange = 1 << 5,
-#if ENABLE(WIRELESS_PLAYBACK_TARGET)
-        RequireUserGestureToShowPlaybackTargetPicker = 1 << 6,
-        WirelessVideoPlaybackDisabled =  1 << 7,
-        RequireUserGestureToAutoplayToExternalDevice = 1 << 8,
-#endif
-    };
-    typedef unsigned BehaviorRestrictions;
-
-    WEBCORE_EXPORT BehaviorRestrictions behaviorRestrictions() const { return m_restrictions; }
-    WEBCORE_EXPORT void addBehaviorRestriction(BehaviorRestrictions);
-    WEBCORE_EXPORT void removeBehaviorRestriction(BehaviorRestrictions);
-    bool hasBehaviorRestriction(BehaviorRestrictions restriction) const { return restriction & m_restrictions; }
-
-#if ENABLE(MEDIA_SOURCE)
-    size_t maximumMediaSourceBufferSize(const SourceBuffer&) const;
-#endif
-
-private:
-
-#if ENABLE(WIRELESS_PLAYBACK_TARGET)
-    void targetAvailabilityChangedTimerFired();
-
-    // MediaPlaybackTargetClient
-    virtual void setPlaybackTarget(Ref<MediaPlaybackTarget>&&) override;
-    virtual void externalOutputDeviceAvailableDidChange(bool) override;
-    virtual void setShouldPlayToPlaybackTarget(bool) override;
-#endif
-#if PLATFORM(IOS)
-    bool requiresPlaybackTargetRouteMonitoring() const override { return m_hasPlaybackTargetAvailabilityListeners; }
-#endif
-
-    BehaviorRestrictions m_restrictions;
-
-#if ENABLE(WIRELESS_PLAYBACK_TARGET)
-    mutable Timer m_targetAvailabilityChangedTimer;
-    RefPtr<MediaPlaybackTarget> m_playbackTarget;
-    bool m_shouldPlayToPlaybackTarget { false };
-    mutable bool m_hasPlaybackTargets { false };
-#endif
-#if PLATFORM(IOS)
-    bool m_hasPlaybackTargetAvailabilityListeners { false };
-#endif
-};
-
-}
-
-#endif // MediaSession_h
-
-#endif // ENABLE(VIDEO)

Copied: trunk/Source/WebCore/html/MediaElementSession.cpp (from rev 184965, trunk/Source/WebCore/html/HTMLMediaSession.cpp) (0 => 184966)


--- trunk/Source/WebCore/html/MediaElementSession.cpp	                        (rev 0)
+++ trunk/Source/WebCore/html/MediaElementSession.cpp	2015-05-28 23:03:34 UTC (rev 184966)
@@ -0,0 +1,422 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(VIDEO)
+
+#include "MediaElementSession.h"
+
+#include "Chrome.h"
+#include "ChromeClient.h"
+#include "Document.h"
+#include "Frame.h"
+#include "FrameView.h"
+#include "HTMLMediaElement.h"
+#include "HTMLNames.h"
+#include "HTMLVideoElement.h"
+#include "Logging.h"
+#include "MediaSessionManager.h"
+#include "Page.h"
+#include "ScriptController.h"
+#include "SourceBuffer.h"
+
+#if PLATFORM(IOS)
+#include "AudioSession.h"
+#include "RuntimeApplicationChecksIOS.h"
+#endif
+
+namespace WebCore {
+
+#if !LOG_DISABLED
+static String restrictionName(MediaElementSession::BehaviorRestrictions restriction)
+{
+    StringBuilder restrictionBuilder;
+#define CASE(restrictionType) \
+    if (restriction & MediaElementSession::restrictionType) { \
+        if (!restrictionBuilder.isEmpty()) \
+            restrictionBuilder.append(", "); \
+        restrictionBuilder.append(#restrictionType); \
+    } \
+
+    CASE(NoRestrictions);
+    CASE(RequireUserGestureForLoad);
+    CASE(RequireUserGestureForRateChange);
+    CASE(RequireUserGestureForAudioRateChange);
+    CASE(RequireUserGestureForFullscreen);
+    CASE(RequirePageConsentToLoadMedia);
+    CASE(RequirePageConsentToResumeMedia);
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+    CASE(RequireUserGestureToShowPlaybackTargetPicker);
+    CASE(WirelessVideoPlaybackDisabled);
+#endif
+    CASE(RequireUserGestureForAudioRateChange);
+
+    return restrictionBuilder.toString();
+}
+#endif
+
+MediaElementSession::MediaElementSession(MediaSessionClient& client)
+    : MediaSession(client)
+    , m_restrictions(NoRestrictions)
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+    , m_targetAvailabilityChangedTimer(*this, &MediaElementSession::targetAvailabilityChangedTimerFired)
+#endif
+{
+}
+
+void MediaElementSession::registerWithDocument(const HTMLMediaElement& element)
+{
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+    element.document().addPlaybackTargetPickerClient(*this);
+#else
+    UNUSED_PARAM(element);
+#endif
+}
+
+void MediaElementSession::unregisterWithDocument(const HTMLMediaElement& element)
+{
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+    element.document().removePlaybackTargetPickerClient(*this);
+#else
+    UNUSED_PARAM(element);
+#endif
+}
+
+void MediaElementSession::addBehaviorRestriction(BehaviorRestrictions restriction)
+{
+    LOG(Media, "MediaElementSession::addBehaviorRestriction - adding %s", restrictionName(restriction).utf8().data());
+    m_restrictions |= restriction;
+}
+
+void MediaElementSession::removeBehaviorRestriction(BehaviorRestrictions restriction)
+{
+    LOG(Media, "MediaElementSession::removeBehaviorRestriction - removing %s", restrictionName(restriction).utf8().data());
+    m_restrictions &= ~restriction;
+}
+
+bool MediaElementSession::playbackPermitted(const HTMLMediaElement& element) const
+{
+    if (m_restrictions & RequireUserGestureForRateChange && !ScriptController::processingUserGesture()) {
+        LOG(Media, "MediaElementSession::playbackPermitted - returning FALSE");
+        return false;
+    }
+
+    if (m_restrictions & RequireUserGestureForAudioRateChange && element.hasAudio() && !ScriptController::processingUserGesture()) {
+        LOG(Media, "MediaElementSession::playbackPermitted - returning FALSE");
+        return false;
+    }
+
+    return true;
+}
+
+bool MediaElementSession::dataLoadingPermitted(const HTMLMediaElement&) const
+{
+    if (m_restrictions & RequireUserGestureForLoad && !ScriptController::processingUserGesture()) {
+        LOG(Media, "MediaElementSession::dataLoadingPermitted - returning FALSE");
+        return false;
+    }
+
+    return true;
+}
+
+bool MediaElementSession::fullscreenPermitted(const HTMLMediaElement&) const
+{
+    if (m_restrictions & RequireUserGestureForFullscreen && !ScriptController::processingUserGesture()) {
+        LOG(Media, "MediaElementSession::fullscreenPermitted - returning FALSE");
+        return false;
+    }
+
+    return true;
+}
+
+bool MediaElementSession::pageAllowsDataLoading(const HTMLMediaElement& element) const
+{
+    Page* page = element.document().page();
+    if (m_restrictions & RequirePageConsentToLoadMedia && page && !page->canStartMedia()) {
+        LOG(Media, "MediaElementSession::pageAllowsDataLoading - returning FALSE");
+        return false;
+    }
+
+    return true;
+}
+
+bool MediaElementSession::pageAllowsPlaybackAfterResuming(const HTMLMediaElement& element) const
+{
+    Page* page = element.document().page();
+    if (m_restrictions & RequirePageConsentToResumeMedia && page && !page->canStartMedia()) {
+        LOG(Media, "MediaElementSession::pageAllowsPlaybackAfterResuming - returning FALSE");
+        return false;
+    }
+
+    return true;
+}
+
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+void MediaElementSession::showPlaybackTargetPicker(const HTMLMediaElement& element)
+{
+    LOG(Media, "MediaElementSession::showPlaybackTargetPicker");
+
+    if (m_restrictions & RequireUserGestureToShowPlaybackTargetPicker && !ScriptController::processingUserGesture()) {
+        LOG(Media, "MediaElementSession::showPlaybackTargetPicker - returning early because of permissions");
+        return;
+    }
+
+    if (!element.document().page()) {
+        LOG(Media, "MediaElementSession::showingPlaybackTargetPickerPermitted - returning early because page is NULL");
+        return;
+    }
+
+#if !PLATFORM(IOS)
+    if (!element.hasVideo()) {
+        LOG(Media, "MediaElementSession::showPlaybackTargetPicker - returning early because element has no video");
+        return;
+    }
+#endif
+
+    element.document().showPlaybackTargetPicker(*this, is<HTMLVideoElement>(element));
+}
+
+bool MediaElementSession::hasWirelessPlaybackTargets(const HTMLMediaElement&) const
+{
+#if PLATFORM(IOS)
+    // FIXME: consolidate Mac and iOS implementations
+    m_hasPlaybackTargets = MediaSessionManager::sharedManager().hasWirelessTargetsAvailable();
+#endif
+
+    LOG(Media, "MediaElementSession::hasWirelessPlaybackTargets - returning %s", m_hasPlaybackTargets ? "TRUE" : "FALSE");
+
+    return m_hasPlaybackTargets;
+}
+
+bool MediaElementSession::wirelessVideoPlaybackDisabled(const HTMLMediaElement& element) const
+{
+    Settings* settings = element.document().settings();
+    if (!settings || !settings->allowsAirPlayForMediaPlayback()) {
+        LOG(Media, "MediaElementSession::wirelessVideoPlaybackDisabled - returning TRUE because of settings");
+        return true;
+    }
+
+    if (element.fastHasAttribute(HTMLNames::webkitwirelessvideoplaybackdisabledAttr)) {
+        LOG(Media, "MediaElementSession::wirelessVideoPlaybackDisabled - returning TRUE because of attribute");
+        return true;
+    }
+
+#if PLATFORM(IOS)
+    String legacyAirplayAttributeValue = element.fastGetAttribute(HTMLNames::webkitairplayAttr);
+    if (equalIgnoringCase(legacyAirplayAttributeValue, "deny")) {
+        LOG(Media, "MediaElementSession::wirelessVideoPlaybackDisabled - returning TRUE because of legacy attribute");
+        return true;
+    }
+    if (equalIgnoringCase(legacyAirplayAttributeValue, "allow")) {
+        LOG(Media, "MediaElementSession::wirelessVideoPlaybackDisabled - returning FALSE because of legacy attribute");
+        return false;
+    }
+#endif
+
+    MediaPlayer* player = element.player();
+    if (!player)
+        return true;
+
+    bool disabled = player->wirelessVideoPlaybackDisabled();
+    LOG(Media, "MediaElementSession::wirelessVideoPlaybackDisabled - returning %s because media engine says so", disabled ? "TRUE" : "FALSE");
+    
+    return disabled;
+}
+
+void MediaElementSession::setWirelessVideoPlaybackDisabled(const HTMLMediaElement& element, bool disabled)
+{
+    if (disabled)
+        addBehaviorRestriction(WirelessVideoPlaybackDisabled);
+    else
+        removeBehaviorRestriction(WirelessVideoPlaybackDisabled);
+
+    MediaPlayer* player = element.player();
+    if (!player)
+        return;
+
+    LOG(Media, "MediaElementSession::setWirelessVideoPlaybackDisabled - disabled %s", disabled ? "TRUE" : "FALSE");
+    player->setWirelessVideoPlaybackDisabled(disabled);
+}
+
+void MediaElementSession::setHasPlaybackTargetAvailabilityListeners(const HTMLMediaElement& element, bool hasListeners)
+{
+    LOG(Media, "MediaElementSession::setHasPlaybackTargetAvailabilityListeners - hasListeners %s", hasListeners ? "TRUE" : "FALSE");
+
+#if PLATFORM(IOS)
+    UNUSED_PARAM(element);
+    m_hasPlaybackTargetAvailabilityListeners = hasListeners;
+    MediaSessionManager::sharedManager().configureWireLessTargetMonitoring();
+#else
+    UNUSED_PARAM(hasListeners);
+    element.document().playbackTargetPickerClientStateDidChange(*this, element.mediaState());
+#endif
+}
+
+void MediaElementSession::setPlaybackTarget(Ref<MediaPlaybackTarget>&& device)
+{
+    m_playbackTarget = WTF::move(device);
+    client().setWirelessPlaybackTarget(*m_playbackTarget.copyRef());
+}
+
+void MediaElementSession::targetAvailabilityChangedTimerFired()
+{
+    client().wirelessRoutesAvailableDidChange();
+}
+
+void MediaElementSession::externalOutputDeviceAvailableDidChange(bool hasTargets)
+{
+    if (m_hasPlaybackTargets == hasTargets)
+        return;
+
+    LOG(Media, "MediaElementSession::externalOutputDeviceAvailableDidChange(%p) - hasTargets %s", this, hasTargets ? "TRUE" : "FALSE");
+
+    m_hasPlaybackTargets = hasTargets;
+    m_targetAvailabilityChangedTimer.startOneShot(0);
+}
+
+bool MediaElementSession::canPlayToWirelessPlaybackTarget() const
+{
+    if (!m_playbackTarget || !m_playbackTarget->hasActiveRoute())
+        return false;
+
+    return client().canPlayToWirelessPlaybackTarget();
+}
+
+bool MediaElementSession::isPlayingToWirelessPlaybackTarget() const
+{
+    if (!m_playbackTarget || !m_playbackTarget->hasActiveRoute())
+        return false;
+
+    return client().isPlayingToWirelessPlaybackTarget();
+}
+
+void MediaElementSession::setShouldPlayToPlaybackTarget(bool shouldPlay)
+{
+    LOG(Media, "MediaElementSession::setShouldPlayToPlaybackTarget - shouldPlay %s", shouldPlay ? "TRUE" : "FALSE");
+    m_shouldPlayToPlaybackTarget = shouldPlay;
+    client().setShouldPlayToPlaybackTarget(shouldPlay);
+}
+
+void MediaElementSession::mediaStateDidChange(const HTMLMediaElement& element, MediaProducer::MediaStateFlags state)
+{
+    element.document().playbackTargetPickerClientStateDidChange(*this, state);
+}
+#endif
+
+MediaPlayer::Preload MediaElementSession::effectivePreloadForElement(const HTMLMediaElement& element) const
+{
+    MediaSessionManager::SessionRestrictions restrictions = MediaSessionManager::sharedManager().restrictions(mediaType());
+    MediaPlayer::Preload preload = element.preloadValue();
+
+    if ((restrictions & MediaSessionManager::MetadataPreloadingNotPermitted) == MediaSessionManager::MetadataPreloadingNotPermitted)
+        return MediaPlayer::None;
+
+    if ((restrictions & MediaSessionManager::AutoPreloadingNotPermitted) == MediaSessionManager::AutoPreloadingNotPermitted) {
+        if (preload > MediaPlayer::MetaData)
+            return MediaPlayer::MetaData;
+    }
+
+    return preload;
+}
+
+bool MediaElementSession::requiresFullscreenForVideoPlayback(const HTMLMediaElement& element) const
+{
+    if (!MediaSessionManager::sharedManager().sessionRestrictsInlineVideoPlayback(*this))
+        return false;
+
+    Settings* settings = element.document().settings();
+    if (!settings || !settings->allowsInlineMediaPlayback())
+        return true;
+
+    if (element.fastHasAttribute(HTMLNames::webkit_playsinlineAttr))
+        return false;
+
+#if PLATFORM(IOS)
+    if (applicationIsDumpRenderTree())
+        return false;
+#endif
+
+    return true;
+}
+
+void MediaElementSession::mediaEngineUpdated(const HTMLMediaElement& element)
+{
+    LOG(Media, "MediaElementSession::mediaEngineUpdated");
+
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+    if (m_restrictions & WirelessVideoPlaybackDisabled)
+        setWirelessVideoPlaybackDisabled(element, true);
+    if (m_playbackTarget)
+        client().setWirelessPlaybackTarget(*m_playbackTarget.copyRef());
+    if (m_shouldPlayToPlaybackTarget)
+        client().setShouldPlayToPlaybackTarget(true);
+#else
+    UNUSED_PARAM(element);
+#endif
+    
+}
+
+bool MediaElementSession::allowsAlternateFullscreen(const HTMLMediaElement& element) const
+{
+    Settings* settings = element.document().settings();
+    return settings && settings->allowsAlternateFullscreen();
+}
+
+#if ENABLE(MEDIA_SOURCE)
+const unsigned fiveMinutesOf1080PVideo = 290 * 1024 * 1024; // 290 MB is approximately 5 minutes of 8Mbps (1080p) content.
+const unsigned fiveMinutesStereoAudio = 14 * 1024 * 1024; // 14 MB is approximately 5 minutes of 384kbps content.
+
+size_t MediaElementSession::maximumMediaSourceBufferSize(const SourceBuffer& buffer) const
+{
+    // A good quality 1080p video uses 8,000 kbps and stereo audio uses 384 kbps, so assume 95% for video and 5% for audio.
+    const float bufferBudgetPercentageForVideo = .95;
+    const float bufferBudgetPercentageForAudio = .05;
+
+    size_t maximum;
+    Settings* settings = buffer.document().settings();
+    if (settings)
+        maximum = settings->maximumSourceBufferSize();
+    else
+        maximum = fiveMinutesOf1080PVideo + fiveMinutesStereoAudio;
+
+    // Allow a SourceBuffer to buffer as though it is audio-only even if it doesn't have any active tracks (yet).
+    size_t bufferSize = static_cast<size_t>(maximum * bufferBudgetPercentageForAudio);
+    if (buffer.hasVideo())
+        bufferSize += static_cast<size_t>(maximum * bufferBudgetPercentageForVideo);
+
+    // FIXME: we might want to modify this algorithm to:
+    // - decrease the maximum size for background tabs
+    // - decrease the maximum size allowed for inactive elements when a process has more than one
+    //   element, eg. so a page with many elements which are played one at a time doesn't keep
+    //   everything buffered after an element has finished playing.
+
+    return bufferSize;
+}
+#endif
+
+}
+
+#endif // ENABLE(VIDEO)

Copied: trunk/Source/WebCore/html/MediaElementSession.h (from rev 184965, trunk/Source/WebCore/html/HTMLMediaSession.h) (0 => 184966)


--- trunk/Source/WebCore/html/MediaElementSession.h	                        (rev 0)
+++ trunk/Source/WebCore/html/MediaElementSession.h	2015-05-28 23:03:34 UTC (rev 184966)
@@ -0,0 +1,134 @@
+/*
+ * Copyright (C) 2014-2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef MediaElementSession_h
+#define MediaElementSession_h
+
+#if ENABLE(VIDEO)
+
+#include "MediaPlayer.h"
+#include "MediaSession.h"
+#include "Timer.h"
+
+namespace WebCore {
+
+class Document;
+class HTMLMediaElement;
+class SourceBuffer;
+
+class MediaElementSession final : public MediaSession {
+    WTF_MAKE_FAST_ALLOCATED;
+public:
+    explicit MediaElementSession(MediaSessionClient&);
+    virtual ~MediaElementSession() { }
+
+    void registerWithDocument(const HTMLMediaElement&);
+    void unregisterWithDocument(const HTMLMediaElement&);
+
+    bool playbackPermitted(const HTMLMediaElement&) const;
+    bool dataLoadingPermitted(const HTMLMediaElement&) const;
+    bool fullscreenPermitted(const HTMLMediaElement&) const;
+    bool pageAllowsDataLoading(const HTMLMediaElement&) const;
+    bool pageAllowsPlaybackAfterResuming(const HTMLMediaElement&) const;
+
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+    void showPlaybackTargetPicker(const HTMLMediaElement&);
+    bool hasWirelessPlaybackTargets(const HTMLMediaElement&) const;
+
+    bool wirelessVideoPlaybackDisabled(const HTMLMediaElement&) const;
+    void setWirelessVideoPlaybackDisabled(const HTMLMediaElement&, bool);
+
+    void setHasPlaybackTargetAvailabilityListeners(const HTMLMediaElement&, bool);
+
+    virtual bool canPlayToWirelessPlaybackTarget() const override;
+    virtual bool isPlayingToWirelessPlaybackTarget() const override;
+
+    void mediaStateDidChange(const HTMLMediaElement&, MediaProducer::MediaStateFlags);
+#endif
+
+    bool requiresFullscreenForVideoPlayback(const HTMLMediaElement&) const;
+    WEBCORE_EXPORT bool allowsAlternateFullscreen(const HTMLMediaElement&) const;
+    MediaPlayer::Preload effectivePreloadForElement(const HTMLMediaElement&) const;
+
+    void mediaEngineUpdated(const HTMLMediaElement&);
+
+    // Restrictions to modify default behaviors.
+    enum BehaviorRestrictionFlags {
+        NoRestrictions = 0,
+        RequireUserGestureForLoad = 1 << 0,
+        RequireUserGestureForRateChange = 1 << 1,
+        RequireUserGestureForFullscreen = 1 << 2,
+        RequirePageConsentToLoadMedia = 1 << 3,
+        RequirePageConsentToResumeMedia = 1 << 4,
+        RequireUserGestureForAudioRateChange = 1 << 5,
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+        RequireUserGestureToShowPlaybackTargetPicker = 1 << 6,
+        WirelessVideoPlaybackDisabled =  1 << 7,
+        RequireUserGestureToAutoplayToExternalDevice = 1 << 8,
+#endif
+    };
+    typedef unsigned BehaviorRestrictions;
+
+    WEBCORE_EXPORT BehaviorRestrictions behaviorRestrictions() const { return m_restrictions; }
+    WEBCORE_EXPORT void addBehaviorRestriction(BehaviorRestrictions);
+    WEBCORE_EXPORT void removeBehaviorRestriction(BehaviorRestrictions);
+    bool hasBehaviorRestriction(BehaviorRestrictions restriction) const { return restriction & m_restrictions; }
+
+#if ENABLE(MEDIA_SOURCE)
+    size_t maximumMediaSourceBufferSize(const SourceBuffer&) const;
+#endif
+
+private:
+
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+    void targetAvailabilityChangedTimerFired();
+
+    // MediaPlaybackTargetClient
+    virtual void setPlaybackTarget(Ref<MediaPlaybackTarget>&&) override;
+    virtual void externalOutputDeviceAvailableDidChange(bool) override;
+    virtual void setShouldPlayToPlaybackTarget(bool) override;
+#endif
+#if PLATFORM(IOS)
+    bool requiresPlaybackTargetRouteMonitoring() const override { return m_hasPlaybackTargetAvailabilityListeners; }
+#endif
+
+    BehaviorRestrictions m_restrictions;
+
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+    mutable Timer m_targetAvailabilityChangedTimer;
+    RefPtr<MediaPlaybackTarget> m_playbackTarget;
+    bool m_shouldPlayToPlaybackTarget { false };
+    mutable bool m_hasPlaybackTargets { false };
+#endif
+#if PLATFORM(IOS)
+    bool m_hasPlaybackTargetAvailabilityListeners { false };
+#endif
+};
+
+}
+
+#endif // MediaElementSession_h
+
+#endif // ENABLE(VIDEO)

Modified: trunk/Source/WebCore/testing/Internals.cpp (184965 => 184966)


--- trunk/Source/WebCore/testing/Internals.cpp	2015-05-28 22:41:19 UTC (rev 184965)
+++ trunk/Source/WebCore/testing/Internals.cpp	2015-05-28 23:03:34 UTC (rev 184966)
@@ -2648,34 +2648,34 @@
         return;
     }
 
-    HTMLMediaSession::BehaviorRestrictions restrictions = element->mediaSession().behaviorRestrictions();
+    MediaElementSession::BehaviorRestrictions restrictions = element->mediaSession().behaviorRestrictions();
     element->mediaSession().removeBehaviorRestriction(restrictions);
 
-    restrictions = HTMLMediaSession::NoRestrictions;
+    restrictions = MediaElementSession::NoRestrictions;
 
     Vector<String> restrictionsArray;
     restrictionsString.split(',', false, restrictionsArray);
     for (auto& restrictionString : restrictionsArray) {
         if (equalIgnoringCase(restrictionString, "NoRestrictions"))
-            restrictions |= HTMLMediaSession::NoRestrictions;
+            restrictions |= MediaElementSession::NoRestrictions;
         if (equalIgnoringCase(restrictionString, "RequireUserGestureForLoad"))
-            restrictions |= HTMLMediaSession::RequireUserGestureForLoad;
+            restrictions |= MediaElementSession::RequireUserGestureForLoad;
         if (equalIgnoringCase(restrictionString, "RequireUserGestureForRateChange"))
-            restrictions |= HTMLMediaSession::RequireUserGestureForRateChange;
+            restrictions |= MediaElementSession::RequireUserGestureForRateChange;
         if (equalIgnoringCase(restrictionString, "RequireUserGestureForFullscreen"))
-            restrictions |= HTMLMediaSession::RequireUserGestureForFullscreen;
+            restrictions |= MediaElementSession::RequireUserGestureForFullscreen;
         if (equalIgnoringCase(restrictionString, "RequirePageConsentToLoadMedia"))
-            restrictions |= HTMLMediaSession::RequirePageConsentToLoadMedia;
+            restrictions |= MediaElementSession::RequirePageConsentToLoadMedia;
         if (equalIgnoringCase(restrictionString, "RequirePageConsentToResumeMedia"))
-            restrictions |= HTMLMediaSession::RequirePageConsentToResumeMedia;
+            restrictions |= MediaElementSession::RequirePageConsentToResumeMedia;
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
         if (equalIgnoringCase(restrictionString, "RequireUserGestureToShowPlaybackTargetPicker"))
-            restrictions |= HTMLMediaSession::RequireUserGestureToShowPlaybackTargetPicker;
+            restrictions |= MediaElementSession::RequireUserGestureToShowPlaybackTargetPicker;
         if (equalIgnoringCase(restrictionString, "WirelessVideoPlaybackDisabled"))
-            restrictions |= HTMLMediaSession::WirelessVideoPlaybackDisabled;
+            restrictions |= MediaElementSession::WirelessVideoPlaybackDisabled;
 #endif
         if (equalIgnoringCase(restrictionString, "RequireUserGestureForAudioRateChange"))
-            restrictions |= HTMLMediaSession::RequireUserGestureForAudioRateChange;
+            restrictions |= MediaElementSession::RequireUserGestureForAudioRateChange;
     }
     element->mediaSession().addBehaviorRestriction(restrictions);
 }
@@ -2727,7 +2727,7 @@
     AudioContext::BehaviorRestrictions restrictions = context->behaviorRestrictions();
     context->removeBehaviorRestriction(restrictions);
 
-    restrictions = HTMLMediaSession::NoRestrictions;
+    restrictions = MediaElementSession::NoRestrictions;
 
     Vector<String> restrictionsArray;
     restrictionsString.split(',', false, restrictionsArray);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to