[iPad] YouTube does not automatically AirPlay when a route is selected from Control...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Jan 2020 21:44:00 +0000 (21:44 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Jan 2020 21:44:00 +0000 (21:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=206539
Source/WebCore:

Patch by Jer Noble <jer.noble@apple.com> 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 <jer.noble@apple.com> on 2020-01-21
Reviewed by Eric Carlson.

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

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

12 files changed:
Source/WebCore/ChangeLog
Source/WebCore/PlatformMac.cmake
Source/WebCore/SourcesCocoa.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h
Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm
Source/WebCore/platform/graphics/avfoundation/MediaPlaybackTargetCocoa.h [moved from Source/WebCore/platform/graphics/avfoundation/MediaPlaybackTargetMac.h with 86% similarity]
Source/WebCore/platform/graphics/avfoundation/MediaPlaybackTargetCocoa.mm [moved from Source/WebCore/platform/graphics/avfoundation/MediaPlaybackTargetMac.mm with 67% similarity]
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlaybackTargetPickerMac.mm
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm

index c811556..6aedd27 100644 (file)
@@ -1,3 +1,53 @@
+2020-01-21  Jer Noble  <jer.noble@apple.com>
+
+        [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  <antti@apple.com>
 
         [LFC] Typed accessors for formatting states
index c03ce6b..993355d 100644 (file)
@@ -242,7 +242,7 @@ list(APPEND WebCore_SOURCES
     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 @@ list(APPEND WebCore_PRIVATE_FRAMEWORK_HEADERS
     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
index 8e2aadd..106740d 100644 (file)
@@ -237,7 +237,7 @@ platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.mm @no-unify
 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
index 092990f..9a72cb1 100644 (file)
                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 */; };
                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>"; };
                                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 */,
                                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 */,
                                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 */,
index 3fbae09..43cea91 100644 (file)
@@ -51,6 +51,7 @@ public:
     void carPlayServerDied();
     void updateCarPlayIsConnected(Optional<bool>&&);
     void activeAudioRouteDidChange(Optional<bool>&&);
+    void activeVideoRouteDidChange(Optional<bool>&&);
 #endif
 
 private:
index c7a3460..6c90b3c 100644 (file)
@@ -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_CarPlayIsConnectedNoti
 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 @@ void MediaSessionManageriOS::activeAudioRouteDidChange(Optional<bool>&& shouldPa
             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 @@ void MediaSessionManageriOS::activeAudioRouteDidChange(Optional<bool>&& shouldPa
             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));
+        }
     });
 
 }
 
 namespace WebCore {
 
-class MediaPlaybackTargetMac : public MediaPlaybackTarget {
+class MediaPlaybackTargetCocoa : public MediaPlaybackTarget {
 public:
     WEBCORE_EXPORT static Ref<MediaPlaybackTarget> create(AVOutputContext *);
 
-    virtual ~MediaPlaybackTargetMac();
+    virtual ~MediaPlaybackTargetCocoa();
 
     TargetType targetType() const override { return AVFoundation; }
 
@@ -49,15 +49,15 @@ public:
     AVOutputContext *outputContext() const { return m_outputContext.get(); }
 
 protected:
-    MediaPlaybackTargetMac(AVOutputContext *);
+    MediaPlaybackTargetCocoa(AVOutputContext *);
 
     RetainPtr<AVOutputContext> m_outputContext;
     mutable MediaPlaybackTargetContext m_context;
     String m_deviceName;
 };
 
-MediaPlaybackTargetMac* toMediaPlaybackTargetMac(MediaPlaybackTarget*);
-const MediaPlaybackTargetMac* toMediaPlaybackTargetMac(const MediaPlaybackTarget*);
+MediaPlaybackTargetCocoa* toMediaPlaybackTargetCocoa(MediaPlaybackTarget*);
+const MediaPlaybackTargetCocoa* toMediaPlaybackTargetCocoa(const MediaPlaybackTarget*);
 
 }
 
@@ -24,9 +24,9 @@
  */
 
 #import "config.h"
-#import "MediaPlaybackTargetMac.h"
+#import "MediaPlaybackTargetCocoa.h"
 
-#if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS_FAMILY)
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
 
 #import <objc/runtime.h>
 #import <pal/spi/mac/AVFoundationSPI.h>
 
 namespace WebCore {
 
-Ref<MediaPlaybackTarget> MediaPlaybackTargetMac::create(AVOutputContext *context)
+Ref<MediaPlaybackTarget> MediaPlaybackTargetCocoa::create(AVOutputContext *context)
 {
-    return adoptRef(*new MediaPlaybackTargetMac(context));
+    return adoptRef(*new MediaPlaybackTargetCocoa(context));
 }
 
-MediaPlaybackTargetMac::MediaPlaybackTargetMac(AVOutputContext *context)
+MediaPlaybackTargetCocoa::MediaPlaybackTargetCocoa(AVOutputContext *context)
     : MediaPlaybackTarget()
     , m_outputContext(context)
 {
 }
 
-MediaPlaybackTargetMac::~MediaPlaybackTargetMac()
+MediaPlaybackTargetCocoa::~MediaPlaybackTargetCocoa()
 {
 }
 
-const MediaPlaybackTargetContext& MediaPlaybackTargetMac::targetContext() const
+const MediaPlaybackTargetContext& MediaPlaybackTargetCocoa::targetContext() const
 {
     m_context = MediaPlaybackTargetContext(m_outputContext.get());
     return m_context;
 }
 
-bool MediaPlaybackTargetMac::hasActiveRoute() const
+bool MediaPlaybackTargetCocoa::hasActiveRoute() const
 {
     return m_outputContext && m_outputContext.get().deviceName;
 }
 
-String MediaPlaybackTargetMac::deviceName() const
+String MediaPlaybackTargetCocoa::deviceName() const
 {
     if (m_outputContext)
         return m_outputContext.get().deviceName;
@@ -69,17 +69,17 @@ String MediaPlaybackTargetMac::deviceName() const
     return emptyString();
 }
 
-MediaPlaybackTargetMac* toMediaPlaybackTargetMac(MediaPlaybackTarget* rep)
+MediaPlaybackTargetCocoa* toMediaPlaybackTargetCocoa(MediaPlaybackTarget* rep)
 {
-    return const_cast<MediaPlaybackTargetMac*>(toMediaPlaybackTargetMac(const_cast<const MediaPlaybackTarget*>(rep)));
+    return const_cast<MediaPlaybackTargetCocoa*>(toMediaPlaybackTargetCocoa(const_cast<const MediaPlaybackTarget*>(rep)));
 }
 
-const MediaPlaybackTargetMac* toMediaPlaybackTargetMac(const MediaPlaybackTarget* rep)
+const MediaPlaybackTargetCocoa* toMediaPlaybackTargetCocoa(const MediaPlaybackTarget* rep)
 {
     ASSERT_WITH_SECURITY_IMPLICATION(rep->targetType() == MediaPlaybackTarget::AVFoundation);
-    return static_cast<const MediaPlaybackTargetMac*>(rep);
+    return static_cast<const MediaPlaybackTargetCocoa*>(rep);
 }
 
 } // namespace WebCore
 
-#endif // ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS_FAMILY)
+#endif // ENABLE(WIRELESS_PLAYBACK_TARGET)
index f0b5c34..888a96b 100644 (file)
@@ -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 @@ Ref<MediaPlaybackTarget> MediaPlaybackTargetPickerMac::playbackTarget()
 {
     AVOutputContext* context = m_outputDeviceMenuController ? [m_outputDeviceMenuController.get() outputContext] : nullptr;
 
-    return WebCore::MediaPlaybackTargetMac::create(context);
+    return WebCore::MediaPlaybackTargetCocoa::create(context);
 }
 
 AVOutputDeviceMenuController *MediaPlaybackTargetPickerMac::devicePicker()
index c8c4c36..638580d 100644 (file)
@@ -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 @@ void MediaPlayerPrivateAVFoundationObjC::setWirelessPlaybackTarget(Ref<MediaPlay
 {
     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);
 
index 14c73a0..3c68ffe 100644 (file)
@@ -1,3 +1,14 @@
+2020-01-21  Jer Noble  <jer.noble@apple.com>
+
+        [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  <achristensen@webkit.org>
 
         Add SPI on WKURLSchemeTask to access WKFrameInfo of originating frame
index 2aa8e76..5f1eb7f 100644 (file)
@@ -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 @@ void WebPage::playbackTargetSelected(uint64_t contextId, const WebCore::MediaPla
 {
     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()));