[iOS] Notify fullscreen controller in UIProcess whether external playback is allowed
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Jul 2015 18:20:50 +0000 (18:20 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Jul 2015 18:20:50 +0000 (18:20 +0000)
https://bugs.webkit.org/show_bug.cgi?id=147343

Reviewed by Brady Eidson.

Source/WebCore:

Pass the value of the MediaElementSession's wirelessVideoPlaybackDisabled() property up through WebKit2 to
WebVideoFullscreenControllerAVKit.

* platform/ios/WebVideoFullscreenControllerAVKit.mm:
(WebVideoFullscreenControllerContext::setWirelessVideoPlaybackDisabled): Pass to the interface on the main thread.
* platform/ios/WebVideoFullscreenInterface.h:
* platform/ios/WebVideoFullscreenInterfaceAVKit.h:
* platform/ios/WebVideoFullscreenInterfaceAVKit.mm:
(WebVideoFullscreenInterfaceAVKit::setWirelessVideoPlaybackDisabled): Sets .allowsExternalPlayback to !disabled.
(WebVideoFullscreenInterfaceAVKit::wirelessVideoPlaybackDisabled): Returns the last value set.
* platform/ios/WebVideoFullscreenModelVideoElement.mm:
(WebVideoFullscreenModelVideoElement::setWebVideoFullscreenInterface): Update the value of wirelessVideoPlaybackDisabled
    if the element is present.
(WebVideoFullscreenModelVideoElement::setVideoElement): Ditto if the interface is present.
(WebVideoFullscreenModelVideoElement::updateForEventName): Update the value either way.

Source/WebKit2:

Pass the boolean property wirelessVideoPlaybackDisabled across the UIProcess/WebProcess boundary.

* UIProcess/ios/WebVideoFullscreenManagerProxy.mm:
(WebKit::WebVideoFullscreenManagerProxy::setWirelessVideoPlaybackDisabled):
* WebProcess/ios/WebVideoFullscreenManager.mm:
(WebKit::WebVideoFullscreenInterfaceContext::setWirelessVideoPlaybackDisabled):
(WebKit::WebVideoFullscreenManager::WebVideoFullscreenManager):
(WebKit::WebVideoFullscreenManager::setWirelessVideoPlaybackDisabled):

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

12 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm
Source/WebCore/platform/ios/WebVideoFullscreenInterface.h
Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.h
Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm
Source/WebCore/platform/ios/WebVideoFullscreenModelVideoElement.mm
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.h
Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.messages.in
Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.mm
Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.h
Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.mm

index a4e07a0..ac29d9b 100644 (file)
@@ -1,3 +1,26 @@
+2015-07-28  Jer Noble  <jer.noble@apple.com>
+
+        [iOS] Notify fullscreen controller in UIProcess whether external playback is allowed
+        https://bugs.webkit.org/show_bug.cgi?id=147343
+
+        Reviewed by Brady Eidson.
+
+        Pass the value of the MediaElementSession's wirelessVideoPlaybackDisabled() property up through WebKit2 to
+        WebVideoFullscreenControllerAVKit.
+
+        * platform/ios/WebVideoFullscreenControllerAVKit.mm:
+        (WebVideoFullscreenControllerContext::setWirelessVideoPlaybackDisabled): Pass to the interface on the main thread.
+        * platform/ios/WebVideoFullscreenInterface.h:
+        * platform/ios/WebVideoFullscreenInterfaceAVKit.h:
+        * platform/ios/WebVideoFullscreenInterfaceAVKit.mm:
+        (WebVideoFullscreenInterfaceAVKit::setWirelessVideoPlaybackDisabled): Sets .allowsExternalPlayback to !disabled.
+        (WebVideoFullscreenInterfaceAVKit::wirelessVideoPlaybackDisabled): Returns the last value set.
+        * platform/ios/WebVideoFullscreenModelVideoElement.mm:
+        (WebVideoFullscreenModelVideoElement::setWebVideoFullscreenInterface): Update the value of wirelessVideoPlaybackDisabled
+            if the element is present.
+        (WebVideoFullscreenModelVideoElement::setVideoElement): Ditto if the interface is present.
+        (WebVideoFullscreenModelVideoElement::updateForEventName): Update the value either way.
+
 2015-07-28  Brady Eidson  <beidson@apple.com>
 
         Handle null CFArrayRef returning from _CFHTTPParsedCookiesWithResponseHeaderFields.
index b440f3f..8f0be5e 100644 (file)
@@ -130,7 +130,8 @@ private:
     virtual void setAudioMediaSelectionOptions(const Vector<String>& options, uint64_t selectedIndex) override;
     virtual void setLegibleMediaSelectionOptions(const Vector<String>& options, uint64_t selectedIndex) override;
     virtual void setExternalPlayback(bool enabled, ExternalPlaybackTargetType, String localizedDeviceName) override;
-    
+    virtual void setWirelessVideoPlaybackDisabled(bool) override;
+
     // WebVideoFullscreenModel
     virtual void play() override;
     virtual void pause() override;
@@ -348,6 +349,16 @@ void WebVideoFullscreenControllerContext::setExternalPlayback(bool enabled, Exte
     });
 }
 
+void WebVideoFullscreenControllerContext::setWirelessVideoPlaybackDisabled(bool disabled)
+{
+    ASSERT(WebThreadIsCurrent());
+    RefPtr<WebVideoFullscreenControllerContext> strongThis(this);
+    dispatch_async(dispatch_get_main_queue(), [strongThis, this, disabled] {
+        if (m_interface)
+            m_interface->setWirelessVideoPlaybackDisabled(disabled);
+    });
+}
+
 #pragma mark WebVideoFullscreenModel
 
 void WebVideoFullscreenControllerContext::play()
index b89b6b0..32e7f23 100644 (file)
@@ -55,6 +55,7 @@ public:
     virtual void setAudioMediaSelectionOptions(const Vector<WTF::String>& options, uint64_t selectedIndex) = 0;
     virtual void setLegibleMediaSelectionOptions(const Vector<WTF::String>& options, uint64_t selectedIndex) = 0;
     virtual void setExternalPlayback(bool enabled, ExternalPlaybackTargetType, WTF::String localizedDeviceName) = 0;
+    virtual void setWirelessVideoPlaybackDisabled(bool) = 0;
 };
 
 }
index d337d52..66ba775 100644 (file)
@@ -90,7 +90,8 @@ public:
     WEBCORE_EXPORT virtual void setAudioMediaSelectionOptions(const Vector<WTF::String>& options, uint64_t selectedIndex) override;
     WEBCORE_EXPORT virtual void setLegibleMediaSelectionOptions(const Vector<WTF::String>& options, uint64_t selectedIndex) override;
     WEBCORE_EXPORT virtual void setExternalPlayback(bool enabled, ExternalPlaybackTargetType, WTF::String localizedDeviceName) override;
-    
+    WEBCORE_EXPORT virtual void setWirelessVideoPlaybackDisabled(bool) override;
+
     WEBCORE_EXPORT virtual void setupFullscreen(UIView&, const IntRect& initialRect, UIView *, HTMLMediaElementEnums::VideoFullscreenMode, bool allowsPictureInPicturePlayback);
     WEBCORE_EXPORT virtual void enterFullscreen();
     WEBCORE_EXPORT virtual void exitFullscreen(const IntRect& finalRect);
@@ -112,6 +113,7 @@ public:
     bool allowsPictureInPicturePlayback() const { return m_allowsPictureInPicturePlayback; }
     WEBCORE_EXPORT bool mayAutomaticallyShowVideoPictureInPicture() const;
     void fullscreenMayReturnToInline(std::function<void(bool)> callback);
+    bool wirelessVideoPlaybackDisabled() const;
 
     void willStartPictureInPicture();
     void didStartPictureInPicture();
@@ -148,6 +150,7 @@ protected:
     bool m_exitRequested { false };
     bool m_exitCompleted { false };
     bool m_enterRequested { false };
+    bool m_wirelessVideoPlaybackDisabled { true };
 
     void doEnterFullscreen();
 };
index 8d42aa4..352aa7f 100644 (file)
@@ -126,6 +126,7 @@ static const char* boolString(bool val)
 @property (getter=isExternalPlaybackActive) BOOL externalPlaybackActive;
 @property AVPlayerControllerExternalPlaybackType externalPlaybackType;
 @property (retain) NSString *externalPlaybackAirPlayDeviceLocalizedName;
+@property BOOL allowsExternalPlayback;
 
 - (BOOL)playerViewController:(AVPlayerViewController *)playerViewController shouldExitFullScreenWithReason:(AVPlayerViewControllerExitFullScreenReason)reason;
 @end
@@ -1018,6 +1019,16 @@ void WebVideoFullscreenInterfaceAVKit::setExternalPlayback(bool enabled, Externa
     [m_playerLayerView setHidden:enabled];
 }
 
+void WebVideoFullscreenInterfaceAVKit::setWirelessVideoPlaybackDisabled(bool disabled)
+{
+    [m_playerController setAllowsExternalPlayback:!disabled];
+}
+
+bool WebVideoFullscreenInterfaceAVKit::wirelessVideoPlaybackDisabled() const
+{
+    return [m_playerController allowsExternalPlayback];
+}
+
 @interface UIWindow ()
 - (BOOL)_isHostedInAnotherProcess;
 @end
index b852e9f..0e8dfbc 100644 (file)
@@ -69,8 +69,10 @@ void WebVideoFullscreenModelVideoElement::setWebVideoFullscreenInterface(WebVide
 
     if (m_videoFullscreenInterface) {
         m_videoFullscreenInterface->resetMediaState();
-        if (m_videoElement)
+        if (m_videoElement) {
             m_videoFullscreenInterface->setVideoDimensions(true, m_videoElement->videoWidth(), m_videoElement->videoHeight());
+            m_videoFullscreenInterface->setWirelessVideoPlaybackDisabled(m_videoElement->mediaSession().wirelessVideoPlaybackDisabled(*m_videoElement));
+        }
     }
 }
 
@@ -102,8 +104,10 @@ void WebVideoFullscreenModelVideoElement::setVideoElement(HTMLVideoElement* vide
 
     updateForEventName(eventNameAll());
 
-    if (m_videoFullscreenInterface)
+    if (m_videoFullscreenInterface) {
         m_videoFullscreenInterface->setVideoDimensions(true, videoElement->videoWidth(), videoElement->videoHeight());
+        m_videoFullscreenInterface->setWirelessVideoPlaybackDisabled(m_videoElement->mediaSession().wirelessVideoPlaybackDisabled(*m_videoElement));
+    }
 }
 
 void WebVideoFullscreenModelVideoElement::handleEvent(WebCore::ScriptExecutionContext*, WebCore::Event* event)
@@ -164,6 +168,7 @@ void WebVideoFullscreenModelVideoElement::updateForEventName(const WTF::AtomicSt
             localizedDeviceName = m_videoElement->mediaControlsHost()->externalDeviceDisplayName();
         }
         m_videoFullscreenInterface->setExternalPlayback(enabled, targetType, localizedDeviceName);
+        m_videoFullscreenInterface->setWirelessVideoPlaybackDisabled(m_videoElement->mediaSession().wirelessVideoPlaybackDisabled(*m_videoElement));
     }
 }
 
index 68f64b8..0f264df 100644 (file)
@@ -1,3 +1,19 @@
+2015-07-28  Jer Noble  <jer.noble@apple.com>
+
+        [iOS] Notify fullscreen controller in UIProcess whether external playback is allowed
+        https://bugs.webkit.org/show_bug.cgi?id=147343
+
+        Reviewed by Brady Eidson.
+
+        Pass the boolean property wirelessVideoPlaybackDisabled across the UIProcess/WebProcess boundary.
+
+        * UIProcess/ios/WebVideoFullscreenManagerProxy.mm:
+        (WebKit::WebVideoFullscreenManagerProxy::setWirelessVideoPlaybackDisabled):
+        * WebProcess/ios/WebVideoFullscreenManager.mm:
+        (WebKit::WebVideoFullscreenInterfaceContext::setWirelessVideoPlaybackDisabled):
+        (WebKit::WebVideoFullscreenManager::WebVideoFullscreenManager):
+        (WebKit::WebVideoFullscreenManager::setWirelessVideoPlaybackDisabled):
+
 2015-07-28  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GTK] Use fastMalloc instead of g_slice
index fa31eed..4f719fb 100644 (file)
@@ -127,6 +127,7 @@ private:
     void setAudioMediaSelectionOptions(uint64_t contextId, Vector<String> options, uint64_t selectedIndex);
     void setLegibleMediaSelectionOptions(uint64_t contextId, Vector<String> options, uint64_t selectedIndex);
     void setExternalPlaybackProperties(uint64_t contextId, bool enabled, uint32_t targetType, String localizedDeviceName);
+    void setWirelessVideoPlaybackDisabled(uint64_t contextId, bool);
     void setDuration(uint64_t contextId, double duration);
     void setRate(uint64_t contextId, bool isPlaying, double rate);
     void enterFullscreen(uint64_t contextId);
index 6bb076d..7e447da 100644 (file)
@@ -31,6 +31,7 @@ messages -> WebVideoFullscreenManagerProxy {
     SetAudioMediaSelectionOptions(uint64_t contextId, Vector<String> options, uint64_t selectedIndex)
     SetLegibleMediaSelectionOptions(uint64_t contextId, Vector<String> options, uint64_t selectedIndex)
     SetExternalPlaybackProperties(uint64_t contextId, bool enabled, uint32_t targetType, String localizedDeviceName)
+    SetWirelessVideoPlaybackDisabled(uint64_t contextId, bool disabled)
     SetDuration(uint64_t contextId, double duration)
     SetRate(uint64_t contextId, bool isPlaying, double rate)
     SetupFullscreenWithID(uint64_t contextId, uint32_t videoLayerID, WebCore::IntRect initialRect, float hostingScaleFactor, WebCore::HTMLMediaElementEnums::VideoFullscreenMode videoFullscreenMode, bool allowsPictureInPicture)
index 0d52384..a3c5953 100644 (file)
@@ -393,6 +393,11 @@ void WebVideoFullscreenManagerProxy::setExternalPlaybackProperties(uint64_t cont
     ensureInterface(contextId).setExternalPlayback(enabled, type, localizedDeviceName);
 }
 
+void WebVideoFullscreenManagerProxy::setWirelessVideoPlaybackDisabled(uint64_t contextId, bool disabled)
+{
+    ensureInterface(contextId).setWirelessVideoPlaybackDisabled(disabled);
+}
+
 void WebVideoFullscreenManagerProxy::setDuration(uint64_t contextId, double duration)
 {
     ensureInterface(contextId).setDuration(duration);
index 2106c2b..7f4e375 100644 (file)
@@ -92,6 +92,7 @@ private:
     virtual void setAudioMediaSelectionOptions(const Vector<WTF::String>& options, uint64_t selectedIndex) override;
     virtual void setLegibleMediaSelectionOptions(const Vector<WTF::String>& options, uint64_t selectedIndex) override;
     virtual void setExternalPlayback(bool enabled, ExternalPlaybackTargetType, WTF::String localizedDeviceName) override;
+    virtual void setWirelessVideoPlaybackDisabled(bool) override;
 
     WebVideoFullscreenInterfaceContext(WebVideoFullscreenManager&, uint64_t contextId);
 
@@ -139,6 +140,7 @@ protected:
     void setAudioMediaSelectionOptions(uint64_t contextId, const Vector<String>& options, uint64_t selectedIndex);
     void setLegibleMediaSelectionOptions(uint64_t contextId, const Vector<String>& options, uint64_t selectedIndex);
     void setExternalPlayback(uint64_t contextId, bool enabled, WebCore::WebVideoFullscreenInterface::ExternalPlaybackTargetType, String localizedDeviceName);
+    void setWirelessVideoPlaybackDisabled(uint64_t contextId, bool);
 
     // Messages from WebVideoFullscreenManagerProxy
     void play(uint64_t contextId);
index 81c4dc7..f5ea14e 100644 (file)
@@ -149,6 +149,12 @@ void WebVideoFullscreenInterfaceContext::setExternalPlayback(bool enabled, Exter
         m_manager->setExternalPlayback(m_contextId, enabled, type, localizedDeviceName);
 }
 
+void WebVideoFullscreenInterfaceContext::setWirelessVideoPlaybackDisabled(bool disabled)
+{
+    if (m_manager)
+        m_manager->setWirelessVideoPlaybackDisabled(m_contextId, disabled);
+}
+
 #pragma mark - WebVideoFullscreenManager
 
 Ref<WebVideoFullscreenManager> WebVideoFullscreenManager::create(PassRefPtr<WebPage> page)
@@ -331,6 +337,11 @@ void WebVideoFullscreenManager::setExternalPlayback(uint64_t contextId, bool ena
     m_page->send(Messages::WebVideoFullscreenManagerProxy::SetExternalPlaybackProperties(contextId, enabled, static_cast<uint32_t>(targetType), localizedDeviceName), m_page->pageID());
 }
 
+void WebVideoFullscreenManager::setWirelessVideoPlaybackDisabled(uint64_t contextId, bool disabled)
+{
+    m_page->send(Messages::WebVideoFullscreenManagerProxy::SetWirelessVideoPlaybackDisabled(contextId, disabled));
+}
+
 #pragma mark Messages from WebVideoFullscreenManagerProxy:
 
 void WebVideoFullscreenManager::play(uint64_t contextId)