Title: [200264] trunk
Revision
200264
Author
[email protected]
Date
2016-04-29 14:29:01 -0700 (Fri, 29 Apr 2016)

Log Message

[Mac] AirPlay fails if target is set before AVPlayer has been created
https://bugs.webkit.org/show_bug.cgi?id=157147
<rdar://problem/24197592>

Reviewed by Jer Noble.

Source/WebCore:

Test: media/media-source/media-source-airplay.html

* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayer): Clear flag before calling
  setShouldPlayToPlaybackTarget so it does the necessary setup.

* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::isAvailable): Return false if the mock
  MSE source has been registered.
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::supportsType): Return 'not supported' if
  isAvailable is false.
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::load): Fail if isAvailable is false.
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::isCurrentPlaybackTargetWireless): Cleanup.

* platform/mock/mediasource/MockMediaPlayerMediaSource.cpp:
(WebCore::registered): Global accessor.
(WebCore::MockMediaPlayerMediaSource::isRegistered):
(WebCore::MockMediaPlayerMediaSource::registerMediaEngine): Set registered to true.
(WebCore::MockMediaPlayerMediaSource::setWirelessPlaybackTarget): New, remember the target.
(WebCore::MockMediaPlayerMediaSource::setShouldPlayToPlaybackTarget): New, remember the setting.
(WebCore::MockMediaPlayerMediaSource::isCurrentPlaybackTargetWireless):
* platform/mock/mediasource/MockMediaPlayerMediaSource.h:

* testing/Internals.cpp:
(WebCore::Internals::initializeMockMediaSource): Don't disable AVFoundation.

LayoutTests:

* media/media-source/media-source-airplay-expected.txt: Added.
* media/media-source/media-source-airplay.html: Added.
* platform/efl/TestExpectations: Skip Mac-only test.
* platform/gtk/TestExpectations: Ditto.
* platform/ios-simulator/TestExpectations: Ditto.
* platform/mac/TestExpectations: Skipped new tests on older versions of OS X.
* platform/win/TestExpectations: Skip Mac-only test.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (200263 => 200264)


--- trunk/LayoutTests/ChangeLog	2016-04-29 21:17:44 UTC (rev 200263)
+++ trunk/LayoutTests/ChangeLog	2016-04-29 21:29:01 UTC (rev 200264)
@@ -1,3 +1,19 @@
+2016-04-29  Eric Carlson  <[email protected]>
+
+        [Mac] AirPlay fails if target is set before AVPlayer has been created
+        https://bugs.webkit.org/show_bug.cgi?id=157147
+        <rdar://problem/24197592>
+
+        Reviewed by Jer Noble.
+
+        * media/media-source/media-source-airplay-expected.txt: Added.
+        * media/media-source/media-source-airplay.html: Added.
+        * platform/efl/TestExpectations: Skip Mac-only test.
+        * platform/gtk/TestExpectations: Ditto.
+        * platform/ios-simulator/TestExpectations: Ditto.
+        * platform/mac/TestExpectations: Skipped new tests on older versions of OS X.
+        * platform/win/TestExpectations: Skip Mac-only test.
+
 2016-04-29  Myles C. Maxfield  <[email protected]>
 
         [RTL Scrollbars] REGRESSION(r200116): Positioned contents can overlap RTL scrollbars

Added: trunk/LayoutTests/media/media-source/media-source-airplay-expected.txt (0 => 200264)


--- trunk/LayoutTests/media/media-source/media-source-airplay-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/media/media-source/media-source-airplay-expected.txt	2016-04-29 21:29:01 UTC (rev 200264)
@@ -0,0 +1,22 @@
+
+** create a MediaSource object, set as video.src
+RUN(source = new MediaSource())
+RUN(source.addEventListener('sourceopen', startLoad))
+RUN(video.src = ""
+EVENT( webkitplaybacktargetavailabilitychanged ) : event.availability = 'not-available'
+
+** create a source buffer, add an init segment with 1 video track
+RUN(sourceBuffer = source.addSourceBuffer('video/mock; codecs="mock"'))
+RUN(init = makeAInit(100, [makeATrack(1, 'mock', TRACK_KIND.VIDEO)]))
+RUN(sourceBuffer.appendBuffer(init))
+
+EVENT(canplaythrough)
+
+** simulate choosing a device from the menu
+EVENT( webkitplaybacktargetavailabilitychanged ) : event.availability = 'available'
+
+** change video.src to one that supports AirPlay
+EXPECTED (video.webkitCurrentPlaybackTargetIsWireless == 'true') OK
+
+END OF TEST
+

Added: trunk/LayoutTests/media/media-source/media-source-airplay.html (0 => 200264)


--- trunk/LayoutTests/media/media-source/media-source-airplay.html	                        (rev 0)
+++ trunk/LayoutTests/media/media-source/media-source-airplay.html	2016-04-29 21:29:01 UTC (rev 200264)
@@ -0,0 +1,96 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <title>Media engine change after selecting AirPlay targe</title>
+    <script src=""
+    <script src=""
+    <script src=""
+    <script>
+
+    var sourceBuffer;
+    var requestLength = 200000;
+    var nextRequest = 0;
+    var totalLength = 100;
+    var previousAvailable = '';
+
+    if (window.internals) {
+        internals.initializeMockMediaSource();
+        internals.setMockMediaPlaybackTargetPickerEnabled(true);
+        internals.setMockMediaPlaybackTargetPickerState('', 'Unknown');
+    }
+
+    function start() 
+    {
+        findMediaElement();
+
+        consoleWrite('** create a MediaSource object, set as video.src');
+        run(`source = new MediaSource()`);
+        run(`source.addEventListener('sourceopen', startLoad)`);
+        run(`video.src = ""
+
+        video.addEventListener('webkitcurrentplaybacktargetiswirelesschanged', currentTargetChanged, true);
+        video.addEventListener('webkitplaybacktargetavailabilitychanged', targetAvailabilityChanged, true);
+        waitForEventOnce('canplaythrough', canplaythrough);
+    }
+
+    function startLoad()
+    {
+        consoleWrite('<br>** create a source buffer, add an init segment with 1 video track');
+        run(`sourceBuffer = source.addSourceBuffer('video/mock; codecs="mock"')`);
+        sourceBuffer.addEventListener('update', sourceUpdated);
+        nextRequest = 0;
+
+        run(`init = makeAInit(100, [makeATrack(1, 'mock', TRACK_KIND.VIDEO)])`);
+        run(`sourceBuffer.appendBuffer(init)`);
+        consoleWrite('');
+    }
+
+    function sourceUpdated()
+    {
+        if (nextRequest >= totalLength)
+            return;
+
+        sourceBuffer.appendBuffer(makeASample(nextRequest, nextRequest, 1, 1, SAMPLE_FLAG.SYNC));
+        ++nextRequest;
+    }
+
+    function canplaythrough()
+    {
+        consoleWrite('<br>** simulate choosing a device from the menu');
+        runWithKeyDown(function() {
+            if (window.internals) {
+                internals.setMockMediaPlaybackTargetPickerEnabled(true);
+                internals.setMockMediaPlaybackTargetPickerState('Sleepy TV', 'DeviceAvailable');
+                video.webkitShowPlaybackTargetPicker();
+            }
+        });
+    }
+
+    function currentTargetChanged()
+    {
+        if (video.src.indexOf("/test.") > 0) {
+            testExpected("video.webkitCurrentPlaybackTargetIsWireless", true);
+            consoleWrite('');
+            endTest();
+            return;
+        }
+            
+        consoleWrite('<br>** change video.src to one that supports AirPlay');
+        video.src = "" '../content/test')
+    }
+
+    function targetAvailabilityChanged(event)
+    {
+        if (previousAvailable == event.availability)
+            return;
+
+        consoleWrite(`EVENT( ${event.type} ) : event.availability = '${event.availability}'`);
+        previousAvailable = event.availability;
+    }
+    
+    </script>
+</head>
+<body _onload_="start()">
+    <video controls></video>
+</body>
+</html>

Modified: trunk/LayoutTests/platform/efl/TestExpectations (200263 => 200264)


--- trunk/LayoutTests/platform/efl/TestExpectations	2016-04-29 21:17:44 UTC (rev 200263)
+++ trunk/LayoutTests/platform/efl/TestExpectations	2016-04-29 21:29:01 UTC (rev 200264)
@@ -2627,6 +2627,9 @@
 webkit.org/b/156024 svg/zoom/page/zoom-svg-through-object-with-absolute-size.xhtml [ Failure ]
 webkit.org/b/156024 svg/zoom/page/zoom-svg-through-object-with-percentage-size.xhtml [ Failure ]
 
+# WIRELESS_PLAYBACK_TARGET not enabled.
+media/media-source/media-source-airplay.html [ Skip ]
+
 # Media tests have been failing since we bumped gstreamer ver.
 webkit.org/b/156969 media/media-source/media-source-canplaythrough.html [ Timeout ]
 webkit.org/b/156969 media/media-source/media-source-end-of-stream-buffered.html [ Timeout ]

Modified: trunk/LayoutTests/platform/gtk/TestExpectations (200263 => 200264)


--- trunk/LayoutTests/platform/gtk/TestExpectations	2016-04-29 21:17:44 UTC (rev 200263)
+++ trunk/LayoutTests/platform/gtk/TestExpectations	2016-04-29 21:29:01 UTC (rev 200264)
@@ -1865,6 +1865,9 @@
 webkit.org/b/123097 media/track/track-user-preferences.html [ Skip ]
 webkit.org/b/121995 media/video-controls-captions-trackmenu-includes-enabled-track.html [ Failure ]
 
+# WIRELESS_PLAYBACK_TARGET not enabled.
+media/media-source/media-source-airplay.html [ Skip ]
+
 Bug(GTK) http/tests/media/video-play-stall-seek.html [ Skip ]
 
 Bug(GTK) http/tests/misc/acid3.html [ Failure ]

Modified: trunk/LayoutTests/platform/ios-simulator/TestExpectations (200263 => 200264)


--- trunk/LayoutTests/platform/ios-simulator/TestExpectations	2016-04-29 21:17:44 UTC (rev 200263)
+++ trunk/LayoutTests/platform/ios-simulator/TestExpectations	2016-04-29 21:29:01 UTC (rev 200264)
@@ -3002,6 +3002,9 @@
 fast/forms/listbox-padding-clip-overlay.html [ ImageOnlyFailure ]
 fast/forms/listbox-padding-clip-selected.html [ ImageOnlyFailure ]
 
+# MSE not enabled.
+media/media-source/media-source-airplay.html [ Skip ]
+
 # No focusring on iOS.
 fast/images/image-map-outline-in-positioned-container.html [ Pass ImageOnlyFailure ]
 fast/images/image-map-outline-with-paint-root-offset.html [ Pass ImageOnlyFailure ]

Modified: trunk/LayoutTests/platform/mac/TestExpectations (200263 => 200264)


--- trunk/LayoutTests/platform/mac/TestExpectations	2016-04-29 21:17:44 UTC (rev 200263)
+++ trunk/LayoutTests/platform/mac/TestExpectations	2016-04-29 21:29:01 UTC (rev 200264)
@@ -1287,6 +1287,7 @@
 # WIRELESS_PLAYBACK_TARGET not enabled on Yosemite.
 [ Yosemite ] media/airplay-target-availability.html
 [ Yosemite ] media/controls/airplay-picker.html
+[ Yosemite ] media/media-source/media-source-airplay.html
 
 webkit.org/b/153086 sputnik/Conformance/15_Native_Objects/15.1_The_Global_Object/15.1.3/15.1.3.3_encodeURI/S15.1.3.3_A2.4_T2.html [ Pass Crash ]
 

Modified: trunk/LayoutTests/platform/win/TestExpectations (200263 => 200264)


--- trunk/LayoutTests/platform/win/TestExpectations	2016-04-29 21:17:44 UTC (rev 200263)
+++ trunk/LayoutTests/platform/win/TestExpectations	2016-04-29 21:29:01 UTC (rev 200264)
@@ -3337,6 +3337,7 @@
 
 # WIRELESS_PLAYBACK_TARGET not enabled.
 media/airplay-target-availability.html
+media/media-source/media-source-airplay.html
 
 webkit.org/b/152411 http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-always.html [ Failure ]
 webkit.org/b/152411 http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-default.html [ Failure ]

Modified: trunk/Source/WebCore/ChangeLog (200263 => 200264)


--- trunk/Source/WebCore/ChangeLog	2016-04-29 21:17:44 UTC (rev 200263)
+++ trunk/Source/WebCore/ChangeLog	2016-04-29 21:29:01 UTC (rev 200264)
@@ -1,3 +1,37 @@
+2016-04-29  Eric Carlson  <[email protected]>
+
+        [Mac] AirPlay fails if target is set before AVPlayer has been created
+        https://bugs.webkit.org/show_bug.cgi?id=157147
+        <rdar://problem/24197592>
+
+        Reviewed by Jer Noble.
+
+        Test: media/media-source/media-source-airplay.html
+
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayer): Clear flag before calling
+          setShouldPlayToPlaybackTarget so it does the necessary setup.
+
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::isAvailable): Return false if the mock
+          MSE source has been registered.
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::supportsType): Return 'not supported' if
+          isAvailable is false.
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::load): Fail if isAvailable is false.
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::isCurrentPlaybackTargetWireless): Cleanup.
+
+        * platform/mock/mediasource/MockMediaPlayerMediaSource.cpp:
+        (WebCore::registered): Global accessor.
+        (WebCore::MockMediaPlayerMediaSource::isRegistered): 
+        (WebCore::MockMediaPlayerMediaSource::registerMediaEngine): Set registered to true.
+        (WebCore::MockMediaPlayerMediaSource::setWirelessPlaybackTarget): New, remember the target.
+        (WebCore::MockMediaPlayerMediaSource::setShouldPlayToPlaybackTarget): New, remember the setting.
+        (WebCore::MockMediaPlayerMediaSource::isCurrentPlaybackTargetWireless):
+        * platform/mock/mediasource/MockMediaPlayerMediaSource.h:
+
+        * testing/Internals.cpp:
+        (WebCore::Internals::initializeMockMediaSource): Don't disable AVFoundation.
+
 2016-04-29  Myles C. Maxfield  <[email protected]>
 
         [RTL Scrollbars] REGRESSION(r200116): Positioned contents can overlap RTL scrollbars

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (200263 => 200264)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2016-04-29 21:17:44 UTC (rev 200263)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2016-04-29 21:29:01 UTC (rev 200264)
@@ -1036,8 +1036,11 @@
 #endif
 
 #if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS)
-    if (m_shouldPlayToPlaybackTarget)
+    if (m_shouldPlayToPlaybackTarget) {
+        // Clear m_shouldPlayToPlaybackTarget so doesn't return without doing anything.
+        m_shouldPlayToPlaybackTarget = false;
         setShouldPlayToPlaybackTarget(true);
+    }
 #endif
 
     if (player()->client().mediaPlayerIsVideo())

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm (200263 => 200264)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm	2016-04-29 21:17:44 UTC (rev 200263)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm	2016-04-29 21:29:01 UTC (rev 200264)
@@ -35,6 +35,7 @@
 #import "MediaSourcePrivateAVFObjC.h"
 #import "MediaSourcePrivateClient.h"
 #import "MediaTimeAVFoundation.h"
+#import "MockMediaPlayerMediaSource.h"
 #import "PlatformClockCM.h"
 #import "WebCoreSystemInterface.h"
 #import <AVFoundation/AVAsset.h>
@@ -210,6 +211,9 @@
 
 bool MediaPlayerPrivateMediaSourceAVFObjC::isAvailable()
 {
+    if (MockMediaPlayerMediaSource::isRegistered())
+        return false;
+
     return AVFoundationLibrary()
         && isCoreMediaFrameworkAvailable()
         && getAVStreamDataParserClass()
@@ -241,6 +245,9 @@
 
 MediaPlayer::SupportsType MediaPlayerPrivateMediaSourceAVFObjC::supportsType(const MediaEngineSupportParameters& parameters)
 {
+    if (!isAvailable())
+        return MediaPlayer::IsNotSupported;
+
     // This engine does not support non-media-source sources.
     if (!parameters.isMediaSource)
         return MediaPlayer::IsNotSupported;
@@ -275,6 +282,11 @@
 {
     UNUSED_PARAM(url);
 
+    if (!isAvailable()) {
+        setNetworkState(MediaPlayer::FormatError);
+        return;
+    }
+
     m_mediaSourcePrivate = MediaSourcePrivateAVFObjC::create(this, client);
 }
 
@@ -858,10 +870,7 @@
 
 bool MediaPlayerPrivateMediaSourceAVFObjC::isCurrentPlaybackTargetWireless() const
 {
-    if (!m_playbackTarget)
-        return false;
-
-    return m_shouldPlayToTarget && m_playbackTarget->hasActiveRoute();
+    return m_playbackTarget && m_shouldPlayToTarget && m_playbackTarget->hasActiveRoute();
 }
 #endif
 

Modified: trunk/Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.cpp (200263 => 200264)


--- trunk/Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.cpp	2016-04-29 21:17:44 UTC (rev 200263)
+++ trunk/Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.cpp	2016-04-29 21:29:01 UTC (rev 200264)
@@ -39,8 +39,20 @@
 namespace WebCore {
 
 // MediaPlayer Enigne Support
+static bool& registered()
+{
+    static bool isRegistered = false;
+    return isRegistered;
+}
+
+bool MockMediaPlayerMediaSource::isRegistered()
+{
+    return registered();
+}
+
 void MockMediaPlayerMediaSource::registerMediaEngine(MediaEngineRegistrar registrar)
 {
+    registered() = true;
     registrar([](MediaPlayer* player) { return std::make_unique<MockMediaPlayerMediaSource>(player); }, getSupportedTypes,
         supportsType, 0, 0, 0, 0);
 }
@@ -293,6 +305,28 @@
     return m_mediaSourcePrivate ? m_mediaSourcePrivate->totalFrameDelay() : MediaTime::zeroTime();
 }
 
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+void MockMediaPlayerMediaSource::setWirelessPlaybackTarget(Ref<MediaPlaybackTarget>&& target)
+{
+    m_playbackTarget = WTFMove(target);
 }
 
+void MockMediaPlayerMediaSource::setShouldPlayToPlaybackTarget(bool shouldPlayToTarget)
+{
+    if (shouldPlayToTarget == m_shouldPlayToTarget)
+        return;
+
+    m_shouldPlayToTarget = shouldPlayToTarget;
+
+    if (m_player)
+        m_player->currentPlaybackTargetIsWirelessChanged();
+}
+
+bool MockMediaPlayerMediaSource::isCurrentPlaybackTargetWireless() const
+{
+    return m_playbackTarget && m_shouldPlayToTarget && m_playbackTarget->hasActiveRoute();
+}
 #endif
+}
+
+#endif

Modified: trunk/Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.h (200263 => 200264)


--- trunk/Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.h	2016-04-29 21:17:44 UTC (rev 200263)
+++ trunk/Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.h	2016-04-29 21:29:01 UTC (rev 200264)
@@ -44,6 +44,7 @@
     WEBCORE_EXPORT static void registerMediaEngine(MediaEngineRegistrar);
     static void getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& types);
     static MediaPlayer::SupportsType supportsType(const MediaEngineSupportParameters&);
+    static bool isRegistered();
 
     virtual ~MockMediaPlayerMediaSource();
 
@@ -86,6 +87,13 @@
     unsigned long corruptedVideoFrames() override;
     MediaTime totalFrameDelay() override;
 
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+    bool isCurrentPlaybackTargetWireless() const override;
+    void setWirelessPlaybackTarget(Ref<MediaPlaybackTarget>&&) override;
+    void setShouldPlayToPlaybackTarget(bool) override;
+    bool wirelessVideoPlaybackDisabled() const override { return false; }
+#endif
+
     MediaPlayer* m_player;
     RefPtr<MockMediaSourcePrivate> m_mediaSourcePrivate;
 
@@ -93,6 +101,10 @@
     MediaTime m_duration;
     MediaPlayer::ReadyState m_readyState;
     MediaPlayer::NetworkState m_networkState;
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+    RefPtr<MediaPlaybackTarget> m_playbackTarget;
+    bool m_shouldPlayToTarget { false };
+#endif
     bool m_playing;
     bool m_seekCompleted;
 };

Modified: trunk/Source/WebCore/testing/Internals.cpp (200263 => 200264)


--- trunk/Source/WebCore/testing/Internals.cpp	2016-04-29 21:17:44 UTC (rev 200263)
+++ trunk/Source/WebCore/testing/Internals.cpp	2016-04-29 21:29:01 UTC (rev 200264)
@@ -2741,9 +2741,6 @@
 
 void Internals::initializeMockMediaSource()
 {
-#if USE(AVFOUNDATION)
-    WebCore::Settings::setAVFoundationEnabled(false);
-#endif
     MediaPlayerFactorySupport::callRegisterMediaEngine(MockMediaPlayerMediaSource::registerMediaEngine);
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to