<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[182486] trunk/Source/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/182486">182486</a></dd>
<dt>Author</dt> <dd>eric.carlson@apple.com</dd>
<dt>Date</dt> <dd>2015-04-07 13:23:17 -0700 (Tue, 07 Apr 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>[Mac] video playing to external device should not be interrupted
https://bugs.webkit.org/show_bug.cgi?id=143492

Reviewed by Jer Noble.

* Modules/mediacontrols/mediaControlsApple.js:
(Controller.prototype.handlePanelTransitionEnd):  Drive-by fix to make sure the controls are 
    not hidden if the opacity timer is primed before they go into a state where they should
    never be hidden.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::canPlayToWirelessPlaybackTarget): Make it const.
(WebCore::HTMLMediaElement::isPlayingToWirelessPlaybackTarget): New.
* html/HTMLMediaElement.h:

* html/HTMLMediaSession.cpp:
(WebCore::HTMLMediaSession::canPlayToWirelessPlaybackTarget): New. Short-circuit call to
    client when we already know the answer.
(WebCore::HTMLMediaSession::isPlayingToWirelessPlaybackTarget): Ditto.
(WebCore::HTMLMediaSession::startPlayingToPlaybackTarget): Ditto.
(WebCore::HTMLMediaSession::stopPlayingToPlaybackTarget): Ditto.
* html/HTMLMediaSession.h:

* platform/audio/MediaSession.cpp:
(WebCore::MediaSession::canPlayToWirelessPlaybackTarget): Deleted, moved inline and neutered
    because only HTMLMediaSession needs to use them.
(WebCore::MediaSession::startPlayingToPlaybackTarget): Ditto.
(WebCore::MediaSession::stopPlayingToPlaybackTarget): Ditto.
* platform/audio/MediaSession.h:
(WebCore::MediaSession::canPlayToWirelessPlaybackTarget):
(WebCore::MediaSession::isPlayingToWirelessPlaybackTarget):
(WebCore::MediaSession::startPlayingToPlaybackTarget):
(WebCore::MediaSession::stopPlayingToPlaybackTarget):
(WebCore::MediaSessionClient::canPlayToWirelessPlaybackTarget):
(WebCore::MediaSessionClient::isPlayingToWirelessPlaybackTarget):

* platform/audio/MediaSessionManager.cpp:
(WebCore::MediaSessionManager::MediaSessionManager):
(WebCore::MediaSessionManager::sessionShouldBeginPlayingToWirelessPlaybackTarget): New.
(WebCore::MediaSessionManager::sessionWillBeginPlayback): Don't interrupt an active session
    playing to a target device.
* platform/audio/MediaSessionManager.h:

* platform/graphics/MediaPlayer.cpp:
(WebCore::MediaPlayer::isPlayingToWirelessPlaybackTarget): New, passthrough.
* platform/graphics/MediaPlayer.h:
* platform/graphics/MediaPlayerPrivate.h:
(WebCore::MediaPlayerPrivateInterface::isPlayingToWirelessPlaybackTarget):

* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
(WebCore::MediaPlayerPrivateAVFoundationObjC::canPlayToWirelessPlaybackTarget):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::setWirelessPlaybackTarget): Explicitly call 
    when passed a nil or inactive target context.
(WebCore::MediaPlayerPrivateAVFoundationObjC::startPlayingToPlaybackTarget): Add logging.
(WebCore::MediaPlayerPrivateAVFoundationObjC::stopPlayingToPlaybackTarget): Ditto.
(WebCore::MediaPlayerPrivateAVFoundationObjC::isPlayingToWirelessPlaybackTarget): New. Return
    true when playing with an active context.
(WebCore::playerKVOProperties): &quot;outputContext&quot; is not observable.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesmediacontrolsmediaControlsApplejs">trunk/Source/WebCore/Modules/mediacontrols/mediaControlsApple.js</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLMediaElementcpp">trunk/Source/WebCore/html/HTMLMediaElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLMediaElementh">trunk/Source/WebCore/html/HTMLMediaElement.h</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLMediaSessioncpp">trunk/Source/WebCore/html/HTMLMediaSession.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLMediaSessionh">trunk/Source/WebCore/html/HTMLMediaSession.h</a></li>
<li><a href="#trunkSourceWebCoreplatformaudioMediaSessioncpp">trunk/Source/WebCore/platform/audio/MediaSession.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformaudioMediaSessionh">trunk/Source/WebCore/platform/audio/MediaSession.h</a></li>
<li><a href="#trunkSourceWebCoreplatformaudioMediaSessionManagercpp">trunk/Source/WebCore/platform/audio/MediaSessionManager.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformaudioMediaSessionManagerh">trunk/Source/WebCore/platform/audio/MediaSessionManager.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsMediaPlayercpp">trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsMediaPlayerh">trunk/Source/WebCore/platform/graphics/MediaPlayer.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsMediaPlayerPrivateh">trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsavfoundationobjcMediaPlayerPrivateAVFoundationObjCh">trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsavfoundationobjcMediaPlayerPrivateAVFoundationObjCmm">trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (182485 => 182486)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-04-07 20:14:20 UTC (rev 182485)
+++ trunk/Source/WebCore/ChangeLog        2015-04-07 20:23:17 UTC (rev 182486)
</span><span class="lines">@@ -1,3 +1,65 @@
</span><ins>+2015-04-07  Eric Carlson  &lt;eric.carlson@apple.com&gt;
+
+        [Mac] video playing to external device should not be interrupted
+        https://bugs.webkit.org/show_bug.cgi?id=143492
+
+        Reviewed by Jer Noble.
+
+        * Modules/mediacontrols/mediaControlsApple.js:
+        (Controller.prototype.handlePanelTransitionEnd):  Drive-by fix to make sure the controls are 
+            not hidden if the opacity timer is primed before they go into a state where they should
+            never be hidden.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::canPlayToWirelessPlaybackTarget): Make it const.
+        (WebCore::HTMLMediaElement::isPlayingToWirelessPlaybackTarget): New.
+        * html/HTMLMediaElement.h:
+
+        * html/HTMLMediaSession.cpp:
+        (WebCore::HTMLMediaSession::canPlayToWirelessPlaybackTarget): New. Short-circuit call to
+            client when we already know the answer.
+        (WebCore::HTMLMediaSession::isPlayingToWirelessPlaybackTarget): Ditto.
+        (WebCore::HTMLMediaSession::startPlayingToPlaybackTarget): Ditto.
+        (WebCore::HTMLMediaSession::stopPlayingToPlaybackTarget): Ditto.
+        * html/HTMLMediaSession.h:
+
+        * platform/audio/MediaSession.cpp:
+        (WebCore::MediaSession::canPlayToWirelessPlaybackTarget): Deleted, moved inline and neutered
+            because only HTMLMediaSession needs to use them.
+        (WebCore::MediaSession::startPlayingToPlaybackTarget): Ditto.
+        (WebCore::MediaSession::stopPlayingToPlaybackTarget): Ditto.
+        * platform/audio/MediaSession.h:
+        (WebCore::MediaSession::canPlayToWirelessPlaybackTarget):
+        (WebCore::MediaSession::isPlayingToWirelessPlaybackTarget):
+        (WebCore::MediaSession::startPlayingToPlaybackTarget):
+        (WebCore::MediaSession::stopPlayingToPlaybackTarget):
+        (WebCore::MediaSessionClient::canPlayToWirelessPlaybackTarget):
+        (WebCore::MediaSessionClient::isPlayingToWirelessPlaybackTarget):
+
+        * platform/audio/MediaSessionManager.cpp:
+        (WebCore::MediaSessionManager::MediaSessionManager):
+        (WebCore::MediaSessionManager::sessionShouldBeginPlayingToWirelessPlaybackTarget): New.
+        (WebCore::MediaSessionManager::sessionWillBeginPlayback): Don't interrupt an active session
+            playing to a target device.
+        * platform/audio/MediaSessionManager.h:
+
+        * platform/graphics/MediaPlayer.cpp:
+        (WebCore::MediaPlayer::isPlayingToWirelessPlaybackTarget): New, passthrough.
+        * platform/graphics/MediaPlayer.h:
+        * platform/graphics/MediaPlayerPrivate.h:
+        (WebCore::MediaPlayerPrivateInterface::isPlayingToWirelessPlaybackTarget):
+
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::canPlayToWirelessPlaybackTarget):
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::setWirelessPlaybackTarget): Explicitly call 
+            when passed a nil or inactive target context.
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::startPlayingToPlaybackTarget): Add logging.
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::stopPlayingToPlaybackTarget): Ditto.
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::isPlayingToWirelessPlaybackTarget): New. Return
+            true when playing with an active context.
+        (WebCore::playerKVOProperties): &quot;outputContext&quot; is not observable.
+
</ins><span class="cx"> 2015-04-07  Sam Weinig  &lt;sam@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Re-add JSReadableStream and JSReadableStreamReader the Xcode project to
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediacontrolsmediaControlsApplejs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediacontrols/mediaControlsApple.js (182485 => 182486)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediacontrols/mediaControlsApple.js        2015-04-07 20:14:20 UTC (rev 182485)
+++ trunk/Source/WebCore/Modules/mediacontrols/mediaControlsApple.js        2015-04-07 20:23:17 UTC (rev 182486)
</span><span class="lines">@@ -783,7 +783,7 @@
</span><span class="cx">         var opacity = window.getComputedStyle(this.controls.panel).opacity;
</span><span class="cx">         if (parseInt(opacity) &gt; 0) {
</span><span class="cx">             this.controls.panel.classList.remove(this.ClassNames.hidden);
</span><del>-        } else {
</del><ins>+        } else if (!this.controlsAlwaysVisible()) {
</ins><span class="cx">             this.controls.panel.classList.add(this.ClassNames.hidden);
</span><span class="cx">         }
</span><span class="cx">     },
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (182485 => 182486)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-04-07 20:14:20 UTC (rev 182485)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-04-07 20:23:17 UTC (rev 182486)
</span><span class="lines">@@ -7303,7 +7303,7 @@
</span><span class="cx">                 078E43D81ABB6C7E001C2FA6 /* MediaPlaybackTargetPicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaPlaybackTargetPicker.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 078E43DB1ABB6F6F001C2FA6 /* MediaPlaybackTargetPickerMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MediaPlaybackTargetPickerMac.h; path = objc/MediaPlaybackTargetPickerMac.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 078E43DC1ABB6F6F001C2FA6 /* MediaPlaybackTargetPickerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MediaPlaybackTargetPickerMac.mm; path = objc/MediaPlaybackTargetPickerMac.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><del>-                079216531AA560AA00A3C049 /* MediaPlaybackTargetPickerClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MediaPlaybackTargetPickerClient.h; path = graphics/MediaPlaybackTargetPickerClient.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</del><ins>+                079216531AA560AA00A3C049 /* MediaPlaybackTargetPickerClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaPlaybackTargetPickerClient.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 0794178F166E855F009416C2 /* InbandTextTrack.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InbandTextTrack.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 07941790166E855F009416C2 /* InbandTextTrack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InbandTextTrack.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 07941793166EA04E009416C2 /* InbandTextTrackPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InbandTextTrackPrivate.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -20818,6 +20818,7 @@
</span><span class="cx">                                 6C568CAF19DAFEA000430CA2 /* MaskImageOperation.h */,
</span><span class="cx">                                 078E43D71ABB6C7E001C2FA6 /* MediaPlaybackTargetPicker.cpp */,
</span><span class="cx">                                 078E43D81ABB6C7E001C2FA6 /* MediaPlaybackTargetPicker.h */,
</span><ins>+                                079216531AA560AA00A3C049 /* MediaPlaybackTargetPickerClient.h */,
</ins><span class="cx">                                 E4B41E0C0CBF90BD00AF2ECE /* MediaPlayer.cpp */,
</span><span class="cx">                                 E4B41E0D0CBF90BD00AF2ECE /* MediaPlayer.h */,
</span><span class="cx">                                 079F5E4B0F3BEBEA005E0782 /* MediaPlayerPrivate.h */,
</span><span class="lines">@@ -21623,7 +21624,6 @@
</span><span class="cx">                 BCF1A5BA097832090061A123 /* platform */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><del>-                                079216531AA560AA00A3C049 /* MediaPlaybackTargetPickerClient.h */,
</del><span class="cx">                                 49E912A40EFAC8E6009D0CAF /* animation */,
</span><span class="cx">                                 FD31604012B026A300C1A359 /* audio */,
</span><span class="cx">                                 1AE42F670AA4B8CB00C8612D /* cf */,
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLMediaElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (182485 => 182486)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLMediaElement.cpp        2015-04-07 20:14:20 UTC (rev 182485)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp        2015-04-07 20:23:17 UTC (rev 182486)
</span><span class="lines">@@ -4885,7 +4885,7 @@
</span><span class="cx">         m_player-&gt;setWirelessPlaybackTarget(device);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool HTMLMediaElement::canPlayToWirelessPlaybackTarget()
</del><ins>+bool HTMLMediaElement::canPlayToWirelessPlaybackTarget() const
</ins><span class="cx"> {
</span><span class="cx">     bool canPlay = m_player &amp;&amp; m_player-&gt;canPlayToWirelessPlaybackTarget();
</span><span class="cx"> 
</span><span class="lines">@@ -4894,6 +4894,15 @@
</span><span class="cx">     return canPlay;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool HTMLMediaElement::isPlayingToWirelessPlaybackTarget() const
+{
+    bool isPlaying = m_player &amp;&amp; m_player-&gt;isPlayingToWirelessPlaybackTarget();
+
+    LOG(Media, &quot;HTMLMediaElement::isPlayingToWirelessPlaybackTarget(%p) - returning %s&quot;, this, boolString(isPlaying));
+    
+    return isPlaying;
+}
+
</ins><span class="cx"> void HTMLMediaElement::startPlayingToPlaybackTarget()
</span><span class="cx"> {
</span><span class="cx">     if (m_player)
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLMediaElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (182485 => 182486)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLMediaElement.h        2015-04-07 20:14:20 UTC (rev 182485)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h        2015-04-07 20:23:17 UTC (rev 182486)
</span><span class="lines">@@ -361,7 +361,8 @@
</span><span class="cx">     virtual bool removeEventListener(const AtomicString&amp; eventType, EventListener*, bool useCapture) override;
</span><span class="cx"> 
</span><span class="cx">     virtual void wirelessRoutesAvailableDidChange() override;
</span><del>-    virtual bool canPlayToWirelessPlaybackTarget() override;
</del><ins>+    virtual bool canPlayToWirelessPlaybackTarget() const override;
+    virtual bool isPlayingToWirelessPlaybackTarget() const override;
</ins><span class="cx">     virtual void setWirelessPlaybackTarget(const MediaPlaybackTarget&amp;) override;
</span><span class="cx">     virtual void startPlayingToPlaybackTarget() override;
</span><span class="cx">     virtual void stopPlayingToPlaybackTarget() override;
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLMediaSessioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLMediaSession.cpp (182485 => 182486)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLMediaSession.cpp        2015-04-07 20:14:20 UTC (rev 182485)
+++ trunk/Source/WebCore/html/HTMLMediaSession.cpp        2015-04-07 20:23:17 UTC (rev 182486)
</span><span class="lines">@@ -317,6 +317,38 @@
</span><span class="cx"> {
</span><span class="cx">     return m_hasPlaybackTargetAvailabilityListeners;
</span><span class="cx"> }
</span><ins>+
+bool HTMLMediaSession::canPlayToWirelessPlaybackTarget() const
+{
+    if (!m_playbackTarget || !m_playbackTarget-&gt;hasActiveRoute())
+        return false;
+
+    return client().canPlayToWirelessPlaybackTarget();
+}
+
+bool HTMLMediaSession::isPlayingToWirelessPlaybackTarget() const
+{
+    if (!m_playbackTarget || !m_playbackTarget-&gt;hasActiveRoute())
+        return false;
+
+    return client().isPlayingToWirelessPlaybackTarget();
+}
+
+void HTMLMediaSession::startPlayingToPlaybackTarget()
+{
+    if (!m_playbackTarget || !m_playbackTarget-&gt;hasActiveRoute())
+        return;
+
+    client().startPlayingToPlaybackTarget();
+}
+
+void HTMLMediaSession::stopPlayingToPlaybackTarget()
+{
+    if (!m_playbackTarget || !m_playbackTarget-&gt;hasActiveRoute())
+        return;
+
+    client().stopPlayingToPlaybackTarget();
+}    
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> MediaPlayer::Preload HTMLMediaSession::effectivePreloadForElement(const HTMLMediaElement&amp; element) const
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLMediaSessionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLMediaSession.h (182485 => 182486)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLMediaSession.h        2015-04-07 20:14:20 UTC (rev 182485)
+++ trunk/Source/WebCore/html/HTMLMediaSession.h        2015-04-07 20:23:17 UTC (rev 182486)
</span><span class="lines">@@ -63,6 +63,11 @@
</span><span class="cx">     void setWirelessVideoPlaybackDisabled(const HTMLMediaElement&amp;, bool);
</span><span class="cx"> 
</span><span class="cx">     void setHasPlaybackTargetAvailabilityListeners(const HTMLMediaElement&amp;, bool);
</span><ins>+
+    virtual bool canPlayToWirelessPlaybackTarget() const override;
+    virtual bool isPlayingToWirelessPlaybackTarget() const override;
+    virtual void startPlayingToPlaybackTarget() override;
+    virtual void stopPlayingToPlaybackTarget() override;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     bool requiresFullscreenForVideoPlayback(const HTMLMediaElement&amp;) const;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformaudioMediaSessioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/audio/MediaSession.cpp (182485 => 182486)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/audio/MediaSession.cpp        2015-04-07 20:14:20 UTC (rev 182485)
+++ trunk/Source/WebCore/platform/audio/MediaSession.cpp        2015-04-07 20:23:17 UTC (rev 182486)
</span><span class="lines">@@ -227,21 +227,6 @@
</span><span class="cx">     return m_client.displayType();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool MediaSession::canPlayToWirelessPlaybackTarget() const
-{
-    return m_client.canPlayToWirelessPlaybackTarget();
-}
-
-void MediaSession::startPlayingToPlaybackTarget()
-{
-    client().startPlayingToPlaybackTarget();
-}
-
-void MediaSession::stopPlayingToPlaybackTarget()
-{
-    client().stopPlayingToPlaybackTarget();
-}
-
</del><span class="cx"> String MediaSessionClient::mediaSessionTitle() const
</span><span class="cx"> {
</span><span class="cx">     return String();
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformaudioMediaSessionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/audio/MediaSession.h (182485 => 182486)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/audio/MediaSession.h        2015-04-07 20:14:20 UTC (rev 182485)
+++ trunk/Source/WebCore/platform/audio/MediaSession.h        2015-04-07 20:23:17 UTC (rev 182486)
</span><span class="lines">@@ -117,9 +117,10 @@
</span><span class="cx"> 
</span><span class="cx">     bool isHidden() const;
</span><span class="cx"> 
</span><del>-    bool canPlayToWirelessPlaybackTarget() const;
-    void startPlayingToPlaybackTarget();
-    void stopPlayingToPlaybackTarget();
</del><ins>+    virtual bool canPlayToWirelessPlaybackTarget() const { return false; }
+    virtual bool isPlayingToWirelessPlaybackTarget() const { return false; }
+    virtual void startPlayingToPlaybackTarget() { }
+    virtual void stopPlayingToPlaybackTarget() { }
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(WIRELESS_PLAYBACK_TARGET)
</span><span class="cx">     // MediaPlaybackTargetPickerClient
</span><span class="lines">@@ -169,7 +170,8 @@
</span><span class="cx"> 
</span><span class="cx">     virtual void wirelessRoutesAvailableDidChange() { }
</span><span class="cx">     virtual void setWirelessPlaybackTarget(const MediaPlaybackTarget&amp;) { }
</span><del>-    virtual bool canPlayToWirelessPlaybackTarget() { return false; }
</del><ins>+    virtual bool canPlayToWirelessPlaybackTarget() const { return false; }
+    virtual bool isPlayingToWirelessPlaybackTarget() const { return false; }
</ins><span class="cx">     virtual void startPlayingToPlaybackTarget() { }
</span><span class="cx">     virtual void stopPlayingToPlaybackTarget() { }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformaudioMediaSessionManagercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/audio/MediaSessionManager.cpp (182485 => 182486)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/audio/MediaSessionManager.cpp        2015-04-07 20:14:20 UTC (rev 182485)
+++ trunk/Source/WebCore/platform/audio/MediaSessionManager.cpp        2015-04-07 20:23:17 UTC (rev 182486)
</span><span class="lines">@@ -45,7 +45,6 @@
</span><span class="cx"> 
</span><span class="cx"> MediaSessionManager::MediaSessionManager()
</span><span class="cx">     : m_systemSleepListener(SystemSleepListener::create(*this))
</span><del>-    , m_interrupted(false)
</del><span class="cx"> {
</span><span class="cx">     resetRestrictions();
</span><span class="cx"> }
</span><span class="lines">@@ -167,6 +166,25 @@
</span><span class="cx">     return m_restrictions[type];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool MediaSessionManager::sessionShouldBeginPlayingToWirelessPlaybackTarget(MediaSession&amp; session) const
+{
+    if (!session.canPlayToWirelessPlaybackTarget())
+        return false;
+
+    if (session.isPlayingToWirelessPlaybackTarget())
+        return false;
+
+    Vector&lt;MediaSession*&gt; sessions = m_sessions;
+    for (auto* oneSession : sessions) {
+        if (oneSession == &amp;session)
+            continue;
+        if (oneSession-&gt;isPlayingToWirelessPlaybackTarget())
+            return false;
+    }
+
+    return true;
+}
+
</ins><span class="cx"> bool MediaSessionManager::sessionWillBeginPlayback(MediaSession&amp; session)
</span><span class="cx"> {
</span><span class="cx">     LOG(Media, &quot;MediaSessionManager::sessionWillBeginPlayback - %p&quot;, &amp;session);
</span><span class="lines">@@ -186,18 +204,20 @@
</span><span class="cx">     if (m_interrupted)
</span><span class="cx">         endInterruption(MediaSession::NoFlags);
</span><span class="cx"> 
</span><del>-    bool newSessionCanPlayToPlaybackTarget = session.canPlayToWirelessPlaybackTarget();
</del><ins>+    bool shouldPlayToPlaybackTarget = sessionShouldBeginPlayingToWirelessPlaybackTarget(session);
</ins><span class="cx">     Vector&lt;MediaSession*&gt; sessions = m_sessions;
</span><span class="cx">     for (auto* oneSession : sessions) {
</span><span class="cx">         if (oneSession == &amp;session)
</span><span class="cx">             continue;
</span><del>-        if (newSessionCanPlayToPlaybackTarget)
</del><ins>+        if (shouldPlayToPlaybackTarget)
</ins><span class="cx">             oneSession-&gt;stopPlayingToPlaybackTarget();
</span><span class="cx">         if (oneSession-&gt;mediaType() == sessionType &amp;&amp; restrictions &amp; ConcurrentPlaybackNotPermitted)
</span><span class="cx">             oneSession-&gt;pauseSession();
</span><span class="cx">     }
</span><del>-    session.startPlayingToPlaybackTarget();
</del><span class="cx"> 
</span><ins>+    if (shouldPlayToPlaybackTarget)
+        session.startPlayingToPlaybackTarget();
+
</ins><span class="cx">     updateSessionState();
</span><span class="cx">     return true;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformaudioMediaSessionManagerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/audio/MediaSessionManager.h (182485 => 182486)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/audio/MediaSessionManager.h        2015-04-07 20:14:20 UTC (rev 182485)
+++ trunk/Source/WebCore/platform/audio/MediaSessionManager.h        2015-04-07 20:23:17 UTC (rev 182486)
</span><span class="lines">@@ -101,6 +101,7 @@
</span><span class="cx">     friend class Internals;
</span><span class="cx"> 
</span><span class="cx">     void updateSessionState();
</span><ins>+    bool sessionShouldBeginPlayingToWirelessPlaybackTarget(MediaSession&amp;) const;
</ins><span class="cx"> 
</span><span class="cx">     // RemoteCommandListenerClient
</span><span class="cx">     WEBCORE_EXPORT virtual void didReceiveRemoteControlCommand(MediaSession::RemoteControlCommandType) override;
</span><span class="lines">@@ -117,10 +118,11 @@
</span><span class="cx">     SessionRestrictions m_restrictions[MediaSession::WebAudio + 1];
</span><span class="cx"> 
</span><span class="cx">     Vector&lt;MediaSession*&gt; m_sessions;
</span><ins>+
</ins><span class="cx">     std::unique_ptr&lt;RemoteCommandListener&gt; m_remoteCommandListener;
</span><span class="cx">     std::unique_ptr&lt;SystemSleepListener&gt; m_systemSleepListener;
</span><span class="cx">     RefPtr&lt;AudioHardwareListener&gt; m_audioHardwareListener;
</span><del>-    bool m_interrupted;
</del><ins>+    bool m_interrupted { false };
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsMediaPlayercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp (182485 => 182486)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp        2015-04-07 20:14:20 UTC (rev 182485)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp        2015-04-07 20:23:17 UTC (rev 182486)
</span><span class="lines">@@ -878,6 +878,11 @@
</span><span class="cx">     return m_private-&gt;canPlayToWirelessPlaybackTarget();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool MediaPlayer::isPlayingToWirelessPlaybackTarget() const
+{
+    return m_private-&gt;isPlayingToWirelessPlaybackTarget();
+}
+
</ins><span class="cx"> void MediaPlayer::setWirelessPlaybackTarget(const MediaPlaybackTarget&amp; device)
</span><span class="cx"> {
</span><span class="cx">     m_private-&gt;setWirelessPlaybackTarget(device);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsMediaPlayerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.h (182485 => 182486)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/MediaPlayer.h        2015-04-07 20:14:20 UTC (rev 182485)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.h        2015-04-07 20:23:17 UTC (rev 182486)
</span><span class="lines">@@ -480,6 +480,7 @@
</span><span class="cx">     void playbackTargetAvailabilityChanged();
</span><span class="cx"> 
</span><span class="cx">     bool canPlayToWirelessPlaybackTarget() const;
</span><ins>+    bool isPlayingToWirelessPlaybackTarget() const;
</ins><span class="cx">     void setWirelessPlaybackTarget(const MediaPlaybackTarget&amp;);
</span><span class="cx"> 
</span><span class="cx">     void startPlayingToPlaybackTarget();
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsMediaPlayerPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h (182485 => 182486)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h        2015-04-07 20:14:20 UTC (rev 182485)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h        2015-04-07 20:23:17 UTC (rev 182486)
</span><span class="lines">@@ -170,6 +170,7 @@
</span><span class="cx">     virtual void setWirelessVideoPlaybackDisabled(bool) { }
</span><span class="cx"> 
</span><span class="cx">     virtual bool canPlayToWirelessPlaybackTarget() const { return false; }
</span><ins>+    virtual bool isPlayingToWirelessPlaybackTarget() { return false; }
</ins><span class="cx">     virtual void setWirelessPlaybackTarget(const MediaPlaybackTarget&amp;) { }
</span><span class="cx"> 
</span><span class="cx">     virtual void startPlayingToPlaybackTarget() { }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsavfoundationobjcMediaPlayerPrivateAVFoundationObjCh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h (182485 => 182486)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h        2015-04-07 20:14:20 UTC (rev 182485)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h        2015-04-07 20:23:17 UTC (rev 182486)
</span><span class="lines">@@ -277,14 +277,15 @@
</span><span class="cx">     virtual MediaPlayer::WirelessPlaybackTargetType wirelessPlaybackTargetType() const override;
</span><span class="cx">     virtual bool wirelessVideoPlaybackDisabled() const override;
</span><span class="cx">     virtual void setWirelessVideoPlaybackDisabled(bool) override;
</span><ins>+    virtual bool canPlayToWirelessPlaybackTarget() const { return true; }
</ins><span class="cx">     void updateDisableExternalPlayback();
</span><del>-    bool canPlayToWirelessPlaybackTarget() const { return true; }
</del><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(WIRELESS_PLAYBACK_TARGET) &amp;&amp; !PLATFORM(IOS)
</span><span class="cx">     virtual void setWirelessPlaybackTarget(const MediaPlaybackTarget&amp;) override;
</span><span class="cx">     virtual void startPlayingToPlaybackTarget() override;
</span><span class="cx">     virtual void stopPlayingToPlaybackTarget() override;
</span><ins>+    virtual bool isPlayingToWirelessPlaybackTarget();
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     virtual double maxFastForwardRate() const override { return m_cachedCanPlayFastForward ? std::numeric_limits&lt;double&gt;::infinity() : 2.0; }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsavfoundationobjcMediaPlayerPrivateAVFoundationObjCmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (182485 => 182486)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm        2015-04-07 20:14:20 UTC (rev 182485)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm        2015-04-07 20:23:17 UTC (rev 182486)
</span><span class="lines">@@ -2768,6 +2768,9 @@
</span><span class="cx"> {
</span><span class="cx">     m_outputContext = target.devicePickerContext();
</span><span class="cx">     LOG(Media, &quot;MediaPlayerPrivateAVFoundationObjC::setWirelessPlaybackTarget(%p) - target = %p&quot;, this, m_outputContext.get());
</span><ins>+
+    if (!m_outputContext || !m_outputContext.get().deviceName)
+        stopPlayingToPlaybackTarget();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void MediaPlayerPrivateAVFoundationObjC::startPlayingToPlaybackTarget()
</span><span class="lines">@@ -2781,6 +2784,8 @@
</span><span class="cx">     setDelayCallbacks(true);
</span><span class="cx">     m_avPlayer.get().outputContext = m_outputContext.get();
</span><span class="cx">     setDelayCallbacks(false);
</span><ins>+
+    LOG(Media, &quot;MediaPlayerPrivateAVFoundationObjC::startPlayingToPlaybackTarget(%p) - target = %p&quot;, this, m_avPlayer.get().outputContext);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void MediaPlayerPrivateAVFoundationObjC::stopPlayingToPlaybackTarget()
</span><span class="lines">@@ -2792,9 +2797,22 @@
</span><span class="cx">     // FIXME: uncomment the following line once rdar://20335217 has been fixed.
</span><span class="cx">     // m_avPlayer.get().outputContext = nil;
</span><span class="cx">     setDelayCallbacks(false);
</span><ins>+
+    LOG(Media, &quot;MediaPlayerPrivateAVFoundationObjC::stopPlayingToPlaybackTarget(%p) - target = %p&quot;, this, m_avPlayer.get().outputContext);
</ins><span class="cx"> }
</span><del>-#endif
</del><span class="cx"> 
</span><ins>+bool MediaPlayerPrivateAVFoundationObjC::isPlayingToWirelessPlaybackTarget()
+{
+    if (!m_avPlayer)
+        return false;
+
+    if (!m_outputContext || !m_outputContext.get().deviceName)
+        return false;
+
+    return m_cachedRate;
+}
+#endif // !PLATFORM(IOS)
+
</ins><span class="cx"> void MediaPlayerPrivateAVFoundationObjC::updateDisableExternalPlayback()
</span><span class="cx"> {
</span><span class="cx">     if (!m_avPlayer)
</span><span class="lines">@@ -3110,7 +3128,7 @@
</span><span class="cx"> {
</span><span class="cx">     static NSArray* keys = [[NSArray alloc] initWithObjects:@&quot;rate&quot;,
</span><span class="cx"> #if ENABLE(WIRELESS_PLAYBACK_TARGET)
</span><del>-                            @&quot;externalPlaybackActive&quot;, @&quot;outputContext&quot;, @&quot;allowsExternalPlayback&quot;,
</del><ins>+                            @&quot;externalPlaybackActive&quot;, @&quot;allowsExternalPlayback&quot;,
</ins><span class="cx"> #endif
</span><span class="cx">                             nil];
</span><span class="cx">     return keys;
</span><span class="lines">@@ -3231,7 +3249,7 @@
</span><span class="cx">         if ([keyPath isEqualToString:@&quot;rate&quot;])
</span><span class="cx">             function = WTF::bind(&amp;MediaPlayerPrivateAVFoundationObjC::rateDidChange, m_callback, [newValue doubleValue]);
</span><span class="cx"> #if ENABLE(WIRELESS_PLAYBACK_TARGET)
</span><del>-        else if ([keyPath isEqualToString:@&quot;externalPlaybackActive&quot;] || [keyPath isEqualToString:@&quot;outputContext&quot;] || [keyPath isEqualToString:@&quot;allowsExternalPlayback&quot;])
</del><ins>+        else if ([keyPath isEqualToString:@&quot;externalPlaybackActive&quot;] || [keyPath isEqualToString:@&quot;allowsExternalPlayback&quot;])
</ins><span class="cx">             function = WTF::bind(&amp;MediaPlayerPrivateAVFoundationObjC::playbackTargetIsWirelessDidChange, m_callback);
</span><span class="cx"> #endif
</span><span class="cx">     }
</span></span></pre>
</div>
</div>

</body>
</html>