Changeset 236011 in webkit
- Timestamp:
- Sep 14, 2018, 11:17:42 AM (8 years ago)
- Location:
- trunk/Source
- Files:
-
- 1 added
- 8 edited
- 1 copied
- 1 moved
-
WTF/ChangeLog (modified) (1 diff)
-
WTF/wtf/Platform.h (modified) (1 diff)
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/SourcesCocoa.txt (modified) (2 diffs)
-
WebCore/WebCore.xcodeproj/project.pbxproj (modified) (8 diffs)
-
WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.cpp (added)
-
WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.h (modified) (2 diffs)
-
WebCore/platform/audio/ios/MediaSessionManagerIOS.h (modified) (1 diff)
-
WebCore/platform/audio/ios/MediaSessionManagerIOS.mm (modified) (3 diffs)
-
WebCore/platform/audio/mac/MediaSessionManagerMac.h (copied) (copied from trunk/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.h ) (5 diffs)
-
WebCore/platform/audio/mac/MediaSessionManagerMac.mm (moved) (moved from trunk/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.mm ) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r235990 r236011 1 2018-09-14 Ryan Haddad <ryanhaddad@apple.com> 2 3 Unreviewed, rolling out r235990. 4 5 Introduced TestWebKitAPI.NowPlayingTest timeouts on iOS 6 7 Reverted changeset: 8 9 "Enable USE_MEDIAREMOTE on iOS" 10 https://bugs.webkit.org/show_bug.cgi?id=189096 11 https://trac.webkit.org/changeset/235990 12 1 13 2018-09-13 Jer Noble <jer.noble@apple.com> 2 14 -
trunk/Source/WTF/wtf/Platform.h
r235990 r236011 1304 1304 #endif 1305 1305 1306 #if PLATFORM(MAC) || PLATFORM(IOS)1306 #if PLATFORM(MAC) 1307 1307 #define USE_MEDIAREMOTE 1 1308 1308 #endif -
trunk/Source/WebCore/ChangeLog
r236010 r236011 1 2018-09-14 Ryan Haddad <ryanhaddad@apple.com> 2 3 Unreviewed, rolling out r235990. 4 5 Introduced TestWebKitAPI.NowPlayingTest timeouts on iOS 6 7 Reverted changeset: 8 9 "Enable USE_MEDIAREMOTE on iOS" 10 https://bugs.webkit.org/show_bug.cgi?id=189096 11 https://trac.webkit.org/changeset/235990 12 1 13 2018-09-14 Jer Noble <jer.noble@apple.com> 2 14 -
trunk/Source/WebCore/SourcesCocoa.txt
r235990 r236011 160 160 platform/audio/AudioSession.cpp 161 161 162 platform/audio/cocoa/MediaSessionManagerCocoa. mm162 platform/audio/cocoa/MediaSessionManagerCocoa.cpp 163 163 platform/audio/cocoa/WebAudioBufferList.cpp 164 164 … … 177 177 platform/audio/mac/CARingBuffer.cpp 178 178 platform/audio/mac/FFTFrameMac.cpp 179 platform/audio/mac/MediaSessionManagerMac.mm 179 180 180 181 platform/cf/CFURLExtras.cpp -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r235990 r236011 3966 3966 CD0EEE0E14743F39003EAFA2 /* AudioDestinationIOS.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD0EEE0B14743E35003EAFA2 /* AudioDestinationIOS.cpp */; }; 3967 3967 CD127DEE14F3098400E84779 /* WebCoreFullScreenWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = CD127DEA14F3097900E84779 /* WebCoreFullScreenWindow.h */; settings = {ATTRIBUTES = (Private, ); }; }; 3968 CD17A45D213740810079EC7B /* UnifiedSource62-mm.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD17A459213740160079EC7B /* UnifiedSource62-mm.mm */; };3969 3968 CD19A2681A13E700008D650E /* DiagnosticLoggingClient.h in Headers */ = {isa = PBXBuildFile; fileRef = CD19A2671A13E700008D650E /* DiagnosticLoggingClient.h */; settings = {ATTRIBUTES = (Private, ); }; }; 3970 3969 CD19FEA81F573972000C42FB /* ImageDecoder.h in Headers */ = {isa = PBXBuildFile; fileRef = CD19FEA61F573972000C42FB /* ImageDecoder.h */; }; … … 5441 5440 07E9E12D18F5E2760011A3A4 /* InbandMetadataTextTrackPrivateAVF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InbandMetadataTextTrackPrivateAVF.h; sourceTree = "<group>"; }; 5442 5441 07E9E12F18F62B370011A3A4 /* InbandMetadataTextTrackPrivateAVF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InbandMetadataTextTrackPrivateAVF.cpp; sourceTree = "<group>"; }; 5442 07EDC3ED1AACB75D00983EB5 /* MediaSessionManagerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MediaSessionManagerMac.mm; sourceTree = "<group>"; }; 5443 5443 07EE76E91BE96DB000F89133 /* MockRealtimeVideoSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MockRealtimeVideoSource.cpp; sourceTree = "<group>"; }; 5444 5444 07EE76EA1BE96DB000F89133 /* MockRealtimeVideoSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MockRealtimeVideoSource.h; sourceTree = "<group>"; }; … … 13188 13188 CD127DEA14F3097900E84779 /* WebCoreFullScreenWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreFullScreenWindow.h; sourceTree = "<group>"; }; 13189 13189 CD127DEB14F3097900E84779 /* WebCoreFullScreenWindow.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreFullScreenWindow.mm; sourceTree = "<group>"; }; 13190 CD17A459213740160079EC7B /* UnifiedSource62-mm.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "UnifiedSource62-mm.mm"; sourceTree = "<group>"; };13191 13190 CD19A2671A13E700008D650E /* DiagnosticLoggingClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DiagnosticLoggingClient.h; sourceTree = "<group>"; }; 13192 13191 CD19FEA61F573972000C42FB /* ImageDecoder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ImageDecoder.h; sourceTree = "<group>"; }; … … 13253 13252 CD641EB21818F5ED00EE4C41 /* SourceBufferPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SourceBufferPrivate.h; sourceTree = "<group>"; }; 13254 13253 CD641EC7181ED60100EE4C41 /* MediaSample.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MediaSample.h; sourceTree = "<group>"; }; 13255 CD669D6 61D232DFF004D1866 /* MediaSessionManagerCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MediaSessionManagerCocoa.mm; path = cocoa/MediaSessionManagerCocoa.mm; sourceTree = "<group>"; };13254 CD669D671D232E10004D1866 /* MediaSessionManagerMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaSessionManagerMac.h; sourceTree = "<group>"; }; 13256 13255 CD78A2EC1F75648600DE371B /* CDMInstanceFairPlayStreamingAVFObjC.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CDMInstanceFairPlayStreamingAVFObjC.mm; sourceTree = "<group>"; }; 13257 13256 CD78A2EE1F75648600DE371B /* CDMInstanceFairPlayStreamingAVFObjC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDMInstanceFairPlayStreamingAVFObjC.h; sourceTree = "<group>"; }; … … 18245 18244 DE5F863A1FA2AF07006DB63B /* UnifiedSource61-mm.mm */, 18246 18245 538EC87E1F993F33004D22A8 /* UnifiedSource61.cpp */, 18247 CD17A459213740160079EC7B /* UnifiedSource62-mm.mm */,18248 18246 538EC85A1F993F20004D22A8 /* UnifiedSource62.cpp */, 18249 18247 538EC8611F993F24004D22A8 /* UnifiedSource63.cpp */, … … 26938 26936 CDC734131977896C0046BFC5 /* CARingBuffer.h */, 26939 26937 FD3160BA12B0272A00C1A359 /* FFTFrameMac.cpp */, 26938 CD669D671D232E10004D1866 /* MediaSessionManagerMac.h */, 26939 07EDC3ED1AACB75D00983EB5 /* MediaSessionManagerMac.mm */, 26940 26940 ); 26941 26941 path = mac; … … 31326 31326 runOnlyForDeploymentPostprocessing = 0; 31327 31327 shellPath = /bin/sh; 31328 shellScript = "set -e\n\ncd $SRCROOT\n\nif [ \"${DEPLOYMENT_LOCATION}\" == \"YES\" ]; then\nBUILD_SCRIPTS_DIR=\"${SDKROOT}${WK_ALTERNATE_WEBKIT_SDK_PATH}/usr/local/include/wtf/Scripts\"\nelse\nBUILD_SCRIPTS_DIR=\"${BUILT_PRODUCTS_DIR}/usr/local/include/wtf/Scripts\"\nfi\n\nUnifiedSourceCppFileCount=530\nUnifiedSourceMmFileCount=6 2\n\necho \"Using unified source list files: Sources.txt, SourcesCocoa.txt\"\n\n/usr/bin/env ruby \"${BUILD_SCRIPTS_DIR}/generate-unified-source-bundles.rb\" \"--derived-sources-path\" \"${BUILT_PRODUCTS_DIR}/DerivedSources/WebCore\" \"--source-tree-path\" \"${SRCROOT}\" \"--feature-flags\" \"${FEATURE_DEFINES}\" \"--max-cpp-bundle-count\" \"${UnifiedSourceCppFileCount}\" \"--max-obj-c-bundle-count\" \"${UnifiedSourceMmFileCount}\" \"Sources.txt\" \"SourcesCocoa.txt\" > /dev/null\n";31328 shellScript = "set -e\n\ncd $SRCROOT\n\nif [ \"${DEPLOYMENT_LOCATION}\" == \"YES\" ]; then\nBUILD_SCRIPTS_DIR=\"${SDKROOT}${WK_ALTERNATE_WEBKIT_SDK_PATH}/usr/local/include/wtf/Scripts\"\nelse\nBUILD_SCRIPTS_DIR=\"${BUILT_PRODUCTS_DIR}/usr/local/include/wtf/Scripts\"\nfi\n\nUnifiedSourceCppFileCount=530\nUnifiedSourceMmFileCount=61\n\necho \"Using unified source list files: Sources.txt, SourcesCocoa.txt\"\n\n/usr/bin/env ruby \"${BUILD_SCRIPTS_DIR}/generate-unified-source-bundles.rb\" \"--derived-sources-path\" \"${BUILT_PRODUCTS_DIR}/DerivedSources/WebCore\" \"--source-tree-path\" \"${SRCROOT}\" \"--feature-flags\" \"${FEATURE_DEFINES}\" \"--max-cpp-bundle-count\" \"${UnifiedSourceCppFileCount}\" \"--max-obj-c-bundle-count\" \"${UnifiedSourceMmFileCount}\" \"Sources.txt\" \"SourcesCocoa.txt\" > /dev/null\n"; 31329 31329 }; 31330 31330 5D0D540D0E9862F60029E223 /* Check For Weak VTables and Externals */ = { … … 31751 31751 538EC8AE1F993F9D004D22A8 /* UnifiedSource61.cpp in Sources */, 31752 31752 538EC8AF1F993F9D004D22A8 /* UnifiedSource62.cpp in Sources */, 31753 CD17A45D213740810079EC7B /* UnifiedSource62-mm.mm in Sources */,31754 31753 538EC8B01F993F9D004D22A8 /* UnifiedSource63.cpp in Sources */, 31755 31754 538EC8B11F993F9D004D22A8 /* UnifiedSource64.cpp in Sources */, -
trunk/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.h
r235990 r236011 28 28 #if PLATFORM(COCOA) 29 29 30 #include "GenericTaskQueue.h"31 30 #include "PlatformMediaSessionManager.h" 32 31 … … 35 34 class MediaSessionManagerCocoa : public PlatformMediaSessionManager { 36 35 public: 37 virtual ~MediaSessionManagerCocoa() = default;38 39 36 void updateSessionState() override; 40 37 void beginInterruption(PlatformMediaSession::InterruptionType) override; 41 42 bool hasActiveNowPlayingSession() const final { return m_nowPlayingActive; }43 String lastUpdatedNowPlayingTitle() const final { return m_lastUpdatedNowPlayingTitle; }44 double lastUpdatedNowPlayingDuration() const final { return m_lastUpdatedNowPlayingDuration; }45 double lastUpdatedNowPlayingElapsedTime() const final { return m_lastUpdatedNowPlayingElapsedTime; }46 uint64_t lastUpdatedNowPlayingInfoUniqueIdentifier() const final { return m_lastUpdatedNowPlayingInfoUniqueIdentifier; }47 bool registeredAsNowPlayingApplication() const final { return m_registeredAsNowPlayingApplication; }48 49 protected:50 void scheduleUpdateNowPlayingInfo() override;51 void updateNowPlayingInfo();52 void removeSession(PlatformMediaSession&) override;53 54 bool sessionWillBeginPlayback(PlatformMediaSession&) override;55 void sessionWillEndPlayback(PlatformMediaSession&) override;56 void sessionDidEndRemoteScrubbing(const PlatformMediaSession&) override;57 void clientCharacteristicsChanged(PlatformMediaSession&) override;58 void sessionCanProduceAudioChanged(PlatformMediaSession&) override;59 60 PlatformMediaSession* nowPlayingEligibleSession();61 62 private:63 bool m_nowPlayingActive { false };64 bool m_registeredAsNowPlayingApplication { false };65 66 // For testing purposes only.67 String m_lastUpdatedNowPlayingTitle;68 double m_lastUpdatedNowPlayingDuration { NAN };69 double m_lastUpdatedNowPlayingElapsedTime { NAN };70 uint64_t m_lastUpdatedNowPlayingInfoUniqueIdentifier { 0 };71 72 GenericTaskQueue<Timer> m_nowPlayingUpdateTaskQueue;73 38 }; 74 39 -
trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h
r235990 r236011 54 54 MediaSessionManageriOS(); 55 55 56 void removeSession(PlatformMediaSession&) override; 57 58 bool sessionWillBeginPlayback(PlatformMediaSession&) override; 59 void sessionWillEndPlayback(PlatformMediaSession&) override; 60 void clientCharacteristicsChanged(PlatformMediaSession&) override; 61 62 void updateNowPlayingInfo(); 63 56 64 void resetRestrictions() override; 57 65 58 66 void configureWireLessTargetMonitoring() override; 59 67 68 bool hasActiveNowPlayingSession() const final { return m_nowPlayingActive; } 69 String lastUpdatedNowPlayingTitle() const final { return m_reportedTitle; } 70 double lastUpdatedNowPlayingDuration() const final { return m_reportedDuration; } 71 double lastUpdatedNowPlayingElapsedTime() const final { return m_reportedCurrentTime; } 72 uint64_t lastUpdatedNowPlayingInfoUniqueIdentifier() const final { return m_lastUpdatedNowPlayingInfoUniqueIdentifier; } 73 bool registeredAsNowPlayingApplication() const final { return m_nowPlayingActive; } 74 75 PlatformMediaSession* nowPlayingEligibleSession(); 76 60 77 RetainPtr<WebMediaSessionHelper> m_objcObserver; 78 double m_reportedRate { 0 }; 79 double m_reportedDuration { 0 }; 80 double m_reportedCurrentTime { 0 }; 81 uint64_t m_lastUpdatedNowPlayingInfoUniqueIdentifier { 0 }; 82 String m_reportedTitle; 83 bool m_nowPlayingActive { false }; 61 84 }; 62 85 -
trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm
r235990 r236011 44 44 #import <wtf/SoftLinking.h> 45 45 46 #if HAVE(MEDIA_PLAYER) 47 #import <MediaPlayer/MPMediaItem.h> 48 #import <MediaPlayer/MPNowPlayingInfoCenter.h> 49 #import <pal/spi/ios/MediaPlayerSPI.h> 50 #endif 51 46 52 SOFT_LINK_FRAMEWORK(AVFoundation) 47 53 SOFT_LINK_CLASS(AVFoundation, AVAudioSession) … … 73 79 #define UIApplicationDidEnterBackgroundNotification getUIApplicationDidEnterBackgroundNotification() 74 80 81 #if HAVE(MEDIA_PLAYER) 82 SOFT_LINK_FRAMEWORK(MediaPlayer) 83 SOFT_LINK_CLASS(MediaPlayer, MPNowPlayingInfoCenter) 84 SOFT_LINK_CONSTANT(MediaPlayer, MPMediaItemPropertyTitle, NSString *) 85 SOFT_LINK_CONSTANT(MediaPlayer, MPMediaItemPropertyPlaybackDuration, NSString *) 86 SOFT_LINK_CONSTANT(MediaPlayer, MPNowPlayingInfoPropertyElapsedPlaybackTime, NSString *) 87 SOFT_LINK_CONSTANT(MediaPlayer, MPNowPlayingInfoPropertyPlaybackRate, NSString *) 88 SOFT_LINK_CONSTANT(MediaPlayer, kMRMediaRemoteNowPlayingInfoUniqueIdentifier, NSString *) 89 90 #define MPMediaItemPropertyTitle getMPMediaItemPropertyTitle() 91 #define MPMediaItemPropertyPlaybackDuration getMPMediaItemPropertyPlaybackDuration() 92 #define MPNowPlayingInfoPropertyElapsedPlaybackTime getMPNowPlayingInfoPropertyElapsedPlaybackTime() 93 #define MPNowPlayingInfoPropertyPlaybackRate getMPNowPlayingInfoPropertyPlaybackRate() 94 #define kMRMediaRemoteNowPlayingInfoUniqueIdentifier getkMRMediaRemoteNowPlayingInfoUniqueIdentifier() 95 #endif // HAVE(MEDIA_PLAYER) 96 75 97 WEBCORE_EXPORT NSString* WebUIApplicationWillResignActiveNotification = @"WebUIApplicationWillResignActiveNotification"; 76 98 WEBCORE_EXPORT NSString* WebUIApplicationWillEnterForegroundNotification = @"WebUIApplicationWillEnterForegroundNotification"; … … 181 203 END_BLOCK_OBJC_EXCEPTIONS 182 204 #endif 205 } 206 207 bool MediaSessionManageriOS::sessionWillBeginPlayback(PlatformMediaSession& session) 208 { 209 if (!PlatformMediaSessionManager::sessionWillBeginPlayback(session)) 210 return false; 211 212 LOG(Media, "MediaSessionManageriOS::sessionWillBeginPlayback"); 213 updateNowPlayingInfo(); 214 return true; 215 } 216 217 void MediaSessionManageriOS::removeSession(PlatformMediaSession& session) 218 { 219 PlatformMediaSessionManager::removeSession(session); 220 LOG(Media, "MediaSessionManageriOS::removeSession"); 221 updateNowPlayingInfo(); 222 } 223 224 void MediaSessionManageriOS::sessionWillEndPlayback(PlatformMediaSession& session) 225 { 226 PlatformMediaSessionManager::sessionWillEndPlayback(session); 227 LOG(Media, "MediaSessionManageriOS::sessionWillEndPlayback"); 228 updateNowPlayingInfo(); 229 } 230 231 void MediaSessionManageriOS::clientCharacteristicsChanged(PlatformMediaSession&) 232 { 233 LOG(Media, "MediaSessionManageriOS::clientCharacteristicsChanged"); 234 updateNowPlayingInfo(); 235 } 236 237 PlatformMediaSession* MediaSessionManageriOS::nowPlayingEligibleSession() 238 { 239 return findSession([] (PlatformMediaSession& session, size_t) { 240 PlatformMediaSession::MediaType type = session.mediaType(); 241 if (type != PlatformMediaSession::VideoAudio && type != PlatformMediaSession::Audio) 242 return false; 243 244 if (session.characteristics() & PlatformMediaSession::HasAudio) 245 return true; 246 247 return false; 248 }); 249 } 250 251 void MediaSessionManageriOS::updateNowPlayingInfo() 252 { 253 #if HAVE(MEDIA_PLAYER) 254 BEGIN_BLOCK_OBJC_EXCEPTIONS 255 MPNowPlayingInfoCenter *nowPlaying = (MPNowPlayingInfoCenter *)[getMPNowPlayingInfoCenterClass() defaultCenter]; 256 const PlatformMediaSession* currentSession = this->nowPlayingEligibleSession(); 257 258 LOG(Media, "MediaSessionManageriOS::updateNowPlayingInfo - currentSession = %p", currentSession); 259 260 if (!currentSession) { 261 if (m_nowPlayingActive) { 262 LOG(Media, "MediaSessionManageriOS::updateNowPlayingInfo - clearing now playing info"); 263 [nowPlaying setNowPlayingInfo:nil]; 264 m_nowPlayingActive = false; 265 } 266 267 return; 268 } 269 270 String title = currentSession->title(); 271 double duration = currentSession->duration(); 272 double rate = currentSession->state() == PlatformMediaSession::Playing ? 1 : 0; 273 double currentTime = currentSession->currentTime(); 274 if (m_reportedTitle == title && m_reportedRate == rate && m_reportedDuration == duration) { 275 LOG(Media, "MediaSessionManageriOS::updateNowPlayingInfo - nothing new to show"); 276 return; 277 } 278 279 m_reportedRate = rate; 280 m_reportedDuration = duration; 281 m_reportedTitle = title; 282 m_reportedCurrentTime = currentTime; 283 m_lastUpdatedNowPlayingInfoUniqueIdentifier = currentSession->uniqueIdentifier(); 284 285 auto info = adoptNS([[NSMutableDictionary alloc] init]); 286 if (!title.isEmpty()) 287 info.get()[MPMediaItemPropertyTitle] = static_cast<NSString *>(title); 288 if (std::isfinite(duration) && duration != MediaPlayer::invalidTime()) 289 info.get()[MPMediaItemPropertyPlaybackDuration] = @(duration); 290 info.get()[MPNowPlayingInfoPropertyPlaybackRate] = @(rate); 291 info.get()[kMRMediaRemoteNowPlayingInfoUniqueIdentifier] = @(title.impl() ? title.impl()->hash() : 0); 292 293 if (std::isfinite(currentTime) && currentTime != MediaPlayer::invalidTime()) 294 info.get()[MPNowPlayingInfoPropertyElapsedPlaybackTime] = @(currentTime); 295 296 LOG(Media, "MediaSessionManageriOS::updateNowPlayingInfo - title = \"%s\", rate = %f, duration = %f, now = %f", 297 title.utf8().data(), rate, duration, currentTime); 298 299 m_nowPlayingActive = true; 300 [nowPlaying setNowPlayingInfo:info.get()]; 301 END_BLOCK_OBJC_EXCEPTIONS 302 #endif // HAVE(MEDIA_PLAYER) 183 303 } 184 304 -
trunk/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.h
r236010 r236011 1 1 /* 2 * Copyright (C) 201 8Apple Inc. All rights reserved.2 * Copyright (C) 2016-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 26 26 #pragma once 27 27 28 #if PLATFORM( COCOA)28 #if PLATFORM(MAC) 29 29 30 30 #include "GenericTaskQueue.h" 31 #include " PlatformMediaSessionManager.h"31 #include "MediaSessionManagerCocoa.h" 32 32 33 33 namespace WebCore { 34 34 35 class MediaSessionManager Cocoa : public PlatformMediaSessionManager{35 class MediaSessionManagerMac : public MediaSessionManagerCocoa { 36 36 public: 37 virtual ~MediaSessionManagerCocoa() = default; 38 39 void updateSessionState() override; 40 void beginInterruption(PlatformMediaSession::InterruptionType) override; 37 virtual ~MediaSessionManagerMac(); 41 38 42 39 bool hasActiveNowPlayingSession() const final { return m_nowPlayingActive; } … … 47 44 bool registeredAsNowPlayingApplication() const final { return m_registeredAsNowPlayingApplication; } 48 45 49 protected: 46 private: 47 friend class PlatformMediaSessionManager; 48 49 MediaSessionManagerMac(); 50 50 51 void scheduleUpdateNowPlayingInfo() override; 51 void updateNowPlayingInfo();52 52 void removeSession(PlatformMediaSession&) override; 53 53 54 54 bool sessionWillBeginPlayback(PlatformMediaSession&) override; 55 55 void sessionWillEndPlayback(PlatformMediaSession&) override; … … 58 58 void sessionCanProduceAudioChanged(PlatformMediaSession&) override; 59 59 60 void updateNowPlayingInfo(); 61 60 62 PlatformMediaSession* nowPlayingEligibleSession(); 61 63 62 private:63 64 bool m_nowPlayingActive { false }; 65 bool m_isInBackground { false }; 64 66 bool m_registeredAsNowPlayingApplication { false }; 65 67 66 68 // For testing purposes only. 67 69 String m_lastUpdatedNowPlayingTitle; … … 73 75 }; 74 76 75 } 77 } // namespace WebCore 76 78 77 #endif // PLATFORM( COCOA)79 #endif // PLATFORM(MAC) -
trunk/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.mm
r236010 r236011 1 1 /* 2 * Copyright (C) 201 3-2014Apple Inc. All rights reserved.2 * Copyright (C) 2016-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 #include "config.h" 27 #include "MediaSessionManagerCocoa.h" 28 29 #if USE(AUDIO_SESSION) && PLATFORM(COCOA) 30 31 #include "AudioSession.h" 32 #include "DeprecatedGlobalSettings.h" 33 #include "HTMLMediaElement.h" 34 #include "Logging.h" 35 #include "MediaPlayer.h" 36 #include "PlatformMediaSession.h" 37 #include <wtf/BlockObjCExceptions.h> 38 #include <wtf/Function.h> 39 40 #include "MediaRemoteSoftLink.h" 26 #import "config.h" 27 #import "MediaSessionManagerMac.h" 28 29 #if PLATFORM(MAC) 30 31 #import "HTMLMediaElement.h" 32 #import "Logging.h" 33 #import "MediaPlayer.h" 34 #import "PlatformMediaSession.h" 35 #import <wtf/BlockObjCExceptions.h> 36 37 #import "MediaRemoteSoftLink.h" 41 38 42 39 using namespace WebCore; 43 40 44 static const size_t kWebAudioBufferSize = 128; 45 static const size_t kLowPowerVideoBufferSize = 4096; 46 47 #if PLATFORM(MAC) 48 static MediaSessionManagerCocoa* platformMediaSessionManager = nullptr; 41 namespace WebCore { 42 43 static MediaSessionManagerMac* platformMediaSessionManager = nullptr; 49 44 50 45 PlatformMediaSessionManager& PlatformMediaSessionManager::sharedManager() 51 46 { 52 47 if (!platformMediaSessionManager) 53 platformMediaSessionManager = new MediaSessionManager Cocoa;48 platformMediaSessionManager = new MediaSessionManagerMac; 54 49 return *platformMediaSessionManager; 55 50 } … … 59 54 return platformMediaSessionManager; 60 55 } 61 #endif 62 63 void MediaSessionManagerCocoa::updateSessionState() 64 { 65 LOG(Media, "PlatformMediaSessionManager::scheduleUpdateSessionState() - types: Video(%d), Audio(%d), WebAudio(%d)", count(PlatformMediaSession::Video), count(PlatformMediaSession::Audio), count(PlatformMediaSession::WebAudio)); 66 67 if (has(PlatformMediaSession::WebAudio)) 68 AudioSession::sharedSession().setPreferredBufferSize(kWebAudioBufferSize); 69 // In case of audio capture, we want to grab 20 ms chunks to limit the latency so that it is not noticeable by users 70 // while having a large enough buffer so that the audio rendering remains stable, hence a computation based on sample rate. 71 else if (has(PlatformMediaSession::MediaStreamCapturingAudio)) 72 AudioSession::sharedSession().setPreferredBufferSize(AudioSession::sharedSession().sampleRate() / 50); 73 else if ((has(PlatformMediaSession::VideoAudio) || has(PlatformMediaSession::Audio)) && DeprecatedGlobalSettings::lowPowerVideoAudioBufferSizeEnabled()) { 74 // FIXME: <http://webkit.org/b/116725> Figure out why enabling the code below 75 // causes media LayoutTests to fail on 10.8. 76 77 size_t bufferSize; 78 if (audioHardwareListener() && audioHardwareListener()->outputDeviceSupportsLowPowerMode()) 79 bufferSize = kLowPowerVideoBufferSize; 80 else 81 bufferSize = kWebAudioBufferSize; 82 83 AudioSession::sharedSession().setPreferredBufferSize(bufferSize); 84 } 85 86 if (!DeprecatedGlobalSettings::shouldManageAudioSessionCategory()) 87 return; 88 89 bool hasWebAudioType = false; 90 bool hasAudibleAudioOrVideoMediaType = false; 91 bool hasAudioCapture = anyOfSessions([&hasWebAudioType, &hasAudibleAudioOrVideoMediaType] (PlatformMediaSession& session, size_t) mutable { 92 auto type = session.mediaType(); 93 if (type == PlatformMediaSession::WebAudio) 94 hasWebAudioType = true; 95 if ((type == PlatformMediaSession::VideoAudio || type == PlatformMediaSession::Audio) && session.canProduceAudio() && session.hasPlayedSinceLastInterruption()) 96 hasAudibleAudioOrVideoMediaType = true; 97 if (session.isPlayingToWirelessPlaybackTarget()) 98 hasAudibleAudioOrVideoMediaType = true; 99 return (type == PlatformMediaSession::MediaStreamCapturingAudio); 100 }); 101 102 if (hasAudioCapture) 103 AudioSession::sharedSession().setCategory(AudioSession::PlayAndRecord); 104 else if (hasAudibleAudioOrVideoMediaType) 105 AudioSession::sharedSession().setCategory(AudioSession::MediaPlayback); 106 else if (hasWebAudioType) 107 AudioSession::sharedSession().setCategory(AudioSession::AmbientSound); 108 else 109 AudioSession::sharedSession().setCategory(AudioSession::None); 110 } 111 112 void MediaSessionManagerCocoa::beginInterruption(PlatformMediaSession::InterruptionType type) 113 { 114 if (type == PlatformMediaSession::InterruptionType::SystemInterruption) { 115 forEachSession([] (PlatformMediaSession& session, size_t) { 116 session.clearHasPlayedSinceLastInterruption(); 117 }); 118 } 119 120 PlatformMediaSessionManager::beginInterruption(type); 121 } 122 123 void MediaSessionManagerCocoa::scheduleUpdateNowPlayingInfo() 56 57 MediaSessionManagerMac::MediaSessionManagerMac() 58 : MediaSessionManagerCocoa() 59 { 60 resetRestrictions(); 61 } 62 63 MediaSessionManagerMac::~MediaSessionManagerMac() 64 { 65 } 66 67 void MediaSessionManagerMac::scheduleUpdateNowPlayingInfo() 124 68 { 125 69 if (!m_nowPlayingUpdateTaskQueue.hasPendingTasks()) 126 m_nowPlayingUpdateTaskQueue.enqueueTask(std::bind(&MediaSessionManager Cocoa::updateNowPlayingInfo, this));127 } 128 129 bool MediaSessionManager Cocoa::sessionWillBeginPlayback(PlatformMediaSession& session)70 m_nowPlayingUpdateTaskQueue.enqueueTask(std::bind(&MediaSessionManagerMac::updateNowPlayingInfo, this)); 71 } 72 73 bool MediaSessionManagerMac::sessionWillBeginPlayback(PlatformMediaSession& session) 130 74 { 131 75 if (!PlatformMediaSessionManager::sessionWillBeginPlayback(session)) 132 76 return false; 77 78 LOG(Media, "MediaSessionManagerMac::sessionWillBeginPlayback"); 79 scheduleUpdateNowPlayingInfo(); 80 return true; 81 } 82 83 void MediaSessionManagerMac::sessionDidEndRemoteScrubbing(const PlatformMediaSession&) 84 { 85 scheduleUpdateNowPlayingInfo(); 86 } 87 88 void MediaSessionManagerMac::removeSession(PlatformMediaSession& session) 89 { 90 PlatformMediaSessionManager::removeSession(session); 91 LOG(Media, "MediaSessionManagerMac::removeSession"); 92 scheduleUpdateNowPlayingInfo(); 93 } 94 95 void MediaSessionManagerMac::sessionWillEndPlayback(PlatformMediaSession& session) 96 { 97 PlatformMediaSessionManager::sessionWillEndPlayback(session); 98 LOG(Media, "MediaSessionManagerMac::sessionWillEndPlayback"); 99 updateNowPlayingInfo(); 100 } 101 102 void MediaSessionManagerMac::clientCharacteristicsChanged(PlatformMediaSession&) 103 { 104 LOG(Media, "MediaSessionManagerMac::clientCharacteristicsChanged"); 105 scheduleUpdateNowPlayingInfo(); 106 } 133 107 134 LOG(Media, "MediaSessionManagerCocoa::sessionWillBeginPlayback"); 135 scheduleUpdateNowPlayingInfo(); 136 return true; 137 } 138 139 void MediaSessionManagerCocoa::sessionDidEndRemoteScrubbing(const PlatformMediaSession&) 140 { 141 scheduleUpdateNowPlayingInfo(); 142 } 143 144 void MediaSessionManagerCocoa::removeSession(PlatformMediaSession& session) 145 { 146 PlatformMediaSessionManager::removeSession(session); 147 LOG(Media, "MediaSessionManagerCocoa::removeSession"); 148 scheduleUpdateNowPlayingInfo(); 149 } 150 151 void MediaSessionManagerCocoa::sessionWillEndPlayback(PlatformMediaSession& session) 152 { 153 PlatformMediaSessionManager::sessionWillEndPlayback(session); 154 LOG(Media, "MediaSessionManagerCocoa::sessionWillEndPlayback"); 155 updateNowPlayingInfo(); 156 } 157 158 void MediaSessionManagerCocoa::clientCharacteristicsChanged(PlatformMediaSession&) 159 { 160 LOG(Media, "MediaSessionManagerCocoa::clientCharacteristicsChanged"); 161 scheduleUpdateNowPlayingInfo(); 162 } 163 164 void MediaSessionManagerCocoa::sessionCanProduceAudioChanged(PlatformMediaSession& session) 108 void MediaSessionManagerMac::sessionCanProduceAudioChanged(PlatformMediaSession& session) 165 109 { 166 110 PlatformMediaSessionManager::sessionCanProduceAudioChanged(session); … … 168 112 } 169 113 170 PlatformMediaSession* MediaSessionManager Cocoa::nowPlayingEligibleSession()114 PlatformMediaSession* MediaSessionManagerMac::nowPlayingEligibleSession() 171 115 { 172 116 if (auto element = HTMLMediaElement::bestMediaElementForShowingPlaybackControlsManager(MediaElementSession::PlaybackControlsPurpose::NowPlaying)) … … 176 120 } 177 121 178 void MediaSessionManager Cocoa::updateNowPlayingInfo()122 void MediaSessionManagerMac::updateNowPlayingInfo() 179 123 { 180 124 #if USE(MEDIAREMOTE) … … 186 130 const PlatformMediaSession* currentSession = this->nowPlayingEligibleSession(); 187 131 188 LOG(Media, "MediaSessionManager Cocoa::updateNowPlayingInfo - currentSession = %p", currentSession);132 LOG(Media, "MediaSessionManagerMac::updateNowPlayingInfo - currentSession = %p", currentSession); 189 133 190 134 if (!currentSession) { … … 192 136 MRMediaRemoteSetNowPlayingVisibility(MRMediaRemoteGetLocalOrigin(), MRNowPlayingClientVisibilityNeverVisible); 193 137 194 LOG(Media, "MediaSessionManager Cocoa::updateNowPlayingInfo - clearing now playing info");138 LOG(Media, "MediaSessionManagerMac::updateNowPlayingInfo - clearing now playing info"); 195 139 196 140 MRMediaRemoteSetCanBeNowPlayingApplication(false); … … 208 152 #else 209 153 if (error) 210 LOG(Media, "MediaSessionManager Cocoa::updateNowPlayingInfo - MRMediaRemoteSetNowPlayingApplicationPlaybackStateForOrigin(stopped) failed with error %ud", error);154 LOG(Media, "MediaSessionManagerMac::updateNowPlayingInfo - MRMediaRemoteSetNowPlayingApplicationPlaybackStateForOrigin(stopped) failed with error %ud", error); 211 155 #endif 212 156 }); … … 250 194 } 251 195 252 LOG(Media, "MediaSessionManager Cocoa::updateNowPlayingInfo - title = \"%s\", rate = %f, duration = %f, now = %f",196 LOG(Media, "MediaSessionManagerMac::updateNowPlayingInfo - title = \"%s\", rate = %f, duration = %f, now = %f", 253 197 title.utf8().data(), rate, duration, currentTime); 254 198 … … 263 207 UNUSED_PARAM(error); 264 208 #else 265 LOG(Media, "MediaSessionManager Cocoa::updateNowPlayingInfo - MRMediaRemoteSetNowPlayingApplicationPlaybackStateForOrigin(playing) failed with error %ud", error);209 LOG(Media, "MediaSessionManagerMac::updateNowPlayingInfo - MRMediaRemoteSetNowPlayingApplicationPlaybackStateForOrigin(playing) failed with error %ud", error); 266 210 #endif 267 211 }); … … 276 220 } 277 221 278 #endif // USE(AUDIO_SESSION) 222 } // namespace WebCore 223 224 #endif // PLATFORM(MAC)
Note:
See TracChangeset
for help on using the changeset viewer.