Title: [257551] trunk/Source
Revision
257551
Author
[email protected]
Date
2020-02-26 19:51:17 -0800 (Wed, 26 Feb 2020)

Log Message

Create AudioDestination in the GPU process
https://bugs.webkit.org/show_bug.cgi?id=208179

Reviewed by Jer Noble.

Source/WebCore:

Add an abstraction around the creation of AudioDestination using newly introduced mediaStrategy.

* Headers.cmake:
* Modules/webaudio/DefaultAudioDestinationNode.cpp:
(WebCore::DefaultAudioDestinationNode::createDestination): Use MediaStrategy::createAudioDestination
* WebCore.xcodeproj/project.pbxproj:
* platform/MediaStrategy.h: Added.
(WebCore::MediaStrategy): Added.
* platform/PlatformStrategies.h:
(WebCore::PlatformStrategies::mediaStrategy): Added.
* platform/audio/AudioBus.h:
* platform/audio/AudioDestination.h:

Source/WebKit:

Create AudioDestination in the GPU process instead of the WebContent process for WebAudio API when
the Media-in-GPU-process feature is enabled.

To do this, WebMediaStrategy, a concrete implementation of MediaStrategy, in the WebContent process gets
a boolean flag indicating whether the GPU process should be used for AudioDestination or not. When the flag
is set, we create RemoteAudioDestinationProxy instead of AudioDestination in WebContent process.

Each RemoteAudioDestinationProxy talks to RemoteAudioDestinationManager in the GPU process and creates
a corresponding RemoteAudioDestination which in turn creates WebCore's AudioDestination in the GPU process.

RemoteAudioDestination is itself an AudioIOCallback for AudioDestination it creates, and delegates
its callback to WebContent process' RemoteAudioDestinationProxy as needed.

In this initial patch, we send RemoteAudioDestinationProxy::RenderBuffer IPC call to the WebContent process
for each render call we get from CoreAudio for simplicity using newly introduced RemoteAudioBusData,
which holds a SharedMemory for each channel in the audio bus.

We will eliminate this IPC overhead in a follow up patch using CARingBuffer.

* DerivedSources-input.xcfilelist:
* DerivedSources-output.xcfilelist:
* DerivedSources.make:
* GPUProcess/GPUConnectionToWebProcess.cpp:
(WebKit::GPUConnectionToWebProcess::remoteAudioDestinationManager): Added.
(WebKit::GPUConnectionToWebProcess::didReceiveMessage): Added the code to dispatch messages to
RemoteAudioDestinationManager.
(WebKit::GPUConnectionToWebProcess::didReceiveSyncMessage): Ditto.
* GPUProcess/GPUConnectionToWebProcess.h:
* GPUProcess/media/RemoteAudioDestinationManager.cpp: Added.
(WebKit::RemoteAudioDestination): Added. This class is the backing object which creates WebCore's
AudioDestination and actually talks to CoreAudio in GPU process.
(WebKit::RemoteAudioDestination::create): Added.

(WebKit::RemoteAudioDestination::~RemoteAudioDestination): Added.
(WebKit::RemoteAudioDestination::scheduleGracefulShutdownIfNeeded): Delays the deletion of this object
until the audio threads stops running.
(WebKit::RemoteAudioDestination::start): Added.
(WebKit::RemoteAudioDestination::stop): Added.
(WebKit::RemoteAudioDestination::isPlaying): Added.
(WebKit::RemoteAudioDestination::RemoteAudioDestination): Added.
(WebKit::RemoteAudioDestination::render): Sends a sync IPC to the WebContent process'
RemoteAudioDestinationProxy to fill the audio buffer. Note that this function gets called in audio thread.
(WebKit::RemoteAudioDestination::isPlayingDidChange): Added.
(WebKit::RemoteAudioDestinationManager): Added. This class manages all RemoteAudioDestination objects owned
by a single WebContent process.
(WebKit::RemoteAudioDestinationManager::RemoteAudioDestinationManager): Added.
(WebKit::RemoteAudioDestinationManager::~RemoteAudioDestinationManager): Added.
(WebKit::RemoteAudioDestinationManager::createAudioDestination): Added.
(WebKit::RemoteAudioDestinationManager::deleteAudioDestination): Added.
(WebKit::RemoteAudioDestinationManager::startAudioDestination): Added.
(WebKit::RemoteAudioDestinationManager::stopAudioDestination): Added.
* GPUProcess/media/RemoteAudioDestinationManager.h: Added.
(WebKit::RemoteAudioDestinationManager): Added.
(WebKit::RemoteAudioDestinationManager::didReceiveSyncMessageFromWebProcess): Added.
(WebKit::RemoteAudioDestinationManager::didReceiveMessageFromWebProcess): Added.
* GPUProcess/media/RemoteAudioDestinationManager.messages.in: Added.
* NetworkProcess/NetworkProcessPlatformStrategies.cpp:
(WebKit::NetworkProcessPlatformStrategies::createMediaStrategy): Added. Returns nullptr since Networking
process has no business running AudioDestination.
* NetworkProcess/NetworkProcessPlatformStrategies.h:
(WebKit::NetworkProcessPlatformStrategies):
* PlatformMac.cmake:
* Scripts/webkit/messages.py:
* Shared/RemoteAudioDestinationIdentifier.h: Added.
(WebKit::RemoteAudioDestinationIdentifierType): Added.
(WebKit::RemoteAudioDestinationIdentifier): Added. The identifier for each RemoteAudioDestination
and RemoteAudioDestinationProxy (corresponding objects of each class use the same ID to communicate).
* Sources.txt:
* SourcesCocoa.txt:
* WebKit.xcodeproj/project.pbxproj:
* WebProcess/GPU/media/RemoteAudioBusData.h: Added.
(WebKit::RemoteAudioBusData): Added. Encodes the information about each render call.
(WebKit::RemoteAudioBusData::encode const): Added.
(WebKit::RemoteAudioBusData::decode): Added.
* WebProcess/GPU/media/RemoteAudioDestinationProxy.cpp: Added.
(WebKit::RemoteAudioDestinationProxy): Added.
(WebKit::RemoteAudioDestinationProxy::create): Added.
(WebKit::RemoteAudioDestinationProxy::RemoteAudioDestinationProxy): Added.
(WebKit::RemoteAudioDestinationProxy::~RemoteAudioDestinationProxy): Added.
(WebKit::RemoteAudioDestinationProxy::start): Added.
(WebKit::RemoteAudioDestinationProxy::stop): Added.
(WebKit::RemoteAudioDestinationProxy::renderBuffer): Added. Calls WebCore's AudioIOCallback to fill
the audio buffer given by the GPU process.
(WebKit::RemoteAudioDestinationProxy::didChangeIsPlaying):
* WebProcess/GPU/media/RemoteAudioDestinationProxy.h: Added.
(WebKit::RemoteAudioDestinationProxy::didReceiveMessageFromGPUProcess): Added.
(WebKit::RemoteAudioDestinationProxy::isPlaying): Added.
(WebKit::RemoteAudioDestinationProxy::sampleRate): Added.
* WebProcess/GPU/media/RemoteAudioDestinationProxy.messages.in: Added.
* WebProcess/GPU/media/TextTrackPrivateRemote.cpp: Fixed the unified builds.
* WebProcess/GPU/media/TextTrackPrivateRemote.h: Ditto.
* WebProcess/GPU/media/WebMediaStrategy.cpp: Added.
(WebKit::WebMediaStrategy::createAudioDestination): Added.
* WebProcess/GPU/media/WebMediaStrategy.h: Added.
(WebKit::WebMediaStrategy): Added.
(WebKit::WebMediaStrategy::setUseGPUProcess): Added.
* WebProcess/GPU/webrtc/SampleBufferDisplayLayer.cpp: Fixed the unified builds.
* WebProcess/GPU/webrtc/SampleBufferDisplayLayerManager.cpp: Fixed the unified builds.
* WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
(WebKit::WebPlatformStrategies::createMediaStrategy): Added.
* WebProcess/WebCoreSupport/WebPlatformStrategies.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences): Sets WebMediaStrategy's flag to use GPU process.

Source/WebKitLegacy/mac:

Added WebMediaStrategy which is a wrapper around AudioDestination::create.

* WebCoreSupport/WebPlatformStrategies.h:
* WebCoreSupport/WebPlatformStrategies.mm:
(WebMediaStrategy): Added.
(WebPlatformStrategies::createMediaStrategy):

Source/WebKitLegacy/win:

Added WebMediaStrategy which is a wrapper around AudioDestination::create.

* WebCoreSupport/WebPlatformStrategies.cpp:
(WebMediaStrategy): Added.
(WebPlatformStrategies::createMediaStrategy):
* WebCoreSupport/WebPlatformStrategies.h:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (257550 => 257551)


--- trunk/Source/WebCore/ChangeLog	2020-02-27 03:18:38 UTC (rev 257550)
+++ trunk/Source/WebCore/ChangeLog	2020-02-27 03:51:17 UTC (rev 257551)
@@ -1,3 +1,23 @@
+2020-02-26  Ryosuke Niwa  <[email protected]>
+
+        Create AudioDestination in the GPU process
+        https://bugs.webkit.org/show_bug.cgi?id=208179
+
+        Reviewed by Jer Noble.
+
+        Add an abstraction around the creation of AudioDestination using newly introduced mediaStrategy.
+
+        * Headers.cmake:
+        * Modules/webaudio/DefaultAudioDestinationNode.cpp:
+        (WebCore::DefaultAudioDestinationNode::createDestination): Use MediaStrategy::createAudioDestination
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/MediaStrategy.h: Added.
+        (WebCore::MediaStrategy): Added.
+        * platform/PlatformStrategies.h:
+        (WebCore::PlatformStrategies::mediaStrategy): Added.
+        * platform/audio/AudioBus.h:
+        * platform/audio/AudioDestination.h:
+
 2020-02-26  Myles C. Maxfield  <[email protected]>
 
         [iPadOS] REGRESSION(r247667): Autosizing style changes don't invalidate RenderText's preferred logical widths

Modified: trunk/Source/WebCore/Headers.cmake (257550 => 257551)


--- trunk/Source/WebCore/Headers.cmake	2020-02-27 03:18:38 UTC (rev 257550)
+++ trunk/Source/WebCore/Headers.cmake	2020-02-27 03:51:17 UTC (rev 257551)
@@ -950,6 +950,7 @@
     platform/MIMETypeRegistry.h
     platform/MediaSample.h
     platform/MediaSelectionOption.h
+    platform/MediaStrategy.h
     platform/NotImplemented.h
     platform/OrientationNotifier.h
     platform/PODInterval.h
@@ -1021,7 +1022,12 @@
     platform/animation/AnimationUtilities.h
     platform/animation/TimingFunction.h
 
+    platform/audio/AudioArray.h
+    platform/audio/AudioBus.h
+    platform/audio/AudioChannel.h
+    platform/audio/AudioDestination.h
     platform/audio/AudioHardwareListener.h
+    platform/audio/AudioIOCallback.h
     platform/audio/AudioSession.h
     platform/audio/AudioSourceProvider.h
     platform/audio/AudioStreamDescription.h

Modified: trunk/Source/WebCore/Modules/webaudio/DefaultAudioDestinationNode.cpp (257550 => 257551)


--- trunk/Source/WebCore/Modules/webaudio/DefaultAudioDestinationNode.cpp	2020-02-27 03:18:38 UTC (rev 257550)
+++ trunk/Source/WebCore/Modules/webaudio/DefaultAudioDestinationNode.cpp	2020-02-27 03:51:17 UTC (rev 257551)
@@ -31,6 +31,8 @@
 #include "AudioContext.h"
 #include "AudioDestination.h"
 #include "Logging.h"
+#include "MediaStrategy.h"
+#include "PlatformStrategies.h"
 #include "ScriptExecutionContext.h"
 #include <wtf/IsoMallocInlines.h>
 #include <wtf/MainThread.h>
@@ -84,8 +86,8 @@
 {
     float hardwareSampleRate = AudioDestination::hardwareSampleRate();
     LOG(WebAudio, ">>>> hardwareSampleRate = %f\n", hardwareSampleRate);
-    
-    m_destination = AudioDestination::create(*this, m_inputDeviceId, m_numberOfInputChannels, channelCount(), hardwareSampleRate);
+
+    m_destination = platformStrategies()->mediaStrategy().createAudioDestination(*this, m_inputDeviceId, m_numberOfInputChannels, channelCount(), hardwareSampleRate);
 }
 
 void DefaultAudioDestinationNode::enableInput(const String& inputDeviceId)

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (257550 => 257551)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-02-27 03:18:38 UTC (rev 257550)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-02-27 03:51:17 UTC (rev 257551)
@@ -2889,6 +2889,8 @@
 		9AB1F38018E2489A00534743 /* CSSToLengthConversionData.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AB1F37E18E2489A00534743 /* CSSToLengthConversionData.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		9B02E0C8235EAD2A004044B2 /* TextManipulationController.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B02E0C3235E76AA004044B2 /* TextManipulationController.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		9B0ABCAE236BB43100B45085 /* TaskSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B0ABCAC236BB40A00B45085 /* TaskSource.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		9B1229C423FE4BD2008CA751 /* AudioDestinationCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = 413151862357745E00115E6E /* AudioDestinationCocoa.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		9B1229C723FE4D6A008CA751 /* MediaStrategy.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B1229C623FE4D5F008CA751 /* MediaStrategy.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		9B24DE8E15194B9500C59C27 /* HTMLBDIElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B24DE8C15194B9500C59C27 /* HTMLBDIElement.h */; };
 		9B27FC60234D9ADB00394A46 /* WindowEventLoop.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B27FC5E234D9ADA00394A46 /* WindowEventLoop.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		9B2D8A7914997CCF00ECEF3E /* UndoStep.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B2D8A7814997CCF00ECEF3E /* UndoStep.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -5067,10 +5069,10 @@
 		FD31603612B0267600C1A359 /* ScriptProcessorNode.h in Headers */ = {isa = PBXBuildFile; fileRef = FD315FEC12B0267600C1A359 /* ScriptProcessorNode.h */; };
 		FD31603C12B0267600C1A359 /* RealtimeAnalyser.h in Headers */ = {isa = PBXBuildFile; fileRef = FD315FF212B0267600C1A359 /* RealtimeAnalyser.h */; };
 		FD31603E12B0267600C1A359 /* AnalyserNode.h in Headers */ = {isa = PBXBuildFile; fileRef = FD315FF412B0267600C1A359 /* AnalyserNode.h */; };
-		FD31607A12B026F700C1A359 /* AudioArray.h in Headers */ = {isa = PBXBuildFile; fileRef = FD31604412B026F700C1A359 /* AudioArray.h */; };
-		FD31607C12B026F700C1A359 /* AudioBus.h in Headers */ = {isa = PBXBuildFile; fileRef = FD31604612B026F700C1A359 /* AudioBus.h */; };
-		FD31607E12B026F700C1A359 /* AudioChannel.h in Headers */ = {isa = PBXBuildFile; fileRef = FD31604812B026F700C1A359 /* AudioChannel.h */; };
-		FD31607F12B026F700C1A359 /* AudioDestination.h in Headers */ = {isa = PBXBuildFile; fileRef = FD31604912B026F700C1A359 /* AudioDestination.h */; };
+		FD31607A12B026F700C1A359 /* AudioArray.h in Headers */ = {isa = PBXBuildFile; fileRef = FD31604412B026F700C1A359 /* AudioArray.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		FD31607C12B026F700C1A359 /* AudioBus.h in Headers */ = {isa = PBXBuildFile; fileRef = FD31604612B026F700C1A359 /* AudioBus.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		FD31607E12B026F700C1A359 /* AudioChannel.h in Headers */ = {isa = PBXBuildFile; fileRef = FD31604812B026F700C1A359 /* AudioChannel.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		FD31607F12B026F700C1A359 /* AudioDestination.h in Headers */ = {isa = PBXBuildFile; fileRef = FD31604912B026F700C1A359 /* AudioDestination.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		FD31608012B026F700C1A359 /* AudioDSPKernel.h in Headers */ = {isa = PBXBuildFile; fileRef = FD31604A12B026F700C1A359 /* AudioDSPKernel.h */; };
 		FD31608212B026F700C1A359 /* AudioDSPKernelProcessor.h in Headers */ = {isa = PBXBuildFile; fileRef = FD31604C12B026F700C1A359 /* AudioDSPKernelProcessor.h */; };
 		FD31608312B026F700C1A359 /* AudioFileReader.h in Headers */ = {isa = PBXBuildFile; fileRef = FD31604D12B026F700C1A359 /* AudioFileReader.h */; };
@@ -5148,7 +5150,7 @@
 		FDB1700614A2BAB200A2B5D9 /* MultiChannelResampler.h in Headers */ = {isa = PBXBuildFile; fileRef = FDB1700414A2BAB200A2B5D9 /* MultiChannelResampler.h */; };
 		FDBD480D159BC6870093EB4F /* JSMediaStreamAudioSourceNode.h in Headers */ = {isa = PBXBuildFile; fileRef = FDBD480B159BC6870093EB4F /* JSMediaStreamAudioSourceNode.h */; };
 		FDC54F051399B0DA008D9117 /* BiquadFilterNode.h in Headers */ = {isa = PBXBuildFile; fileRef = FDC54F021399B0DA008D9117 /* BiquadFilterNode.h */; };
-		FDE2D55B159E66EB00DCCCF8 /* AudioIOCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = FDE2D55A159E66EB00DCCCF8 /* AudioIOCallback.h */; };
+		FDE2D55B159E66EB00DCCCF8 /* AudioIOCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = FDE2D55A159E66EB00DCCCF8 /* AudioIOCallback.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		FDEA6243152102E200479DF0 /* JSOscillatorNode.h in Headers */ = {isa = PBXBuildFile; fileRef = FDEA6241152102E200479DF0 /* JSOscillatorNode.h */; };
 		FDEA6247152102FC00479DF0 /* JSPeriodicWave.h in Headers */ = {isa = PBXBuildFile; fileRef = FDEA6245152102FC00479DF0 /* JSPeriodicWave.h */; };
 		FDF09DC91399B62200688E5B /* JSBiquadFilterNode.h in Headers */ = {isa = PBXBuildFile; fileRef = FDF09DC71399B62200688E5B /* JSBiquadFilterNode.h */; };
@@ -11203,6 +11205,7 @@
 		9B0ABCA423679ACF00B45085 /* WorkerEventLoop.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WorkerEventLoop.h; sourceTree = "<group>"; };
 		9B0ABCAC236BB40A00B45085 /* TaskSource.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TaskSource.h; sourceTree = "<group>"; };
 		9B0FE8731D9E02DF004A8ACB /* DocumentOrShadowRoot.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DocumentOrShadowRoot.idl; sourceTree = "<group>"; };
+		9B1229C623FE4D5F008CA751 /* MediaStrategy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MediaStrategy.h; sourceTree = "<group>"; };
 		9B13257B1F3D2ABA00DAAB69 /* DataTransferItemList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DataTransferItemList.cpp; sourceTree = "<group>"; };
 		9B19B67E1B964E5200348745 /* ShadowRoot.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ShadowRoot.idl; sourceTree = "<group>"; };
 		9B1AB0791648C69D0051F3F2 /* HTMLFormControlsCollection.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = HTMLFormControlsCollection.idl; sourceTree = "<group>"; };
@@ -25931,6 +25934,7 @@
 				CDF2B003181F059C00F2B424 /* MediaDescription.h */,
 				CD641EC7181ED60100EE4C41 /* MediaSample.h */,
 				A17D275D1EAC579800BF01E7 /* MediaSelectionOption.h */,
+				9B1229C623FE4D5F008CA751 /* MediaStrategy.h */,
 				BC772C4C0C4EB3040083285F /* MIMETypeRegistry.cpp */,
 				BC772C4D0C4EB3040083285F /* MIMETypeRegistry.h */,
 				E1513D501677F08800149FCB /* NotImplemented.cpp */,
@@ -29056,6 +29060,7 @@
 				FD31607E12B026F700C1A359 /* AudioChannel.h in Headers */,
 				FD31600512B0267600C1A359 /* AudioContext.h in Headers */,
 				FD31607F12B026F700C1A359 /* AudioDestination.h in Headers */,
+				9B1229C423FE4BD2008CA751 /* AudioDestinationCocoa.h in Headers */,
 				FD3160BD12B0272A00C1A359 /* AudioDestinationMac.h in Headers */,
 				FD31600812B0267600C1A359 /* AudioDestinationNode.h in Headers */,
 				FD31608012B026F700C1A359 /* AudioDSPKernel.h in Headers */,
@@ -31489,6 +31494,7 @@
 				CD641EB31818F5ED00EE4C41 /* MediaSourcePrivate.h in Headers */,
 				CDC8B5A7180474F70016E685 /* MediaSourcePrivateAVFObjC.h in Headers */,
 				CDDC1E7A18A952F30027A9D4 /* MediaSourcePrivateClient.h in Headers */,
+				9B1229C723FE4D6A008CA751 /* MediaStrategy.h in Headers */,
 				078E091517D14D1C00420AA1 /* MediaStream.h in Headers */,
 				078E094C17D1709600420AA1 /* MediaStreamAudioDestinationNode.h in Headers */,
 				0783228518013ED800999E0C /* MediaStreamAudioSource.h in Headers */,

Added: trunk/Source/WebCore/platform/MediaStrategy.h (0 => 257551)


--- trunk/Source/WebCore/platform/MediaStrategy.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/MediaStrategy.h	2020-02-27 03:51:17 UTC (rev 257551)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2020 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
+
+#include <wtf/Forward.h>
+
+namespace WebCore {
+
+class AudioDestination;
+class AudioIOCallback;
+
+class WEBCORE_EXPORT MediaStrategy {
+public:
+#if ENABLE(WEB_AUDIO)
+    virtual std::unique_ptr<AudioDestination> createAudioDestination(
+        AudioIOCallback&, const String& inputDeviceId, unsigned numberOfInputChannels, unsigned numberOfOutputChannels, float sampleRate) = 0;
+#endif
+protected:
+    virtual ~MediaStrategy() = default;
+};
+
+} // namespace WebCore

Modified: trunk/Source/WebCore/platform/PlatformStrategies.h (257550 => 257551)


--- trunk/Source/WebCore/platform/PlatformStrategies.h	2020-02-27 03:18:38 UTC (rev 257550)
+++ trunk/Source/WebCore/platform/PlatformStrategies.h	2020-02-27 03:51:17 UTC (rev 257551)
@@ -29,6 +29,7 @@
 
 class BlobRegistry;
 class LoaderStrategy;
+class MediaStrategy;
 class PasteboardStrategy;
 
 class PlatformStrategies {
@@ -39,7 +40,7 @@
             m_loaderStrategy = createLoaderStrategy();
         return m_loaderStrategy;
     }
-    
+
     PasteboardStrategy* pasteboardStrategy()
     {
         if (!m_pasteboardStrategy)
@@ -47,6 +48,13 @@
         return m_pasteboardStrategy;
     }
 
+    MediaStrategy& mediaStrategy()
+    {
+        if (!m_mediaStrategy)
+            m_mediaStrategy = createMediaStrategy();
+        return *m_mediaStrategy;
+    }
+
     BlobRegistry* blobRegistry()
     {
         if (!m_blobRegistry)
@@ -64,10 +72,12 @@
 private:
     virtual LoaderStrategy* createLoaderStrategy() = 0;
     virtual PasteboardStrategy* createPasteboardStrategy() = 0;
+    virtual MediaStrategy* createMediaStrategy() = 0;
     virtual BlobRegistry* createBlobRegistry() = 0;
 
     LoaderStrategy* m_loaderStrategy { };
     PasteboardStrategy* m_pasteboardStrategy { };
+    MediaStrategy* m_mediaStrategy { };
     BlobRegistry* m_blobRegistry { };
 };
 

Modified: trunk/Source/WebCore/platform/audio/AudioBus.h (257550 => 257551)


--- trunk/Source/WebCore/platform/audio/AudioBus.h	2020-02-27 03:18:38 UTC (rev 257550)
+++ trunk/Source/WebCore/platform/audio/AudioBus.h	2020-02-27 03:51:17 UTC (rev 257551)
@@ -66,10 +66,10 @@
     // allocate indicates whether or not to initially have the AudioChannels created with managed storage.
     // Normal usage is to pass true here, in which case the AudioChannels will memory-manage their own storage.
     // If allocate is false then setChannelMemory() has to be called later on for each channel before the AudioBus is useable...
-    static RefPtr<AudioBus> create(unsigned numberOfChannels, size_t length, bool allocate = true);
+    WEBCORE_EXPORT static RefPtr<AudioBus> create(unsigned numberOfChannels, size_t length, bool allocate = true);
 
     // Tells the given channel to use an externally allocated buffer.
-    void setChannelMemory(unsigned channelIndex, float* storage, size_t length);
+    WEBCORE_EXPORT void setChannelMemory(unsigned channelIndex, float* storage, size_t length);
 
     // Channels
     unsigned numberOfChannels() const { return m_channels.size(); }
@@ -126,7 +126,7 @@
 
     // Copies the samples from the source bus to this one.
     // This is just a simple per-channel copy if the number of channels match, otherwise an up-mix or down-mix is done.
-    void copyFrom(const AudioBus& sourceBus, ChannelInterpretation = Speakers);
+    WEBCORE_EXPORT void copyFrom(const AudioBus& sourceBus, ChannelInterpretation = Speakers);
 
     // Sums the samples from the source bus to this one.
     // This is just a simple per-channel summing if the number of channels match, otherwise an up-mix or down-mix is done.

Modified: trunk/Source/WebCore/platform/audio/AudioDestination.h (257550 => 257551)


--- trunk/Source/WebCore/platform/audio/AudioDestination.h	2020-02-27 03:18:38 UTC (rev 257550)
+++ trunk/Source/WebCore/platform/audio/AudioDestination.h	2020-02-27 03:51:17 UTC (rev 257551)
@@ -45,7 +45,7 @@
 public:
     // Pass in (numberOfInputChannels > 0) if live/local audio input is desired.
     // Port-specific device identification information for live/local input streams can be passed in the inputDeviceId.
-    static std::unique_ptr<AudioDestination> create(AudioIOCallback&, const String& inputDeviceId, unsigned numberOfInputChannels, unsigned numberOfOutputChannels, float sampleRate);
+    WEBCORE_EXPORT static std::unique_ptr<AudioDestination> create(AudioIOCallback&, const String& inputDeviceId, unsigned numberOfInputChannels, unsigned numberOfOutputChannels, float sampleRate);
 
     virtual ~AudioDestination() = default;
 

Modified: trunk/Source/WebKit/ChangeLog (257550 => 257551)


--- trunk/Source/WebKit/ChangeLog	2020-02-27 03:18:38 UTC (rev 257550)
+++ trunk/Source/WebKit/ChangeLog	2020-02-27 03:51:17 UTC (rev 257551)
@@ -1,3 +1,114 @@
+2020-02-26  Ryosuke Niwa  <[email protected]>
+
+        Create AudioDestination in the GPU process
+        https://bugs.webkit.org/show_bug.cgi?id=208179
+
+        Reviewed by Jer Noble.
+
+        Create AudioDestination in the GPU process instead of the WebContent process for WebAudio API when
+        the Media-in-GPU-process feature is enabled.
+
+        To do this, WebMediaStrategy, a concrete implementation of MediaStrategy, in the WebContent process gets
+        a boolean flag indicating whether the GPU process should be used for AudioDestination or not. When the flag
+        is set, we create RemoteAudioDestinationProxy instead of AudioDestination in WebContent process.
+
+        Each RemoteAudioDestinationProxy talks to RemoteAudioDestinationManager in the GPU process and creates
+        a corresponding RemoteAudioDestination which in turn creates WebCore's AudioDestination in the GPU process.
+
+        RemoteAudioDestination is itself an AudioIOCallback for AudioDestination it creates, and delegates
+        its callback to WebContent process' RemoteAudioDestinationProxy as needed.
+
+        In this initial patch, we send RemoteAudioDestinationProxy::RenderBuffer IPC call to the WebContent process
+        for each render call we get from CoreAudio for simplicity using newly introduced RemoteAudioBusData,
+        which holds a SharedMemory for each channel in the audio bus.
+
+        We will eliminate this IPC overhead in a follow up patch using CARingBuffer.
+
+        * DerivedSources-input.xcfilelist:
+        * DerivedSources-output.xcfilelist:
+        * DerivedSources.make:
+        * GPUProcess/GPUConnectionToWebProcess.cpp:
+        (WebKit::GPUConnectionToWebProcess::remoteAudioDestinationManager): Added.
+        (WebKit::GPUConnectionToWebProcess::didReceiveMessage): Added the code to dispatch messages to
+        RemoteAudioDestinationManager.
+        (WebKit::GPUConnectionToWebProcess::didReceiveSyncMessage): Ditto.
+        * GPUProcess/GPUConnectionToWebProcess.h:
+        * GPUProcess/media/RemoteAudioDestinationManager.cpp: Added.
+        (WebKit::RemoteAudioDestination): Added. This class is the backing object which creates WebCore's
+        AudioDestination and actually talks to CoreAudio in GPU process.
+        (WebKit::RemoteAudioDestination::create): Added.
+
+        (WebKit::RemoteAudioDestination::~RemoteAudioDestination): Added.
+        (WebKit::RemoteAudioDestination::scheduleGracefulShutdownIfNeeded): Delays the deletion of this object
+        until the audio threads stops running.
+        (WebKit::RemoteAudioDestination::start): Added.
+        (WebKit::RemoteAudioDestination::stop): Added.
+        (WebKit::RemoteAudioDestination::isPlaying): Added.
+        (WebKit::RemoteAudioDestination::RemoteAudioDestination): Added.
+        (WebKit::RemoteAudioDestination::render): Sends a sync IPC to the WebContent process'
+        RemoteAudioDestinationProxy to fill the audio buffer. Note that this function gets called in audio thread.
+        (WebKit::RemoteAudioDestination::isPlayingDidChange): Added.
+        (WebKit::RemoteAudioDestinationManager): Added. This class manages all RemoteAudioDestination objects owned
+        by a single WebContent process.
+        (WebKit::RemoteAudioDestinationManager::RemoteAudioDestinationManager): Added.
+        (WebKit::RemoteAudioDestinationManager::~RemoteAudioDestinationManager): Added.
+        (WebKit::RemoteAudioDestinationManager::createAudioDestination): Added.
+        (WebKit::RemoteAudioDestinationManager::deleteAudioDestination): Added.
+        (WebKit::RemoteAudioDestinationManager::startAudioDestination): Added.
+        (WebKit::RemoteAudioDestinationManager::stopAudioDestination): Added.
+        * GPUProcess/media/RemoteAudioDestinationManager.h: Added.
+        (WebKit::RemoteAudioDestinationManager): Added.
+        (WebKit::RemoteAudioDestinationManager::didReceiveSyncMessageFromWebProcess): Added.
+        (WebKit::RemoteAudioDestinationManager::didReceiveMessageFromWebProcess): Added.
+        * GPUProcess/media/RemoteAudioDestinationManager.messages.in: Added.
+        * NetworkProcess/NetworkProcessPlatformStrategies.cpp:
+        (WebKit::NetworkProcessPlatformStrategies::createMediaStrategy): Added. Returns nullptr since Networking
+        process has no business running AudioDestination.
+        * NetworkProcess/NetworkProcessPlatformStrategies.h:
+        (WebKit::NetworkProcessPlatformStrategies):
+        * PlatformMac.cmake:
+        * Scripts/webkit/messages.py:
+        * Shared/RemoteAudioDestinationIdentifier.h: Added.
+        (WebKit::RemoteAudioDestinationIdentifierType): Added.
+        (WebKit::RemoteAudioDestinationIdentifier): Added. The identifier for each RemoteAudioDestination
+        and RemoteAudioDestinationProxy (corresponding objects of each class use the same ID to communicate).
+        * Sources.txt:
+        * SourcesCocoa.txt:
+        * WebKit.xcodeproj/project.pbxproj:
+        * WebProcess/GPU/media/RemoteAudioBusData.h: Added.
+        (WebKit::RemoteAudioBusData): Added. Encodes the information about each render call.
+        (WebKit::RemoteAudioBusData::encode const): Added.
+        (WebKit::RemoteAudioBusData::decode): Added.
+        * WebProcess/GPU/media/RemoteAudioDestinationProxy.cpp: Added.
+        (WebKit::RemoteAudioDestinationProxy): Added.
+        (WebKit::RemoteAudioDestinationProxy::create): Added.
+        (WebKit::RemoteAudioDestinationProxy::RemoteAudioDestinationProxy): Added.
+        (WebKit::RemoteAudioDestinationProxy::~RemoteAudioDestinationProxy): Added.
+        (WebKit::RemoteAudioDestinationProxy::start): Added.
+        (WebKit::RemoteAudioDestinationProxy::stop): Added.
+        (WebKit::RemoteAudioDestinationProxy::renderBuffer): Added. Calls WebCore's AudioIOCallback to fill
+        the audio buffer given by the GPU process.
+        (WebKit::RemoteAudioDestinationProxy::didChangeIsPlaying):
+        * WebProcess/GPU/media/RemoteAudioDestinationProxy.h: Added.
+        (WebKit::RemoteAudioDestinationProxy::didReceiveMessageFromGPUProcess): Added.
+        (WebKit::RemoteAudioDestinationProxy::isPlaying): Added.
+        (WebKit::RemoteAudioDestinationProxy::sampleRate): Added.
+        * WebProcess/GPU/media/RemoteAudioDestinationProxy.messages.in: Added.
+        * WebProcess/GPU/media/TextTrackPrivateRemote.cpp: Fixed the unified builds.
+        * WebProcess/GPU/media/TextTrackPrivateRemote.h: Ditto.
+        * WebProcess/GPU/media/WebMediaStrategy.cpp: Added.
+        (WebKit::WebMediaStrategy::createAudioDestination): Added.
+        * WebProcess/GPU/media/WebMediaStrategy.h: Added.
+        (WebKit::WebMediaStrategy): Added.
+        (WebKit::WebMediaStrategy::setUseGPUProcess): Added.
+        * WebProcess/GPU/webrtc/SampleBufferDisplayLayer.cpp: Fixed the unified builds.
+        * WebProcess/GPU/webrtc/SampleBufferDisplayLayerManager.cpp: Fixed the unified builds.
+        * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
+        (WebKit::WebPlatformStrategies::createMediaStrategy): Added.
+        * WebProcess/WebCoreSupport/WebPlatformStrategies.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::updatePreferences): Sets WebMediaStrategy's flag to use GPU process.
+
 2020-02-26  Said Abou-Hallawa  <[email protected]>
 
         Implement the remote RenderingBackend

Modified: trunk/Source/WebKit/DerivedSources-input.xcfilelist (257550 => 257551)


--- trunk/Source/WebKit/DerivedSources-input.xcfilelist	2020-02-27 03:18:38 UTC (rev 257550)
+++ trunk/Source/WebKit/DerivedSources-input.xcfilelist	2020-02-27 03:51:17 UTC (rev 257551)
@@ -17,6 +17,7 @@
 $(PROJECT_DIR)/GPUProcess/GPUProcess.messages.in
 $(PROJECT_DIR)/GPUProcess/graphics/RemoteRenderingBackendProxy.messages.in
 $(PROJECT_DIR)/GPUProcess/mac/com.apple.WebKit.GPUProcess.sb.in
+$(PROJECT_DIR)/GPUProcess/media/RemoteAudioDestinationManager.messages.in
 $(PROJECT_DIR)/GPUProcess/media/RemoteMediaPlayerManagerProxy.messages.in
 $(PROJECT_DIR)/GPUProcess/media/RemoteMediaPlayerProxy.messages.in
 $(PROJECT_DIR)/GPUProcess/media/RemoteMediaResourceManager.messages.in
@@ -110,6 +111,7 @@
 $(PROJECT_DIR)/WebProcess/GPU/GPUProcessConnection.messages.in
 $(PROJECT_DIR)/WebProcess/GPU/graphics/RemoteRenderingBackend.messages.in
 $(PROJECT_DIR)/WebProcess/GPU/media/MediaPlayerPrivateRemote.messages.in
+$(PROJECT_DIR)/WebProcess/GPU/media/RemoteAudioDestinationProxy.messages.in
 $(PROJECT_DIR)/WebProcess/GPU/media/RemoteMediaPlayerManager.messages.in
 $(PROJECT_DIR)/WebProcess/GPU/media/TextTrackPrivateRemote.messages.in
 $(PROJECT_DIR)/WebProcess/GPU/webrtc/LibWebRTCCodecs.messages.in

Modified: trunk/Source/WebKit/DerivedSources-output.xcfilelist (257550 => 257551)


--- trunk/Source/WebKit/DerivedSources-output.xcfilelist	2020-02-27 03:18:38 UTC (rev 257550)
+++ trunk/Source/WebKit/DerivedSources-output.xcfilelist	2020-02-27 03:51:17 UTC (rev 257551)
@@ -123,6 +123,14 @@
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/PluginProxyMessageReceiver.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/PluginProxyMessages.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/PluginProxyMessagesReplies.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteAudioDestinationManagerMessageReceiver.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteAudioDestinationManagerMessages.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteAudioDestinationManagerMessages.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteAudioDestinationManagerMessagesReplies.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteAudioDestinationProxyMessageReceiver.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteAudioDestinationProxyMessages.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteAudioDestinationProxyMessages.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteAudioDestinationProxyMessagesReplies.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteAudioMediaStreamTrackRendererManagerMessageReceiver.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteAudioMediaStreamTrackRendererManagerMessages.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteAudioMediaStreamTrackRendererManagerMessagesReplies.h

Modified: trunk/Source/WebKit/DerivedSources.make (257550 => 257551)


--- trunk/Source/WebKit/DerivedSources.make	2020-02-27 03:18:38 UTC (rev 257550)
+++ trunk/Source/WebKit/DerivedSources.make	2020-02-27 03:51:17 UTC (rev 257551)
@@ -146,6 +146,8 @@
     PluginProcessConnectionManager \
     PluginProcessProxy \
     PluginProxy \
+    RemoteAudioDestinationManager \
+    RemoteAudioDestinationProxy \
     RemoteAudioMediaStreamTrackRendererManager \
     RemoteAudioMediaStreamTrackRenderer \
     RemoteLayerTreeDrawingAreaProxy \

Modified: trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp (257550 => 257551)


--- trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp	2020-02-27 03:18:38 UTC (rev 257550)
+++ trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp	2020-02-27 03:51:17 UTC (rev 257551)
@@ -36,6 +36,8 @@
 #include "LibWebRTCCodecsProxy.h"
 #include "LibWebRTCCodecsProxyMessages.h"
 #include "Logging.h"
+#include "RemoteAudioDestinationManager.h"
+#include "RemoteAudioDestinationManagerMessages.h"
 #include "RemoteAudioMediaStreamTrackRendererManager.h"
 #include "RemoteAudioMediaStreamTrackRendererManagerMessages.h"
 #include "RemoteAudioMediaStreamTrackRendererMessages.h"
@@ -127,6 +129,14 @@
     CRASH();
 }
 
+RemoteAudioDestinationManager& GPUConnectionToWebProcess::remoteAudioDestinationManager()
+{
+    if (!m_remoteAudioDestinationManager)
+        m_remoteAudioDestinationManager = makeUnique<RemoteAudioDestinationManager>(*this);
+
+    return *m_remoteAudioDestinationManager;
+}
+
 RemoteMediaResourceManager& GPUConnectionToWebProcess::remoteMediaResourceManager()
 {
     if (!m_remoteMediaResourceManager)
@@ -205,6 +215,10 @@
 
 bool GPUConnectionToWebProcess::dispatchMessage(IPC::Connection& connection, IPC::Decoder& decoder)
 {
+    if (decoder.messageReceiverName() == Messages::RemoteAudioDestinationManager::messageReceiverName()) {
+        remoteAudioDestinationManager().didReceiveMessageFromWebProcess(connection, decoder);
+        return true;
+    }
     if (decoder.messageReceiverName() == Messages::RemoteMediaPlayerManagerProxy::messageReceiverName()) {
         remoteMediaPlayerManagerProxy().didReceiveMessageFromWebProcess(connection, decoder);
         return true;
@@ -260,6 +274,10 @@
 
 bool GPUConnectionToWebProcess::dispatchSyncMessage(IPC::Connection& connection, IPC::Decoder& decoder, std::unique_ptr<IPC::Encoder>& replyEncoder)
 {
+    if (decoder.messageReceiverName() == Messages::RemoteAudioDestinationManager::messageReceiverName()) {
+        remoteAudioDestinationManager().didReceiveSyncMessageFromWebProcess(connection, decoder, replyEncoder);
+        return true;
+    }
     if (decoder.messageReceiverName() == Messages::RemoteMediaPlayerManagerProxy::messageReceiverName()) {
         remoteMediaPlayerManagerProxy().didReceiveSyncMessageFromWebProcess(connection, decoder, replyEncoder);
         return true;

Modified: trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h (257550 => 257551)


--- trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h	2020-02-27 03:18:38 UTC (rev 257550)
+++ trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h	2020-02-27 03:51:17 UTC (rev 257551)
@@ -46,6 +46,7 @@
 
 class GPUProcess;
 class LibWebRTCCodecsProxy;
+class RemoteAudioDestinationManager;
 class RemoteAudioMediaStreamTrackRendererManager;
 class RemoteMediaPlayerManagerProxy;
 class RemoteMediaRecorderManager;
@@ -87,6 +88,7 @@
 private:
     GPUConnectionToWebProcess(GPUProcess&, WebCore::ProcessIdentifier, IPC::Connection::Identifier, PAL::SessionID);
 
+    RemoteAudioDestinationManager& remoteAudioDestinationManager();
     RemoteMediaPlayerManagerProxy& remoteMediaPlayerManagerProxy();
 #if PLATFORM(COCOA) && USE(LIBWEBRTC)
     LibWebRTCCodecsProxy& libWebRTCCodecsProxy();
@@ -117,6 +119,7 @@
     IPC::MessageReceiverMap m_messageReceiverMap;
     Ref<GPUProcess> m_gpuProcess;
     const WebCore::ProcessIdentifier m_webProcessIdentifier;
+    std::unique_ptr<RemoteAudioDestinationManager> m_remoteAudioDestinationManager;
     std::unique_ptr<RemoteMediaResourceManager> m_remoteMediaResourceManager;
     std::unique_ptr<RemoteMediaPlayerManagerProxy> m_remoteMediaPlayerManagerProxy;
     PAL::SessionID m_sessionID;

Added: trunk/Source/WebKit/GPUProcess/media/RemoteAudioDestinationManager.cpp (0 => 257551)


--- trunk/Source/WebKit/GPUProcess/media/RemoteAudioDestinationManager.cpp	                        (rev 0)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteAudioDestinationManager.cpp	2020-02-27 03:51:17 UTC (rev 257551)
@@ -0,0 +1,177 @@
+/*
+ * Copyright (C) 2020 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 "RemoteAudioDestinationManager.h"
+
+#if ENABLE(GPU_PROCESS)
+
+#include "GPUConnectionToWebProcess.h"
+#include "RemoteAudioBusData.h"
+#include "RemoteAudioDestinationProxyMessages.h"
+#include "SharedMemory.h"
+#include <WebCore/AudioBus.h>
+#include <WebCore/AudioDestination.h>
+#include <WebCore/AudioIOCallback.h>
+#include <WebCore/SharedBuffer.h>
+#include <wtf/ThreadSafeRefCounted.h>
+#include <wtf/threads/BinarySemaphore.h>
+
+namespace WebKit {
+
+class RemoteAudioDestination : public ThreadSafeRefCounted<RemoteAudioDestination>, public WebCore::AudioIOCallback {
+public:
+    using AudioBus = WebCore::AudioBus;
+    using AudioDestination = WebCore::AudioDestination;
+    using SharedBuffer = WebCore::SharedBuffer;
+
+    static Ref<RemoteAudioDestination> create(GPUConnectionToWebProcess& connection, RemoteAudioDestinationIdentifier id,
+        const String& inputDeviceId, uint32_t numberOfInputChannels, uint32_t numberOfOutputChannels, float sampleRate)
+    {
+        return adoptRef(*new RemoteAudioDestination(connection, id, inputDeviceId, numberOfInputChannels, numberOfOutputChannels, sampleRate));
+    }
+
+    virtual ~RemoteAudioDestination()
+    {
+        RELEASE_ASSERT(!m_destination->isPlaying());
+    }
+
+    void scheduleGracefulShutdownIfNeeded()
+    {
+        if (!isPlaying())
+            return;
+        m_protectThisDuringGracefulShutdown = this;
+        stop();
+    }
+
+    void start() { m_destination->start(); }
+    void stop() { m_destination->stop(); }
+    bool isPlaying() { return m_destination->isPlaying(); }
+
+private:
+    RemoteAudioDestination(GPUConnectionToWebProcess& connection, RemoteAudioDestinationIdentifier id, const String& inputDeviceId, uint32_t numberOfInputChannels, uint32_t numberOfOutputChannels, float sampleRate)
+        : m_connection(connection)
+        , m_id(id)
+        , m_destination(AudioDestination::create(*this, inputDeviceId, numberOfInputChannels, numberOfOutputChannels, sampleRate))
+    {
+    }
+
+    void render(AudioBus* sourceBus, AudioBus* destinationBus, size_t framesToProcess) override
+    {
+        if (m_protectThisDuringGracefulShutdown)
+            return;
+
+        auto protectedThis = makeRef(*this);
+        BinarySemaphore renderSemaphore;
+
+        Vector<Ref<SharedMemory>> buffers;
+        for (unsigned i = 0; i < destinationBus->numberOfChannels(); ++i) {
+            auto memory = SharedMemory::allocate(sizeof(float) * framesToProcess);
+            buffers.append(*memory);
+        }
+
+        // FIXME: Replace this code with a ring buffer. At least this happens in audio thread.
+        ASSERT(!isMainThread());
+        callOnMainThread([this, framesToProcess, &buffers, &renderSemaphore] {
+            RemoteAudioBusData busData { framesToProcess, buffers.map([](auto& memory) { return memory.copyRef(); }) };
+            ASSERT(framesToProcess);
+            m_connection.connection().sendWithAsyncReply(Messages::RemoteAudioDestinationProxy::RenderBuffer(busData), [&]() {
+                renderSemaphore.signal();
+            }, m_id.toUInt64());
+        });
+        renderSemaphore.wait();
+
+        auto audioBus = AudioBus::create(buffers.size(), framesToProcess, false);
+        for (unsigned i = 0; i < buffers.size(); ++i)
+            audioBus->setChannelMemory(i, (float*)buffers[i]->data(), framesToProcess);
+        destinationBus->copyFrom(*audioBus);
+    }
+
+    void isPlayingDidChange() override
+    {
+        if (m_protectThisDuringGracefulShutdown) {
+            RELEASE_ASSERT(!m_destination->isPlaying());
+            RELEASE_ASSERT(refCount() == 1);
+            m_protectThisDuringGracefulShutdown = nullptr; // Deletes "this".
+            return;
+        }
+        callOnMainThread([this, protectedThis = makeRef(*this), isPlaying = m_destination->isPlaying(), id = m_id.toUInt64()] {
+            m_connection.connection().send(Messages::RemoteAudioDestinationProxy::DidChangeIsPlaying(isPlaying), id);
+        });
+    }
+
+    GPUConnectionToWebProcess& m_connection;
+    RemoteAudioDestinationIdentifier m_id;
+    std::unique_ptr<AudioDestination> m_destination;
+    RefPtr<RemoteAudioDestination> m_protectThisDuringGracefulShutdown;
+};
+
+RemoteAudioDestinationManager::RemoteAudioDestinationManager(GPUConnectionToWebProcess& connection)
+    : m_gpuConnectionToWebProcess(connection)
+{
+}
+
+RemoteAudioDestinationManager::~RemoteAudioDestinationManager() = default;
+
+void RemoteAudioDestinationManager::createAudioDestination(const String& inputDeviceId, uint32_t numberOfInputChannels, uint32_t numberOfOutputChannels, float sampleRate,
+    CompletionHandler<void(RemoteAudioDestinationIdentifier)>&& completionHandler)
+{
+    auto newID = RemoteAudioDestinationIdentifier::generateThreadSafe();
+    auto callback = RemoteAudioDestination::create(m_gpuConnectionToWebProcess, newID, inputDeviceId, numberOfInputChannels, numberOfOutputChannels, sampleRate);
+    m_audioDestinations.add(newID, WTFMove(callback));
+    completionHandler(newID);
+}
+
+void RemoteAudioDestinationManager::deleteAudioDestination(RemoteAudioDestinationIdentifier id, CompletionHandler<void()>&& completionHandler)
+{
+    auto destination = m_audioDestinations.take(id);
+    if (destination)
+        destination.value()->scheduleGracefulShutdownIfNeeded();
+    completionHandler();
+}
+
+void RemoteAudioDestinationManager::startAudioDestination(RemoteAudioDestinationIdentifier id, CompletionHandler<void(bool)>&& completionHandler)
+{
+    bool isPlaying = false;
+    if (auto* item = m_audioDestinations.get(id)) {
+        item->start();
+        isPlaying = item->isPlaying();
+    }
+    completionHandler(isPlaying);
+}
+
+void RemoteAudioDestinationManager::stopAudioDestination(RemoteAudioDestinationIdentifier id, CompletionHandler<void(bool)>&& completionHandler)
+{
+    bool isPlaying = false;
+    if (auto* item = m_audioDestinations.get(id)) {
+        item->stop();
+        isPlaying = item->isPlaying();
+    }
+    completionHandler(isPlaying);
+}
+
+} // namespace WebKit
+
+#endif

Added: trunk/Source/WebKit/GPUProcess/media/RemoteAudioDestinationManager.h (0 => 257551)


--- trunk/Source/WebKit/GPUProcess/media/RemoteAudioDestinationManager.h	                        (rev 0)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteAudioDestinationManager.h	2020-02-27 03:51:17 UTC (rev 257551)
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2020 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 ENABLE(GPU_PROCESS)
+
+#include "Connection.h"
+#include "RemoteAudioDestinationIdentifier.h"
+#include "SharedMemory.h"
+#include <memory>
+#include <wtf/CompletionHandler.h>
+#include <wtf/HashMap.h>
+
+namespace WebKit {
+
+class GPUConnectionToWebProcess;
+class RemoteAudioDestination;
+
+class RemoteAudioDestinationManager : private IPC::MessageReceiver {
+    WTF_MAKE_FAST_ALLOCATED;
+    WTF_MAKE_NONCOPYABLE(RemoteAudioDestinationManager);
+public:
+    RemoteAudioDestinationManager(GPUConnectionToWebProcess&);
+    ~RemoteAudioDestinationManager();
+
+    void createAudioDestination(const String& inputDeviceId, uint32_t numberOfInputChannels, uint32_t numberOfOutputChannels, float sampleRate, CompletionHandler<void(RemoteAudioDestinationIdentifier)>&&);
+    void deleteAudioDestination(RemoteAudioDestinationIdentifier, CompletionHandler<void()>&&);
+    void startAudioDestination(RemoteAudioDestinationIdentifier, CompletionHandler<void(bool)>&&);
+    void stopAudioDestination(RemoteAudioDestinationIdentifier, CompletionHandler<void(bool)>&&);
+
+    void didReceiveSyncMessageFromWebProcess(IPC::Connection& connection, IPC::Decoder& decoder, std::unique_ptr<IPC::Encoder>& encoder)
+    {
+        didReceiveSyncMessage(connection, decoder, encoder);
+    }
+    void didReceiveMessageFromWebProcess(IPC::Connection& connection, IPC::Decoder& decoder) { didReceiveMessage(connection, decoder); }
+
+private:
+    void didReceiveMessage(IPC::Connection&, IPC::Decoder&);
+    void didReceiveSyncMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&);
+
+    HashMap<RemoteAudioDestinationIdentifier, Ref<RemoteAudioDestination>> m_audioDestinations;
+    GPUConnectionToWebProcess& m_gpuConnectionToWebProcess;
+};
+
+} // namespace WebCore;
+
+#endif

Added: trunk/Source/WebKit/GPUProcess/media/RemoteAudioDestinationManager.messages.in (0 => 257551)


--- trunk/Source/WebKit/GPUProcess/media/RemoteAudioDestinationManager.messages.in	                        (rev 0)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteAudioDestinationManager.messages.in	2020-02-27 03:51:17 UTC (rev 257551)
@@ -0,0 +1,37 @@
+# Copyright (C) 2020 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.
+
+#if ENABLE(GPU_PROCESS)
+
+messages -> RemoteAudioDestinationManager NotRefCounted {
+
+    CreateAudioDestination(String inputDeviceId, uint32_t numberOfInputChannels, uint32_t numberOfOutputChannels, float sampleRate) -> (WebKit::RemoteAudioDestinationIdentifier id) Synchronous
+
+    DeleteAudioDestination(WebKit::RemoteAudioDestinationIdentifier id) -> () Async
+
+    StartAudioDestination(WebKit::RemoteAudioDestinationIdentifier id) -> (bool isPlaying) Synchronous
+    StopAudioDestination(WebKit::RemoteAudioDestinationIdentifier id) -> (bool isPlaying) Synchronous
+
+}
+
+#endif

Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcessPlatformStrategies.cpp (257550 => 257551)


--- trunk/Source/WebKit/NetworkProcess/NetworkProcessPlatformStrategies.cpp	2020-02-27 03:18:38 UTC (rev 257550)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcessPlatformStrategies.cpp	2020-02-27 03:51:17 UTC (rev 257551)
@@ -48,6 +48,11 @@
     return nullptr;
 }
 
+MediaStrategy* NetworkProcessPlatformStrategies::createMediaStrategy()
+{
+    return nullptr;
+}
+
 BlobRegistry* NetworkProcessPlatformStrategies::createBlobRegistry()
 {
     using namespace WebCore;

Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcessPlatformStrategies.h (257550 => 257551)


--- trunk/Source/WebKit/NetworkProcess/NetworkProcessPlatformStrategies.h	2020-02-27 03:18:38 UTC (rev 257550)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcessPlatformStrategies.h	2020-02-27 03:51:17 UTC (rev 257551)
@@ -38,6 +38,7 @@
     // WebCore::PlatformStrategies
     WebCore::LoaderStrategy* createLoaderStrategy() override;
     WebCore::PasteboardStrategy* createPasteboardStrategy() override;
+    WebCore::MediaStrategy* createMediaStrategy() override;
     WebCore::BlobRegistry* createBlobRegistry() override;
 };
 

Modified: trunk/Source/WebKit/PlatformMac.cmake (257550 => 257551)


--- trunk/Source/WebKit/PlatformMac.cmake	2020-02-27 03:18:38 UTC (rev 257550)
+++ trunk/Source/WebKit/PlatformMac.cmake	2020-02-27 03:51:17 UTC (rev 257551)
@@ -161,6 +161,11 @@
     GPUProcess/GPUConnectionToWebProcess.messages.in
     GPUProcess/GPUProcess.messages.in
 
+    GPUProcess/media/RemoteAudioDestinationManager.messages.in
+    GPUProcess/media/RemoteMediaPlayerManagerProxy.messages.in
+    GPUProcess/media/RemoteMediaPlayerProxy.messages.in
+    GPUProcess/media/RemoteMediaResourceManager.messages.in
+
     GPUProcess/webrtc/LibWebRTCCodecsProxy.messages.in
     GPUProcess/webrtc/RemoteSampleBufferDisplayLayerManager.messages.in
     GPUProcess/webrtc/RemoteAudioMediaStreamTrackRendererManager.messages.in
@@ -171,10 +176,6 @@
     GPUProcess/webrtc/RemoteAudioMediaStreamTrackRenderer.messages.in
     GPUProcess/webrtc/RemoteSampleBufferDisplayLayerManager.messages.in
 
-    GPUProcess/media/RemoteMediaPlayerProxy.messages.in
-    GPUProcess/media/RemoteMediaResourceManager.messages.in
-    GPUProcess/media/RemoteMediaPlayerManagerProxy.messages.in
-    
     NetworkProcess/CustomProtocols/LegacyCustomProtocolManager.messages.in
 
     Shared/ApplePay/WebPaymentCoordinatorProxy.messages.in

Modified: trunk/Source/WebKit/Scripts/webkit/messages.py (257550 => 257551)


--- trunk/Source/WebKit/Scripts/webkit/messages.py	2020-02-27 03:18:38 UTC (rev 257550)
+++ trunk/Source/WebKit/Scripts/webkit/messages.py	2020-02-27 03:51:17 UTC (rev 257551)
@@ -231,6 +231,7 @@
         'WebKit::MDNSRegisterIdentifier',
         'WebKit::MediaPlayerPrivateRemoteIdentifier',
         'WebKit::MediaRecorderIdentifier',
+        'WebKit::RemoteAudioDestinationIdentifier',
         'WebKit::RemoteMediaResourceIdentifier',
         'WebKit::RenderingBackendIdentifier',
         'WebKit::RTCDecoderIdentifier',

Added: trunk/Source/WebKit/Shared/RemoteAudioDestinationIdentifier.h (0 => 257551)


--- trunk/Source/WebKit/Shared/RemoteAudioDestinationIdentifier.h	                        (rev 0)
+++ trunk/Source/WebKit/Shared/RemoteAudioDestinationIdentifier.h	2020-02-27 03:51:17 UTC (rev 257551)
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2020 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 ENABLE(GPU_PROCESS)
+
+#include <wtf/ObjectIdentifier.h>
+
+namespace WebKit {
+
+enum RemoteAudioDestinationIdentifierType { };
+using RemoteAudioDestinationIdentifier = ObjectIdentifier<RemoteAudioDestinationIdentifierType>;
+
+} // namespace WebKit
+
+#endif

Modified: trunk/Source/WebKit/Sources.txt (257550 => 257551)


--- trunk/Source/WebKit/Sources.txt	2020-02-27 03:18:38 UTC (rev 257550)
+++ trunk/Source/WebKit/Sources.txt	2020-02-27 03:51:17 UTC (rev 257551)
@@ -538,11 +538,13 @@
 WebProcess/GPU/graphics/RemoteRenderingBackend.cpp
 WebProcess/GPU/media/AudioTrackPrivateRemote.cpp
 WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp
+WebProcess/GPU/media/RemoteAudioDestinationProxy.cpp
 WebProcess/GPU/media/RemoteMediaPlayerManager.cpp
 WebProcess/GPU/media/RemoteMediaPlayerMIMETypeCache.cpp @no-unify
 WebProcess/GPU/media/RemoteMediaResourceProxy.cpp
 WebProcess/GPU/media/TextTrackPrivateRemote.cpp
 WebProcess/GPU/media/VideoTrackPrivateRemote.cpp
+WebProcess/GPU/media/WebMediaStrategy.cpp
 WebProcess/GPU/webrtc/LibWebRTCCodecs.cpp
 WebProcess/GPU/webrtc/MediaRecorderPrivate.cpp
 WebProcess/GPU/webrtc/MediaRecorderProvider.cpp

Modified: trunk/Source/WebKit/SourcesCocoa.txt (257550 => 257551)


--- trunk/Source/WebKit/SourcesCocoa.txt	2020-02-27 03:18:38 UTC (rev 257550)
+++ trunk/Source/WebKit/SourcesCocoa.txt	2020-02-27 03:51:17 UTC (rev 257551)
@@ -650,6 +650,8 @@
 GPUProcessMessageReceiver.cpp
 LibWebRTCCodecsProxyMessageReceiver.cpp
 LibWebRTCCodecsMessageReceiver.cpp
+RemoteAudioDestinationManagerMessageReceiver.cpp
+RemoteAudioDestinationProxyMessageReceiver.cpp
 RemoteAudioMediaStreamTrackRendererManagerMessageReceiver.cpp
 RemoteAudioMediaStreamTrackRendererMessageReceiver.cpp
 RemoteMediaRecorderMessageReceiver.cpp

Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (257550 => 257551)


--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2020-02-27 03:18:38 UTC (rev 257550)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2020-02-27 03:51:17 UTC (rev 257551)
@@ -1410,8 +1410,14 @@
 		9B02E0CB235EB953004044B2 /* _WKTextManipulationDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B02E0C9235EB62D004044B2 /* _WKTextManipulationDelegate.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		9B02E0CC235EB957004044B2 /* _WKTextManipulationItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B02E0CA235EB884004044B2 /* _WKTextManipulationItem.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		9B02E0D7235FC94F004044B2 /* _WKTextManipulationToken.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B02E0CD235EB967004044B2 /* _WKTextManipulationToken.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		9B1229CD23FF25F2008CA751 /* RemoteAudioDestinationManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B1229CB23FF25F2008CA751 /* RemoteAudioDestinationManager.h */; };
+		9B1229CE23FF25F2008CA751 /* RemoteAudioDestinationManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9B1229CC23FF25F2008CA751 /* RemoteAudioDestinationManager.cpp */; };
+		9B1229D223FF2BCC008CA751 /* RemoteAudioDestinationIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B1229D023FF2A5E008CA751 /* RemoteAudioDestinationIdentifier.h */; };
 		9B5499AD2362A6F900DF8BA5 /* _WKTextManipulationConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B5499AC2362A6F600DF8BA5 /* _WKTextManipulationConfiguration.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		9B5499B22362A7EC00DF8BA5 /* _WKTextManipulationExclusionRule.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B5499B02362A7EC00DF8BA5 /* _WKTextManipulationExclusionRule.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		9B5BEC262400F4A90070C6EF /* WebMediaStrategy.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B5BEC242400F4A90070C6EF /* WebMediaStrategy.h */; };
+		9B5BEC2A240101580070C6EF /* RemoteAudioDestinationProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B5BEC28240101580070C6EF /* RemoteAudioDestinationProxy.h */; };
+		9B5BEC31240102220070C6EF /* RemoteAudioBusData.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 9B5BEC30240102220070C6EF /* RemoteAudioBusData.h */; };
 		9FB5F395169E6A80002C25BF /* WKContextPrivateMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 9FB5F393169E6A80002C25BF /* WKContextPrivateMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		A102A7081EC0EEE900D81D82 /* com.macromedia.Flash Player ESR.plugin.sb in Copy Plug-in Sandbox Profiles */ = {isa = PBXBuildFile; fileRef = 7A5E39491D5BD8A700B4B7CE /* com.macromedia.Flash Player ESR.plugin.sb */; };
 		A1046EA12079263100F0C5D8 /* WKPDFView.h in Headers */ = {isa = PBXBuildFile; fileRef = A1046E9F2079263100F0C5D8 /* WKPDFView.h */; };
@@ -2066,6 +2072,7 @@
 				2DB96053239886C100102791 /* com.apple.WebKit.GPU.sb in CopyFiles */,
 				A78CCDDB193AC9F8005ECC25 /* com.apple.WebKit.Networking.sb in CopyFiles */,
 				A78CCDDC193AC9FB005ECC25 /* com.apple.WebKit.WebContent.sb in CopyFiles */,
+				9B5BEC31240102220070C6EF /* RemoteAudioBusData.h in CopyFiles */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -4403,10 +4410,20 @@
 		9B02E0CD235EB967004044B2 /* _WKTextManipulationToken.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = _WKTextManipulationToken.h; sourceTree = "<group>"; };
 		9B02E0CE235EBB14004044B2 /* _WKTextManipulationToken.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKTextManipulationToken.mm; sourceTree = "<group>"; };
 		9B02E0D0235EBCCA004044B2 /* _WKTextManipulationItem.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKTextManipulationItem.mm; sourceTree = "<group>"; };
+		9B1229CB23FF25F2008CA751 /* RemoteAudioDestinationManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteAudioDestinationManager.h; sourceTree = "<group>"; };
+		9B1229CC23FF25F2008CA751 /* RemoteAudioDestinationManager.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteAudioDestinationManager.cpp; sourceTree = "<group>"; };
+		9B1229CF23FF2814008CA751 /* RemoteAudioDestinationManager.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = RemoteAudioDestinationManager.messages.in; sourceTree = "<group>"; };
+		9B1229D023FF2A5E008CA751 /* RemoteAudioDestinationIdentifier.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteAudioDestinationIdentifier.h; sourceTree = "<group>"; };
 		9B5499AC2362A6F600DF8BA5 /* _WKTextManipulationConfiguration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = _WKTextManipulationConfiguration.h; sourceTree = "<group>"; };
 		9B5499AE2362A7A700DF8BA5 /* _WKTextManipulationConfiguration.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKTextManipulationConfiguration.mm; sourceTree = "<group>"; };
 		9B5499B02362A7EC00DF8BA5 /* _WKTextManipulationExclusionRule.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = _WKTextManipulationExclusionRule.h; sourceTree = "<group>"; };
 		9B5499B12362A7EC00DF8BA5 /* _WKTextManipulationExclusionRule.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKTextManipulationExclusionRule.mm; sourceTree = "<group>"; };
+		9B5BEC242400F4A90070C6EF /* WebMediaStrategy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebMediaStrategy.h; sourceTree = "<group>"; };
+		9B5BEC252400F4A90070C6EF /* WebMediaStrategy.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebMediaStrategy.cpp; sourceTree = "<group>"; };
+		9B5BEC28240101580070C6EF /* RemoteAudioDestinationProxy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteAudioDestinationProxy.h; sourceTree = "<group>"; };
+		9B5BEC29240101580070C6EF /* RemoteAudioDestinationProxy.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteAudioDestinationProxy.cpp; sourceTree = "<group>"; };
+		9B5BEC2E2401018C0070C6EF /* RemoteAudioDestinationProxy.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = RemoteAudioDestinationProxy.messages.in; sourceTree = "<group>"; };
+		9B5BEC30240102220070C6EF /* RemoteAudioBusData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteAudioBusData.h; sourceTree = "<group>"; };
 		9BC59D6C1EFCCCB6001E8D09 /* CallbackID.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CallbackID.h; sourceTree = "<group>"; };
 		9BC59D6D1EFCDC6D001E8D09 /* OptionalCallbackID.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OptionalCallbackID.h; sourceTree = "<group>"; };
 		9F54F88E16488E87007DF81A /* AuxiliaryProcessMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AuxiliaryProcessMac.mm; sourceTree = "<group>"; };
@@ -5288,6 +5305,10 @@
 				07923132239B3B0C009598E2 /* MediaPlayerPrivateRemote.h */,
 				07B1D04B23D38FCE00399A6E /* MediaPlayerPrivateRemote.messages.in */,
 				0792314E239D5F53009598E2 /* MediaPlayerPrivateRemoteIdentifier.h */,
+				9B5BEC30240102220070C6EF /* RemoteAudioBusData.h */,
+				9B5BEC29240101580070C6EF /* RemoteAudioDestinationProxy.cpp */,
+				9B5BEC28240101580070C6EF /* RemoteAudioDestinationProxy.h */,
+				9B5BEC2E2401018C0070C6EF /* RemoteAudioDestinationProxy.messages.in */,
 				07B93FF523AF0CB80036F8EA /* RemoteMediaPlayerConfiguration.h */,
 				07923130239B3B0C009598E2 /* RemoteMediaPlayerManager.cpp */,
 				07923134239B3B0C009598E2 /* RemoteMediaPlayerManager.h */,
@@ -5303,6 +5324,8 @@
 				1DFDD0E223F610F000E9B490 /* VideoLayerRemote.h */,
 				071BC58323CC2BD500680D7C /* VideoTrackPrivateRemote.cpp */,
 				071BC58223CC2BD300680D7C /* VideoTrackPrivateRemote.h */,
+				9B5BEC252400F4A90070C6EF /* WebMediaStrategy.cpp */,
+				9B5BEC242400F4A90070C6EF /* WebMediaStrategy.h */,
 			);
 			path = media;
 			sourceTree = "<group>";
@@ -5311,6 +5334,9 @@
 			isa = PBXGroup;
 			children = (
 				1D0ECEA923FC84BB00D172F6 /* cocoa */,
+				9B1229CC23FF25F2008CA751 /* RemoteAudioDestinationManager.cpp */,
+				9B1229CB23FF25F2008CA751 /* RemoteAudioDestinationManager.h */,
+				9B1229CF23FF2814008CA751 /* RemoteAudioDestinationManager.messages.in */,
 				071BC57E23CA5DB100680D7C /* RemoteAudioTrackProxy.cpp */,
 				071BC57F23CA5DB100680D7C /* RemoteAudioTrackProxy.h */,
 				0725EFAD239B024500A538A9 /* RemoteMediaPlayerManagerProxy.cpp */,
@@ -5771,6 +5797,7 @@
 				E18C92F312DB9E7100CF2AEB /* PrintInfo.cpp */,
 				E1CC1B8E12D7EADF00625838 /* PrintInfo.h */,
 				463FD4811EB94EAD00A2982C /* ProcessTerminationReason.h */,
+				9B1229D023FF2A5E008CA751 /* RemoteAudioDestinationIdentifier.h */,
 				F6A0C13F13281E6E0070430F /* ResourceCachesToClear.h */,
 				5CB7AFE623C681B000E49CF3 /* ResourceLoadInfo.h */,
 				410482CB1DDD2FB500F006D0 /* RTCNetwork.cpp */,
@@ -10591,6 +10618,9 @@
 				83048AE61ACA45DC0082C832 /* ProcessThrottlerClient.h in Headers */,
 				A1E688701F6E2BAB007006A6 /* QuarantineSPI.h in Headers */,
 				57FD318222B3515E008D0E8B /* RedirectSOAuthorizationSession.h in Headers */,
+				9B1229D223FF2BCC008CA751 /* RemoteAudioDestinationIdentifier.h in Headers */,
+				9B1229CD23FF25F2008CA751 /* RemoteAudioDestinationManager.h in Headers */,
+				9B5BEC2A240101580070C6EF /* RemoteAudioDestinationProxy.h in Headers */,
 				2D47B56D1810714E003A3AEE /* RemoteLayerBackingStore.h in Headers */,
 				2DDF731518E95060004F5A66 /* RemoteLayerBackingStoreCollection.h in Headers */,
 				1AB16AEA164B3A8800290D62 /* RemoteLayerTreeContext.h in Headers */,
@@ -10843,6 +10873,7 @@
 				C98C48A61B6FD4C300145103 /* WebMediaSessionFocusManager.h in Headers */,
 				C9C1833C1B74026D007036A7 /* WebMediaSessionFocusManagerClient.h in Headers */,
 				C9CD43981B4B001D00239E33 /* WebMediaSessionMetadata.h in Headers */,
+				9B5BEC262400F4A90070C6EF /* WebMediaStrategy.h in Headers */,
 				2D3EF4431917646300034184 /* WebMemoryPressureHandler.h in Headers */,
 				909854ED12BC4E18000AD080 /* WebMemorySampler.h in Headers */,
 				513FFB91201459C6002596EA /* WebMessagePortChannelProvider.h in Headers */,
@@ -12288,6 +12319,7 @@
 				C15CBB3723F37ECB00300CC7 /* PreferenceObserver.mm in Sources */,
 				2D54C31B212F4DA60049C174 /* ProcessLauncher.cpp in Sources */,
 				CD2865EF2255562000606AC7 /* ProcessTaskStateObserver.mm in Sources */,
+				9B1229CE23FF25F2008CA751 /* RemoteAudioDestinationManager.cpp in Sources */,
 				2D72A1FA212BF46E00517A20 /* RemoteLayerTreeDrawingArea.mm in Sources */,
 				0FF24A2D1879E4BC003ABF0C /* RemoteLayerTreeDrawingAreaProxyMessageReceiver.cpp in Sources */,
 				2DC18FB4218A6E9E0025A88D /* RemoteLayerTreeViews.mm in Sources */,

Added: trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioBusData.h (0 => 257551)


--- trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioBusData.h	                        (rev 0)
+++ trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioBusData.h	2020-02-27 03:51:17 UTC (rev 257551)
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2020 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 ENABLE(GPU_PROCESS)
+
+#include "DataReference.h"
+#include "SharedBufferDataReference.h"
+#include "SharedMemory.h"
+#include <WebCore/SharedBuffer.h>
+
+namespace WebKit {
+
+struct RemoteAudioBusData {
+    uint64_t framesToProcess { 0 };
+    Vector<Ref<SharedMemory>> channelBuffers;
+
+    template<typename Encoder>
+    void encode(Encoder& encoder) const
+    {
+        encoder << framesToProcess;
+        encoder << static_cast<uint64_t>(channelBuffers.size());
+        for (size_t i = 0; i < channelBuffers.size(); ++i) {
+            SharedMemory::Handle handle;
+            channelBuffers[i]->createHandle(handle, SharedMemory::Protection::ReadWrite);
+            encoder << handle;
+        }
+    }
+
+    template<typename Decoder>
+    static bool decode(Decoder& decoder, RemoteAudioBusData& result)
+    {
+        uint64_t framesToProcess;
+        if (!decoder.decode(framesToProcess))
+            return false;
+        result.framesToProcess = framesToProcess;
+
+        uint64_t size = 0;
+        if (!decoder.decode(size))
+            return false;
+
+        for (size_t i = 0; i < size; ++i) {
+            SharedMemory::Handle handle;
+            if (!decoder.decode(handle))
+                return false;
+            auto memory = SharedMemory::map(handle, SharedMemory::Protection::ReadWrite);
+            if (memory)
+                result.channelBuffers.append(*memory);
+        }
+
+        return true;
+    }
+};
+
+} // namespace WebKit
+
+#endif

Added: trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioDestinationProxy.cpp (0 => 257551)


--- trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioDestinationProxy.cpp	                        (rev 0)
+++ trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioDestinationProxy.cpp	2020-02-27 03:51:17 UTC (rev 257551)
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2020 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 "RemoteAudioDestinationProxy.h"
+
+#if ENABLE(GPU_PROCESS)
+
+#include "GPUConnectionToWebProcess.h"
+#include "RemoteAudioDestinationManager.h"
+#include "RemoteAudioDestinationManagerMessages.h"
+#include "RemoteAudioDestinationProxyMessages.h"
+#include "WebProcess.h"
+#include <WebCore/AudioBus.h>
+#include <WebCore/AudioDestination.h>
+
+namespace WebKit {
+
+using AudioBus = WebCore::AudioBus;
+using AudioDestination = WebCore::AudioDestination;
+using AudioIOCallback = WebCore::AudioIOCallback;
+
+std::unique_ptr<AudioDestination> RemoteAudioDestinationProxy::create(AudioIOCallback& callback,
+    const String& inputDeviceId, unsigned numberOfInputChannels, unsigned numberOfOutputChannels, float sampleRate)
+{
+    return makeUnique<RemoteAudioDestinationProxy>(callback, inputDeviceId, numberOfInputChannels, numberOfOutputChannels, sampleRate);
+}
+
+RemoteAudioDestinationProxy::RemoteAudioDestinationProxy(AudioIOCallback& callback, const String& inputDeviceId, unsigned numberOfInputChannels, unsigned numberOfOutputChannels, float sampleRate)
+    : m_callback(callback)
+    , m_sampleRate(sampleRate)
+{
+    RemoteAudioDestinationIdentifier destinationID;
+
+    auto& connection = WebProcess::singleton().ensureGPUProcessConnection();
+    connection.connection().sendSync(
+        Messages::RemoteAudioDestinationManager::CreateAudioDestination(inputDeviceId, numberOfInputChannels, numberOfOutputChannels, sampleRate),
+        Messages::RemoteAudioDestinationManager::CreateAudioDestination::Reply(destinationID), 0);
+    connection.messageReceiverMap().addMessageReceiver(Messages::RemoteAudioDestinationProxy::messageReceiverName(), destinationID.toUInt64(), *this);
+
+    m_destinationID = destinationID;
+}
+
+RemoteAudioDestinationProxy::~RemoteAudioDestinationProxy()
+{
+    auto& connection =  WebProcess::singleton().ensureGPUProcessConnection();
+    connection.messageReceiverMap().removeMessageReceiver(Messages::RemoteAudioDestinationProxy::messageReceiverName(), m_destinationID.toUInt64());
+
+    connection.connection().sendWithAsyncReply(
+        Messages::RemoteAudioDestinationManager::DeleteAudioDestination(m_destinationID), [] {
+        // Can't remove this from proxyMap() here because the object would have been already deleted.
+    });
+}
+
+void RemoteAudioDestinationProxy::start()
+{
+    WebProcess::singleton().ensureGPUProcessConnection().connection().sendSync(
+        Messages::RemoteAudioDestinationManager::StartAudioDestination(m_destinationID),
+        Messages::RemoteAudioDestinationManager::StartAudioDestination::Reply(m_isPlaying), 0);
+}
+
+void RemoteAudioDestinationProxy::stop()
+{
+    WebProcess::singleton().ensureGPUProcessConnection().connection().sendSync(
+        Messages::RemoteAudioDestinationManager::StopAudioDestination(m_destinationID),
+        Messages::RemoteAudioDestinationManager::StopAudioDestination::Reply(m_isPlaying), 0);
+}
+
+void RemoteAudioDestinationProxy::renderBuffer(const WebKit::RemoteAudioBusData& audioBusData, CompletionHandler<void()>&& completionHandler)
+{
+    ASSERT(audioBusData.framesToProcess);
+    ASSERT(audioBusData.channelBuffers.size());
+    auto audioBus = AudioBus::create(audioBusData.channelBuffers.size(), audioBusData.framesToProcess, false);
+    for (unsigned i = 0; i < audioBusData.channelBuffers.size(); ++i)
+        audioBus->setChannelMemory(i, (float*)audioBusData.channelBuffers[i]->data(), audioBusData.framesToProcess);
+
+    m_callback.render(0, audioBus.get(), audioBusData.framesToProcess);
+
+    completionHandler();
+}
+
+void RemoteAudioDestinationProxy::didChangeIsPlaying(bool isPlaying)
+{
+}
+
+} // namespace WebKit
+
+#endif

Added: trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioDestinationProxy.h (0 => 257551)


--- trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioDestinationProxy.h	                        (rev 0)
+++ trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioDestinationProxy.h	2020-02-27 03:51:17 UTC (rev 257551)
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2020 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 ENABLE(GPU_PROCESS)
+
+#include "Connection.h"
+#include "RemoteAudioBusData.h"
+#include "RemoteAudioDestinationIdentifier.h"
+#include "WebProcessSupplement.h"
+#include <WebCore/AudioDestination.h>
+#include <WebCore/AudioIOCallback.h>
+
+#if PLATFORM(COCOA)
+#include <WebCore/CARingBuffer.h>
+#endif
+
+namespace WebKit {
+
+class RemoteAudioDestinationProxy : public WebCore::AudioDestination, private IPC::MessageReceiver {
+    WTF_MAKE_FAST_ALLOCATED;
+    WTF_MAKE_NONCOPYABLE(RemoteAudioDestinationProxy);
+public:
+    using AudioBus = WebCore::AudioBus;
+    using AudioIOCallback = WebCore::AudioIOCallback;
+
+    static std::unique_ptr<AudioDestination> create(AudioIOCallback&, const String& inputDeviceId, unsigned numberOfInputChannels, unsigned numberOfOutputChannels, float sampleRate);
+
+    RemoteAudioDestinationProxy(AudioIOCallback&, const String& inputDeviceId, unsigned numberOfInputChannels, unsigned numberOfOutputChannels, float sampleRate);
+    ~RemoteAudioDestinationProxy();
+
+    void didReceiveMessageFromGPUProcess(IPC::Connection& connection, IPC::Decoder& decoder) { didReceiveMessage(connection, decoder); }
+
+    void renderBuffer(const WebKit::RemoteAudioBusData&, CompletionHandler<void()>&&);
+    void didChangeIsPlaying(bool isPlaying);
+
+private:
+    // WebCore::AudioDestination
+    void start() override;
+    void stop() override;
+    bool isPlaying() override { return m_isPlaying; }
+    float sampleRate() const override { return m_sampleRate; }
+
+    // IPC::MessageReceiver
+    void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;
+
+    AudioIOCallback& m_callback;
+    float m_sampleRate;
+    RemoteAudioDestinationIdentifier m_destinationID;
+    bool m_isPlaying { false };
+};
+
+} // namespace WebKit
+
+#endif

Added: trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioDestinationProxy.messages.in (0 => 257551)


--- trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioDestinationProxy.messages.in	                        (rev 0)
+++ trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioDestinationProxy.messages.in	2020-02-27 03:51:17 UTC (rev 257551)
@@ -0,0 +1,33 @@
+# Copyright (C) 2020 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.
+
+#if ENABLE(GPU_PROCESS)
+
+messages -> RemoteAudioDestinationProxy NotRefCounted {
+
+    RenderBuffer(struct WebKit::RemoteAudioBusData data) -> () Async
+    DidChangeIsPlaying(bool isPlaying)
+
+}
+
+#endif

Modified: trunk/Source/WebKit/WebProcess/GPU/media/TextTrackPrivateRemote.cpp (257550 => 257551)


--- trunk/Source/WebKit/WebProcess/GPU/media/TextTrackPrivateRemote.cpp	2020-02-27 03:18:38 UTC (rev 257550)
+++ trunk/Source/WebKit/WebProcess/GPU/media/TextTrackPrivateRemote.cpp	2020-02-27 03:51:17 UTC (rev 257551)
@@ -139,7 +139,7 @@
 {
     ASSERT(client());
     if (auto* client = this->client())
-        client->addDataCue(WTFMove(start), WTFMove(end), SerializedPlatformDataCue::create(WTFMove(dataValue)), type);
+        client->addDataCue(WTFMove(start), WTFMove(end), WebCore::SerializedPlatformDataCue::create(WTFMove(dataValue)), type);
 }
 
 void TextTrackPrivateRemote::updateDataCue(MediaTime&& start, MediaTime&& end, SerializedPlatformDataCueValue&& dataValue)
@@ -146,7 +146,7 @@
 {
     ASSERT(client());
     if (auto* client = this->client())
-        client->updateDataCue(WTFMove(start), WTFMove(end), SerializedPlatformDataCue::create(WTFMove(dataValue)));
+        client->updateDataCue(WTFMove(start), WTFMove(end), WebCore::SerializedPlatformDataCue::create(WTFMove(dataValue)));
 }
 
 void TextTrackPrivateRemote::removeDataCue(MediaTime&& start, MediaTime&& end, SerializedPlatformDataCueValue&& dataValue)
@@ -153,7 +153,7 @@
 {
     ASSERT(client());
     if (auto* client = this->client())
-        client->removeDataCue(WTFMove(start), WTFMove(end), SerializedPlatformDataCue::create(WTFMove(dataValue)));
+        client->removeDataCue(WTFMove(start), WTFMove(end), WebCore::SerializedPlatformDataCue::create(WTFMove(dataValue)));
 }
 #endif
 

Modified: trunk/Source/WebKit/WebProcess/GPU/media/TextTrackPrivateRemote.h (257550 => 257551)


--- trunk/Source/WebKit/WebProcess/GPU/media/TextTrackPrivateRemote.h	2020-02-27 03:18:38 UTC (rev 257550)
+++ trunk/Source/WebKit/WebProcess/GPU/media/TextTrackPrivateRemote.h	2020-02-27 03:51:17 UTC (rev 257551)
@@ -28,6 +28,7 @@
 
 #if ENABLE(GPU_PROCESS)
 
+#include "DataReference.h"
 #include "TextTrackPrivateRemoteConfiguration.h"
 #include "TrackPrivateRemoteIdentifier.h"
 #include <WebCore/InbandTextTrackPrivate.h>
@@ -48,6 +49,10 @@
 class TextTrackPrivateRemote final : public WebCore::InbandTextTrackPrivate {
     WTF_MAKE_NONCOPYABLE(TextTrackPrivateRemote)
 public:
+    using GenericCueData = WebCore::GenericCueData;
+    using ISOWebVTTCue = WebCore::ISOWebVTTCue;
+    using SerializedPlatformDataCueValue = WebCore::SerializedPlatformDataCueValue;
+
     static Ref<TextTrackPrivateRemote> create(MediaPlayerPrivateRemote& player, TrackPrivateRemoteIdentifier idendifier, TextTrackPrivateRemoteConfiguration&& configuration)
     {
         return adoptRef(*new TextTrackPrivateRemote(player, idendifier, WTFMove(configuration)));

Added: trunk/Source/WebKit/WebProcess/GPU/media/WebMediaStrategy.cpp (0 => 257551)


--- trunk/Source/WebKit/WebProcess/GPU/media/WebMediaStrategy.cpp	                        (rev 0)
+++ trunk/Source/WebKit/WebProcess/GPU/media/WebMediaStrategy.cpp	2020-02-27 03:51:17 UTC (rev 257551)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2020 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 "WebMediaStrategy.h"
+
+#include "GPUProcessConnection.h"
+#include "RemoteAudioDestinationProxy.h"
+#include <WebCore/AudioDestination.h>
+#include <WebCore/AudioIOCallback.h>
+
+namespace WebKit {
+
+WebMediaStrategy::~WebMediaStrategy() = default;
+
+#if ENABLE(WEB_AUDIO)
+std::unique_ptr<WebCore::AudioDestination> WebMediaStrategy::createAudioDestination(WebCore::AudioIOCallback& callback, const String& inputDeviceId,
+    unsigned numberOfInputChannels, unsigned numberOfOutputChannels, float sampleRate)
+{
+#if ENABLE(GPU_PROCESS)
+    if (m_useGPUProcess)
+        return RemoteAudioDestinationProxy::create(callback, inputDeviceId, numberOfInputChannels, numberOfOutputChannels, sampleRate);
+#endif
+    return WebCore::AudioDestination::create(callback, inputDeviceId, numberOfInputChannels, numberOfOutputChannels, sampleRate);
+}
+#endif
+
+} // namespace WebKit

Added: trunk/Source/WebKit/WebProcess/GPU/media/WebMediaStrategy.h (0 => 257551)


--- trunk/Source/WebKit/WebProcess/GPU/media/WebMediaStrategy.h	                        (rev 0)
+++ trunk/Source/WebKit/WebProcess/GPU/media/WebMediaStrategy.h	2020-02-27 03:51:17 UTC (rev 257551)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2020 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
+
+#include <WebCore/MediaStrategy.h>
+
+namespace WebKit {
+
+class WebMediaStrategy : public WebCore::MediaStrategy {
+public:
+    virtual ~WebMediaStrategy();
+
+#if ENABLE(GPU_PROCESS)
+    void setUseGPUProcess(bool useGPUProcess) { m_useGPUProcess = useGPUProcess; }
+#endif
+
+private:
+#if ENABLE(WEB_AUDIO)
+    std::unique_ptr<WebCore::AudioDestination> createAudioDestination(WebCore::AudioIOCallback&,
+        const String& inputDeviceId, unsigned numberOfInputChannels, unsigned numberOfOutputChannels, float sampleRate) override;
+#endif
+
+#if ENABLE(GPU_PROCESS)
+    bool m_useGPUProcess { false };
+#endif
+
+};
+
+} // namespace WebKit
+
+

Modified: trunk/Source/WebKit/WebProcess/GPU/webrtc/SampleBufferDisplayLayer.cpp (257550 => 257551)


--- trunk/Source/WebKit/WebProcess/GPU/webrtc/SampleBufferDisplayLayer.cpp	2020-02-27 03:18:38 UTC (rev 257550)
+++ trunk/Source/WebKit/WebProcess/GPU/webrtc/SampleBufferDisplayLayer.cpp	2020-02-27 03:51:17 UTC (rev 257551)
@@ -28,6 +28,7 @@
 
 #if PLATFORM(COCOA) && ENABLE(GPU_PROCESS) && ENABLE(VIDEO_TRACK) && ENABLE(MEDIA_STREAM)
 
+#include "GPUProcessConnection.h"
 #include "LayerHostingContext.h"
 #include "RemoteSampleBufferDisplayLayerManagerMessages.h"
 #include "RemoteSampleBufferDisplayLayerManagerMessagesReplies.h"
@@ -34,6 +35,8 @@
 #include "RemoteSampleBufferDisplayLayerMessages.h"
 #include "SampleBufferDisplayLayerManager.h"
 #include "WebCoreArgumentCoders.h"
+#include "WebProcess.h"
+#include <WebCore/RemoteVideoSample.h>
 
 namespace WebKit {
 using namespace WebCore;

Modified: trunk/Source/WebKit/WebProcess/GPU/webrtc/SampleBufferDisplayLayerManager.cpp (257550 => 257551)


--- trunk/Source/WebKit/WebProcess/GPU/webrtc/SampleBufferDisplayLayerManager.cpp	2020-02-27 03:18:38 UTC (rev 257550)
+++ trunk/Source/WebKit/WebProcess/GPU/webrtc/SampleBufferDisplayLayerManager.cpp	2020-02-27 03:51:17 UTC (rev 257551)
@@ -26,6 +26,9 @@
 #include "config.h"
 #include "SampleBufferDisplayLayerManager.h"
 
+#include "Decoder.h"
+#include <WebCore/IntSize.h>
+
 #if PLATFORM(COCOA) && ENABLE(GPU_PROCESS) && ENABLE(VIDEO_TRACK) && ENABLE(MEDIA_STREAM)
 
 namespace WebKit {

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp (257550 => 257551)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp	2020-02-27 03:18:38 UTC (rev 257550)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp	2020-02-27 03:51:17 UTC (rev 257551)
@@ -39,16 +39,19 @@
 #include "WebFrame.h"
 #include "WebFrameLoaderClient.h"
 #include "WebLoaderStrategy.h"
+#include "WebMediaStrategy.h"
 #include "WebPage.h"
 #include "WebPasteboardOverrides.h"
 #include "WebPasteboardProxyMessages.h"
 #include "WebProcess.h"
 #include "WebProcessProxyMessages.h"
+#include <WebCore/AudioDestination.h>
 #include <WebCore/Color.h>
 #include <WebCore/Document.h>
 #include <WebCore/DocumentLoader.h>
 #include <WebCore/Frame.h>
 #include <WebCore/LoaderStrategy.h>
+#include <WebCore/MediaStrategy.h>
 #include <WebCore/NetworkStorageSession.h>
 #include <WebCore/Page.h>
 #include <WebCore/PageGroup.h>
@@ -73,6 +76,8 @@
 namespace WebKit {
 using namespace WebCore;
 
+class RemoteAudioDestination;
+
 void WebPlatformStrategies::initialize()
 {
     static NeverDestroyed<WebPlatformStrategies> platformStrategies;
@@ -93,6 +98,11 @@
     return this;
 }
 
+MediaStrategy* WebPlatformStrategies::createMediaStrategy()
+{
+    return new WebMediaStrategy;
+}
+
 BlobRegistry* WebPlatformStrategies::createBlobRegistry()
 {
     return new BlobRegistryProxy;

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.h (257550 => 257551)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.h	2020-02-27 03:18:38 UTC (rev 257550)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.h	2020-02-27 03:51:17 UTC (rev 257551)
@@ -42,6 +42,7 @@
     // WebCore::PlatformStrategies
     WebCore::LoaderStrategy* createLoaderStrategy() override;
     WebCore::PasteboardStrategy* createPasteboardStrategy() override;
+    WebCore::MediaStrategy* createMediaStrategy() override;
     WebCore::BlobRegistry* createBlobRegistry() override;
 
     // WebCore::PasteboardStrategy

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (257550 => 257551)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2020-02-27 03:18:38 UTC (rev 257550)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2020-02-27 03:51:17 UTC (rev 257551)
@@ -101,6 +101,7 @@
 #include "WebInspectorUIMessages.h"
 #include "WebLoaderStrategy.h"
 #include "WebMediaKeyStorageManager.h"
+#include "WebMediaStrategy.h"
 #include "WebNotificationClient.h"
 #include "WebOpenPanelResultListener.h"
 #include "WebPageCreationParameters.h"
@@ -199,6 +200,7 @@
 #include <WebCore/PingLoader.h>
 #include <WebCore/PlatformKeyboardEvent.h>
 #include <WebCore/PlatformMediaSessionManager.h>
+#include <WebCore/PlatformStrategies.h>
 #include <WebCore/PluginDocument.h>
 #include <WebCore/PointerCaptureController.h>
 #include <WebCore/PrintContext.h>
@@ -3696,6 +3698,8 @@
         m_drawingArea->updatePreferences(store);
 
 #if ENABLE(GPU_PROCESS)
+    // FIXME: useGPUProcessForMedia should be a RuntimeEnabledFeature since it's global.
+    static_cast<WebMediaStrategy&>(platformStrategies()->mediaStrategy()).setUseGPUProcess(settings.useGPUProcessForMedia());
     WebProcess::singleton().supplement<RemoteMediaPlayerManager>()->updatePreferences(settings);
 #endif
 }

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (257550 => 257551)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2020-02-27 03:18:38 UTC (rev 257550)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2020-02-27 03:51:17 UTC (rev 257551)
@@ -1,3 +1,17 @@
+2020-02-26  Ryosuke Niwa  <[email protected]>
+
+        Create AudioDestination in the GPU process
+        https://bugs.webkit.org/show_bug.cgi?id=208179
+
+        Reviewed by Jer Noble.
+
+        Added WebMediaStrategy which is a wrapper around AudioDestination::create.
+
+        * WebCoreSupport/WebPlatformStrategies.h:
+        * WebCoreSupport/WebPlatformStrategies.mm:
+        (WebMediaStrategy): Added.
+        (WebPlatformStrategies::createMediaStrategy):
+
 2020-02-25  Megan Gardner  <[email protected]>
 
         Build Fix

Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.h (257550 => 257551)


--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.h	2020-02-27 03:18:38 UTC (rev 257550)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.h	2020-02-27 03:51:17 UTC (rev 257551)
@@ -43,6 +43,7 @@
     // WebCore::PlatformStrategies
     WebCore::LoaderStrategy* createLoaderStrategy() override;
     WebCore::PasteboardStrategy* createPasteboardStrategy() override;
+    WebCore::MediaStrategy* createMediaStrategy() override;
     WebCore::BlobRegistry* createBlobRegistry() override;
 
     // WebCore::PasteboardStrategy

Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.mm (257550 => 257551)


--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.mm	2020-02-27 03:18:38 UTC (rev 257550)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.mm	2020-02-27 03:51:17 UTC (rev 257551)
@@ -28,9 +28,11 @@
 #import "WebFrameNetworkingContext.h"
 #import "WebPluginPackage.h"
 #import "WebResourceLoadScheduler.h"
+#import <WebCore/AudioDestination.h>
 #import <WebCore/BlobRegistryImpl.h>
 #import <WebCore/Color.h>
 #import <WebCore/Frame.h>
+#import <WebCore/MediaStrategy.h>
 #import <WebCore/NetworkStorageSession.h>
 #import <WebCore/PasteboardItemInfo.h>
 #import <WebCore/PlatformPasteboard.h>
@@ -62,6 +64,22 @@
     return this;
 }
 
+class WebMediaStrategy final : public MediaStrategy {
+private:
+#if ENABLE(WEB_AUDIO)
+    std::unique_ptr<AudioDestination> createAudioDestination(AudioIOCallback& callback, const String& inputDeviceId,
+        unsigned numberOfInputChannels, unsigned numberOfOutputChannels, float sampleRate) override
+    {
+        return AudioDestination::create(callback, inputDeviceId, numberOfInputChannels, numberOfOutputChannels, sampleRate);
+    }
+#endif
+};
+
+MediaStrategy* WebPlatformStrategies::createMediaStrategy()
+{
+    return new WebMediaStrategy;
+}
+
 class WebBlobRegistry final : public BlobRegistry {
 private:
     void registerFileBlobURL(const URL& url, Ref<BlobDataFileReference>&& reference, const String& contentType) final { m_blobRegistry.registerFileBlobURL(url, WTFMove(reference), contentType); }

Modified: trunk/Source/WebKitLegacy/win/ChangeLog (257550 => 257551)


--- trunk/Source/WebKitLegacy/win/ChangeLog	2020-02-27 03:18:38 UTC (rev 257550)
+++ trunk/Source/WebKitLegacy/win/ChangeLog	2020-02-27 03:51:17 UTC (rev 257551)
@@ -1,3 +1,17 @@
+2020-02-26  Ryosuke Niwa  <[email protected]>
+
+        Create AudioDestination in the GPU process
+        https://bugs.webkit.org/show_bug.cgi?id=208179
+
+        Reviewed by Jer Noble.
+
+        Added WebMediaStrategy which is a wrapper around AudioDestination::create.
+
+        * WebCoreSupport/WebPlatformStrategies.cpp:
+        (WebMediaStrategy): Added.
+        (WebPlatformStrategies::createMediaStrategy):
+        * WebCoreSupport/WebPlatformStrategies.h:
+
 2020-02-26  Antti Koivisto  <[email protected]>
 
         Remove throttling code from RenderLayerCompositor

Modified: trunk/Source/WebKitLegacy/win/WebCoreSupport/WebPlatformStrategies.cpp (257550 => 257551)


--- trunk/Source/WebKitLegacy/win/WebCoreSupport/WebPlatformStrategies.cpp	2020-02-27 03:18:38 UTC (rev 257550)
+++ trunk/Source/WebKitLegacy/win/WebCoreSupport/WebPlatformStrategies.cpp	2020-02-27 03:51:17 UTC (rev 257551)
@@ -27,9 +27,11 @@
 
 #include "WebFrameNetworkingContext.h"
 #include "WebResourceLoadScheduler.h"
+#include <WebCore/AudioDestination.h>
 #include <WebCore/BlobRegistry.h>
 #include <WebCore/BlobRegistryImpl.h>
 #include <WebCore/FrameLoader.h>
+#include <WebCore/MediaStrategy.h>
 #include <WebCore/NetworkStorageSession.h>
 #include <WebCore/Page.h>
 #include <WebCore/PageGroup.h>
@@ -60,6 +62,22 @@
     return nullptr;
 }
 
+class WebMediaStrategy final : public MediaStrategy {
+private:
+#if ENABLE(WEB_AUDIO)
+    std::unique_ptr<AudioDestination> createAudioDestination(AudioIOCallback& callback, const String& inputDeviceId,
+        unsigned numberOfInputChannels, unsigned numberOfOutputChannels, float sampleRate) override
+    {
+        return AudioDestination::create(callback, inputDeviceId, numberOfInputChannels, numberOfOutputChannels, sampleRate);
+    }
+#endif
+};
+
+MediaStrategy* WebPlatformStrategies::createMediaStrategy()
+{
+    return new WebMediaStrategy;
+}
+
 class WebBlobRegistry final : public BlobRegistry {
 private:
     void registerFileBlobURL(const URL& url, Ref<BlobDataFileReference>&& reference, const String& contentType) final { m_blobRegistry.registerFileBlobURL(url, WTFMove(reference), contentType); }

Modified: trunk/Source/WebKitLegacy/win/WebCoreSupport/WebPlatformStrategies.h (257550 => 257551)


--- trunk/Source/WebKitLegacy/win/WebCoreSupport/WebPlatformStrategies.h	2020-02-27 03:18:38 UTC (rev 257550)
+++ trunk/Source/WebKitLegacy/win/WebCoreSupport/WebPlatformStrategies.h	2020-02-27 03:51:17 UTC (rev 257551)
@@ -38,7 +38,8 @@
     WebPlatformStrategies();
 
     // WebCore::PlatformStrategies
-    virtual WebCore::LoaderStrategy* createLoaderStrategy();
-    virtual WebCore::PasteboardStrategy* createPasteboardStrategy();
-    virtual WebCore::BlobRegistry* createBlobRegistry();
+    WebCore::LoaderStrategy* createLoaderStrategy() override;
+    WebCore::PasteboardStrategy* createPasteboardStrategy() override;
+    WebCore::MediaStrategy* createMediaStrategy() override;
+    WebCore::BlobRegistry* createBlobRegistry() override;
 };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to