[iOS] Tell AirPlay picker when a file has video
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Nov 2018 21:11:40 +0000 (21:11 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Nov 2018 21:11:40 +0000 (21:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=192155
Source/WebCore/PAL:

Reviewed by Jer Noble.

* pal/spi/ios/MediaPlayerSPI.h:

Source/WebKit:

<rdar://problem/43843865>

Reviewed by Jer Noble.

* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _showPlaybackTargetPicker:fromRect:routeSharingPolicy:routingContextUID:]):
Add hasVideo parameter.

* UIProcess/ios/forms/WKAirPlayRoutePicker.h:
* UIProcess/ios/forms/WKAirPlayRoutePicker.mm:
(-[WKAirPlayRoutePicker showFromView:routeSharingPolicy:routingContextUID:hasVideo:]): Add
hasVideo parameter, pass info to MPMediaControlsViewController.
(-[WKAirPlayRoutePicker showFromView:routeSharingPolicy:routingContextUID:]): Deleted.

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

Source/WebCore/PAL/ChangeLog
Source/WebCore/PAL/pal/spi/ios/MediaPlayerSPI.h
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
Source/WebKit/UIProcess/ios/forms/WKAirPlayRoutePicker.h
Source/WebKit/UIProcess/ios/forms/WKAirPlayRoutePicker.mm

index a45827b..db61700 100644 (file)
@@ -1,3 +1,12 @@
+2018-11-29  Eric Carlson  <eric.carlson@apple.com>
+
+        [iOS] Tell AirPlay picker when a file has video
+        https://bugs.webkit.org/show_bug.cgi?id=192155
+
+        Reviewed by Jer Noble.
+
+        * pal/spi/ios/MediaPlayerSPI.h:
+
 2018-11-29  Alexey Proskuryakov  <ap@apple.com>
 
         Modernize the check for kCFURLRequestContentDecoderSkipURLCheck existence
index 15ebf0d..82c8a20 100644 (file)
@@ -66,6 +66,9 @@ typedef NSInteger MPRouteDiscoveryMode;
 @property (nonatomic, copy, nullable) void (^didDismissHandler)(void);
 @end
 
+@interface MPMediaControlsConfiguration : NSObject <NSSecureCoding, NSCopying>
+@end
+
 #else
 
 enum {
index 53412db..c9b05d8 100644 (file)
@@ -1,3 +1,21 @@
+2018-11-29  Eric Carlson  <eric.carlson@apple.com>
+
+        [iOS] Tell AirPlay picker when a file has video
+        https://bugs.webkit.org/show_bug.cgi?id=192155
+        <rdar://problem/43843865>
+
+        Reviewed by Jer Noble.
+
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _showPlaybackTargetPicker:fromRect:routeSharingPolicy:routingContextUID:]):
+        Add hasVideo parameter.
+
+        * UIProcess/ios/forms/WKAirPlayRoutePicker.h:
+        * UIProcess/ios/forms/WKAirPlayRoutePicker.mm:
+        (-[WKAirPlayRoutePicker showFromView:routeSharingPolicy:routingContextUID:hasVideo:]): Add
+        hasVideo parameter, pass info to MPMediaControlsViewController.
+        (-[WKAirPlayRoutePicker showFromView:routeSharingPolicy:routingContextUID:]): Deleted.
+
 2018-11-29  Alexey Proskuryakov  <ap@apple.com>
 
         Modernize the check for kCFURLRequestContentDecoderSkipURLCheck existence
index 60cfb8f..b24b302 100644 (file)
@@ -4926,7 +4926,7 @@ static bool isAssistableInputType(InputType type)
 #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000 && !PLATFORM(WATCHOS) && !PLATFORM(APPLETV)
     if (!_airPlayRoutePicker)
         _airPlayRoutePicker = adoptNS([[WKAirPlayRoutePicker alloc] init]);
-    [_airPlayRoutePicker showFromView:self routeSharingPolicy:routeSharingPolicy routingContextUID:routingContextUID];
+    [_airPlayRoutePicker showFromView:self routeSharingPolicy:routeSharingPolicy routingContextUID:routingContextUID hasVideo:hasVideo];
 #else
     if (!_airPlayRoutePicker)
         _airPlayRoutePicker = adoptNS([[WKAirPlayRoutePicker alloc] initWithView:self]);
index 4f6f7e3..022f76b 100644 (file)
@@ -36,7 +36,7 @@ enum class RouteSharingPolicy : uint8_t;
 @class UIView;
 
 @interface WKAirPlayRoutePicker : NSObject
-- (void)showFromView:(UIView *)view routeSharingPolicy:(WebCore::RouteSharingPolicy)policy routingContextUID:(NSString *)contextUID;
+- (void)showFromView:(UIView *)view routeSharingPolicy:(WebCore::RouteSharingPolicy)policy routingContextUID:(NSString *)contextUID hasVideo:(BOOL)hasVideo;
 @end
 
 #else
index 54307b5..3fb4a7c 100644 (file)
@@ -167,8 +167,13 @@ ALLOW_DEPRECATED_DECLARATIONS_END
 
 SOFT_LINK_FRAMEWORK(MediaPlayer)
 SOFT_LINK_CLASS(MediaPlayer, MPAVRoutingController)
+SOFT_LINK_CLASS(MediaPlayer, MPMediaControlsConfiguration)
 SOFT_LINK_CLASS(MediaPlayer, MPMediaControlsViewController)
 
+@interface MPMediaControlsConfiguration (WKMPMediaControlsConfiguration)
+@property (nonatomic) BOOL sortByIsVideoRoute;
+@end
+
 enum {
     WKAirPlayRoutePickerRouteSharingPolicyDefault = 0,
     WKAirPlayRoutePickerRouteSharingPolicyLongForm = 1,
@@ -177,6 +182,7 @@ enum {
 typedef NSInteger WKAirPlayRoutePickerRouteSharingPolicy;
 
 @interface MPMediaControlsViewController (WKMPMediaControlsViewControllerPrivate)
+- (instancetype)initWithConfiguration:(MPMediaControlsConfiguration *)configuration;
 - (void)setOverrideRouteSharingPolicy:(WKAirPlayRoutePickerRouteSharingPolicy)routeSharingPolicy routingContextUID:(NSString *)routingContextUID;
 @end
 
@@ -190,7 +196,7 @@ typedef NSInteger WKAirPlayRoutePickerRouteSharingPolicy;
     [super dealloc];
 }
 
-- (void)showFromView:(UIView *)view routeSharingPolicy:(WebCore::RouteSharingPolicy)routeSharingPolicy routingContextUID:(NSString *)routingContextUID
+- (void)showFromView:(UIView *)view routeSharingPolicy:(WebCore::RouteSharingPolicy)routeSharingPolicy routingContextUID:(NSString *)routingContextUID hasVideo:(BOOL)hasVideo
 {
     static_assert(static_cast<size_t>(WebCore::RouteSharingPolicy::Default) == static_cast<size_t>(WKAirPlayRoutePickerRouteSharingPolicyDefault), "RouteSharingPolicy::Default is not WKAirPlayRoutePickerRouteSharingPolicyDefault as expected");
     static_assert(static_cast<size_t>(WebCore::RouteSharingPolicy::LongForm) == static_cast<size_t>(WKAirPlayRoutePickerRouteSharingPolicyLongForm), "RouteSharingPolicy::LongForm is not WKAirPlayRoutePickerRouteSharingPolicyLongForm as expected");
@@ -202,7 +208,12 @@ typedef NSInteger WKAirPlayRoutePickerRouteSharingPolicy;
     __block RetainPtr<MPAVRoutingController> routingController = adoptNS([allocMPAVRoutingControllerInstance() initWithName:@"WebKit - HTML media element showing AirPlay route picker"]);
     [routingController setDiscoveryMode:MPRouteDiscoveryModeDetailed];
 
-    _actionSheet = adoptNS([allocMPMediaControlsViewControllerInstance() init]);
+    RetainPtr<MPMediaControlsConfiguration> configuration;
+    if ([getMPMediaControlsConfigurationClass() instancesRespondToSelector:@selector(setSortByIsVideoRoute:)]) {
+        configuration = adoptNS([allocMPMediaControlsConfigurationInstance() init]);
+        configuration.get().sortByIsVideoRoute = hasVideo;
+    }
+    _actionSheet = adoptNS([allocMPMediaControlsViewControllerInstance() initWithConfiguration:configuration.get()]);
 
     if ([_actionSheet respondsToSelector:@selector(setOverrideRouteSharingPolicy:routingContextUID:)])
         [_actionSheet setOverrideRouteSharingPolicy:static_cast<WKAirPlayRoutePickerRouteSharingPolicy>(routeSharingPolicy) routingContextUID:routingContextUID];