Changeset 245947 in webkit
- Timestamp:
- May 30, 2019, 9:46:39 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 10 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/media/video-isplayingtoautomotiveheadunit-expected.txt (added)
-
LayoutTests/media/video-isplayingtoautomotiveheadunit.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/html/HTMLMediaElement.cpp (modified) (2 diffs)
-
Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp (modified) (1 diff)
-
Source/WebCore/platform/audio/PlatformMediaSessionManager.h (modified) (2 diffs)
-
Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h (modified) (1 diff)
-
Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm (modified) (12 diffs)
-
Source/WebCore/testing/Internals.cpp (modified) (2 diffs)
-
Source/WebCore/testing/Internals.h (modified) (1 diff)
-
Source/WebCore/testing/Internals.idl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r245946 r245947 1 2019-05-30 Jer Noble <jer.noble@apple.com> 2 3 Video playback in Safari should continue when CarPlay is plugged in 4 https://bugs.webkit.org/show_bug.cgi?id=198345 5 <rdar://problem/45505750> 6 7 Reviewed by Eric Carlson. 8 9 * media/video-isplayingtoautomotiveheadunit-expected.txt: Added. 10 * media/video-isplayingtoautomotiveheadunit.html: Added. 11 1 12 2019-05-30 Youenn Fablet <youenn@apple.com> 2 13 -
trunk/Source/WebCore/ChangeLog
r245946 r245947 1 2019-05-30 Jer Noble <jer.noble@apple.com> 2 3 Video playback in Safari should continue when CarPlay is plugged in 4 https://bugs.webkit.org/show_bug.cgi?id=198345 5 <rdar://problem/45505750> 6 7 Reviewed by Eric Carlson. 8 9 Test: media/video-isplayingtoautomotiveheadunit.html 10 11 * html/HTMLMediaElement.cpp: 12 (WebCore::HTMLMediaElement::shouldOverrideBackgroundPlaybackRestriction const): 13 * platform/audio/PlatformMediaSessionManager.cpp: 14 (WebCore::PlatformMediaSessionManager::setIsPlayingToAutomotiveHeadUnit): 15 * platform/audio/PlatformMediaSessionManager.h: 16 (WebCore::PlatformMediaSessionManager::isPlayingToAutomotiveHeadUnit const): 17 * platform/audio/ios/MediaSessionManagerIOS.h: 18 * platform/audio/ios/MediaSessionManagerIOS.mm: 19 (WebCore::MediaSessionManageriOS::MediaSessionManageriOS): 20 (WebCore::MediaSessionManageriOS::carPlayServerDied): 21 (WebCore::MediaSessionManageriOS::updateCarPlayIsConnected): 22 (-[WebMediaSessionHelper initWithCallback:]): 23 (-[WebMediaSessionHelper startMonitoringAirPlayRoutes]): 24 (-[WebMediaSessionHelper interruption:]): 25 (-[WebMediaSessionHelper applicationWillEnterForeground:]): 26 (-[WebMediaSessionHelper applicationDidBecomeActive:]): 27 (-[WebMediaSessionHelper applicationWillResignActive:]): 28 (-[WebMediaSessionHelper wirelessRoutesAvailableDidChange:]): 29 (-[WebMediaSessionHelper applicationDidEnterBackground:]): 30 (-[WebMediaSessionHelper carPlayServerDied:]): 31 (-[WebMediaSessionHelper carPlayIsConnectedDidChange:]): 32 * testing/Internals.cpp: 33 (WebCore::Internals::resetToConsistentState): 34 (WebCore::Internals::setIsPlayingToAutomotiveHeadUnit): 35 * testing/Internals.h: 36 * testing/Internals.idl: 37 1 38 2019-05-30 Youenn Fablet <youenn@apple.com> 2 39 -
trunk/Source/WebCore/html/HTMLMediaElement.cpp
r245944 r245947 7716 7716 return true; 7717 7717 } 7718 if (PlatformMediaSessionManager::sharedManager().isPlayingToAutomotiveHeadUnit()) { 7719 INFO_LOG(LOGIDENTIFIER, "returning true because isPlayingToAutomotiveHeadUnit() is true"); 7720 return true; 7721 } 7718 7722 if (m_videoFullscreenMode & VideoFullscreenModePictureInPicture) 7719 7723 return true; … … 7725 7729 if (isPlayingToExternalTarget()) { 7726 7730 INFO_LOG(LOGIDENTIFIER, "returning true because isPlayingToExternalTarget() is true"); 7731 return true; 7732 } 7733 if (PlatformMediaSessionManager::sharedManager().isPlayingToAutomotiveHeadUnit()) { 7734 INFO_LOG(LOGIDENTIFIER, "returning true because isPlayingToAutomotiveHeadUnit() is true"); 7727 7735 return true; 7728 7736 } -
trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp
r245944 r245947 392 392 } 393 393 394 void PlatformMediaSessionManager::setIsPlayingToAutomotiveHeadUnit(bool isPlayingToAutomotiveHeadUnit) 395 { 396 if (isPlayingToAutomotiveHeadUnit == m_isPlayingToAutomotiveHeadUnit) 397 return; 398 399 ALWAYS_LOG(LOGIDENTIFIER, isPlayingToAutomotiveHeadUnit); 400 m_isPlayingToAutomotiveHeadUnit = isPlayingToAutomotiveHeadUnit; 401 } 394 402 395 403 void PlatformMediaSessionManager::sessionIsPlayingToWirelessPlaybackTargetChanged(PlatformMediaSession& session) -
trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.h
r245944 r245947 130 130 void sessionIsPlayingToWirelessPlaybackTargetChanged(PlatformMediaSession&); 131 131 132 WEBCORE_EXPORT void setIsPlayingToAutomotiveHeadUnit(bool); 133 bool isPlayingToAutomotiveHeadUnit() const { return m_isPlayingToAutomotiveHeadUnit; } 134 132 135 void forEachMatchingSession(const Function<bool(const PlatformMediaSession&)>& predicate, const Function<void(PlatformMediaSession&)>& matchingCallback); 133 136 … … 189 192 bool m_willIgnoreSystemInterruptions { false }; 190 193 bool m_processIsSuspended { false }; 194 bool m_isPlayingToAutomotiveHeadUnit { false }; 191 195 192 196 #if USE(AUDIO_SESSION) -
trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h
r245944 r245947 48 48 void externalOutputDeviceAvailableDidChange(); 49 49 bool hasWirelessTargetsAvailable() override; 50 #if HAVE(CELESTIAL) 51 void carPlayServerDied(); 52 void updateCarPlayIsConnected(Optional<bool>&&); 53 #endif 50 54 51 55 private: -
trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm
r245944 r245947 57 57 SOFT_LINK_CLASS_OPTIONAL(Celestial, AVSystemController) 58 58 SOFT_LINK_CONSTANT_MAY_FAIL(Celestial, AVSystemController_PIDToInheritApplicationStateFrom, NSString *) 59 SOFT_LINK_CONSTANT_MAY_FAIL(Celestial, AVSystemController_CarPlayIsConnectedAttribute, NSString *) 60 SOFT_LINK_CONSTANT_MAY_FAIL(Celestial, AVSystemController_CarPlayIsConnectedDidChangeNotification, NSString *) 61 SOFT_LINK_CONSTANT_MAY_FAIL(Celestial, AVSystemController_CarPlayIsConnectedNotificationParameter, NSString *) 62 SOFT_LINK_CONSTANT_MAY_FAIL(Celestial, AVSystemController_ServerConnectionDiedNotification, NSString *) 59 63 #endif 60 64 … … 110 114 END_BLOCK_OBJC_EXCEPTIONS 111 115 resetRestrictions(); 116 117 #if HAVE(CELESTIAL) 118 updateCarPlayIsConnected(WTF::nullopt); 119 #endif 112 120 } 113 121 … … 194 202 END_BLOCK_OBJC_EXCEPTIONS 195 203 } 204 205 #if HAVE(CELESTIAL) 206 void MediaSessionManageriOS::carPlayServerDied() 207 { 208 ALWAYS_LOG(LOGIDENTIFIER); 209 updateCarPlayIsConnected(WTF::nullopt); 210 } 211 212 void MediaSessionManageriOS::updateCarPlayIsConnected(Optional<bool>&& carPlayIsConnected) 213 { 214 if (carPlayIsConnected) { 215 setIsPlayingToAutomotiveHeadUnit(carPlayIsConnected.value()); 216 return; 217 } 218 219 if (!canLoadAVSystemController_CarPlayIsConnectedAttribute()) { 220 setIsPlayingToAutomotiveHeadUnit(false); 221 return; 222 } 223 224 setIsPlayingToAutomotiveHeadUnit([[[getAVSystemControllerClass() sharedAVSystemController] attributeForKey:getAVSystemController_CarPlayIsConnectedAttribute()] boolValue]); 225 } 226 #endif 196 227 197 228 } // namespace WebCore … … 219 250 [center addObserver:self selector:@selector(applicationDidEnterBackground:) name:PAL::get_UIKit_UIApplicationDidEnterBackgroundNotification() object:nil]; 220 251 [center addObserver:self selector:@selector(applicationDidEnterBackground:) name:WebUIApplicationDidEnterBackgroundNotification object:nil]; 252 #if HAVE(CELESTIAL) 253 if (canLoadAVSystemController_ServerConnectionDiedNotification()) 254 [center addObserver:self selector:@selector(carPlayServerDied:) name:getAVSystemController_ServerConnectionDiedNotification() object:nil]; 255 if (canLoadAVSystemController_CarPlayIsConnectedDidChangeNotification()) 256 [center addObserver:self selector:@selector(carPlayIsConnectedDidChange:) name:getAVSystemController_CarPlayIsConnectedDidChangeNotification() object:nil]; 257 #endif 221 258 222 259 // Now playing won't work unless we turn on the delivery of remote control events. … … 287 324 LOG(Media, "-[WebMediaSessionHelper startMonitoringAirPlayRoutes]"); 288 325 289 callOnWebThreadOrDispatchAsyncOnMainThread([protectedSelf = WTFMove(self)]() mutable {326 callOnWebThreadOrDispatchAsyncOnMainThread([protectedSelf = retainPtr(self)]() mutable { 290 327 ASSERT(!protectedSelf->_routeDetector); 291 328 … … 294 331 protectedSelf->_routeDetector = adoptNS([PAL::allocAVRouteDetectorInstance() init]); 295 332 protectedSelf->_routeDetector.get().routeDetectionEnabled = protectedSelf->_monitoringAirPlayRoutes; 296 [[NSNotificationCenter defaultCenter] addObserver:protectedSelf selector:@selector(wirelessRoutesAvailableDidChange:) name:AVRouteDetectorMultipleRoutesDetectedDidChangeNotification object:protectedSelf->_routeDetector.get()];333 [[NSNotificationCenter defaultCenter] addObserver:protectedSelf.get() selector:@selector(wirelessRoutesAvailableDidChange:) name:AVRouteDetectorMultipleRoutesDetectedDidChangeNotification object:protectedSelf->_routeDetector.get()]; 297 334 298 335 protectedSelf->_callback->externalOutputDeviceAvailableDidChange(); … … 329 366 flags = PlatformMediaSession::MayResumePlaying; 330 367 331 callOnWebThreadOrDispatchAsyncOnMainThread([protectedSelf = WTFMove(self), type, flags]() mutable {368 callOnWebThreadOrDispatchAsyncOnMainThread([protectedSelf = retainPtr(self), type, flags]() mutable { 332 369 auto* callback = protectedSelf->_callback; 333 370 if (!callback) … … 352 389 353 390 BOOL isSuspendedUnderLock = [[[notification userInfo] objectForKey:@"isSuspendedUnderLock"] boolValue]; 354 callOnWebThreadOrDispatchAsyncOnMainThread([protectedSelf = WTFMove(self), isSuspendedUnderLock]() mutable {391 callOnWebThreadOrDispatchAsyncOnMainThread([protectedSelf = retainPtr(self), isSuspendedUnderLock]() mutable { 355 392 if (auto* callback = protectedSelf->_callback) 356 393 callback->applicationWillEnterForeground(isSuspendedUnderLock); … … 367 404 LOG(Media, "-[WebMediaSessionHelper applicationDidBecomeActive]"); 368 405 369 callOnWebThreadOrDispatchAsyncOnMainThread([protectedSelf = WTFMove(self)]() mutable {406 callOnWebThreadOrDispatchAsyncOnMainThread([protectedSelf = retainPtr(self)]() mutable { 370 407 if (auto* callback = protectedSelf->_callback) 371 408 callback->applicationDidBecomeActive(); … … 382 419 LOG(Media, "-[WebMediaSessionHelper applicationWillResignActive]"); 383 420 384 callOnWebThreadOrDispatchAsyncOnMainThread([protectedSelf = WTFMove(self)]() mutable {421 callOnWebThreadOrDispatchAsyncOnMainThread([protectedSelf = retainPtr(self)]() mutable { 385 422 if (auto* callback = protectedSelf->_callback) 386 423 callback->applicationWillBecomeInactive(); … … 397 434 LOG(Media, "-[WebMediaSessionHelper wirelessRoutesAvailableDidChange]"); 398 435 399 callOnWebThreadOrDispatchAsyncOnMainThread([protectedSelf = WTFMove(self)]() mutable {436 callOnWebThreadOrDispatchAsyncOnMainThread([protectedSelf = retainPtr(self)]() mutable { 400 437 if (auto* callback = protectedSelf->_callback) 401 438 callback->externalOutputDeviceAvailableDidChange(); … … 411 448 412 449 BOOL isSuspendedUnderLock = [[[notification userInfo] objectForKey:@"isSuspendedUnderLock"] boolValue]; 413 callOnWebThreadOrDispatchAsyncOnMainThread([protectedSelf = WTFMove(self), isSuspendedUnderLock]() mutable {450 callOnWebThreadOrDispatchAsyncOnMainThread([protectedSelf = retainPtr(self), isSuspendedUnderLock]() mutable { 414 451 if (auto* callback = protectedSelf->_callback) 415 452 callback->applicationDidEnterBackground(isSuspendedUnderLock); 416 453 }); 417 454 } 455 456 #if HAVE(CELESTIAL) 457 - (void)carPlayServerDied:(NSNotification *)notification 458 { 459 if (!_callback) 460 return; 461 462 LOG(Media, "-[WebMediaSessionHelper carPlayServerDied:]"); 463 UNUSED_PARAM(notification); 464 callOnWebThreadOrDispatchAsyncOnMainThread([protectedSelf = retainPtr(self)]() mutable { 465 if (auto* callback = protectedSelf->_callback) 466 callback->carPlayServerDied(); 467 }); 468 } 469 470 - (void)carPlayIsConnectedDidChange:(NSNotification *)notification 471 { 472 if (!_callback) 473 return; 474 475 Optional<bool> carPlayIsConnected; 476 if (notification && canLoadAVSystemController_CarPlayIsConnectedNotificationParameter()) { 477 NSNumber *nsCarPlayIsConnected = [[notification userInfo] valueForKey:getAVSystemController_CarPlayIsConnectedNotificationParameter()]; 478 if (nsCarPlayIsConnected) 479 carPlayIsConnected = [nsCarPlayIsConnected boolValue]; 480 } 481 482 callOnWebThreadOrDispatchAsyncOnMainThread([protectedSelf = retainPtr(self), carPlayIsConnected = WTFMove(carPlayIsConnected)]() mutable { 483 if (auto* callback = protectedSelf->_callback) 484 callback->updateCarPlayIsConnected(WTFMove(carPlayIsConnected)); 485 }); 486 } 487 #endif // HAVE(CELESTIAL) 418 488 @end 419 489 -
trunk/Source/WebCore/testing/Internals.cpp
r245946 r245947 493 493 PlatformMediaSessionManager::sharedManager().setWillIgnoreSystemInterruptions(true); 494 494 #endif 495 PlatformMediaSessionManager::sharedManager().setIsPlayingToAutomotiveHeadUnit(false); 495 496 #if HAVE(ACCESSIBILITY) 496 497 AXObjectCache::setEnhancedUserInterfaceAccessibility(false); … … 5076 5077 } 5077 5078 5079 void Internals::setIsPlayingToAutomotiveHeadUnit(bool isPlaying) 5080 { 5081 PlatformMediaSessionManager::sharedManager().setIsPlayingToAutomotiveHeadUnit(isPlaying); 5082 } 5083 5078 5084 } // namespace WebCore -
trunk/Source/WebCore/testing/Internals.h
r245946 r245947 825 825 void setXHRMaximumIntervalForUserGestureForwarding(XMLHttpRequest&, double); 826 826 827 void setIsPlayingToAutomotiveHeadUnit(bool); 828 827 829 private: 828 830 explicit Internals(Document&); -
trunk/Source/WebCore/testing/Internals.idl
r245946 r245947 755 755 756 756 void setXHRMaximumIntervalForUserGestureForwarding(XMLHttpRequest xhr, double interval); 757 }; 757 758 void setIsPlayingToAutomotiveHeadUnit(boolean value); 759 };
Note:
See TracChangeset
for help on using the changeset viewer.