Changeset 245887 in webkit
- Timestamp:
- May 30, 2019, 9:29:38 AM (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
r245877 r245887 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-29 Said Abou-Hallawa <sabouhallawa@apple.com> 2 13 -
trunk/Source/WebCore/ChangeLog
r245883 r245887 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-29 Robin Morisset <rmorisset@apple.com> 2 39 -
trunk/Source/WebCore/html/HTMLMediaElement.cpp
r245712 r245887 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
r245773 r245887 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
r245712 r245887 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
r242901 r245887 48 48 void externalOutputDeviceAvailableDidChange(); 49 49 bool hasWirelessTargetsAvailable() override; 50 void carPlayServerDied(); 51 void updateCarPlayIsConnected(Optional<bool>&&); 50 52 51 53 private: -
trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm
r245712 r245887 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 updateCarPlayIsConnected(WTF::nullopt); 112 118 } 113 119 … … 193 199 194 200 END_BLOCK_OBJC_EXCEPTIONS 201 } 202 203 void MediaSessionManageriOS::carPlayServerDied() 204 { 205 ALWAYS_LOG(LOGIDENTIFIER); 206 updateCarPlayIsConnected(WTF::nullopt); 207 } 208 209 void MediaSessionManageriOS::updateCarPlayIsConnected(Optional<bool>&& carPlayIsConnected) 210 { 211 if (carPlayIsConnected) { 212 setIsPlayingToAutomotiveHeadUnit(carPlayIsConnected.value()); 213 return; 214 } 215 216 if (!canLoadAVSystemController_CarPlayIsConnectedAttribute()) { 217 setIsPlayingToAutomotiveHeadUnit(false) 218 return; 219 } 220 221 setIsPlayingToAutomotiveHeadUnit([[[getAVSystemControllerClass() sharedAVSystemController] attributeForKey:getAVSystemController_CarPlayIsConnectedAttribute()] boolValue]); 195 222 } 196 223 … … 219 246 [center addObserver:self selector:@selector(applicationDidEnterBackground:) name:PAL::get_UIKit_UIApplicationDidEnterBackgroundNotification() object:nil]; 220 247 [center addObserver:self selector:@selector(applicationDidEnterBackground:) name:WebUIApplicationDidEnterBackgroundNotification object:nil]; 248 if (canLoadAVSystemController_ServerConnectionDiedNotification()) 249 [center addObserver:self selector:@selector(carPlayServerDied:) name:getAVSystemController_ServerConnectionDiedNotification() object:nil]; 250 if (canLoadAVSystemController_CarPlayIsConnectedDidChangeNotification()) 251 [center addObserver:self selector:@selector(carPlayIsConnectedDidChange:) name:getAVSystemController_CarPlayIsConnectedDidChangeNotification() object:nil]; 221 252 222 253 // Now playing won't work unless we turn on the delivery of remote control events. … … 287 318 LOG(Media, "-[WebMediaSessionHelper startMonitoringAirPlayRoutes]"); 288 319 289 callOnWebThreadOrDispatchAsyncOnMainThread([protectedSelf = WTFMove(self)]() mutable {320 callOnWebThreadOrDispatchAsyncOnMainThread([protectedSelf = retainPtr(self)]() mutable { 290 321 ASSERT(!protectedSelf->_routeDetector); 291 322 … … 294 325 protectedSelf->_routeDetector = adoptNS([PAL::allocAVRouteDetectorInstance() init]); 295 326 protectedSelf->_routeDetector.get().routeDetectionEnabled = protectedSelf->_monitoringAirPlayRoutes; 296 [[NSNotificationCenter defaultCenter] addObserver:protectedSelf selector:@selector(wirelessRoutesAvailableDidChange:) name:AVRouteDetectorMultipleRoutesDetectedDidChangeNotification object:protectedSelf->_routeDetector.get()];327 [[NSNotificationCenter defaultCenter] addObserver:protectedSelf.get() selector:@selector(wirelessRoutesAvailableDidChange:) name:AVRouteDetectorMultipleRoutesDetectedDidChangeNotification object:protectedSelf->_routeDetector.get()]; 297 328 298 329 protectedSelf->_callback->externalOutputDeviceAvailableDidChange(); … … 329 360 flags = PlatformMediaSession::MayResumePlaying; 330 361 331 callOnWebThreadOrDispatchAsyncOnMainThread([protectedSelf = WTFMove(self), type, flags]() mutable {362 callOnWebThreadOrDispatchAsyncOnMainThread([protectedSelf = retainPtr(self), type, flags]() mutable { 332 363 auto* callback = protectedSelf->_callback; 333 364 if (!callback) … … 352 383 353 384 BOOL isSuspendedUnderLock = [[[notification userInfo] objectForKey:@"isSuspendedUnderLock"] boolValue]; 354 callOnWebThreadOrDispatchAsyncOnMainThread([protectedSelf = WTFMove(self), isSuspendedUnderLock]() mutable {385 callOnWebThreadOrDispatchAsyncOnMainThread([protectedSelf = retainPtr(self), isSuspendedUnderLock]() mutable { 355 386 if (auto* callback = protectedSelf->_callback) 356 387 callback->applicationWillEnterForeground(isSuspendedUnderLock); … … 367 398 LOG(Media, "-[WebMediaSessionHelper applicationDidBecomeActive]"); 368 399 369 callOnWebThreadOrDispatchAsyncOnMainThread([protectedSelf = WTFMove(self)]() mutable {400 callOnWebThreadOrDispatchAsyncOnMainThread([protectedSelf = retainPtr(self)]() mutable { 370 401 if (auto* callback = protectedSelf->_callback) 371 402 callback->applicationDidBecomeActive(); … … 382 413 LOG(Media, "-[WebMediaSessionHelper applicationWillResignActive]"); 383 414 384 callOnWebThreadOrDispatchAsyncOnMainThread([protectedSelf = WTFMove(self)]() mutable {415 callOnWebThreadOrDispatchAsyncOnMainThread([protectedSelf = retainPtr(self)]() mutable { 385 416 if (auto* callback = protectedSelf->_callback) 386 417 callback->applicationWillBecomeInactive(); … … 397 428 LOG(Media, "-[WebMediaSessionHelper wirelessRoutesAvailableDidChange]"); 398 429 399 callOnWebThreadOrDispatchAsyncOnMainThread([protectedSelf = WTFMove(self)]() mutable {430 callOnWebThreadOrDispatchAsyncOnMainThread([protectedSelf = retainPtr(self)]() mutable { 400 431 if (auto* callback = protectedSelf->_callback) 401 432 callback->externalOutputDeviceAvailableDidChange(); … … 411 442 412 443 BOOL isSuspendedUnderLock = [[[notification userInfo] objectForKey:@"isSuspendedUnderLock"] boolValue]; 413 callOnWebThreadOrDispatchAsyncOnMainThread([protectedSelf = WTFMove(self), isSuspendedUnderLock]() mutable {444 callOnWebThreadOrDispatchAsyncOnMainThread([protectedSelf = retainPtr(self), isSuspendedUnderLock]() mutable { 414 445 if (auto* callback = protectedSelf->_callback) 415 446 callback->applicationDidEnterBackground(isSuspendedUnderLock); 416 447 }); 417 448 } 449 450 - (void)carPlayServerDied:(NSNotification *)notification 451 { 452 if (!_callback) 453 return; 454 455 LOG(Media, "-[WebMediaSessionHelper carPlayServerDied:]"); 456 UNUSED_PARAM(notification); 457 callOnWebThreadOrDispatchAsyncOnMainThread([protectedSelf = retainPtr(self)]() mutable { 458 if (auto* callback = protectedSelf->_callback) 459 callback->carPlayServerDied(); 460 }); 461 } 462 463 - (void)carPlayIsConnectedDidChange:(NSNotification *)notification 464 { 465 if (!_callback) 466 return; 467 468 Optional<bool> carPlayIsConnected; 469 if (notification && canLoadAVSystemController_CarPlayIsConnectedNotificationParameter()) { 470 NSNumber *nsCarPlayIsConnected = [[notification userInfo] valueForKey:getAVSystemController_CarPlayIsConnectedNotificationParameter()]; 471 if (nsCarPlayIsConnected) 472 carPlayIsConnected = [nsCarPlayIsConnected boolValue]; 473 } 474 475 callOnWebThreadOrDispatchAsyncOnMainThread([protectedSelf = retainPtr(self), carPlayIsConnected = WTFMove(carPlayIsConnected)]() mutable { 476 if (auto* callback = protectedSelf->_callback) 477 callback->updateCarPlayIsConnected(WTFMove(carPlayIsConnected)); 478 }); 479 } 418 480 @end 419 481 -
trunk/Source/WebCore/testing/Internals.cpp
r245716 r245887 493 493 PlatformMediaSessionManager::sharedManager().setWillIgnoreSystemInterruptions(true); 494 494 #endif 495 PlatformMediaSessionManager::sharedManager().setIsPlayingToAutomotiveHeadUnit(false); 495 496 #if HAVE(ACCESSIBILITY) 496 497 AXObjectCache::setEnhancedUserInterfaceAccessibility(false); … … 5068 5069 } 5069 5070 5071 void Internals::setIsPlayingToAutomotiveHeadUnit(bool isPlaying) 5072 { 5073 PlatformMediaSessionManager::sharedManager().setIsPlayingToAutomotiveHeadUnit(isPlaying); 5074 } 5075 5070 5076 } // namespace WebCore -
trunk/Source/WebCore/testing/Internals.h
r245366 r245887 824 824 void setXHRMaximumIntervalForUserGestureForwarding(XMLHttpRequest&, double); 825 825 826 void setIsPlayingToAutomotiveHeadUnit(bool); 827 826 828 private: 827 829 explicit Internals(Document&); -
trunk/Source/WebCore/testing/Internals.idl
r245366 r245887 754 754 755 755 void setXHRMaximumIntervalForUserGestureForwarding(XMLHttpRequest xhr, double interval); 756 }; 756 757 void setIsPlayingToAutomotiveHeadUnit(boolean value); 758 };
Note:
See TracChangeset
for help on using the changeset viewer.