[Mac] Simplify code to support media engines which do not support target playback
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Apr 2015 21:40:10 +0000 (21:40 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Apr 2015 21:40:10 +0000 (21:40 +0000)
https://bugs.webkit.org/show_bug.cgi?id=144332

Reviewed by Jer Noble.

* Modules/mediasession/WebMediaSessionManager.cpp:
(WebCore::WebMediaSessionManager::externalOutputDeviceAvailableDidChange): Always make client
callback, let them decide if it is significant or not.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::HTMLMediaElement): m_loadTimer -> m_pendingActionTimer.
(WebCore::HTMLMediaElement::scheduleDelayedAction): Handle CheckPlaybackTargetCompatablity.
(WebCore::HTMLMediaElement::scheduleNextSourceChild): m_loadTimer -> m_pendingActionTimer.
(WebCore::HTMLMediaElement::loadTimerFired): Renamed pendingActionTimerFired.
(WebCore::HTMLMediaElement::prepareForLoad): m_loadTimer -> m_pendingActionTimer.
(WebCore::HTMLMediaElement::setDefaultPlaybackRate): Add logging.
(WebCore::HTMLMediaElement::clearMediaPlayer): m_loadTimer -> m_pendingActionTimer.
(WebCore::HTMLMediaElement::webkitCurrentPlaybackTargetIsSupported): Removed.
(WebCore::HTMLMediaElement::dispatchEvent): If a 'webkitcurrentplaybacktargetiswirelesschanged'
event is dispatched when the current target is wireless but the media engine does not support
wireless playback, tell the media engine not to play to the target.
* html/HTMLMediaElement.h:
* html/HTMLMediaElement.idl:

* html/HTMLMediaSession.cpp:
(WebCore::HTMLMediaSession::showPlaybackTargetPicker): Drive-by fix to disallow audio-only files.
(WebCore::HTMLMediaSession::currentPlaybackTargetIsSupported): Deleted.
* html/HTMLMediaSession.h:

* platform/graphics/MediaPlayer.cpp:
(WebCore::MediaPlayer::isCurrentPlaybackTargetSupported): Deleted.
* platform/graphics/MediaPlayer.h:
* platform/graphics/MediaPlayerPrivate.h:

* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::setShouldPlayToPlaybackTarget): Use a RetainPtr
to explicitly manage the lifetime of the temporary object.
(WebCore::MediaPlayerPrivateAVFoundationObjC::isPlayingToWirelessPlaybackTarget): Ditto.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:

* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setShouldPlayToPlaybackTarget):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::isCurrentPlaybackTargetWireless):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::isCurrentPlaybackTargetSupported): Deleted.

* platform/graphics/mac/MediaPlayerPrivateQTKit.h:
* platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
(WebCore::MediaPlayerPrivateQTKit::setShouldPlayToPlaybackTarget):
(WebCore::MediaPlayerPrivateQTKit::isCurrentPlaybackTargetWireless):
(WebCore::MediaPlayerPrivateQTKit::isCurrentPlaybackTargetSupported): Deleted.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@183509 268f45cc-cd09-0410-ab3c-d52691b4dbfc

15 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediasession/WebMediaSessionManager.cpp
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/html/HTMLMediaElement.idl
Source/WebCore/html/HTMLMediaSession.cpp
Source/WebCore/html/HTMLMediaSession.h
Source/WebCore/platform/graphics/MediaPlayer.cpp
Source/WebCore/platform/graphics/MediaPlayer.h
Source/WebCore/platform/graphics/MediaPlayerPrivate.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm
Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h
Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm

index b3a107c..d0f0a9a 100644 (file)
@@ -1,3 +1,56 @@
+2015-04-28  Eric Carlson  <eric.carlson@apple.com>
+
+        [Mac] Simplify code to support media engines which do not support target playback
+        https://bugs.webkit.org/show_bug.cgi?id=144332
+
+        Reviewed by Jer Noble.
+
+        * Modules/mediasession/WebMediaSessionManager.cpp:
+        (WebCore::WebMediaSessionManager::externalOutputDeviceAvailableDidChange): Always make client
+        callback, let them decide if it is significant or not.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::HTMLMediaElement): m_loadTimer -> m_pendingActionTimer.
+        (WebCore::HTMLMediaElement::scheduleDelayedAction): Handle CheckPlaybackTargetCompatablity.
+        (WebCore::HTMLMediaElement::scheduleNextSourceChild): m_loadTimer -> m_pendingActionTimer.
+        (WebCore::HTMLMediaElement::loadTimerFired): Renamed pendingActionTimerFired.
+        (WebCore::HTMLMediaElement::prepareForLoad): m_loadTimer -> m_pendingActionTimer.
+        (WebCore::HTMLMediaElement::setDefaultPlaybackRate): Add logging.
+        (WebCore::HTMLMediaElement::clearMediaPlayer): m_loadTimer -> m_pendingActionTimer.
+        (WebCore::HTMLMediaElement::webkitCurrentPlaybackTargetIsSupported): Removed.
+        (WebCore::HTMLMediaElement::dispatchEvent): If a 'webkitcurrentplaybacktargetiswirelesschanged'
+        event is dispatched when the current target is wireless but the media engine does not support
+        wireless playback, tell the media engine not to play to the target.
+        * html/HTMLMediaElement.h:
+        * html/HTMLMediaElement.idl:
+
+        * html/HTMLMediaSession.cpp:
+        (WebCore::HTMLMediaSession::showPlaybackTargetPicker): Drive-by fix to disallow audio-only files.
+        (WebCore::HTMLMediaSession::currentPlaybackTargetIsSupported): Deleted.
+        * html/HTMLMediaSession.h:
+
+        * platform/graphics/MediaPlayer.cpp:
+        (WebCore::MediaPlayer::isCurrentPlaybackTargetSupported): Deleted.
+        * platform/graphics/MediaPlayer.h:
+        * platform/graphics/MediaPlayerPrivate.h:
+
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::setShouldPlayToPlaybackTarget): Use a RetainPtr
+        to explicitly manage the lifetime of the temporary object.
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::isPlayingToWirelessPlaybackTarget): Ditto.
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
+
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setShouldPlayToPlaybackTarget):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::isCurrentPlaybackTargetWireless):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::isCurrentPlaybackTargetSupported): Deleted.
+
+        * platform/graphics/mac/MediaPlayerPrivateQTKit.h:
+        * platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
+        (WebCore::MediaPlayerPrivateQTKit::setShouldPlayToPlaybackTarget):
+        (WebCore::MediaPlayerPrivateQTKit::isCurrentPlaybackTargetWireless):
+        (WebCore::MediaPlayerPrivateQTKit::isCurrentPlaybackTargetSupported): Deleted.
+
 2015-04-28  Alex Christensen  <achristensen@webkit.org>
 
         [Content Extensions] Use less memory for CombinedURLFilters.
index 61c4fdd..ef484db 100644 (file)
@@ -196,9 +196,6 @@ void WebMediaSessionManager::setPlaybackTarget(Ref<MediaPlaybackTarget>&& target
 
 void WebMediaSessionManager::externalOutputDeviceAvailableDidChange(bool available)
 {
-    if (m_externalOutputDeviceAvailable == available)
-        return;
-
     m_externalOutputDeviceAvailable = available;
     for (auto& state : m_clientState)
         state->client->externalOutputDeviceAvailableDidChange(state->contextId, available);
index b794f81..45a1f93 100644 (file)
@@ -256,7 +256,7 @@ private:
 HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document& document, bool createdByParser)
     : HTMLElement(tagName, document)
     , ActiveDOMObject(&document)
-    , m_loadTimer(*this, &HTMLMediaElement::loadTimerFired)
+    , m_pendingActionTimer(*this, &HTMLMediaElement::pendingActionTimerFired)
     , m_progressEventTimer(*this, &HTMLMediaElement::progressEventTimerFired)
     , m_playbackProgressTimer(*this, &HTMLMediaElement::playbackProgressTimerFired)
     , m_scanTimer(*this, &HTMLMediaElement::scanTimerFired)
@@ -694,14 +694,19 @@ void HTMLMediaElement::scheduleDelayedAction(DelayedActionType actionType)
         setFlags(m_pendingActionFlags, TextTrackChangesNotification);
 #endif
 
-    m_loadTimer.startOneShot(0);
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+    if (actionType & CheckPlaybackTargetCompatablity)
+        setFlags(m_pendingActionFlags, CheckPlaybackTargetCompatablity);
+#endif
+
+    m_pendingActionTimer.startOneShot(0);
 }
 
 void HTMLMediaElement::scheduleNextSourceChild()
 {
     // Schedule the timer to try the next <source> element WITHOUT resetting state ala prepareForLoad.
     setFlags(m_pendingActionFlags, LoadMediaResource);
-    m_loadTimer.startOneShot(0);
+    m_pendingActionTimer.startOneShot(0);
 }
 
 void HTMLMediaElement::scheduleEvent(const AtomicString& eventName)
@@ -717,7 +722,7 @@ void HTMLMediaElement::scheduleEvent(const AtomicString& eventName)
     m_asyncEventQueue.enqueueEvent(event.release());
 }
 
-void HTMLMediaElement::loadTimerFired()
+void HTMLMediaElement::pendingActionTimerFired()
 {
     Ref<HTMLMediaElement> protect(*this); // loadNextSourceChild may fire 'beforeload', which can make arbitrary DOM mutations.
 
@@ -738,6 +743,13 @@ void HTMLMediaElement::loadTimerFired()
         notifyMediaPlayerOfTextTrackChanges();
 #endif
 
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+    if (m_pendingActionFlags & CheckPlaybackTargetCompatablity && m_player && m_player->isCurrentPlaybackTargetWireless() && !m_player->canPlayToWirelessPlaybackTarget()) {
+        LOG(Media, "HTMLMediaElement::pendingActionTimerFired(%p) - calling setShouldPlayToPlaybackTarget(false)", this);
+        m_player->setShouldPlayToPlaybackTarget(false);
+    }
+#endif
+
     m_pendingActionFlags = 0;
 }
 
@@ -826,7 +838,7 @@ void HTMLMediaElement::prepareForLoad()
 
     // Perform the cleanup required for the resource load algorithm to run.
     stopPeriodicTimers();
-    m_loadTimer.stop();
+    m_pendingActionTimer.stop();
     // FIXME: Figure out appropriate place to reset LoadTextTrackResource if necessary and set m_pendingActionFlags to 0 here.
     m_pendingActionFlags &= ~LoadMediaResource;
     m_sentEndEvent = false;
@@ -2644,6 +2656,7 @@ double HTMLMediaElement::defaultPlaybackRate() const
 void HTMLMediaElement::setDefaultPlaybackRate(double rate)
 {
     if (m_defaultPlaybackRate != rate) {
+        LOG(Media, "HTMLMediaElement::setDefaultPlaybackRate(%p) - %f", this, rate);
         m_defaultPlaybackRate = rate;
         scheduleEvent(eventNames().ratechangeEvent);
     }
@@ -4709,7 +4722,7 @@ void HTMLMediaElement::clearMediaPlayer(int flags)
     m_player = nullptr;
 
     stopPeriodicTimers();
-    m_loadTimer.stop();
+    m_pendingActionTimer.stop();
 
     clearFlags(m_pendingActionFlags, flags);
     m_loadState = WaitingForSource;
@@ -4858,11 +4871,6 @@ bool HTMLMediaElement::webkitCurrentPlaybackTargetIsWireless() const
     return m_mediaSession->currentPlaybackTargetIsWireless(*this);
 }
 
-bool HTMLMediaElement::webkitCurrentPlaybackTargetIsSupported() const
-{
-    return m_mediaSession->currentPlaybackTargetIsSupported(*this);
-}
-
 void HTMLMediaElement::wirelessRoutesAvailableDidChange()
 {
     enqueuePlaybackTargetAvailabilityChangedEvent();
@@ -4873,9 +4881,15 @@ void HTMLMediaElement::mediaPlayerCurrentPlaybackTargetIsWirelessChanged(MediaPl
     LOG(Media, "HTMLMediaElement::mediaPlayerCurrentPlaybackTargetIsWirelessChanged(%p) - webkitCurrentPlaybackTargetIsWireless = %s", this, boolString(webkitCurrentPlaybackTargetIsWireless()));
     scheduleEvent(eventNames().webkitcurrentplaybacktargetiswirelesschangedEvent);
 
-#if ENABLE(WIRELESS_PLAYBACK_TARGET)
     m_mediaSession->mediaStateDidChange(*this, mediaState());
-#endif
+}
+
+bool HTMLMediaElement::dispatchEvent(PassRefPtr<Event> prpEvent)
+{
+    RefPtr<Event> event = prpEvent;
+    if (event->type() == eventNames().webkitcurrentplaybacktargetiswirelesschangedEvent)
+        scheduleDelayedAction(CheckPlaybackTargetCompatablity);
+    return HTMLElement::dispatchEvent(event);
 }
 
 bool HTMLMediaElement::addEventListener(const AtomicString& eventType, PassRefPtr<EventListener> listener, bool useCapture)
index f63d0b4..864d3ff 100644 (file)
@@ -139,8 +139,9 @@ public:
         ConfigureTextTracks = 1 << 1,
         TextTrackChangesNotification = 1 << 2,
         ConfigureTextTrackDisplay = 1 << 3,
+        CheckPlaybackTargetCompatablity = 1 << 4,
 
-        EveryDelayedAction = LoadMediaResource | ConfigureTextTracks | TextTrackChangesNotification | ConfigureTextTrackDisplay,
+        EveryDelayedAction = LoadMediaResource | ConfigureTextTracks | TextTrackChangesNotification | ConfigureTextTrackDisplay | CheckPlaybackTargetCompatablity,
     };
     void scheduleDelayedAction(DelayedActionType);
     
@@ -356,7 +357,6 @@ public:
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
     void webkitShowPlaybackTargetPicker();
     bool webkitCurrentPlaybackTargetIsWireless() const;
-    bool webkitCurrentPlaybackTargetIsSupported() const;
 
     virtual bool addEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture) override;
     virtual bool removeEventListener(const AtomicString& eventType, EventListener*, bool useCapture) override;
@@ -562,6 +562,9 @@ private:
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
     virtual void mediaPlayerCurrentPlaybackTargetIsWirelessChanged(MediaPlayer*) override;
     void enqueuePlaybackTargetAvailabilityChangedEvent();
+
+    using EventTarget::dispatchEvent;
+    virtual bool dispatchEvent(PassRefPtr<Event>) override;
 #endif
 
     virtual String mediaPlayerReferrer() const override;
@@ -604,7 +607,7 @@ private:
 
     virtual double mediaPlayerRequestedPlaybackRate() const override final;
 
-    void loadTimerFired();
+    void pendingActionTimerFired();
     void progressEventTimerFired();
     void playbackProgressTimerFired();
     void scanTimerFired();
@@ -733,7 +736,7 @@ private:
 
     void updateCaptionContainer();
 
-    Timer m_loadTimer;
+    Timer m_pendingActionTimer;
     Timer m_progressEventTimer;
     Timer m_playbackProgressTimer;
     Timer m_scanTimer;
index fbeb7dd..5309b2e 100644 (file)
 
     [Conditional=WIRELESS_PLAYBACK_TARGET] void webkitShowPlaybackTargetPicker();
     [Conditional=WIRELESS_PLAYBACK_TARGET] readonly attribute boolean webkitCurrentPlaybackTargetIsWireless;
-    [Conditional=WIRELESS_PLAYBACK_TARGET] readonly attribute boolean webkitCurrentPlaybackTargetIsSupported;
 };
index ccd00ec..824be91 100644 (file)
@@ -189,20 +189,6 @@ bool HTMLMediaSession::currentPlaybackTargetIsWireless(const HTMLMediaElement& e
     return isWireless;
 }
 
-bool HTMLMediaSession::currentPlaybackTargetIsSupported(const HTMLMediaElement& element) const
-{
-    MediaPlayer* player = element.player();
-    if (!player) {
-        LOG(Media, "HTMLMediaSession::currentPlaybackTargetIsSupported - returning FALSE because player is NULL");
-        return false;
-    }
-
-    bool isSupported = player->isCurrentPlaybackTargetSupported();
-    LOG(Media, "HTMLMediaSession::currentPlaybackTargetIsSupported - returning %s", isSupported ? "TRUE" : "FALSE");
-    
-    return isSupported;
-}
-
 void HTMLMediaSession::showPlaybackTargetPicker(const HTMLMediaElement& element)
 {
     LOG(Media, "HTMLMediaSession::showPlaybackTargetPicker");
@@ -217,6 +203,13 @@ void HTMLMediaSession::showPlaybackTargetPicker(const HTMLMediaElement& element)
         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));
 }
 
@@ -388,7 +381,8 @@ void HTMLMediaSession::mediaEngineUpdated(const HTMLMediaElement& element)
     LOG(Media, "HTMLMediaSession::mediaEngineUpdated");
 
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
-    setWirelessVideoPlaybackDisabled(element, m_restrictions & WirelessVideoPlaybackDisabled);
+    if (m_restrictions & WirelessVideoPlaybackDisabled)
+        setWirelessVideoPlaybackDisabled(element, true);
     if (m_playbackTarget)
         client().setWirelessPlaybackTarget(*m_playbackTarget.copyRef());
     if (m_shouldPlayToPlaybackTarget)
index c5faa6b..cdc4fac 100644 (file)
@@ -56,7 +56,6 @@ public:
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
     void showPlaybackTargetPicker(const HTMLMediaElement&);
     bool currentPlaybackTargetIsWireless(const HTMLMediaElement&) const;
-    bool currentPlaybackTargetIsSupported(const HTMLMediaElement&) const;
     bool hasWirelessPlaybackTargets(const HTMLMediaElement&) const;
 
     bool wirelessVideoPlaybackDisabled(const HTMLMediaElement&) const;
index 5a7c5d2..fb3901a 100644 (file)
@@ -843,11 +843,6 @@ bool MediaPlayer::isCurrentPlaybackTargetWireless() const
     return m_private->isCurrentPlaybackTargetWireless();
 }
 
-bool MediaPlayer::isCurrentPlaybackTargetSupported() const
-{
-    return m_private->isCurrentPlaybackTargetSupported();
-}
-
 String MediaPlayer::wirelessPlaybackTargetName() const
 {
     return m_private->wirelessPlaybackTargetName();
index 778bf9a..9d41dbc 100644 (file)
@@ -464,7 +464,6 @@ public:
 
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
     bool isCurrentPlaybackTargetWireless() const;
-    bool isCurrentPlaybackTargetSupported() const;
 
     enum WirelessPlaybackTargetType { TargetTypeNone, TargetTypeAirPlay, TargetTypeTVOut };
     WirelessPlaybackTargetType wirelessPlaybackTargetType() const;
index 9938af2..ce7f95a 100644 (file)
@@ -161,7 +161,6 @@ public:
 
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
     virtual bool isCurrentPlaybackTargetWireless() const { return false; }
-    virtual bool isCurrentPlaybackTargetSupported() const { return true; }
 
     virtual String wirelessPlaybackTargetName() const { return emptyString(); }
     virtual MediaPlayer::WirelessPlaybackTargetType wirelessPlaybackTargetType() const { return MediaPlayer::TargetTypeNone; }
index a65717e..afb73ae 100644 (file)
@@ -2798,8 +2798,8 @@ void MediaPlayerPrivateAVFoundationObjC::setShouldPlayToPlaybackTarget(bool shou
         return;
 
     AVOutputContext *newContext = shouldPlay ? m_outputContext.get() : nil;
-    AVOutputContext *currentContext = m_avPlayer.get().outputContext;
-    if ((!newContext && !currentContext) || [currentContext isEqual:newContext])
+    RetainPtr<AVOutputContext> currentContext = m_avPlayer.get().outputContext;
+    if ((!newContext && !currentContext.get()) || [currentContext.get() isEqual:newContext])
         return;
 
     setDelayCallbacks(true);
@@ -2814,10 +2814,8 @@ bool MediaPlayerPrivateAVFoundationObjC::isPlayingToWirelessPlaybackTarget()
     if (!m_avPlayer)
         return false;
 
-    if (!m_outputContext || !m_outputContext.get().deviceName)
-        return false;
-
-    return m_cachedRate;
+    RetainPtr<AVOutputContext> currentContext = m_avPlayer.get().outputContext;
+    return currentContext && currentContext.get().deviceName;
 }
 #endif // !PLATFORM(IOS)
 
index 58e04ad..e9a1b26 100644 (file)
@@ -172,7 +172,7 @@ private:
     virtual MediaTime totalFrameDelay() override;
 
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
-    virtual bool isCurrentPlaybackTargetSupported() const override;
+    virtual bool isCurrentPlaybackTargetWireless() const override;
     virtual void setWirelessPlaybackTarget(Ref<MediaPlaybackTarget>&&);
     virtual void setShouldPlayToPlaybackTarget(bool) override;
 #endif
@@ -220,7 +220,7 @@ private:
     bool m_hasAvailableVideoFrame;
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
     RefPtr<MediaPlaybackTarget> m_playbackTarget;
-    bool m_currentPlaybackTargetIsSupported { true };
+    bool m_shouldPlayToTarget { false };
 #endif
 };
 
index 9c17f82..3a8928e 100644 (file)
@@ -807,14 +807,6 @@ void MediaPlayerPrivateMediaSourceAVFObjC::characteristicsChanged()
 }
 
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
-bool MediaPlayerPrivateMediaSourceAVFObjC::isCurrentPlaybackTargetSupported() const
-{
-    if (!m_playbackTarget)
-        return true;
-
-    return !m_playbackTarget->hasActiveRoute();
-}
-
 void MediaPlayerPrivateMediaSourceAVFObjC::setWirelessPlaybackTarget(Ref<MediaPlaybackTarget>&& target)
 {
     m_playbackTarget = WTF::move(target);
@@ -822,12 +814,22 @@ void MediaPlayerPrivateMediaSourceAVFObjC::setWirelessPlaybackTarget(Ref<MediaPl
 
 void MediaPlayerPrivateMediaSourceAVFObjC::setShouldPlayToPlaybackTarget(bool shouldPlayToTarget)
 {
-    bool oldSupported = m_currentPlaybackTargetIsSupported;
-    m_currentPlaybackTargetIsSupported = !shouldPlayToTarget;
+    if (shouldPlayToTarget == m_shouldPlayToTarget)
+        return;
+
+    m_shouldPlayToTarget = shouldPlayToTarget;
 
-    if (m_player && oldSupported != m_currentPlaybackTargetIsSupported)
+    if (m_player)
         m_player->currentPlaybackTargetIsWirelessChanged();
 }
+
+bool MediaPlayerPrivateMediaSourceAVFObjC::isCurrentPlaybackTargetWireless() const
+{
+    if (!m_playbackTarget)
+        return false;
+
+    return m_shouldPlayToTarget && m_playbackTarget->hasActiveRoute();
+}
 #endif
 
 }
index 313270e..c8c518e 100644 (file)
@@ -180,10 +180,9 @@ private:
     virtual long platformErrorCode() const;
 
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
-    virtual bool isCurrentPlaybackTargetSupported() const override;
+    virtual bool isCurrentPlaybackTargetWireless() const override;
     virtual void setWirelessPlaybackTarget(Ref<MediaPlaybackTarget>&&);
     virtual void setShouldPlayToPlaybackTarget(bool) override;
-    void togglePlayingToPlaybackTarget();
 #endif
 
     MediaPlayer* m_player;
@@ -215,7 +214,7 @@ private:
     mutable FloatSize m_cachedNaturalSize;
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
     RefPtr<MediaPlaybackTarget> m_playbackTarget;
-    bool m_currentPlaybackTargetIsSupported { true };
+    bool m_shouldPlayToTarget { false };
 #endif
 };
 
index b3eec9f..9632bad 100644 (file)
@@ -1541,14 +1541,6 @@ bool MediaPlayerPrivateQTKit::canSaveMediaData() const
 }
 
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
-bool MediaPlayerPrivateQTKit::isCurrentPlaybackTargetSupported() const
-{
-    if (!m_playbackTarget)
-        return true;
-
-    return !m_playbackTarget->hasActiveRoute();
-}
-
 void MediaPlayerPrivateQTKit::setWirelessPlaybackTarget(Ref<MediaPlaybackTarget>&& target)
 {
     m_playbackTarget = WTF::move(target);
@@ -1556,12 +1548,22 @@ void MediaPlayerPrivateQTKit::setWirelessPlaybackTarget(Ref<MediaPlaybackTarget>
 
 void MediaPlayerPrivateQTKit::setShouldPlayToPlaybackTarget(bool shouldPlayToTarget)
 {
-    bool oldSupported = m_currentPlaybackTargetIsSupported;
-    m_currentPlaybackTargetIsSupported = !shouldPlayToTarget;
+    if (shouldPlayToTarget == m_shouldPlayToTarget)
+        return;
 
-    if (m_player && oldSupported != m_currentPlaybackTargetIsSupported)
+    m_shouldPlayToTarget = shouldPlayToTarget;
+
+    if (m_player)
         m_player->currentPlaybackTargetIsWirelessChanged();
 }
+
+bool MediaPlayerPrivateQTKit::isCurrentPlaybackTargetWireless() const
+{
+    if (!m_playbackTarget)
+        return false;
+    
+    return m_shouldPlayToTarget && m_playbackTarget->hasActiveRoute();
+}
 #endif
 
 } // namespace WebCore