Enable USE_MEDIAREMOTE on iOS
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Sep 2018 18:57:53 +0000 (18:57 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Sep 2018 18:57:53 +0000 (18:57 +0000)
https://bugs.webkit.org/show_bug.cgi?id=189096

Reviewed by Eric Carlson.

Source/WebCore:

Migrate to using MediaRemote.framework on iOS from MediaPlayer.framework. This unifies the
Now Playing implementation on iOS and Mac.

* SourcesCocoa.txt:
* WebCore.xcodeproj/project.pbxproj:
* platform/audio/cocoa/MediaSessionManagerCocoa.cpp: Removed.
* platform/audio/cocoa/MediaSessionManagerCocoa.h:
* platform/audio/cocoa/MediaSessionManagerCocoa.mm: Renamed from Source/WebCore/platform/audio/mac/MediaSessionManagerMac.mm.
(PlatformMediaSessionManager::sharedManager):
(PlatformMediaSessionManager::sharedManagerIfExists):
(MediaSessionManagerCocoa::updateSessionState):
(MediaSessionManagerCocoa::beginInterruption):
(MediaSessionManagerCocoa::scheduleUpdateNowPlayingInfo):
(MediaSessionManagerCocoa::sessionWillBeginPlayback):
(MediaSessionManagerCocoa::sessionDidEndRemoteScrubbing):
(MediaSessionManagerCocoa::removeSession):
(MediaSessionManagerCocoa::sessionWillEndPlayback):
(MediaSessionManagerCocoa::clientCharacteristicsChanged):
(MediaSessionManagerCocoa::sessionCanProduceAudioChanged):
(MediaSessionManagerCocoa::nowPlayingEligibleSession):
(MediaSessionManagerCocoa::updateNowPlayingInfo):
* platform/audio/ios/MediaSessionManagerIOS.h:
(): Deleted.
* platform/audio/ios/MediaSessionManagerIOS.mm:
(WebCore::MediaSessionManageriOS::nowPlayingEligibleSession): Deleted.
(WebCore::MediaSessionManageriOS::updateNowPlayingInfo): Deleted.
(WebCore::MediaSessionManageriOS::sessionWillBeginPlayback): Deleted.
(WebCore::MediaSessionManageriOS::removeSession): Deleted.
(WebCore::MediaSessionManageriOS::sessionWillEndPlayback): Deleted.
(WebCore::MediaSessionManageriOS::clientCharacteristicsChanged): Deleted.
* platform/audio/mac/MediaSessionManagerMac.h: Removed.

Source/WTF:

* wtf/Platform.h:

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

12 files changed:
Source/WTF/ChangeLog
Source/WTF/wtf/Platform.h
Source/WebCore/ChangeLog
Source/WebCore/SourcesCocoa.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.cpp [deleted file]
Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.h
Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.mm [moved from Source/WebCore/platform/audio/mac/MediaSessionManagerMac.mm with 56% similarity]
Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h
Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm
Source/WebCore/platform/audio/mac/MediaSessionManagerMac.h [deleted file]
Tools/TestWebKitAPI/Tests/WebKitCocoa/NowPlaying.mm

index b270962..ef794f8 100644 (file)
@@ -1,3 +1,12 @@
+2018-09-17  Jer Noble  <jer.noble@apple.com>
+
+        Enable USE_MEDIAREMOTE on iOS
+        https://bugs.webkit.org/show_bug.cgi?id=189096
+
+        Reviewed by Eric Carlson.
+
+        * wtf/Platform.h:
+
 2018-09-17  Frederic Wang  <fwang@igalia.com>
 
         Build error in ImageBufferCG when compiled with IOSurfacePool
index 3e6acf3..e569cdc 100644 (file)
 #endif
 #endif
 
-#if PLATFORM(MAC)
+#if PLATFORM(MAC) || PLATFORM(IOS)
 #define USE_MEDIAREMOTE 1
 #endif
 
index 1b12cd6..6f49e4c 100644 (file)
@@ -1,3 +1,42 @@
+2018-09-17  Jer Noble  <jer.noble@apple.com>
+
+        Enable USE_MEDIAREMOTE on iOS
+        https://bugs.webkit.org/show_bug.cgi?id=189096
+
+        Reviewed by Eric Carlson.
+
+        Migrate to using MediaRemote.framework on iOS from MediaPlayer.framework. This unifies the
+        Now Playing implementation on iOS and Mac.
+
+        * SourcesCocoa.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/audio/cocoa/MediaSessionManagerCocoa.cpp: Removed.
+        * platform/audio/cocoa/MediaSessionManagerCocoa.h:
+        * platform/audio/cocoa/MediaSessionManagerCocoa.mm: Renamed from Source/WebCore/platform/audio/mac/MediaSessionManagerMac.mm.
+        (PlatformMediaSessionManager::sharedManager):
+        (PlatformMediaSessionManager::sharedManagerIfExists):
+        (MediaSessionManagerCocoa::updateSessionState):
+        (MediaSessionManagerCocoa::beginInterruption):
+        (MediaSessionManagerCocoa::scheduleUpdateNowPlayingInfo):
+        (MediaSessionManagerCocoa::sessionWillBeginPlayback):
+        (MediaSessionManagerCocoa::sessionDidEndRemoteScrubbing):
+        (MediaSessionManagerCocoa::removeSession):
+        (MediaSessionManagerCocoa::sessionWillEndPlayback):
+        (MediaSessionManagerCocoa::clientCharacteristicsChanged):
+        (MediaSessionManagerCocoa::sessionCanProduceAudioChanged):
+        (MediaSessionManagerCocoa::nowPlayingEligibleSession):
+        (MediaSessionManagerCocoa::updateNowPlayingInfo):
+        * platform/audio/ios/MediaSessionManagerIOS.h:
+        (): Deleted.
+        * platform/audio/ios/MediaSessionManagerIOS.mm:
+        (WebCore::MediaSessionManageriOS::nowPlayingEligibleSession): Deleted.
+        (WebCore::MediaSessionManageriOS::updateNowPlayingInfo): Deleted.
+        (WebCore::MediaSessionManageriOS::sessionWillBeginPlayback): Deleted.
+        (WebCore::MediaSessionManageriOS::removeSession): Deleted.
+        (WebCore::MediaSessionManageriOS::sessionWillEndPlayback): Deleted.
+        (WebCore::MediaSessionManageriOS::clientCharacteristicsChanged): Deleted.
+        * platform/audio/mac/MediaSessionManagerMac.h: Removed.
+
 2018-09-17  Frederic Wang  <fwang@igalia.com>
 
         Build error in ImageBufferCG when compiled with IOSurfacePool
index 6a78661..8033a36 100644 (file)
@@ -159,7 +159,7 @@ page/scrolling/mac/ScrollingTreeStickyNode.mm
 
 platform/audio/AudioSession.cpp
 
-platform/audio/cocoa/MediaSessionManagerCocoa.cpp
+platform/audio/cocoa/MediaSessionManagerCocoa.mm
 platform/audio/cocoa/WebAudioBufferList.cpp
 
 platform/audio/ios/AudioDestinationIOS.cpp @no-unify
@@ -176,7 +176,6 @@ platform/audio/mac/AudioHardwareListenerMac.cpp
 platform/audio/mac/AudioSessionMac.cpp
 platform/audio/mac/CARingBuffer.cpp
 platform/audio/mac/FFTFrameMac.cpp
-platform/audio/mac/MediaSessionManagerMac.mm
 
 platform/cf/CFURLExtras.cpp
 platform/cf/FileSystemCF.cpp
index 684644f..7b3ce33 100644 (file)
                CD063F831E23FA8900812BE3 /* InitDataRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = CD063F811E23FA8900812BE3 /* InitDataRegistry.h */; };
                CD0EEE0E14743F39003EAFA2 /* AudioDestinationIOS.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD0EEE0B14743E35003EAFA2 /* AudioDestinationIOS.cpp */; };
                CD127DEE14F3098400E84779 /* WebCoreFullScreenWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = CD127DEA14F3097900E84779 /* WebCoreFullScreenWindow.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               CD17A45D213740810079EC7B /* UnifiedSource62-mm.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD17A459213740160079EC7B /* UnifiedSource62-mm.mm */; };
                CD19A2681A13E700008D650E /* DiagnosticLoggingClient.h in Headers */ = {isa = PBXBuildFile; fileRef = CD19A2671A13E700008D650E /* DiagnosticLoggingClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
                CD19FEA81F573972000C42FB /* ImageDecoder.h in Headers */ = {isa = PBXBuildFile; fileRef = CD19FEA61F573972000C42FB /* ImageDecoder.h */; };
                CD19FEAE1F574B6D000C42FB /* ImageDecoderAVFObjC.h in Headers */ = {isa = PBXBuildFile; fileRef = CD19FEAC1F574B6D000C42FB /* ImageDecoderAVFObjC.h */; };
                07E3DFD01A9E786500764CA8 /* MediaPlaybackTarget.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaPlaybackTarget.h; sourceTree = "<group>"; };
                07E9E12D18F5E2760011A3A4 /* InbandMetadataTextTrackPrivateAVF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InbandMetadataTextTrackPrivateAVF.h; sourceTree = "<group>"; };
                07E9E12F18F62B370011A3A4 /* InbandMetadataTextTrackPrivateAVF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InbandMetadataTextTrackPrivateAVF.cpp; sourceTree = "<group>"; };
-               07EDC3ED1AACB75D00983EB5 /* MediaSessionManagerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MediaSessionManagerMac.mm; sourceTree = "<group>"; };
                07EE76E91BE96DB000F89133 /* MockRealtimeVideoSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MockRealtimeVideoSource.cpp; sourceTree = "<group>"; };
                07EE76EA1BE96DB000F89133 /* MockRealtimeVideoSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MockRealtimeVideoSource.h; sourceTree = "<group>"; };
                07EE76ED1BEA619800F89133 /* MockRealtimeVideoSourceMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MockRealtimeVideoSourceMac.h; sourceTree = "<group>"; };
                417F0D7E1FFEE14E008EF303 /* ServiceWorkerInternals.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ServiceWorkerInternals.h; sourceTree = "<group>"; };
                417F0D801FFEE14F008EF303 /* ServiceWorkerInternals.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ServiceWorkerInternals.cpp; sourceTree = "<group>"; };
                417F0D811FFEE150008EF303 /* ServiceWorkerInternals.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ServiceWorkerInternals.idl; sourceTree = "<group>"; };
-               417F7AEA2139BF6400FBA7EC /* MediaSessionManagerCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaSessionManagerCocoa.cpp; sourceTree = "<group>"; };
+               417F7AEA2139BF6400FBA7EC /* MediaSessionManagerCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MediaSessionManagerCocoa.mm; sourceTree = "<group>"; };
                417F7AEB2139BF6400FBA7EC /* WebAudioBufferList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebAudioBufferList.cpp; sourceTree = "<group>"; };
                417F7AEC2139BF6500FBA7EC /* WebAudioBufferList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebAudioBufferList.h; sourceTree = "<group>"; };
                417F7AED2139BF6500FBA7EC /* MediaSessionManagerCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaSessionManagerCocoa.h; sourceTree = "<group>"; };
                CD0EEE0B14743E35003EAFA2 /* AudioDestinationIOS.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AudioDestinationIOS.cpp; sourceTree = "<group>"; };
                CD127DEA14F3097900E84779 /* WebCoreFullScreenWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreFullScreenWindow.h; sourceTree = "<group>"; };
                CD127DEB14F3097900E84779 /* WebCoreFullScreenWindow.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreFullScreenWindow.mm; sourceTree = "<group>"; };
+               CD17A459213740160079EC7B /* UnifiedSource62-mm.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "UnifiedSource62-mm.mm"; sourceTree = "<group>"; };
                CD19A2671A13E700008D650E /* DiagnosticLoggingClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DiagnosticLoggingClient.h; sourceTree = "<group>"; };
                CD19FEA61F573972000C42FB /* ImageDecoder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ImageDecoder.h; sourceTree = "<group>"; };
                CD19FEA71F573972000C42FB /* ImageDecoder.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ImageDecoder.cpp; sourceTree = "<group>"; };
                CD641EB11818F5ED00EE4C41 /* MediaSourcePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaSourcePrivate.h; sourceTree = "<group>"; };
                CD641EB21818F5ED00EE4C41 /* SourceBufferPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SourceBufferPrivate.h; sourceTree = "<group>"; };
                CD641EC7181ED60100EE4C41 /* MediaSample.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MediaSample.h; sourceTree = "<group>"; };
-               CD669D671D232E10004D1866 /* MediaSessionManagerMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaSessionManagerMac.h; sourceTree = "<group>"; };
                CD78A2EC1F75648600DE371B /* CDMInstanceFairPlayStreamingAVFObjC.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CDMInstanceFairPlayStreamingAVFObjC.mm; sourceTree = "<group>"; };
                CD78A2EE1F75648600DE371B /* CDMInstanceFairPlayStreamingAVFObjC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDMInstanceFairPlayStreamingAVFObjC.h; sourceTree = "<group>"; };
                CD7D33411C7A123F00041293 /* PixelBufferConformerCV.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PixelBufferConformerCV.cpp; sourceTree = "<group>"; };
                                538EC8791F993F31004D22A8 /* UnifiedSource60.cpp */,
                                DE5F863A1FA2AF07006DB63B /* UnifiedSource61-mm.mm */,
                                538EC87E1F993F33004D22A8 /* UnifiedSource61.cpp */,
+                               CD17A459213740160079EC7B /* UnifiedSource62-mm.mm */,
                                538EC85A1F993F20004D22A8 /* UnifiedSource62.cpp */,
                                538EC8611F993F24004D22A8 /* UnifiedSource63.cpp */,
                                538EC8421F993F14004D22A8 /* UnifiedSource64.cpp */,
                CD669D651D232DF4004D1866 /* cocoa */ = {
                        isa = PBXGroup;
                        children = (
-                               417F7AEA2139BF6400FBA7EC /* MediaSessionManagerCocoa.cpp */,
+                               417F7AEA2139BF6400FBA7EC /* MediaSessionManagerCocoa.mm */,
                                417F7AED2139BF6500FBA7EC /* MediaSessionManagerCocoa.h */,
                                417F7AEB2139BF6400FBA7EC /* WebAudioBufferList.cpp */,
                                417F7AEC2139BF6500FBA7EC /* WebAudioBufferList.h */,
                                CDC734121977896C0046BFC5 /* CARingBuffer.cpp */,
                                CDC734131977896C0046BFC5 /* CARingBuffer.h */,
                                FD3160BA12B0272A00C1A359 /* FFTFrameMac.cpp */,
-                               CD669D671D232E10004D1866 /* MediaSessionManagerMac.h */,
-                               07EDC3ED1AACB75D00983EB5 /* MediaSessionManagerMac.mm */,
                        );
                        path = mac;
                        sourceTree = "<group>";
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                        shellPath = /bin/sh;
-                       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";
+                       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";
                };
                5D0D540D0E9862F60029E223 /* Check For Weak VTables and Externals */ = {
                        isa = PBXShellScriptBuildPhase;
                                DE5F86591FA2AF24006DB63B /* UnifiedSource61-mm.mm in Sources */,
                                538EC8AE1F993F9D004D22A8 /* UnifiedSource61.cpp in Sources */,
                                538EC8AF1F993F9D004D22A8 /* UnifiedSource62.cpp in Sources */,
+                               CD17A45D213740810079EC7B /* UnifiedSource62-mm.mm in Sources */,
                                538EC8B01F993F9D004D22A8 /* UnifiedSource63.cpp in Sources */,
                                538EC8B11F993F9D004D22A8 /* UnifiedSource64.cpp in Sources */,
                                538EC8B21F993F9D004D22A8 /* UnifiedSource65.cpp in Sources */,
diff --git a/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.cpp b/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.cpp
deleted file mode 100644 (file)
index 03a96bd..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (C) 2013-2014 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "MediaSessionManagerCocoa.h"
-
-#if USE(AUDIO_SESSION)
-
-#include "AudioSession.h"
-#include "DeprecatedGlobalSettings.h"
-#include "Logging.h"
-#include <wtf/Function.h>
-
-using namespace WebCore;
-
-static const size_t kWebAudioBufferSize = 128;
-static const size_t kLowPowerVideoBufferSize = 4096;
-
-void MediaSessionManagerCocoa::updateSessionState()
-{
-    LOG(Media, "PlatformMediaSessionManager::scheduleUpdateSessionState() - types: Video(%d), Audio(%d), WebAudio(%d)", count(PlatformMediaSession::Video), count(PlatformMediaSession::Audio), count(PlatformMediaSession::WebAudio));
-
-    if (has(PlatformMediaSession::WebAudio))
-        AudioSession::sharedSession().setPreferredBufferSize(kWebAudioBufferSize);
-    // In case of audio capture, we want to grab 20 ms chunks to limit the latency so that it is not noticeable by users
-    // while having a large enough buffer so that the audio rendering remains stable, hence a computation based on sample rate.
-    else if (has(PlatformMediaSession::MediaStreamCapturingAudio))
-        AudioSession::sharedSession().setPreferredBufferSize(AudioSession::sharedSession().sampleRate() / 50);
-    else if ((has(PlatformMediaSession::VideoAudio) || has(PlatformMediaSession::Audio)) && DeprecatedGlobalSettings::lowPowerVideoAudioBufferSizeEnabled()) {
-        // FIXME: <http://webkit.org/b/116725> Figure out why enabling the code below
-        // causes media LayoutTests to fail on 10.8.
-
-        size_t bufferSize;
-        if (audioHardwareListener() && audioHardwareListener()->outputDeviceSupportsLowPowerMode())
-            bufferSize = kLowPowerVideoBufferSize;
-        else
-            bufferSize = kWebAudioBufferSize;
-
-        AudioSession::sharedSession().setPreferredBufferSize(bufferSize);
-    }
-
-    if (!DeprecatedGlobalSettings::shouldManageAudioSessionCategory())
-        return;
-
-    bool hasWebAudioType = false;
-    bool hasAudibleAudioOrVideoMediaType = false;
-    bool hasAudioCapture = anyOfSessions([&hasWebAudioType, &hasAudibleAudioOrVideoMediaType] (PlatformMediaSession& session, size_t) mutable {
-        auto type = session.mediaType();
-        if (type == PlatformMediaSession::WebAudio)
-            hasWebAudioType = true;
-        if ((type == PlatformMediaSession::VideoAudio || type == PlatformMediaSession::Audio) && session.canProduceAudio() && session.hasPlayedSinceLastInterruption())
-            hasAudibleAudioOrVideoMediaType = true;
-        if (session.isPlayingToWirelessPlaybackTarget())
-            hasAudibleAudioOrVideoMediaType = true;
-        return (type == PlatformMediaSession::MediaStreamCapturingAudio);
-    });
-
-    if (hasAudioCapture)
-        AudioSession::sharedSession().setCategory(AudioSession::PlayAndRecord);
-    else if (hasAudibleAudioOrVideoMediaType)
-        AudioSession::sharedSession().setCategory(AudioSession::MediaPlayback);
-    else if (hasWebAudioType)
-        AudioSession::sharedSession().setCategory(AudioSession::AmbientSound);
-    else
-        AudioSession::sharedSession().setCategory(AudioSession::None);
-}
-
-void MediaSessionManagerCocoa::beginInterruption(PlatformMediaSession::InterruptionType type)
-{
-    if (type == PlatformMediaSession::InterruptionType::SystemInterruption) {
-        forEachSession([] (PlatformMediaSession& session, size_t) {
-            session.clearHasPlayedSinceLastInterruption();
-        });
-    }
-
-    PlatformMediaSessionManager::beginInterruption(type);
-}
-
-#endif // USE(AUDIO_SESSION)
index 41fea14..47c1fdf 100644 (file)
 
 #if PLATFORM(COCOA)
 
+#include "GenericTaskQueue.h"
 #include "PlatformMediaSessionManager.h"
 
 namespace WebCore {
 
 class MediaSessionManagerCocoa : public PlatformMediaSessionManager {
 public:
+    virtual ~MediaSessionManagerCocoa() = default;
+    
     void updateSessionState() override;
     void beginInterruption(PlatformMediaSession::InterruptionType) override;
+
+    bool hasActiveNowPlayingSession() const final { return m_nowPlayingActive; }
+    String lastUpdatedNowPlayingTitle() const final { return m_lastUpdatedNowPlayingTitle; }
+    double lastUpdatedNowPlayingDuration() const final { return m_lastUpdatedNowPlayingDuration; }
+    double lastUpdatedNowPlayingElapsedTime() const final { return m_lastUpdatedNowPlayingElapsedTime; }
+    uint64_t lastUpdatedNowPlayingInfoUniqueIdentifier() const final { return m_lastUpdatedNowPlayingInfoUniqueIdentifier; }
+    bool registeredAsNowPlayingApplication() const final { return m_registeredAsNowPlayingApplication; }
+
+protected:
+    void scheduleUpdateNowPlayingInfo() override;
+    void updateNowPlayingInfo();
+    void removeSession(PlatformMediaSession&) override;
+    
+    bool sessionWillBeginPlayback(PlatformMediaSession&) override;
+    void sessionWillEndPlayback(PlatformMediaSession&) override;
+    void sessionDidEndRemoteScrubbing(const PlatformMediaSession&) override;
+    void clientCharacteristicsChanged(PlatformMediaSession&) override;
+    void sessionCanProduceAudioChanged(PlatformMediaSession&) override;
+
+    PlatformMediaSession* nowPlayingEligibleSession();
+
+private:
+    bool m_nowPlayingActive { false };
+    bool m_registeredAsNowPlayingApplication { false };
+    
+    // For testing purposes only.
+    String m_lastUpdatedNowPlayingTitle;
+    double m_lastUpdatedNowPlayingDuration { NAN };
+    double m_lastUpdatedNowPlayingElapsedTime { NAN };
+    uint64_t m_lastUpdatedNowPlayingInfoUniqueIdentifier { 0 };
+
+    GenericTaskQueue<Timer> m_nowPlayingUpdateTaskQueue;
 };
 
 }
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2014 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#import "config.h"
-#import "MediaSessionManagerMac.h"
+#include "config.h"
+#include "MediaSessionManagerCocoa.h"
 
-#if PLATFORM(MAC)
+#if USE(AUDIO_SESSION) && PLATFORM(COCOA)
 
-#import "HTMLMediaElement.h"
-#import "Logging.h"
-#import "MediaPlayer.h"
-#import "PlatformMediaSession.h"
-#import <wtf/BlockObjCExceptions.h>
+#include "AudioSession.h"
+#include "DeprecatedGlobalSettings.h"
+#include "HTMLMediaElement.h"
+#include "Logging.h"
+#include "MediaPlayer.h"
+#include "PlatformMediaSession.h"
+#include <wtf/BlockObjCExceptions.h>
+#include <wtf/Function.h>
 
-#import "MediaRemoteSoftLink.h"
+#include "MediaRemoteSoftLink.h"
 
 using namespace WebCore;
 
-namespace WebCore {
+static const size_t kWebAudioBufferSize = 128;
+static const size_t kLowPowerVideoBufferSize = 4096;
 
-static MediaSessionManagerMac* platformMediaSessionManager = nullptr;
+#if PLATFORM(MAC)
+static MediaSessionManagerCocoa* platformMediaSessionManager = nullptr;
 
 PlatformMediaSessionManager& PlatformMediaSessionManager::sharedManager()
 {
     if (!platformMediaSessionManager)
-        platformMediaSessionManager = new MediaSessionManagerMac;
+        platformMediaSessionManager = new MediaSessionManagerCocoa;
     return *platformMediaSessionManager;
 }
 
@@ -53,65 +58,116 @@ PlatformMediaSessionManager* PlatformMediaSessionManager::sharedManagerIfExists(
 {
     return platformMediaSessionManager;
 }
+#endif
 
-MediaSessionManagerMac::MediaSessionManagerMac()
-    : MediaSessionManagerCocoa()
+void MediaSessionManagerCocoa::updateSessionState()
 {
-    resetRestrictions();
+    LOG(Media, "PlatformMediaSessionManager::scheduleUpdateSessionState() - types: Video(%d), Audio(%d), WebAudio(%d)", count(PlatformMediaSession::Video), count(PlatformMediaSession::Audio), count(PlatformMediaSession::WebAudio));
+
+    if (has(PlatformMediaSession::WebAudio))
+        AudioSession::sharedSession().setPreferredBufferSize(kWebAudioBufferSize);
+    // In case of audio capture, we want to grab 20 ms chunks to limit the latency so that it is not noticeable by users
+    // while having a large enough buffer so that the audio rendering remains stable, hence a computation based on sample rate.
+    else if (has(PlatformMediaSession::MediaStreamCapturingAudio))
+        AudioSession::sharedSession().setPreferredBufferSize(AudioSession::sharedSession().sampleRate() / 50);
+    else if ((has(PlatformMediaSession::VideoAudio) || has(PlatformMediaSession::Audio)) && DeprecatedGlobalSettings::lowPowerVideoAudioBufferSizeEnabled()) {
+        // FIXME: <http://webkit.org/b/116725> Figure out why enabling the code below
+        // causes media LayoutTests to fail on 10.8.
+
+        size_t bufferSize;
+        if (audioHardwareListener() && audioHardwareListener()->outputDeviceSupportsLowPowerMode())
+            bufferSize = kLowPowerVideoBufferSize;
+        else
+            bufferSize = kWebAudioBufferSize;
+
+        AudioSession::sharedSession().setPreferredBufferSize(bufferSize);
+    }
+
+    if (!DeprecatedGlobalSettings::shouldManageAudioSessionCategory())
+        return;
+
+    bool hasWebAudioType = false;
+    bool hasAudibleAudioOrVideoMediaType = false;
+    bool hasAudioCapture = anyOfSessions([&hasWebAudioType, &hasAudibleAudioOrVideoMediaType] (PlatformMediaSession& session, size_t) mutable {
+        auto type = session.mediaType();
+        if (type == PlatformMediaSession::WebAudio)
+            hasWebAudioType = true;
+        if ((type == PlatformMediaSession::VideoAudio || type == PlatformMediaSession::Audio) && session.canProduceAudio() && session.hasPlayedSinceLastInterruption())
+            hasAudibleAudioOrVideoMediaType = true;
+        if (session.isPlayingToWirelessPlaybackTarget())
+            hasAudibleAudioOrVideoMediaType = true;
+        return (type == PlatformMediaSession::MediaStreamCapturingAudio);
+    });
+
+    if (hasAudioCapture)
+        AudioSession::sharedSession().setCategory(AudioSession::PlayAndRecord);
+    else if (hasAudibleAudioOrVideoMediaType)
+        AudioSession::sharedSession().setCategory(AudioSession::MediaPlayback);
+    else if (hasWebAudioType)
+        AudioSession::sharedSession().setCategory(AudioSession::AmbientSound);
+    else
+        AudioSession::sharedSession().setCategory(AudioSession::None);
 }
 
-MediaSessionManagerMac::~MediaSessionManagerMac()
+void MediaSessionManagerCocoa::beginInterruption(PlatformMediaSession::InterruptionType type)
 {
+    if (type == PlatformMediaSession::InterruptionType::SystemInterruption) {
+        forEachSession([] (PlatformMediaSession& session, size_t) {
+            session.clearHasPlayedSinceLastInterruption();
+        });
+    }
+
+    PlatformMediaSessionManager::beginInterruption(type);
 }
 
-void MediaSessionManagerMac::scheduleUpdateNowPlayingInfo()
+void MediaSessionManagerCocoa::scheduleUpdateNowPlayingInfo()
 {
     if (!m_nowPlayingUpdateTaskQueue.hasPendingTasks())
-        m_nowPlayingUpdateTaskQueue.enqueueTask(std::bind(&MediaSessionManagerMac::updateNowPlayingInfo, this));
+        m_nowPlayingUpdateTaskQueue.enqueueTask(std::bind(&MediaSessionManagerCocoa::updateNowPlayingInfo, this));
 }
 
-bool MediaSessionManagerMac::sessionWillBeginPlayback(PlatformMediaSession& session)
+bool MediaSessionManagerCocoa::sessionWillBeginPlayback(PlatformMediaSession& session)
 {
     if (!PlatformMediaSessionManager::sessionWillBeginPlayback(session))
         return false;
-
-    LOG(Media, "MediaSessionManagerMac::sessionWillBeginPlayback");
+    
+    LOG(Media, "MediaSessionManagerCocoa::sessionWillBeginPlayback");
     scheduleUpdateNowPlayingInfo();
     return true;
 }
 
-void MediaSessionManagerMac::sessionDidEndRemoteScrubbing(const PlatformMediaSession&)
+void MediaSessionManagerCocoa::sessionDidEndRemoteScrubbing(const PlatformMediaSession&)
 {
     scheduleUpdateNowPlayingInfo();
 }
 
-void MediaSessionManagerMac::removeSession(PlatformMediaSession& session)
+void MediaSessionManagerCocoa::removeSession(PlatformMediaSession& session)
 {
     PlatformMediaSessionManager::removeSession(session);
-    LOG(Media, "MediaSessionManagerMac::removeSession");
+    LOG(Media, "MediaSessionManagerCocoa::removeSession");
     scheduleUpdateNowPlayingInfo();
 }
 
-void MediaSessionManagerMac::sessionWillEndPlayback(PlatformMediaSession& session)
+void MediaSessionManagerCocoa::sessionWillEndPlayback(PlatformMediaSession& session)
 {
     PlatformMediaSessionManager::sessionWillEndPlayback(session);
-    LOG(Media, "MediaSessionManagerMac::sessionWillEndPlayback");
+    LOG(Media, "MediaSessionManagerCocoa::sessionWillEndPlayback");
     updateNowPlayingInfo();
 }
 
-void MediaSessionManagerMac::clientCharacteristicsChanged(PlatformMediaSession&)
+void MediaSessionManagerCocoa::clientCharacteristicsChanged(PlatformMediaSession&)
 {
-    LOG(Media, "MediaSessionManagerMac::clientCharacteristicsChanged");
+    LOG(Media, "MediaSessionManagerCocoa::clientCharacteristicsChanged");
     scheduleUpdateNowPlayingInfo();
 }
-    
-void MediaSessionManagerMac::sessionCanProduceAudioChanged(PlatformMediaSession& session)
+
+void MediaSessionManagerCocoa::sessionCanProduceAudioChanged(PlatformMediaSession& session)
 {
     PlatformMediaSessionManager::sessionCanProduceAudioChanged(session);
     scheduleUpdateNowPlayingInfo();
 }
 
-PlatformMediaSession* MediaSessionManagerMac::nowPlayingEligibleSession()
+PlatformMediaSession* MediaSessionManagerCocoa::nowPlayingEligibleSession()
 {
     if (auto element = HTMLMediaElement::bestMediaElementForShowingPlaybackControlsManager(MediaElementSession::PlaybackControlsPurpose::NowPlaying))
         return &element->mediaSession();
@@ -119,7 +175,7 @@ PlatformMediaSession* MediaSessionManagerMac::nowPlayingEligibleSession()
     return nullptr;
 }
 
-void MediaSessionManagerMac::updateNowPlayingInfo()
+void MediaSessionManagerCocoa::updateNowPlayingInfo()
 {
 #if USE(MEDIAREMOTE)
     if (!isMediaRemoteFrameworkAvailable())
@@ -129,13 +185,13 @@ void MediaSessionManagerMac::updateNowPlayingInfo()
 
     const PlatformMediaSession* currentSession = this->nowPlayingEligibleSession();
 
-    LOG(Media, "MediaSessionManagerMac::updateNowPlayingInfo - currentSession = %p", currentSession);
+    LOG(Media, "MediaSessionManagerCocoa::updateNowPlayingInfo - currentSession = %p", currentSession);
 
     if (!currentSession) {
         if (canLoad_MediaRemote_MRMediaRemoteSetNowPlayingVisibility())
             MRMediaRemoteSetNowPlayingVisibility(MRMediaRemoteGetLocalOrigin(), MRNowPlayingClientVisibilityNeverVisible);
 
-        LOG(Media, "MediaSessionManagerMac::updateNowPlayingInfo - clearing now playing info");
+        LOG(Media, "MediaSessionManagerCocoa::updateNowPlayingInfo - clearing now playing info");
 
         MRMediaRemoteSetCanBeNowPlayingApplication(false);
         m_registeredAsNowPlayingApplication = false;
@@ -151,7 +207,7 @@ void MediaSessionManagerMac::updateNowPlayingInfo()
             UNUSED_PARAM(error);
 #else
             if (error)
-                LOG(Media, "MediaSessionManagerMac::updateNowPlayingInfo - MRMediaRemoteSetNowPlayingApplicationPlaybackStateForOrigin(stopped) failed with error %ud", error);
+                LOG(Media, "MediaSessionManagerCocoa::updateNowPlayingInfo - MRMediaRemoteSetNowPlayingApplicationPlaybackStateForOrigin(stopped) failed with error %ud", error);
 #endif
         });
 
@@ -193,7 +249,7 @@ void MediaSessionManagerMac::updateNowPlayingInfo()
         m_lastUpdatedNowPlayingElapsedTime = currentTime;
     }
 
-    LOG(Media, "MediaSessionManagerMac::updateNowPlayingInfo - title = \"%s\", rate = %f, duration = %f, now = %f",
+    LOG(Media, "MediaSessionManagerCocoa::updateNowPlayingInfo - title = \"%s\", rate = %f, duration = %f, now = %f",
         title.utf8().data(), rate, duration, currentTime);
 
     String parentApplication = currentSession->sourceApplicationIdentifier();
@@ -206,7 +262,7 @@ void MediaSessionManagerMac::updateNowPlayingInfo()
 #if LOG_DISABLED
         UNUSED_PARAM(error);
 #else
-        LOG(Media, "MediaSessionManagerMac::updateNowPlayingInfo - MRMediaRemoteSetNowPlayingApplicationPlaybackStateForOrigin(playing) failed with error %ud", error);
+        LOG(Media, "MediaSessionManagerCocoa::updateNowPlayingInfo - MRMediaRemoteSetNowPlayingApplicationPlaybackStateForOrigin(playing) failed with error %ud", error);
 #endif
     });
     MRMediaRemoteSetNowPlayingInfo(info.get());
@@ -219,6 +275,4 @@ void MediaSessionManagerMac::updateNowPlayingInfo()
 #endif // USE(MEDIAREMOTE)
 }
 
-} // namespace WebCore
-
-#endif // PLATFORM(MAC)
+#endif // USE(AUDIO_SESSION)
index b9a8608..65daeed 100644 (file)
@@ -53,34 +53,11 @@ private:
 
     MediaSessionManageriOS();
 
-    void removeSession(PlatformMediaSession&) override;
-
-    bool sessionWillBeginPlayback(PlatformMediaSession&) override;
-    void sessionWillEndPlayback(PlatformMediaSession&) override;
-    void clientCharacteristicsChanged(PlatformMediaSession&) override;
-
-    void updateNowPlayingInfo();
-    
     void resetRestrictions() override;
 
     void configureWireLessTargetMonitoring() override;
 
-    bool hasActiveNowPlayingSession() const final { return m_nowPlayingActive; }
-    String lastUpdatedNowPlayingTitle() const final { return m_reportedTitle; }
-    double lastUpdatedNowPlayingDuration() const final { return m_reportedDuration; }
-    double lastUpdatedNowPlayingElapsedTime() const final { return m_reportedCurrentTime; }
-    uint64_t lastUpdatedNowPlayingInfoUniqueIdentifier() const final { return m_lastUpdatedNowPlayingInfoUniqueIdentifier; }
-    bool registeredAsNowPlayingApplication() const final { return m_nowPlayingActive; }
-
-    PlatformMediaSession* nowPlayingEligibleSession();
-    
     RetainPtr<WebMediaSessionHelper> m_objcObserver;
-    double m_reportedRate { 0 };
-    double m_reportedDuration { 0 };
-    double m_reportedCurrentTime { 0 };
-    uint64_t m_lastUpdatedNowPlayingInfoUniqueIdentifier { 0 };
-    String m_reportedTitle;
-    bool m_nowPlayingActive { false };
 };
 
 } // namespace WebCore
index 1cbfc65..383e241 100644 (file)
 #import <wtf/RetainPtr.h>
 #import <wtf/SoftLinking.h>
 
-#if HAVE(MEDIA_PLAYER)
-#import <MediaPlayer/MPMediaItem.h>
-#import <MediaPlayer/MPNowPlayingInfoCenter.h>
-#import <pal/spi/ios/MediaPlayerSPI.h>
-#endif
-
 SOFT_LINK_FRAMEWORK(AVFoundation)
 SOFT_LINK_CLASS(AVFoundation, AVAudioSession)
 SOFT_LINK_CONSTANT(AVFoundation, AVAudioSessionInterruptionNotification, NSString *)
@@ -78,22 +72,6 @@ SOFT_LINK_CONSTANT(UIKit, UIApplicationDidEnterBackgroundNotification, NSString
 #define UIApplicationDidBecomeActiveNotification getUIApplicationDidBecomeActiveNotification()
 #define UIApplicationDidEnterBackgroundNotification getUIApplicationDidEnterBackgroundNotification()
 
-#if HAVE(MEDIA_PLAYER)
-SOFT_LINK_FRAMEWORK(MediaPlayer)
-SOFT_LINK_CLASS(MediaPlayer, MPNowPlayingInfoCenter)
-SOFT_LINK_CONSTANT(MediaPlayer, MPMediaItemPropertyTitle, NSString *)
-SOFT_LINK_CONSTANT(MediaPlayer, MPMediaItemPropertyPlaybackDuration, NSString *)
-SOFT_LINK_CONSTANT(MediaPlayer, MPNowPlayingInfoPropertyElapsedPlaybackTime, NSString *)
-SOFT_LINK_CONSTANT(MediaPlayer, MPNowPlayingInfoPropertyPlaybackRate, NSString *)
-SOFT_LINK_CONSTANT(MediaPlayer, kMRMediaRemoteNowPlayingInfoUniqueIdentifier, NSString *)
-
-#define MPMediaItemPropertyTitle getMPMediaItemPropertyTitle()
-#define MPMediaItemPropertyPlaybackDuration getMPMediaItemPropertyPlaybackDuration()
-#define MPNowPlayingInfoPropertyElapsedPlaybackTime getMPNowPlayingInfoPropertyElapsedPlaybackTime()
-#define MPNowPlayingInfoPropertyPlaybackRate getMPNowPlayingInfoPropertyPlaybackRate()
-#define kMRMediaRemoteNowPlayingInfoUniqueIdentifier getkMRMediaRemoteNowPlayingInfoUniqueIdentifier()
-#endif // HAVE(MEDIA_PLAYER)
-
 WEBCORE_EXPORT NSString* WebUIApplicationWillResignActiveNotification = @"WebUIApplicationWillResignActiveNotification";
 WEBCORE_EXPORT NSString* WebUIApplicationWillEnterForegroundNotification = @"WebUIApplicationWillEnterForegroundNotification";
 WEBCORE_EXPORT NSString* WebUIApplicationDidBecomeActiveNotification = @"WebUIApplicationDidBecomeActiveNotification";
@@ -204,104 +182,6 @@ void MediaSessionManageriOS::configureWireLessTargetMonitoring()
 #endif
 }
 
-bool MediaSessionManageriOS::sessionWillBeginPlayback(PlatformMediaSession& session)
-{
-    if (!PlatformMediaSessionManager::sessionWillBeginPlayback(session))
-        return false;
-
-    LOG(Media, "MediaSessionManageriOS::sessionWillBeginPlayback");
-    updateNowPlayingInfo();
-    return true;
-}
-
-void MediaSessionManageriOS::removeSession(PlatformMediaSession& session)
-{
-    PlatformMediaSessionManager::removeSession(session);
-    LOG(Media, "MediaSessionManageriOS::removeSession");
-    updateNowPlayingInfo();
-}
-
-void MediaSessionManageriOS::sessionWillEndPlayback(PlatformMediaSession& session)
-{
-    PlatformMediaSessionManager::sessionWillEndPlayback(session);
-    LOG(Media, "MediaSessionManageriOS::sessionWillEndPlayback");
-    updateNowPlayingInfo();
-}
-
-void MediaSessionManageriOS::clientCharacteristicsChanged(PlatformMediaSession&)
-{
-    LOG(Media, "MediaSessionManageriOS::clientCharacteristicsChanged");
-    updateNowPlayingInfo();
-}
-
-PlatformMediaSession* MediaSessionManageriOS::nowPlayingEligibleSession()
-{
-    return findSession([] (PlatformMediaSession& session, size_t) {
-        PlatformMediaSession::MediaType type = session.mediaType();
-        if (type != PlatformMediaSession::VideoAudio && type != PlatformMediaSession::Audio)
-            return false;
-
-        if (session.characteristics() & PlatformMediaSession::HasAudio)
-            return true;
-
-        return false;
-    });
-}
-
-void MediaSessionManageriOS::updateNowPlayingInfo()
-{
-#if HAVE(MEDIA_PLAYER)
-    BEGIN_BLOCK_OBJC_EXCEPTIONS
-    MPNowPlayingInfoCenter *nowPlaying = (MPNowPlayingInfoCenter *)[getMPNowPlayingInfoCenterClass() defaultCenter];
-    const PlatformMediaSession* currentSession = this->nowPlayingEligibleSession();
-
-    LOG(Media, "MediaSessionManageriOS::updateNowPlayingInfo - currentSession = %p", currentSession);
-
-    if (!currentSession) {
-        if (m_nowPlayingActive) {
-            LOG(Media, "MediaSessionManageriOS::updateNowPlayingInfo - clearing now playing info");
-            [nowPlaying setNowPlayingInfo:nil];
-            m_nowPlayingActive = false;
-        }
-
-        return;
-    }
-
-    String title = currentSession->title();
-    double duration = currentSession->duration();
-    double rate = currentSession->state() == PlatformMediaSession::Playing ? 1 : 0;
-    double currentTime = currentSession->currentTime();
-    if (m_reportedTitle == title && m_reportedRate == rate && m_reportedDuration == duration) {
-        LOG(Media, "MediaSessionManageriOS::updateNowPlayingInfo - nothing new to show");
-        return;
-    }
-
-    m_reportedRate = rate;
-    m_reportedDuration = duration;
-    m_reportedTitle = title;
-    m_reportedCurrentTime = currentTime;
-    m_lastUpdatedNowPlayingInfoUniqueIdentifier = currentSession->uniqueIdentifier();
-
-    auto info = adoptNS([[NSMutableDictionary alloc] init]);
-    if (!title.isEmpty())
-        info.get()[MPMediaItemPropertyTitle] = static_cast<NSString *>(title);
-    if (std::isfinite(duration) && duration != MediaPlayer::invalidTime())
-        info.get()[MPMediaItemPropertyPlaybackDuration] = @(duration);
-    info.get()[MPNowPlayingInfoPropertyPlaybackRate] = @(rate);
-    info.get()[kMRMediaRemoteNowPlayingInfoUniqueIdentifier] = @(title.impl() ? title.impl()->hash() : 0);
-
-    if (std::isfinite(currentTime) && currentTime != MediaPlayer::invalidTime())
-        info.get()[MPNowPlayingInfoPropertyElapsedPlaybackTime] = @(currentTime);
-
-    LOG(Media, "MediaSessionManageriOS::updateNowPlayingInfo - title = \"%s\", rate = %f, duration = %f, now = %f",
-        title.utf8().data(), rate, duration, currentTime);
-
-    m_nowPlayingActive = true;
-    [nowPlaying setNowPlayingInfo:info.get()];
-    END_BLOCK_OBJC_EXCEPTIONS
-#endif // HAVE(MEDIA_PLAYER)
-}
-
 void MediaSessionManageriOS::externalOutputDeviceAvailableDidChange()
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS
diff --git a/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.h b/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.h
deleted file mode 100644 (file)
index 44cd9c7..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#if PLATFORM(MAC)
-
-#include "GenericTaskQueue.h"
-#include "MediaSessionManagerCocoa.h"
-
-namespace WebCore {
-
-class MediaSessionManagerMac : public MediaSessionManagerCocoa {
-public:
-    virtual ~MediaSessionManagerMac();
-
-    bool hasActiveNowPlayingSession() const final { return m_nowPlayingActive; }
-    String lastUpdatedNowPlayingTitle() const final { return m_lastUpdatedNowPlayingTitle; }
-    double lastUpdatedNowPlayingDuration() const final { return m_lastUpdatedNowPlayingDuration; }
-    double lastUpdatedNowPlayingElapsedTime() const final { return m_lastUpdatedNowPlayingElapsedTime; }
-    uint64_t lastUpdatedNowPlayingInfoUniqueIdentifier() const final { return m_lastUpdatedNowPlayingInfoUniqueIdentifier; }
-    bool registeredAsNowPlayingApplication() const final { return m_registeredAsNowPlayingApplication; }
-
-private:
-    friend class PlatformMediaSessionManager;
-
-    MediaSessionManagerMac();
-
-    void scheduleUpdateNowPlayingInfo() override;
-    void removeSession(PlatformMediaSession&) override;
-
-    bool sessionWillBeginPlayback(PlatformMediaSession&) override;
-    void sessionWillEndPlayback(PlatformMediaSession&) override;
-    void sessionDidEndRemoteScrubbing(const PlatformMediaSession&) override;
-    void clientCharacteristicsChanged(PlatformMediaSession&) override;
-    void sessionCanProduceAudioChanged(PlatformMediaSession&) override;
-
-    void updateNowPlayingInfo();
-
-    PlatformMediaSession* nowPlayingEligibleSession();
-
-    bool m_nowPlayingActive { false };
-    bool m_isInBackground { false };
-    bool m_registeredAsNowPlayingApplication { false };
-
-    // For testing purposes only.
-    String m_lastUpdatedNowPlayingTitle;
-    double m_lastUpdatedNowPlayingDuration { NAN };
-    double m_lastUpdatedNowPlayingElapsedTime { NAN };
-    uint64_t m_lastUpdatedNowPlayingInfoUniqueIdentifier { 0 };
-
-    GenericTaskQueue<Timer> m_nowPlayingUpdateTaskQueue;
-};
-
-} // namespace WebCore
-
-#endif // PLATFORM(MAC)
index 9389476..6c4ab23 100644 (file)
 
 #include "config.h"
 
-#if WK_API_ENABLED && USE(MEDIAREMOTE) && (PLATFORM(IOS) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101304))
+#if WK_API_ENABLED && USE(MEDIAREMOTE) && !PLATFORM(IOS_SIMULATOR) && (PLATFORM(IOS) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101304))
 
 #import "PlatformUtilities.h"
 #import "TestWKWebView.h"
+#import <WebKit/WKWebViewConfigurationPrivate.h>
 #import <WebKit/WKWebViewPrivate.h>
 #import <pal/spi/mac/MediaRemoteSPI.h>
 #import <wtf/Function.h>
@@ -89,6 +90,10 @@ public:
 
         _configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
         [_configuration setMediaTypesRequiringUserActionForPlayback:WKAudiovisualMediaTypeAudio];
+#if PLATFORM(IOS)
+        [_configuration setAllowsInlineMediaPlayback:YES];
+        [_configuration _setInlineMediaPlaybackRequiresPlaysInlineAttribute:NO];
+#endif
 
         _webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300) configuration:_configuration.get() addToWindow:YES]);
     }