Title: [254878] trunk/Source
Revision
254878
Author
[email protected]
Date
2020-01-21 13:44:00 -0800 (Tue, 21 Jan 2020)

Log Message

[iPad] YouTube does not automatically AirPlay when a route is selected from Control Center
https://bugs.webkit.org/show_bug.cgi?id=206539
Source/WebCore:

Patch by Jer Noble <[email protected]> on 2020-01-21
Reviewed by Eric Carlson.

No new tests; change affects an interaction with two platform features (local AirPlay
route picking and actual remote playback over AirPlay routes) that is not testable in
an automated fashion.

The underlying source of the bug is the difference in how the platform communitcates that an
AirPlay route was picked between iOS and macOS. On iOS, route changes are global and are
generally pushed up from AVPlayer notifications. On macOS, route changes are local to the
app and are pushed down from the UIProcess. But when MSE playback was enabled on iPadOS,
there was now a limbo where media playback was no longer using an AVPlayer, but at the same
time, route changes could be initiated globally. The end result is that MSE-based media
elements are never notified that they "should play to playback target", and no remote
playback events are ever fired.

To re-create the same macOS behavior when MSE-backed media elements are used on iPadOS,
re-use the existing route change detection logic in MediaSessionManageriOS to query whether
the newly established route supports AirPlay Video, and if so, send a message to the "now
playing" media element that it should begin AirPlaying, which will fail, but will trigger
the YouTube player to switch to a HLS-backed media element.

This requires renaming MediaPlaybackTargetMac -> MediaPlaybackTargetCocoa.

* SourcesCocoa.txt:
* PlatformMac.cmake:
* WebCore.xcodeproj/project.pbxproj:
* platform/audio/ios/MediaSessionManagerIOS.h:
* platform/audio/ios/MediaSessionManagerIOS.mm:
(WebCore::MediaSessionManageriOS::activeVideoRouteDidChange):
(-[WebMediaSessionHelper activeAudioRouteDidChange:]):
* platform/graphics/avfoundation/MediaPlaybackTargetCocoa.h: Renamed from Source/WebCore/platform/graphics/avfoundation/MediaPlaybackTargetMac.h.
(WebCore::MediaPlaybackTargetCocoa::outputContext const):
* platform/graphics/avfoundation/MediaPlaybackTargetCocoa.mm: Renamed from Source/WebCore/platform/graphics/avfoundation/MediaPlaybackTargetMac.mm.
(WebCore::MediaPlaybackTargetCocoa::create):
(WebCore::MediaPlaybackTargetCocoa::MediaPlaybackTargetCocoa):
(WebCore::MediaPlaybackTargetCocoa::~MediaPlaybackTargetCocoa):
(WebCore::MediaPlaybackTargetCocoa::targetContext const):
(WebCore::MediaPlaybackTargetCocoa::hasActiveRoute const):
(WebCore::MediaPlaybackTargetCocoa::deviceName const):
(WebCore::toMediaPlaybackTargetCocoa):
* platform/graphics/avfoundation/objc/MediaPlaybackTargetPickerMac.mm:
(WebCore::MediaPlaybackTargetPickerMac::playbackTarget):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::setWirelessPlaybackTarget):

Source/WebKit:

<rdar://problem/54173689>

Patch by Jer Noble <[email protected]> on 2020-01-21
Reviewed by Eric Carlson.

* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::playbackTargetSelected const):

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (254877 => 254878)


--- trunk/Source/WebCore/ChangeLog	2020-01-21 21:25:31 UTC (rev 254877)
+++ trunk/Source/WebCore/ChangeLog	2020-01-21 21:44:00 UTC (rev 254878)
@@ -1,3 +1,53 @@
+2020-01-21  Jer Noble  <[email protected]>
+
+        [iPad] YouTube does not automatically AirPlay when a route is selected from Control Center
+        https://bugs.webkit.org/show_bug.cgi?id=206539
+
+        Reviewed by Eric Carlson.
+
+        No new tests; change affects an interaction with two platform features (local AirPlay
+        route picking and actual remote playback over AirPlay routes) that is not testable in
+        an automated fashion.
+
+        The underlying source of the bug is the difference in how the platform communitcates that an
+        AirPlay route was picked between iOS and macOS. On iOS, route changes are global and are
+        generally pushed up from AVPlayer notifications. On macOS, route changes are local to the
+        app and are pushed down from the UIProcess. But when MSE playback was enabled on iPadOS,
+        there was now a limbo where media playback was no longer using an AVPlayer, but at the same
+        time, route changes could be initiated globally. The end result is that MSE-based media
+        elements are never notified that they "should play to playback target", and no remote
+        playback events are ever fired.
+
+        To re-create the same macOS behavior when MSE-backed media elements are used on iPadOS,
+        re-use the existing route change detection logic in MediaSessionManageriOS to query whether
+        the newly established route supports AirPlay Video, and if so, send a message to the "now
+        playing" media element that it should begin AirPlaying, which will fail, but will trigger
+        the YouTube player to switch to a HLS-backed media element.
+
+        This requires renaming MediaPlaybackTargetMac -> MediaPlaybackTargetCocoa.
+
+        * SourcesCocoa.txt:
+        * PlatformMac.cmake:
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/audio/ios/MediaSessionManagerIOS.h:
+        * platform/audio/ios/MediaSessionManagerIOS.mm:
+        (WebCore::MediaSessionManageriOS::activeVideoRouteDidChange):
+        (-[WebMediaSessionHelper activeAudioRouteDidChange:]):
+        * platform/graphics/avfoundation/MediaPlaybackTargetCocoa.h: Renamed from Source/WebCore/platform/graphics/avfoundation/MediaPlaybackTargetMac.h.
+        (WebCore::MediaPlaybackTargetCocoa::outputContext const):
+        * platform/graphics/avfoundation/MediaPlaybackTargetCocoa.mm: Renamed from Source/WebCore/platform/graphics/avfoundation/MediaPlaybackTargetMac.mm.
+        (WebCore::MediaPlaybackTargetCocoa::create):
+        (WebCore::MediaPlaybackTargetCocoa::MediaPlaybackTargetCocoa):
+        (WebCore::MediaPlaybackTargetCocoa::~MediaPlaybackTargetCocoa):
+        (WebCore::MediaPlaybackTargetCocoa::targetContext const):
+        (WebCore::MediaPlaybackTargetCocoa::hasActiveRoute const):
+        (WebCore::MediaPlaybackTargetCocoa::deviceName const):
+        (WebCore::toMediaPlaybackTargetCocoa):
+        * platform/graphics/avfoundation/objc/MediaPlaybackTargetPickerMac.mm:
+        (WebCore::MediaPlaybackTargetPickerMac::playbackTarget):
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::setWirelessPlaybackTarget):
+
 2020-01-21  Antti Koivisto  <[email protected]>
 
         [LFC] Typed accessors for formatting states

Modified: trunk/Source/WebCore/PlatformMac.cmake (254877 => 254878)


--- trunk/Source/WebCore/PlatformMac.cmake	2020-01-21 21:25:31 UTC (rev 254877)
+++ trunk/Source/WebCore/PlatformMac.cmake	2020-01-21 21:44:00 UTC (rev 254878)
@@ -242,7 +242,7 @@
     platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.mm
     platform/graphics/avfoundation/InbandMetadataTextTrackPrivateAVF.cpp
     platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp
-    platform/graphics/avfoundation/MediaPlaybackTargetMac.mm
+    platform/graphics/avfoundation/MediaPlaybackTargetCocoa.mm
     platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp
     platform/graphics/avfoundation/MediaSelectionGroupAVFObjC.mm
 
@@ -507,7 +507,7 @@
     platform/gamepad/mac/HIDGamepad.h
     platform/gamepad/mac/HIDGamepadProvider.h
 
-    platform/graphics/avfoundation/MediaPlaybackTargetMac.h
+    platform/graphics/avfoundation/MediaPlaybackTargetCocoa.h
     platform/graphics/avfoundation/WebMediaSessionManagerMac.h
 
     platform/graphics/avfoundation/objc/AVAssetMIMETypeCache.h

Modified: trunk/Source/WebCore/SourcesCocoa.txt (254877 => 254878)


--- trunk/Source/WebCore/SourcesCocoa.txt	2020-01-21 21:25:31 UTC (rev 254877)
+++ trunk/Source/WebCore/SourcesCocoa.txt	2020-01-21 21:44:00 UTC (rev 254878)
@@ -237,7 +237,7 @@
 platform/graphics/avfoundation/InbandMetadataTextTrackPrivateAVF.cpp @no-unify
 platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp @no-unify
 platform/graphics/avfoundation/ISOFairPlayStreamingPsshBox.cpp
-platform/graphics/avfoundation/MediaPlaybackTargetMac.mm @no-unify
+platform/graphics/avfoundation/MediaPlaybackTargetCocoa.mm @no-unify
 platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp @no-unify
 platform/graphics/avfoundation/MediaSelectionGroupAVFObjC.mm @no-unify
 platform/graphics/avfoundation/WebMediaSessionManagerMac.cpp @no-unify

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (254877 => 254878)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-01-21 21:25:31 UTC (rev 254877)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-01-21 21:44:00 UTC (rev 254878)
@@ -101,8 +101,8 @@
 		0719427F1D088F21002AA51D /* AVAssetMIMETypeCache.mm in Sources */ = {isa = PBXBuildFile; fileRef = 07C8AD111D073D630087C5CE /* AVAssetMIMETypeCache.mm */; };
 		071A9EC2168FBC43002629F9 /* TextTrackCueGeneric.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 071A9EC0168FB56C002629F9 /* TextTrackCueGeneric.cpp */; };
 		071A9EC3168FBC55002629F9 /* TextTrackCueGeneric.h in Headers */ = {isa = PBXBuildFile; fileRef = 071A9EC1168FB56C002629F9 /* TextTrackCueGeneric.h */; settings = {ATTRIBUTES = (Private, ); }; };
-		071E496E1AD5AA0D008A50B4 /* MediaPlaybackTargetMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 071E496D1AD5AA0D008A50B4 /* MediaPlaybackTargetMac.mm */; };
-		071E49701AD5AB5E008A50B4 /* MediaPlaybackTargetMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 071E496F1AD5AB5E008A50B4 /* MediaPlaybackTargetMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		071E496E1AD5AA0D008A50B4 /* MediaPlaybackTargetCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 071E496D1AD5AA0D008A50B4 /* MediaPlaybackTargetCocoa.mm */; };
+		071E49701AD5AB5E008A50B4 /* MediaPlaybackTargetCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = 071E496F1AD5AB5E008A50B4 /* MediaPlaybackTargetCocoa.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		0720B0A114D3323500642955 /* GenericEventQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = 0720B09F14D3323500642955 /* GenericEventQueue.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		0725EFA9239AD79300A538A9 /* MediaPlayerPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 079F5E4B0F3BEBEA005E0782 /* MediaPlayerPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		07277E4D17D018CC0015534D /* JSMediaStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 07277E4117D018CC0015534D /* JSMediaStream.h */; };
@@ -5366,8 +5366,8 @@
 		0711588F17DF633700EDFE2B /* MediaStreamPrivate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaStreamPrivate.cpp; sourceTree = "<group>"; };
 		071A9EC0168FB56C002629F9 /* TextTrackCueGeneric.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextTrackCueGeneric.cpp; sourceTree = "<group>"; };
 		071A9EC1168FB56C002629F9 /* TextTrackCueGeneric.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextTrackCueGeneric.h; sourceTree = "<group>"; };
-		071E496D1AD5AA0D008A50B4 /* MediaPlaybackTargetMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MediaPlaybackTargetMac.mm; sourceTree = "<group>"; };
-		071E496F1AD5AB5E008A50B4 /* MediaPlaybackTargetMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaPlaybackTargetMac.h; sourceTree = "<group>"; };
+		071E496D1AD5AA0D008A50B4 /* MediaPlaybackTargetCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MediaPlaybackTargetCocoa.mm; sourceTree = "<group>"; };
+		071E496F1AD5AB5E008A50B4 /* MediaPlaybackTargetCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaPlaybackTargetCocoa.h; sourceTree = "<group>"; };
 		0720B09E14D3323500642955 /* GenericEventQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GenericEventQueue.cpp; sourceTree = "<group>"; };
 		0720B09F14D3323500642955 /* GenericEventQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GenericEventQueue.h; sourceTree = "<group>"; };
 		07221B4C17CEC32700848E51 /* MediaStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaStream.cpp; sourceTree = "<group>"; };
@@ -16349,8 +16349,8 @@
 				07B442D5166C70B000556CAD /* InbandTextTrackPrivateAVF.h */,
 				CD720B4722682C7E00047FDE /* ISOFairPlayStreamingPsshBox.cpp */,
 				CD720B4922682C7F00047FDE /* ISOFairPlayStreamingPsshBox.h */,
-				071E496F1AD5AB5E008A50B4 /* MediaPlaybackTargetMac.h */,
-				071E496D1AD5AA0D008A50B4 /* MediaPlaybackTargetMac.mm */,
+				071E496F1AD5AB5E008A50B4 /* MediaPlaybackTargetCocoa.h */,
+				071E496D1AD5AA0D008A50B4 /* MediaPlaybackTargetCocoa.mm */,
 				076F0D0912B8192700C26AA4 /* MediaPlayerPrivateAVFoundation.cpp */,
 				076F0D0A12B8192700C26AA4 /* MediaPlayerPrivateAVFoundation.h */,
 				CDBEAEAB19D92B6C00BEBA88 /* MediaSelectionGroupAVFObjC.h */,
@@ -31517,8 +31517,8 @@
 				5EBB89311C7777FF00C65D41 /* MediaPayload.h in Headers */,
 				07E3DFD11A9E786500764CA8 /* MediaPlaybackTarget.h in Headers */,
 				079216551AA560AA00A3C049 /* MediaPlaybackTargetClient.h in Headers */,
+				071E49701AD5AB5E008A50B4 /* MediaPlaybackTargetCocoa.h in Headers */,
 				07F876841AD580F900905849 /* MediaPlaybackTargetContext.h in Headers */,
-				071E49701AD5AB5E008A50B4 /* MediaPlaybackTargetMac.h in Headers */,
 				077B64171B95F703003E9AD5 /* MediaPlaybackTargetMock.h in Headers */,
 				078E43DA1ABB6C7E001C2FA6 /* MediaPlaybackTargetPicker.h in Headers */,
 				078E43DD1ABB6F6F001C2FA6 /* MediaPlaybackTargetPickerMac.h in Headers */,
@@ -33717,7 +33717,7 @@
 				2D9BF7451DBFDC44007A7D99 /* MediaKeySession.cpp in Sources */,
 				2D9BF7441DBFDC41007A7D99 /* MediaKeyStatusMap.cpp in Sources */,
 				2D9BF7431DBFDC3E007A7D99 /* MediaKeySystemAccess.cpp in Sources */,
-				071E496E1AD5AA0D008A50B4 /* MediaPlaybackTargetMac.mm in Sources */,
+				071E496E1AD5AA0D008A50B4 /* MediaPlaybackTargetCocoa.mm in Sources */,
 				078E43DE1ABB6F6F001C2FA6 /* MediaPlaybackTargetPickerMac.mm in Sources */,
 				072C8B11131C518600A4FCE9 /* MediaPlayerPrivateAVFoundation.cpp in Sources */,
 				DF9AFD7313FC31D80015FEB7 /* MediaPlayerPrivateAVFoundationObjC.mm in Sources */,

Modified: trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h (254877 => 254878)


--- trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h	2020-01-21 21:25:31 UTC (rev 254877)
+++ trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h	2020-01-21 21:44:00 UTC (rev 254878)
@@ -51,6 +51,7 @@
     void carPlayServerDied();
     void updateCarPlayIsConnected(Optional<bool>&&);
     void activeAudioRouteDidChange(Optional<bool>&&);
+    void activeVideoRouteDidChange(Optional<bool>&&);
 #endif
 
 private:

Modified: trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm (254877 => 254878)


--- trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm	2020-01-21 21:25:31 UTC (rev 254877)
+++ trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm	2020-01-21 21:44:00 UTC (rev 254878)
@@ -29,6 +29,7 @@
 #if PLATFORM(IOS_FAMILY)
 
 #import "Logging.h"
+#import "MediaPlaybackTargetCocoa.h"
 #import "MediaPlayer.h"
 #import "PlatformMediaSession.h"
 #import "RuntimeApplicationChecks.h"
@@ -40,6 +41,7 @@
 #import <pal/ios/UIKitSoftLink.h>
 #import <pal/spi/ios/CelestialSPI.h>
 #import <pal/spi/ios/UIKitSPI.h>
+#import <pal/spi/mac/AVFoundationSPI.h>
 #import <wtf/BlockObjCExceptions.h>
 #import <wtf/MainThread.h>
 #import <wtf/RAMSize.h>
@@ -62,6 +64,8 @@
 SOFT_LINK_CONSTANT_MAY_FAIL(Celestial, AVSystemController_ServerConnectionDiedNotification, NSString *)
 SOFT_LINK_CONSTANT_MAY_FAIL(Celestial, AVSystemController_ActiveAudioRouteDidChangeNotification, NSString *)
 SOFT_LINK_CONSTANT_MAY_FAIL(Celestial, AVSystemController_ActiveAudioRouteDidChangeNotificationParameter_ShouldPause, NSString *)
+SOFT_LINK_CONSTANT_MAY_FAIL(Celestial, AVSystemController_PickedRouteAttribute, NSString *)
+SOFT_LINK_CONSTANT_MAY_FAIL(Celestial, AVSystemController_RouteDescriptionKey_RouteSupportsAirPlayVideo, NSString *)
 #endif
 
 using namespace WebCore;
@@ -246,6 +250,18 @@
             session.pauseSession();
     });
 }
+
+void MediaSessionManageriOS::activeVideoRouteDidChange(Optional<bool>&& supportsAirPlayVideo)
+{
+    auto nowPlayingSession = nowPlayingEligibleSession();
+    if (!nowPlayingSession)
+        return;
+
+    auto shouldPlayToPlaybackTarget = supportsAirPlayVideo.valueOr(false);
+    auto playbackTarget = MediaPlaybackTargetCocoa::create([PAL::getAVOutputContextClass() sharedAudioPresentationOutputContext]);
+    nowPlayingSession->setShouldPlayToPlaybackTarget(shouldPlayToPlaybackTarget);
+    nowPlayingSession->setPlaybackTarget(WTFMove(playbackTarget));
+}
 #endif
 
 } // namespace WebCore
@@ -523,9 +539,21 @@
             shouldPause = nsShouldPause.boolValue;
     }
 
-    callOnWebThreadOrDispatchAsyncOnMainThread([protectedSelf = retainPtr(self), shouldPause = WTFMove(shouldPause)]() mutable {
-        if (auto* callback = protectedSelf->_callback)
+    Optional<bool> supportsAirPlayVideo;
+    if (canLoadAVSystemController_PickedRouteAttribute() && canLoadAVSystemController_RouteDescriptionKey_RouteSupportsAirPlayVideo()) {
+        NSDictionary* pickedRoute = [[getAVSystemControllerClass() sharedAVSystemController] attributeForKey:getAVSystemController_PickedRouteAttribute()];
+        if ([pickedRoute isKindOfClass:NSDictionary.class]) {
+            NSNumber* nsSupportsAirPlayVideo = [pickedRoute valueForKey:getAVSystemController_RouteDescriptionKey_RouteSupportsAirPlayVideo()];
+            if (nsSupportsAirPlayVideo)
+                supportsAirPlayVideo = nsSupportsAirPlayVideo.boolValue;
+        }
+    }
+
+    callOnWebThreadOrDispatchAsyncOnMainThread([protectedSelf = retainPtr(self), shouldPause = WTFMove(shouldPause), supportsAirPlayVideo = WTFMove(supportsAirPlayVideo)]() mutable {
+        if (auto* callback = protectedSelf->_callback) {
             callback->activeAudioRouteDidChange(WTFMove(shouldPause));
+            callback->activeVideoRouteDidChange(WTFMove(supportsAirPlayVideo));
+        }
     });
 
 }

Copied: trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlaybackTargetCocoa.h (from rev 254877, trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlaybackTargetMac.h) (0 => 254878)


--- trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlaybackTargetCocoa.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlaybackTargetCocoa.h	2020-01-21 21:44:00 UTC (rev 254878)
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#pragma once
+
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+
+#include "MediaPlaybackTarget.h"
+#include "MediaPlaybackTargetContext.h"
+#include <wtf/RetainPtr.h>
+
+namespace WebCore {
+
+class MediaPlaybackTargetCocoa : public MediaPlaybackTarget {
+public:
+    WEBCORE_EXPORT static Ref<MediaPlaybackTarget> create(AVOutputContext *);
+
+    virtual ~MediaPlaybackTargetCocoa();
+
+    TargetType targetType() const override { return AVFoundation; }
+
+    const MediaPlaybackTargetContext& targetContext() const override;
+    bool hasActiveRoute() const override;
+
+    String deviceName() const override;
+
+    AVOutputContext *outputContext() const { return m_outputContext.get(); }
+
+protected:
+    MediaPlaybackTargetCocoa(AVOutputContext *);
+
+    RetainPtr<AVOutputContext> m_outputContext;
+    mutable MediaPlaybackTargetContext m_context;
+    String m_deviceName;
+};
+
+MediaPlaybackTargetCocoa* toMediaPlaybackTargetCocoa(MediaPlaybackTarget*);
+const MediaPlaybackTargetCocoa* toMediaPlaybackTargetCocoa(const MediaPlaybackTarget*);
+
+}
+
+#endif // ENABLE(WIRELESS_PLAYBACK_TARGET)

Copied: trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlaybackTargetCocoa.mm (from rev 254877, trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlaybackTargetMac.mm) (0 => 254878)


--- trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlaybackTargetCocoa.mm	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlaybackTargetCocoa.mm	2020-01-21 21:44:00 UTC (rev 254878)
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#import "config.h"
+#import "MediaPlaybackTargetCocoa.h"
+
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+
+#import <objc/runtime.h>
+#import <pal/spi/mac/AVFoundationSPI.h>
+
+#import <pal/cocoa/AVFoundationSoftLink.h>
+
+namespace WebCore {
+
+Ref<MediaPlaybackTarget> MediaPlaybackTargetCocoa::create(AVOutputContext *context)
+{
+    return adoptRef(*new MediaPlaybackTargetCocoa(context));
+}
+
+MediaPlaybackTargetCocoa::MediaPlaybackTargetCocoa(AVOutputContext *context)
+    : MediaPlaybackTarget()
+    , m_outputContext(context)
+{
+}
+
+MediaPlaybackTargetCocoa::~MediaPlaybackTargetCocoa()
+{
+}
+
+const MediaPlaybackTargetContext& MediaPlaybackTargetCocoa::targetContext() const
+{
+    m_context = MediaPlaybackTargetContext(m_outputContext.get());
+    return m_context;
+}
+
+bool MediaPlaybackTargetCocoa::hasActiveRoute() const
+{
+    return m_outputContext && m_outputContext.get().deviceName;
+}
+
+String MediaPlaybackTargetCocoa::deviceName() const
+{
+    if (m_outputContext)
+        return m_outputContext.get().deviceName;
+
+    return emptyString();
+}
+
+MediaPlaybackTargetCocoa* toMediaPlaybackTargetCocoa(MediaPlaybackTarget* rep)
+{
+    return const_cast<MediaPlaybackTargetCocoa*>(toMediaPlaybackTargetCocoa(const_cast<const MediaPlaybackTarget*>(rep)));
+}
+
+const MediaPlaybackTargetCocoa* toMediaPlaybackTargetCocoa(const MediaPlaybackTarget* rep)
+{
+    ASSERT_WITH_SECURITY_IMPLICATION(rep->targetType() == MediaPlaybackTarget::AVFoundation);
+    return static_cast<const MediaPlaybackTargetCocoa*>(rep);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WIRELESS_PLAYBACK_TARGET)

Deleted: trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlaybackTargetMac.h (254877 => 254878)


--- trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlaybackTargetMac.h	2020-01-21 21:25:31 UTC (rev 254877)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlaybackTargetMac.h	2020-01-21 21:44:00 UTC (rev 254878)
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
- */
-
-#pragma once
-
-#if ENABLE(WIRELESS_PLAYBACK_TARGET)
-
-#include "MediaPlaybackTarget.h"
-#include "MediaPlaybackTargetContext.h"
-#include <wtf/RetainPtr.h>
-
-namespace WebCore {
-
-class MediaPlaybackTargetMac : public MediaPlaybackTarget {
-public:
-    WEBCORE_EXPORT static Ref<MediaPlaybackTarget> create(AVOutputContext *);
-
-    virtual ~MediaPlaybackTargetMac();
-
-    TargetType targetType() const override { return AVFoundation; }
-
-    const MediaPlaybackTargetContext& targetContext() const override;
-    bool hasActiveRoute() const override;
-
-    String deviceName() const override;
-
-    AVOutputContext *outputContext() const { return m_outputContext.get(); }
-
-protected:
-    MediaPlaybackTargetMac(AVOutputContext *);
-
-    RetainPtr<AVOutputContext> m_outputContext;
-    mutable MediaPlaybackTargetContext m_context;
-    String m_deviceName;
-};
-
-MediaPlaybackTargetMac* toMediaPlaybackTargetMac(MediaPlaybackTarget*);
-const MediaPlaybackTargetMac* toMediaPlaybackTargetMac(const MediaPlaybackTarget*);
-
-}
-
-#endif // ENABLE(WIRELESS_PLAYBACK_TARGET)

Deleted: trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlaybackTargetMac.mm (254877 => 254878)


--- trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlaybackTargetMac.mm	2020-01-21 21:25:31 UTC (rev 254877)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlaybackTargetMac.mm	2020-01-21 21:44:00 UTC (rev 254878)
@@ -1,85 +0,0 @@
-/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
- */
-
-#import "config.h"
-#import "MediaPlaybackTargetMac.h"
-
-#if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS_FAMILY)
-
-#import <objc/runtime.h>
-#import <pal/spi/mac/AVFoundationSPI.h>
-
-#import <pal/cocoa/AVFoundationSoftLink.h>
-
-namespace WebCore {
-
-Ref<MediaPlaybackTarget> MediaPlaybackTargetMac::create(AVOutputContext *context)
-{
-    return adoptRef(*new MediaPlaybackTargetMac(context));
-}
-
-MediaPlaybackTargetMac::MediaPlaybackTargetMac(AVOutputContext *context)
-    : MediaPlaybackTarget()
-    , m_outputContext(context)
-{
-}
-
-MediaPlaybackTargetMac::~MediaPlaybackTargetMac()
-{
-}
-
-const MediaPlaybackTargetContext& MediaPlaybackTargetMac::targetContext() const
-{
-    m_context = MediaPlaybackTargetContext(m_outputContext.get());
-    return m_context;
-}
-
-bool MediaPlaybackTargetMac::hasActiveRoute() const
-{
-    return m_outputContext && m_outputContext.get().deviceName;
-}
-
-String MediaPlaybackTargetMac::deviceName() const
-{
-    if (m_outputContext)
-        return m_outputContext.get().deviceName;
-
-    return emptyString();
-}
-
-MediaPlaybackTargetMac* toMediaPlaybackTargetMac(MediaPlaybackTarget* rep)
-{
-    return const_cast<MediaPlaybackTargetMac*>(toMediaPlaybackTargetMac(const_cast<const MediaPlaybackTarget*>(rep)));
-}
-
-const MediaPlaybackTargetMac* toMediaPlaybackTargetMac(const MediaPlaybackTarget* rep)
-{
-    ASSERT_WITH_SECURITY_IMPLICATION(rep->targetType() == MediaPlaybackTarget::AVFoundation);
-    return static_cast<const MediaPlaybackTargetMac*>(rep);
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS_FAMILY)

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlaybackTargetPickerMac.mm (254877 => 254878)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlaybackTargetPickerMac.mm	2020-01-21 21:25:31 UTC (rev 254877)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlaybackTargetPickerMac.mm	2020-01-21 21:44:00 UTC (rev 254878)
@@ -30,7 +30,7 @@
 
 #import "Logging.h"
 #import <WebCore/FloatRect.h>
-#import <WebCore/MediaPlaybackTargetMac.h>
+#import <WebCore/MediaPlaybackTargetCocoa.h>
 #import <objc/runtime.h>
 #import <pal/cf/CoreMediaSoftLink.h>
 #import <pal/spi/cocoa/AVKitSPI.h>
@@ -79,7 +79,7 @@
 {
     AVOutputContext* context = m_outputDeviceMenuController ? [m_outputDeviceMenuController.get() outputContext] : nullptr;
 
-    return WebCore::MediaPlaybackTargetMac::create(context);
+    return WebCore::MediaPlaybackTargetCocoa::create(context);
 }
 
 AVOutputDeviceMenuController *MediaPlaybackTargetPickerMac::devicePicker()

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


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2020-01-21 21:25:31 UTC (rev 254877)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2020-01-21 21:44:00 UTC (rev 254878)
@@ -48,7 +48,7 @@
 #import "InbandTextTrackPrivateAVFObjC.h"
 #import "InbandTextTrackPrivateLegacyAVFObjC.h"
 #import "Logging.h"
-#import "MediaPlaybackTargetMac.h"
+#import "MediaPlaybackTargetCocoa.h"
 #import "MediaPlaybackTargetMock.h"
 #import "MediaSelectionGroupAVFObjC.h"
 #import "OutOfBandTextTrackPrivateAVF.h"
@@ -2822,7 +2822,7 @@
 {
     m_playbackTarget = WTFMove(target);
 
-    m_outputContext = m_playbackTarget->targetType() == MediaPlaybackTarget::AVFoundation ? toMediaPlaybackTargetMac(m_playbackTarget.get())->outputContext() : nullptr;
+    m_outputContext = m_playbackTarget->targetType() == MediaPlaybackTarget::AVFoundation ? toMediaPlaybackTargetCocoa(m_playbackTarget.get())->outputContext() : nullptr;
 
     INFO_LOG(LOGIDENTIFIER);
 

Modified: trunk/Source/WebKit/ChangeLog (254877 => 254878)


--- trunk/Source/WebKit/ChangeLog	2020-01-21 21:25:31 UTC (rev 254877)
+++ trunk/Source/WebKit/ChangeLog	2020-01-21 21:44:00 UTC (rev 254878)
@@ -1,3 +1,14 @@
+2020-01-21  Jer Noble  <[email protected]>
+
+        [iPad] YouTube does not automatically AirPlay when a route is selected from Control Center
+        https://bugs.webkit.org/show_bug.cgi?id=206539
+        <rdar://problem/54173689>
+
+        Reviewed by Eric Carlson.
+
+        * WebProcess/WebPage/mac/WebPageMac.mm:
+        (WebKit::WebPage::playbackTargetSelected const):
+
 2020-01-21  Alex Christensen  <[email protected]>
 
         Add SPI on WKURLSchemeTask to access WKFrameInfo of originating frame

Modified: trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm (254877 => 254878)


--- trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm	2020-01-21 21:25:31 UTC (rev 254877)
+++ trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm	2020-01-21 21:44:00 UTC (rev 254878)
@@ -94,7 +94,7 @@
 #import <wtf/SetForScope.h>
 
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
-#import <WebCore/MediaPlaybackTargetMac.h>
+#import <WebCore/MediaPlaybackTargetCocoa.h>
 #import <WebCore/MediaPlaybackTargetMock.h>
 #endif
 
@@ -1026,7 +1026,7 @@
 {
     switch (targetContext.type()) {
     case MediaPlaybackTargetContext::AVOutputContextType:
-        m_page->setPlaybackTarget(contextId, WebCore::MediaPlaybackTargetMac::create(targetContext.avOutputContext()));
+        m_page->setPlaybackTarget(contextId, WebCore::MediaPlaybackTargetCocoa::create(targetContext.avOutputContext()));
         break;
     case MediaPlaybackTargetContext::MockType:
         m_page->setPlaybackTarget(contextId, WebCore::MediaPlaybackTargetMock::create(targetContext.mockDeviceName(), targetContext.mockState()));
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to