⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 236011 in webkit


Ignore:
Timestamp:
Sep 14, 2018, 11:17:42 AM (8 years ago)
Author:
Ryan Haddad
Message:

Unreviewed, rolling out r235990.

Introduced TestWebKitAPI.NowPlayingTest timeouts on iOS

Reverted changeset:

"Enable USE_MEDIAREMOTE on iOS"
​https://bugs.webkit.org/show_bug.cgi?id=189096
​https://trac.webkit.org/changeset/235990

Location:
trunk/Source
Files:
1 added
8 edited
1 copied
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r235990 r236011  
     12018-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
    1132018-09-13  Jer Noble  <jer.noble@apple.com>
    214
  • trunk/Source/WTF/wtf/Platform.h

    r235990 r236011  
    13041304#endif
    13051305
    1306 #if PLATFORM(MAC) || PLATFORM(IOS)
     1306#if PLATFORM(MAC)
    13071307#define USE_MEDIAREMOTE 1
    13081308#endif
  • trunk/Source/WebCore/ChangeLog

    r236010 r236011  
     12018-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
    1132018-09-14  Jer Noble  <jer.noble@apple.com>
    214
  • trunk/Source/WebCore/SourcesCocoa.txt

    r235990 r236011  
    160160platform/audio/AudioSession.cpp
    161161
    162 platform/audio/cocoa/MediaSessionManagerCocoa.mm
     162platform/audio/cocoa/MediaSessionManagerCocoa.cpp
    163163platform/audio/cocoa/WebAudioBufferList.cpp
    164164
    … …  
    177177platform/audio/mac/CARingBuffer.cpp
    178178platform/audio/mac/FFTFrameMac.cpp
     179platform/audio/mac/MediaSessionManagerMac.mm
    179180
    180181platform/cf/CFURLExtras.cpp
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r235990 r236011  
    39663966                CD0EEE0E14743F39003EAFA2 /* AudioDestinationIOS.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD0EEE0B14743E35003EAFA2 /* AudioDestinationIOS.cpp */; };
    39673967                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 */; };
    39693968                CD19A2681A13E700008D650E /* DiagnosticLoggingClient.h in Headers */ = {isa = PBXBuildFile; fileRef = CD19A2671A13E700008D650E /* DiagnosticLoggingClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
    39703969                CD19FEA81F573972000C42FB /* ImageDecoder.h in Headers */ = {isa = PBXBuildFile; fileRef = CD19FEA61F573972000C42FB /* ImageDecoder.h */; };
    … …  
    54415440                07E9E12D18F5E2760011A3A4 /* InbandMetadataTextTrackPrivateAVF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InbandMetadataTextTrackPrivateAVF.h; sourceTree = "<group>"; };
    54425441                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>"; };
    54435443                07EE76E91BE96DB000F89133 /* MockRealtimeVideoSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MockRealtimeVideoSource.cpp; sourceTree = "<group>"; };
    54445444                07EE76EA1BE96DB000F89133 /* MockRealtimeVideoSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MockRealtimeVideoSource.h; sourceTree = "<group>"; };
    … …  
    1318813188                CD127DEA14F3097900E84779 /* WebCoreFullScreenWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreFullScreenWindow.h; sourceTree = "<group>"; };
    1318913189                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>"; };
    1319113190                CD19A2671A13E700008D650E /* DiagnosticLoggingClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DiagnosticLoggingClient.h; sourceTree = "<group>"; };
    1319213191                CD19FEA61F573972000C42FB /* ImageDecoder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ImageDecoder.h; sourceTree = "<group>"; };
    … …  
    1325313252                CD641EB21818F5ED00EE4C41 /* SourceBufferPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SourceBufferPrivate.h; sourceTree = "<group>"; };
    1325413253                CD641EC7181ED60100EE4C41 /* MediaSample.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MediaSample.h; sourceTree = "<group>"; };
    13255                 CD669D661D232DFF004D1866 /* 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>"; };
    1325613255                CD78A2EC1F75648600DE371B /* CDMInstanceFairPlayStreamingAVFObjC.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CDMInstanceFairPlayStreamingAVFObjC.mm; sourceTree = "<group>"; };
    1325713256                CD78A2EE1F75648600DE371B /* CDMInstanceFairPlayStreamingAVFObjC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDMInstanceFairPlayStreamingAVFObjC.h; sourceTree = "<group>"; };
    … …  
    1824518244                                DE5F863A1FA2AF07006DB63B /* UnifiedSource61-mm.mm */,
    1824618245                                538EC87E1F993F33004D22A8 /* UnifiedSource61.cpp */,
    18247                                 CD17A459213740160079EC7B /* UnifiedSource62-mm.mm */,
    1824818246                                538EC85A1F993F20004D22A8 /* UnifiedSource62.cpp */,
    1824918247                                538EC8611F993F24004D22A8 /* UnifiedSource63.cpp */,
    … …  
    2693826936                                CDC734131977896C0046BFC5 /* CARingBuffer.h */,
    2693926937                                FD3160BA12B0272A00C1A359 /* FFTFrameMac.cpp */,
     26938                                CD669D671D232E10004D1866 /* MediaSessionManagerMac.h */,
     26939                                07EDC3ED1AACB75D00983EB5 /* MediaSessionManagerMac.mm */,
    2694026940                        );
    2694126941                        path = mac;
    … …  
    3132631326                        runOnlyForDeploymentPostprocessing = 0;
    3132731327                        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=62\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";
    3132931329                };
    3133031330                5D0D540D0E9862F60029E223 /* Check For Weak VTables and Externals */ = {
    … …  
    3175131751                                538EC8AE1F993F9D004D22A8 /* UnifiedSource61.cpp in Sources */,
    3175231752                                538EC8AF1F993F9D004D22A8 /* UnifiedSource62.cpp in Sources */,
    31753                                 CD17A45D213740810079EC7B /* UnifiedSource62-mm.mm in Sources */,
    3175431753                                538EC8B01F993F9D004D22A8 /* UnifiedSource63.cpp in Sources */,
    3175531754                                538EC8B11F993F9D004D22A8 /* UnifiedSource64.cpp in Sources */,
  • trunk/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.h

    r235990 r236011  
    2828#if PLATFORM(COCOA)
    2929
    30 #include "GenericTaskQueue.h"
    3130#include "PlatformMediaSessionManager.h"
    3231
    … …  
    3534class MediaSessionManagerCocoa : public PlatformMediaSessionManager {
    3635public:
    37     virtual ~MediaSessionManagerCocoa() = default;
    38    
    3936    void updateSessionState() override;
    4037    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;
    7338};
    7439
  • trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h

    r235990 r236011  
    5454    MediaSessionManageriOS();
    5555
     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   
    5664    void resetRestrictions() override;
    5765
    5866    void configureWireLessTargetMonitoring() override;
    5967
     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   
    6077    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 };
    6184};
    6285
  • trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm

    r235990 r236011  
    4444#import <wtf/SoftLinking.h>
    4545
     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
    4652SOFT_LINK_FRAMEWORK(AVFoundation)
    4753SOFT_LINK_CLASS(AVFoundation, AVAudioSession)
    … …  
    7379#define UIApplicationDidEnterBackgroundNotification getUIApplicationDidEnterBackgroundNotification()
    7480
     81#if HAVE(MEDIA_PLAYER)
     82SOFT_LINK_FRAMEWORK(MediaPlayer)
     83SOFT_LINK_CLASS(MediaPlayer, MPNowPlayingInfoCenter)
     84SOFT_LINK_CONSTANT(MediaPlayer, MPMediaItemPropertyTitle, NSString *)
     85SOFT_LINK_CONSTANT(MediaPlayer, MPMediaItemPropertyPlaybackDuration, NSString *)
     86SOFT_LINK_CONSTANT(MediaPlayer, MPNowPlayingInfoPropertyElapsedPlaybackTime, NSString *)
     87SOFT_LINK_CONSTANT(MediaPlayer, MPNowPlayingInfoPropertyPlaybackRate, NSString *)
     88SOFT_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
    7597WEBCORE_EXPORT NSString* WebUIApplicationWillResignActiveNotification = @"WebUIApplicationWillResignActiveNotification";
    7698WEBCORE_EXPORT NSString* WebUIApplicationWillEnterForegroundNotification = @"WebUIApplicationWillEnterForegroundNotification";
    … …  
    181203    END_BLOCK_OBJC_EXCEPTIONS
    182204#endif
     205}
     206
     207bool 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
     217void MediaSessionManageriOS::removeSession(PlatformMediaSession& session)
     218{
     219    PlatformMediaSessionManager::removeSession(session);
     220    LOG(Media, "MediaSessionManageriOS::removeSession");
     221    updateNowPlayingInfo();
     222}
     223
     224void MediaSessionManageriOS::sessionWillEndPlayback(PlatformMediaSession& session)
     225{
     226    PlatformMediaSessionManager::sessionWillEndPlayback(session);
     227    LOG(Media, "MediaSessionManageriOS::sessionWillEndPlayback");
     228    updateNowPlayingInfo();
     229}
     230
     231void MediaSessionManageriOS::clientCharacteristicsChanged(PlatformMediaSession&)
     232{
     233    LOG(Media, "MediaSessionManageriOS::clientCharacteristicsChanged");
     234    updateNowPlayingInfo();
     235}
     236
     237PlatformMediaSession* 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
     251void 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)
    183303}
    184304
  • trunk/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.h

    r236010 r236011  
    11/*
    2  * Copyright (C) 2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
    … …  
    2626#pragma once
    2727
    28 #if PLATFORM(COCOA)
     28#if PLATFORM(MAC)
    2929
    3030#include "GenericTaskQueue.h"
    31 #include "PlatformMediaSessionManager.h"
     31#include "MediaSessionManagerCocoa.h"
    3232
    3333namespace WebCore {
    3434
    35 class MediaSessionManagerCocoa : public PlatformMediaSessionManager {
     35class MediaSessionManagerMac : public MediaSessionManagerCocoa {
    3636public:
    37     virtual ~MediaSessionManagerCocoa() = default;
    38    
    39     void updateSessionState() override;
    40     void beginInterruption(PlatformMediaSession::InterruptionType) override;
     37    virtual ~MediaSessionManagerMac();
    4138
    4239    bool hasActiveNowPlayingSession() const final { return m_nowPlayingActive; }
    … …  
    4744    bool registeredAsNowPlayingApplication() const final { return m_registeredAsNowPlayingApplication; }
    4845
    49 protected:
     46private:
     47    friend class PlatformMediaSessionManager;
     48
     49    MediaSessionManagerMac();
     50
    5051    void scheduleUpdateNowPlayingInfo() override;
    51     void updateNowPlayingInfo();
    5252    void removeSession(PlatformMediaSession&) override;
    53    
     53
    5454    bool sessionWillBeginPlayback(PlatformMediaSession&) override;
    5555    void sessionWillEndPlayback(PlatformMediaSession&) override;
    … …  
    5858    void sessionCanProduceAudioChanged(PlatformMediaSession&) override;
    5959
     60    void updateNowPlayingInfo();
     61
    6062    PlatformMediaSession* nowPlayingEligibleSession();
    6163
    62 private:
    6364    bool m_nowPlayingActive { false };
     65    bool m_isInBackground { false };
    6466    bool m_registeredAsNowPlayingApplication { false };
    65    
     67
    6668    // For testing purposes only.
    6769    String m_lastUpdatedNowPlayingTitle;
    … …  
    7375};
    7476
    75 }
     77} // namespace WebCore
    7678
    77 #endif // PLATFORM(COCOA)
     79#endif // PLATFORM(MAC)
  • trunk/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.mm

    r236010 r236011  
    11/*
    2  * Copyright (C) 2013-2014 Apple Inc. All rights reserved.
     2 * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
    … …  
    2424 */
    2525
    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"
    4138
    4239using namespace WebCore;
    4340
    44 static const size_t kWebAudioBufferSize = 128;
    45 static const size_t kLowPowerVideoBufferSize = 4096;
    46 
    47 #if PLATFORM(MAC)
    48 static MediaSessionManagerCocoa* platformMediaSessionManager = nullptr;
     41namespace WebCore {
     42
     43static MediaSessionManagerMac* platformMediaSessionManager = nullptr;
    4944
    5045PlatformMediaSessionManager& PlatformMediaSessionManager::sharedManager()
    5146{
    5247    if (!platformMediaSessionManager)
    53         platformMediaSessionManager = new MediaSessionManagerCocoa;
     48        platformMediaSessionManager = new MediaSessionManagerMac;
    5449    return *platformMediaSessionManager;
    5550}
    … …  
    5954    return platformMediaSessionManager;
    6055}
    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
     57MediaSessionManagerMac::MediaSessionManagerMac()
     58    : MediaSessionManagerCocoa()
     59{
     60    resetRestrictions();
     61}
     62
     63MediaSessionManagerMac::~MediaSessionManagerMac()
     64{
     65}
     66
     67void MediaSessionManagerMac::scheduleUpdateNowPlayingInfo()
    12468{
    12569    if (!m_nowPlayingUpdateTaskQueue.hasPendingTasks())
    126         m_nowPlayingUpdateTaskQueue.enqueueTask(std::bind(&MediaSessionManagerCocoa::updateNowPlayingInfo, this));
    127 }
    128 
    129 bool MediaSessionManagerCocoa::sessionWillBeginPlayback(PlatformMediaSession& session)
     70        m_nowPlayingUpdateTaskQueue.enqueueTask(std::bind(&MediaSessionManagerMac::updateNowPlayingInfo, this));
     71}
     72
     73bool MediaSessionManagerMac::sessionWillBeginPlayback(PlatformMediaSession& session)
    13074{
    13175    if (!PlatformMediaSessionManager::sessionWillBeginPlayback(session))
    13276        return false;
     77
     78    LOG(Media, "MediaSessionManagerMac::sessionWillBeginPlayback");
     79    scheduleUpdateNowPlayingInfo();
     80    return true;
     81}
     82
     83void MediaSessionManagerMac::sessionDidEndRemoteScrubbing(const PlatformMediaSession&)
     84{
     85    scheduleUpdateNowPlayingInfo();
     86}
     87
     88void MediaSessionManagerMac::removeSession(PlatformMediaSession& session)
     89{
     90    PlatformMediaSessionManager::removeSession(session);
     91    LOG(Media, "MediaSessionManagerMac::removeSession");
     92    scheduleUpdateNowPlayingInfo();
     93}
     94
     95void MediaSessionManagerMac::sessionWillEndPlayback(PlatformMediaSession& session)
     96{
     97    PlatformMediaSessionManager::sessionWillEndPlayback(session);
     98    LOG(Media, "MediaSessionManagerMac::sessionWillEndPlayback");
     99    updateNowPlayingInfo();
     100}
     101
     102void MediaSessionManagerMac::clientCharacteristicsChanged(PlatformMediaSession&)
     103{
     104    LOG(Media, "MediaSessionManagerMac::clientCharacteristicsChanged");
     105    scheduleUpdateNowPlayingInfo();
     106}
    133107   
    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)
     108void MediaSessionManagerMac::sessionCanProduceAudioChanged(PlatformMediaSession& session)
    165109{
    166110    PlatformMediaSessionManager::sessionCanProduceAudioChanged(session);
    … …  
    168112}
    169113
    170 PlatformMediaSession* MediaSessionManagerCocoa::nowPlayingEligibleSession()
     114PlatformMediaSession* MediaSessionManagerMac::nowPlayingEligibleSession()
    171115{
    172116    if (auto element = HTMLMediaElement::bestMediaElementForShowingPlaybackControlsManager(MediaElementSession::PlaybackControlsPurpose::NowPlaying))
    … …  
    176120}
    177121
    178 void MediaSessionManagerCocoa::updateNowPlayingInfo()
     122void MediaSessionManagerMac::updateNowPlayingInfo()
    179123{
    180124#if USE(MEDIAREMOTE)
    … …  
    186130    const PlatformMediaSession* currentSession = this->nowPlayingEligibleSession();
    187131
    188     LOG(Media, "MediaSessionManagerCocoa::updateNowPlayingInfo - currentSession = %p", currentSession);
     132    LOG(Media, "MediaSessionManagerMac::updateNowPlayingInfo - currentSession = %p", currentSession);
    189133
    190134    if (!currentSession) {
    … …  
    192136            MRMediaRemoteSetNowPlayingVisibility(MRMediaRemoteGetLocalOrigin(), MRNowPlayingClientVisibilityNeverVisible);
    193137
    194         LOG(Media, "MediaSessionManagerCocoa::updateNowPlayingInfo - clearing now playing info");
     138        LOG(Media, "MediaSessionManagerMac::updateNowPlayingInfo - clearing now playing info");
    195139
    196140        MRMediaRemoteSetCanBeNowPlayingApplication(false);
    … …  
    208152#else
    209153            if (error)
    210                 LOG(Media, "MediaSessionManagerCocoa::updateNowPlayingInfo - MRMediaRemoteSetNowPlayingApplicationPlaybackStateForOrigin(stopped) failed with error %ud", error);
     154                LOG(Media, "MediaSessionManagerMac::updateNowPlayingInfo - MRMediaRemoteSetNowPlayingApplicationPlaybackStateForOrigin(stopped) failed with error %ud", error);
    211155#endif
    212156        });
    … …  
    250194    }
    251195
    252     LOG(Media, "MediaSessionManagerCocoa::updateNowPlayingInfo - title = \"%s\", rate = %f, duration = %f, now = %f",
     196    LOG(Media, "MediaSessionManagerMac::updateNowPlayingInfo - title = \"%s\", rate = %f, duration = %f, now = %f",
    253197        title.utf8().data(), rate, duration, currentTime);
    254198
    … …  
    263207        UNUSED_PARAM(error);
    264208#else
    265         LOG(Media, "MediaSessionManagerCocoa::updateNowPlayingInfo - MRMediaRemoteSetNowPlayingApplicationPlaybackStateForOrigin(playing) failed with error %ud", error);
     209        LOG(Media, "MediaSessionManagerMac::updateNowPlayingInfo - MRMediaRemoteSetNowPlayingApplicationPlaybackStateForOrigin(playing) failed with error %ud", error);
    266210#endif
    267211    });
    … …  
    276220}
    277221
    278 #endif // USE(AUDIO_SESSION)
     222} // namespace WebCore
     223
     224#endif // PLATFORM(MAC)
Note: See TracChangeset for help on using the changeset viewer.