Diff
Modified: trunk/Source/WebKit/ChangeLog (272854 => 272855)
--- trunk/Source/WebKit/ChangeLog 2021-02-15 17:07:49 UTC (rev 272854)
+++ trunk/Source/WebKit/ChangeLog 2021-02-15 17:09:25 UTC (rev 272855)
@@ -1,3 +1,40 @@
+2021-02-15 Youenn Fablet <you...@apple.com>
+
+ Share more code between RemoteRealtimeAudioSource and RemoteRealtimeVideoSource
+ https://bugs.webkit.org/show_bug.cgi?id=221898
+
+ Reviewed by Eric Carlson.
+
+ Introduce RemoteRealtimeMediaSourceProxy to share more code between the two classes.
+ This class implements most of the messaging with capture process.
+ No change of behavior.
+
+ * WebProcess/cocoa/RemoteRealtimeAudioSource.cpp:
+ (WebKit::RemoteRealtimeAudioSource::createRemoteMediaSource):
+ * WebProcess/cocoa/RemoteRealtimeAudioSource.h:
+ (WebKit::RemoteRealtimeAudioSource::identifier const): Deleted.
+ (WebKit::RemoteRealtimeAudioSource::connection): Deleted.
+ (WebKit::RemoteRealtimeAudioSource::applyConstraintsFailed): Deleted.
+ * WebProcess/cocoa/RemoteRealtimeMediaSourceProxy.h:
+ (WebKit::RemoteRealtimeMediaSourceProxy::isReady const):
+ * WebProcess/cocoa/RemoteRealtimeVideoSource.cpp:
+ (WebKit::RemoteRealtimeVideoSource::RemoteRealtimeVideoSource):
+ (WebKit::RemoteRealtimeVideoSource::createRemoteMediaSource):
+ (WebKit::RemoteRealtimeVideoSource::~RemoteRealtimeVideoSource):
+ (WebKit::RemoteRealtimeVideoSource::setShouldApplyRotation):
+ (WebKit::RemoteRealtimeVideoSource::hasEnded):
+ (WebKit::RemoteRealtimeVideoSource::generatePresets):
+ (WebKit::RemoteRealtimeVideoSource::setFrameRateWithPreset):
+ (WebKit::RemoteRealtimeVideoSource::gpuProcessConnectionDidClose):
+ (WebKit::RemoteRealtimeVideoSource::whenReady): Deleted.
+ (WebKit::RemoteRealtimeVideoSource::didFail): Deleted.
+ (WebKit::RemoteRealtimeVideoSource::setAsReady): Deleted.
+ (WebKit::RemoteRealtimeVideoSource::connection): Deleted.
+ (WebKit::RemoteRealtimeVideoSource::startProducingData): Deleted.
+ (WebKit::RemoteRealtimeVideoSource::stopProducingData): Deleted.
+ * WebProcess/cocoa/RemoteRealtimeVideoSource.h:
+ (WebKit::RemoteRealtimeVideoSource::identifier const): Deleted.
+
2021-02-15 Michael Catanzaro <mcatanz...@gnome.org>
[WPE][GTK] BubblewrapLauncher should create flatpak-info keyfile only once
Modified: trunk/Source/WebKit/SourcesCocoa.txt (272854 => 272855)
--- trunk/Source/WebKit/SourcesCocoa.txt 2021-02-15 17:07:49 UTC (rev 272854)
+++ trunk/Source/WebKit/SourcesCocoa.txt 2021-02-15 17:09:25 UTC (rev 272855)
@@ -583,6 +583,7 @@
WebProcess/cocoa/PlaybackSessionManager.mm
WebProcess/cocoa/RemoteCaptureSampleManager.cpp
WebProcess/cocoa/RemoteRealtimeAudioSource.cpp
+WebProcess/cocoa/RemoteRealtimeMediaSourceProxy.cpp
WebProcess/cocoa/RemoteRealtimeVideoSource.cpp
WebProcess/cocoa/UserMediaCaptureManager.cpp
WebProcess/cocoa/VideoFullscreenManager.mm
Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (272854 => 272855)
--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2021-02-15 17:07:49 UTC (rev 272854)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2021-02-15 17:09:25 UTC (rev 272855)
@@ -3684,6 +3684,8 @@
4157853021276B6F00DD3800 /* copy-webcontent-resources-to-private-headers.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "copy-webcontent-resources-to-private-headers.sh"; sourceTree = "<group>"; };
4157E4AF20E2EC9800A6C0D7 /* com.google.o1dbrowserplugin.sb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = com.google.o1dbrowserplugin.sb; sourceTree = "<group>"; };
4158649A23BE092400A0A61E /* RTCEncoderIdentifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCEncoderIdentifier.h; sourceTree = "<group>"; };
+ 416008B125DA86B900E892FE /* RemoteRealtimeMediaSourceProxy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteRealtimeMediaSourceProxy.h; sourceTree = "<group>"; };
+ 416008B225DA895B00E892FE /* RemoteRealtimeMediaSourceProxy.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteRealtimeMediaSourceProxy.cpp; sourceTree = "<group>"; };
41684C4D24643BFA001CE8ED /* RemoteCaptureSampleManager.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = RemoteCaptureSampleManager.messages.in; sourceTree = "<group>"; };
41684C4E24643C81001CE8ED /* RemoteCaptureSampleManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteCaptureSampleManager.h; sourceTree = "<group>"; };
41684C4F24643D3F001CE8ED /* RemoteCaptureSampleManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteCaptureSampleManager.cpp; sourceTree = "<group>"; };
@@ -9099,6 +9101,8 @@
41684C4D24643BFA001CE8ED /* RemoteCaptureSampleManager.messages.in */,
41E67A8D25D2CFD0007B0A4C /* RemoteRealtimeAudioSource.cpp */,
41E67A8C25D2CFD0007B0A4C /* RemoteRealtimeAudioSource.h */,
+ 416008B225DA895B00E892FE /* RemoteRealtimeMediaSourceProxy.cpp */,
+ 416008B125DA86B900E892FE /* RemoteRealtimeMediaSourceProxy.h */,
41684C50246450FD001CE8ED /* RemoteRealtimeVideoSource.cpp */,
41684C51246450FD001CE8ED /* RemoteRealtimeVideoSource.h */,
CD491B051E70D05F00009066 /* UserMediaCaptureManager.cpp */,
Modified: trunk/Source/WebKit/WebProcess/cocoa/RemoteRealtimeAudioSource.cpp (272854 => 272855)
--- trunk/Source/WebKit/WebProcess/cocoa/RemoteRealtimeAudioSource.cpp 2021-02-15 17:07:49 UTC (rev 272854)
+++ trunk/Source/WebKit/WebProcess/cocoa/RemoteRealtimeAudioSource.cpp 2021-02-15 17:09:25 UTC (rev 272855)
@@ -55,15 +55,10 @@
RemoteRealtimeAudioSource::RemoteRealtimeAudioSource(RealtimeMediaSourceIdentifier identifier, const CaptureDevice& device, const MediaConstraints* constraints, String&& name, String&& hashSalt, UserMediaCaptureManager& manager, bool shouldCaptureInGPUProcess)
: RealtimeMediaSource(RealtimeMediaSource::Type::Audio, WTFMove(name), String::number(identifier.toUInt64()), WTFMove(hashSalt))
- , m_identifier(identifier)
+ , m_proxy(identifier, device, shouldCaptureInGPUProcess, constraints)
, m_manager(manager)
- , m_shouldCaptureInGPUProcess(shouldCaptureInGPUProcess)
- , m_device(device)
{
- if (constraints)
- m_constraints = *constraints;
-
- ASSERT(m_device.type() == CaptureDevice::DeviceType::Microphone);
+ ASSERT(device.type() == CaptureDevice::DeviceType::Microphone);
#if PLATFORM(IOS_FAMILY)
RealtimeMediaSourceCenter::singleton().audioCaptureFactory().setActiveSource(*this);
#endif
@@ -71,15 +66,18 @@
void RemoteRealtimeAudioSource::createRemoteMediaSource()
{
- connection()->sendWithAsyncReply(Messages::UserMediaCaptureManagerProxy::CreateMediaSourceForCaptureDeviceWithConstraints(identifier(), m_device, deviceIDHashSalt(), m_constraints), [this, protectedThis = makeRef(*this)](bool succeeded, auto&& errorMessage, auto&& settings, auto&& capabilities, auto&&, auto, auto) {
+ m_proxy.createRemoteMediaSource(deviceIDHashSalt(), [this, protectedThis = makeRef(*this)](bool succeeded, auto&& errorMessage, auto&& settings, auto&& capabilities, auto&&, auto, auto) {
if (!succeeded) {
- didFail(WTFMove(errorMessage));
+ m_proxy.didFail(WTFMove(errorMessage));
return;
}
+
setSettings(WTFMove(settings));
setCapabilities(WTFMove(capabilities));
- setAsReady();
- if (m_shouldCaptureInGPUProcess)
+ setName(String { m_settings.label().string() });
+
+ m_proxy.setAsReady();
+ if (m_proxy.shouldCaptureInGPUProcess())
WebProcess::singleton().ensureGPUProcessConnection().addClient(*this);
});
}
@@ -86,7 +84,7 @@
RemoteRealtimeAudioSource::~RemoteRealtimeAudioSource()
{
- if (m_shouldCaptureInGPUProcess)
+ if (m_proxy.shouldCaptureInGPUProcess())
WebProcess::singleton().ensureGPUProcessConnection().removeClient(*this);
#if PLATFORM(IOS_FAMILY)
@@ -94,31 +92,6 @@
#endif
}
-void RemoteRealtimeAudioSource::whenReady(CompletionHandler<void(String)>&& callback)
-{
- if (m_isReady)
- return callback(WTFMove(m_errorMessage));
- m_callback = WTFMove(callback);
-}
-
-void RemoteRealtimeAudioSource::didFail(String&& errorMessage)
-{
- m_isReady = true;
- m_errorMessage = WTFMove(errorMessage);
- if (m_callback)
- m_callback(m_errorMessage);
-}
-
-void RemoteRealtimeAudioSource::setAsReady()
-{
- ASSERT(!m_isReady);
- m_isReady = true;
-
- setName(String { m_settings.label().string() });
- if (m_callback)
- m_callback({ });
-}
-
void RemoteRealtimeAudioSource::setCapabilities(RealtimeMediaSourceCapabilities&& capabilities)
{
m_capabilities = WTFMove(capabilities);
@@ -131,62 +104,22 @@
notifySettingsDidChangeObservers(changed);
}
-void RemoteRealtimeAudioSource::remoteAudioSamplesAvailable(const WTF::MediaTime& time, const PlatformAudioData& data, const AudioStreamDescription& description, size_t size)
+void RemoteRealtimeAudioSource::applyConstraintsSucceeded(WebCore::RealtimeMediaSourceSettings&& settings)
{
- ASSERT(!isMainThread());
- audioSamplesAvailable(time, data, description, size);
-}
-
-IPC::Connection* RemoteRealtimeAudioSource::connection()
-{
- ASSERT(isMainThread());
-#if ENABLE(GPU_PROCESS)
- if (m_shouldCaptureInGPUProcess)
- return &WebProcess::singleton().ensureGPUProcessConnection().connection();
-#endif
- return WebProcess::singleton().parentProcessConnection();
-}
-
-void RemoteRealtimeAudioSource::startProducingData()
-{
- connection()->send(Messages::UserMediaCaptureManagerProxy::StartProducingData { m_identifier }, 0);
-}
-
-void RemoteRealtimeAudioSource::stopProducingData()
-{
- connection()->send(Messages::UserMediaCaptureManagerProxy::StopProducingData { m_identifier }, 0);
-}
-
-const WebCore::RealtimeMediaSourceCapabilities& RemoteRealtimeAudioSource::capabilities()
-{
- return m_capabilities;
-}
-
-void RemoteRealtimeAudioSource::applyConstraints(const MediaConstraints& constraints, ApplyConstraintsHandler&& completionHandler)
-{
- m_pendingApplyConstraintsCallbacks.append(WTFMove(completionHandler));
- // FIXME: Use sendAsyncWithReply.
- connection()->send(Messages::UserMediaCaptureManagerProxy::ApplyConstraints { m_identifier, constraints }, 0);
-}
-
-void RemoteRealtimeAudioSource::applyConstraintsSucceeded(RealtimeMediaSourceSettings&& settings)
-{
setSettings(WTFMove(settings));
-
- auto callback = m_pendingApplyConstraintsCallbacks.takeFirst();
- callback({ });
+ m_proxy.applyConstraintsSucceeded();
}
-void RemoteRealtimeAudioSource::applyConstraintsFailed(String&& failedConstraint, String&& errorMessage)
+void RemoteRealtimeAudioSource::remoteAudioSamplesAvailable(const MediaTime& time, const PlatformAudioData& data, const AudioStreamDescription& description, size_t size)
{
- auto callback = m_pendingApplyConstraintsCallbacks.takeFirst();
- callback(ApplyConstraintsError { WTFMove(failedConstraint), WTFMove(errorMessage) });
+ ASSERT(!isMainThread());
+ audioSamplesAvailable(time, data, description, size);
}
void RemoteRealtimeAudioSource::hasEnded()
{
- connection()->send(Messages::UserMediaCaptureManagerProxy::End { m_identifier }, 0);
- m_manager.removeAudioSource(m_identifier);
+ m_proxy.hasEnded();
+ m_manager.removeAudioSource(identifier());
m_manager.remoteCaptureSampleManager().removeSource(identifier());
}
@@ -205,7 +138,7 @@
#if ENABLE(GPU_PROCESS)
void RemoteRealtimeAudioSource::gpuProcessConnectionDidClose(GPUProcessConnection&)
{
- ASSERT(m_shouldCaptureInGPUProcess);
+ ASSERT(m_proxy.shouldCaptureInGPUProcess());
if (isEnded())
return;
@@ -218,11 +151,13 @@
#endif
m_manager.remoteCaptureSampleManager().didUpdateSourceConnection(connection());
- m_isReady = false;
+ m_proxy.resetReady();
createRemoteMediaSource();
// FIXME: We should update the track according current settings.
if (isProducingData())
startProducingData();
+
+ m_proxy.failApplyConstraintCallbacks("GPU Process terminated"_s);
}
#endif
Modified: trunk/Source/WebKit/WebProcess/cocoa/RemoteRealtimeAudioSource.h (272854 => 272855)
--- trunk/Source/WebKit/WebProcess/cocoa/RemoteRealtimeAudioSource.h 2021-02-15 17:07:49 UTC (rev 272854)
+++ trunk/Source/WebKit/WebProcess/cocoa/RemoteRealtimeAudioSource.h 2021-02-15 17:09:25 UTC (rev 272855)
@@ -28,8 +28,8 @@
#if PLATFORM(COCOA) && ENABLE(MEDIA_STREAM)
#include "GPUProcessConnection.h"
+#include "RemoteRealtimeMediaSourceProxy.h"
#include <WebCore/CaptureDevice.h>
-#include <WebCore/RealtimeMediaSource.h>
#include <WebCore/RealtimeMediaSourceIdentifier.h>
#include <wtf/Deque.h>
@@ -48,7 +48,7 @@
class UserMediaCaptureManager;
-class RemoteRealtimeAudioSource : public WebCore::RealtimeMediaSource
+class RemoteRealtimeAudioSource final : public WebCore::RealtimeMediaSource
#if ENABLE(GPU_PROCESS)
, public GPUProcessConnection::Client
#endif
@@ -57,34 +57,34 @@
static Ref<WebCore::RealtimeMediaSource> create(const WebCore::CaptureDevice&, const WebCore::MediaConstraints*, String&& name, String&& hashSalt, UserMediaCaptureManager&, bool shouldCaptureInGPUProcess);
~RemoteRealtimeAudioSource();
- WebCore::RealtimeMediaSourceIdentifier identifier() const { return m_identifier; }
- IPC::Connection* connection();
+ WebCore::RealtimeMediaSourceIdentifier identifier() const { return m_proxy.identifier(); }
+ IPC::Connection* connection() { return m_proxy.connection(); }
void setSettings(WebCore::RealtimeMediaSourceSettings&&);
void applyConstraintsSucceeded(WebCore::RealtimeMediaSourceSettings&&);
- void applyConstraintsFailed(String&& failedConstraint, String&& errorMessage);
+ void applyConstraintsFailed(String&& failedConstraint, String&& errorMessage) { m_proxy.applyConstraintsFailed(WTFMove(failedConstraint), WTFMove(errorMessage)); }
void captureStopped();
void captureFailed() final;
- void remoteAudioSamplesAvailable(const WTF::MediaTime&, const WebCore::PlatformAudioData&, const WebCore::AudioStreamDescription&, size_t);
+ void remoteAudioSamplesAvailable(const MediaTime&, const WebCore::PlatformAudioData&, const WebCore::AudioStreamDescription&, size_t);
private:
RemoteRealtimeAudioSource(WebCore::RealtimeMediaSourceIdentifier, const WebCore::CaptureDevice&, const WebCore::MediaConstraints*, String&& name, String&& hashSalt, UserMediaCaptureManager&, bool shouldCaptureInGPUProcess);
// RealtimeMediaSource
- void startProducingData() final;
- void stopProducingData() final;
+ void startProducingData() final { m_proxy.startProducingData(); }
+ void stopProducingData() final { m_proxy.stopProducingData(); }
bool isCaptureSource() const final { return true; }
void beginConfiguration() final { }
void commitConfiguration() final { }
- void applyConstraints(const WebCore::MediaConstraints&, ApplyConstraintsHandler&&) final;
+ void applyConstraints(const WebCore::MediaConstraints& constraints, ApplyConstraintsHandler&& callback) final { m_proxy.applyConstraints(constraints, WTFMove(callback)); }
void hasEnded() final;
const WebCore::RealtimeMediaSourceSettings& settings() final { return m_settings; }
- const WebCore::RealtimeMediaSourceCapabilities& capabilities() final;
- void whenReady(CompletionHandler<void(String)>&&) final;
- WebCore::CaptureDevice::DeviceType deviceType() const final { return m_device.type(); }
+ const WebCore::RealtimeMediaSourceCapabilities& capabilities() final { return m_capabilities; }
+ void whenReady(CompletionHandler<void(String)>&& callback) final { m_proxy.whenReady(WTFMove(callback)); }
+ WebCore::CaptureDevice::DeviceType deviceType() const final { return m_proxy.deviceType(); }
#if ENABLE(GPU_PROCESS)
// GPUProcessConnection::Client
@@ -92,22 +92,12 @@
#endif
void createRemoteMediaSource();
- void didFail(String&& errorMessage);
- void setAsReady();
void setCapabilities(WebCore::RealtimeMediaSourceCapabilities&&);
- WebCore::RealtimeMediaSourceIdentifier m_identifier;
+ RemoteRealtimeMediaSourceProxy m_proxy;
UserMediaCaptureManager& m_manager;
WebCore::RealtimeMediaSourceCapabilities m_capabilities;
WebCore::RealtimeMediaSourceSettings m_settings;
-
- Deque<ApplyConstraintsHandler> m_pendingApplyConstraintsCallbacks;
- bool m_shouldCaptureInGPUProcess { false };
- bool m_isReady { false };
- String m_errorMessage;
- CompletionHandler<void(String)> m_callback;
- WebCore::CaptureDevice m_device;
- WebCore::MediaConstraints m_constraints;
};
} // namespace WebKit
Added: trunk/Source/WebKit/WebProcess/cocoa/RemoteRealtimeMediaSourceProxy.cpp (0 => 272855)
--- trunk/Source/WebKit/WebProcess/cocoa/RemoteRealtimeMediaSourceProxy.cpp (rev 0)
+++ trunk/Source/WebKit/WebProcess/cocoa/RemoteRealtimeMediaSourceProxy.cpp 2021-02-15 17:09:25 UTC (rev 272855)
@@ -0,0 +1,128 @@
+/*
+ * 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 "RemoteRealtimeMediaSourceProxy.h"
+
+#if PLATFORM(COCOA) && ENABLE(MEDIA_STREAM)
+
+#include "GPUProcessConnection.h"
+#include "SharedRingBufferStorage.h"
+#include "UserMediaCaptureManager.h"
+#include "UserMediaCaptureManagerMessages.h"
+#include "UserMediaCaptureManagerProxyMessages.h"
+#include "WebCoreArgumentCoders.h"
+#include "WebProcess.h"
+#include <WebCore/MediaConstraints.h>
+#include <WebCore/RealtimeMediaSource.h>
+#include <WebCore/RealtimeMediaSourceCenter.h>
+#include <WebCore/WebAudioBufferList.h>
+
+namespace WebKit {
+using namespace PAL;
+using namespace WebCore;
+
+IPC::Connection* RemoteRealtimeMediaSourceProxy::connection()
+{
+ ASSERT(isMainThread());
+#if ENABLE(GPU_PROCESS)
+ if (m_shouldCaptureInGPUProcess)
+ return &WebProcess::singleton().ensureGPUProcessConnection().connection();
+#endif
+ return WebProcess::singleton().parentProcessConnection();
+}
+
+void RemoteRealtimeMediaSourceProxy::startProducingData()
+{
+ connection()->send(Messages::UserMediaCaptureManagerProxy::StartProducingData { m_identifier }, 0);
+}
+
+void RemoteRealtimeMediaSourceProxy::stopProducingData()
+{
+ connection()->send(Messages::UserMediaCaptureManagerProxy::StopProducingData { m_identifier }, 0);
+}
+
+void RemoteRealtimeMediaSourceProxy::createRemoteMediaSource(const String& deviceIDHashSalt, CreateCallback&& callback)
+{
+ connection()->sendWithAsyncReply(Messages::UserMediaCaptureManagerProxy::CreateMediaSourceForCaptureDeviceWithConstraints(identifier(), m_device, deviceIDHashSalt, m_constraints), WTFMove(callback));
+}
+
+void RemoteRealtimeMediaSourceProxy::applyConstraints(const MediaConstraints& constraints, RealtimeMediaSource::ApplyConstraintsHandler&& completionHandler)
+{
+ m_pendingApplyConstraintsCallbacks.append(WTFMove(completionHandler));
+ // FIXME: Use sendAsyncWithReply.
+ connection()->send(Messages::UserMediaCaptureManagerProxy::ApplyConstraints { m_identifier, constraints }, 0);
+}
+
+void RemoteRealtimeMediaSourceProxy::applyConstraintsSucceeded()
+{
+ auto callback = m_pendingApplyConstraintsCallbacks.takeFirst();
+ callback({ });
+}
+
+void RemoteRealtimeMediaSourceProxy::applyConstraintsFailed(String&& failedConstraint, String&& errorMessage)
+{
+ auto callback = m_pendingApplyConstraintsCallbacks.takeFirst();
+ callback(RealtimeMediaSource::ApplyConstraintsError { WTFMove(failedConstraint), WTFMove(errorMessage) });
+}
+
+void RemoteRealtimeMediaSourceProxy::failApplyConstraintCallbacks(const String& errorMessage)
+{
+ auto callbacks = WTFMove(m_pendingApplyConstraintsCallbacks);
+ while (!callbacks.isEmpty())
+ callbacks.takeFirst()(RealtimeMediaSource::ApplyConstraintsError { { }, errorMessage });
+}
+
+void RemoteRealtimeMediaSourceProxy::hasEnded()
+{
+ connection()->send(Messages::UserMediaCaptureManagerProxy::End { m_identifier }, 0);
+}
+
+void RemoteRealtimeMediaSourceProxy::whenReady(CompletionHandler<void(String)>&& callback)
+{
+ if (m_isReady)
+ return callback(WTFMove(m_errorMessage));
+ m_callback = WTFMove(callback);
+}
+
+void RemoteRealtimeMediaSourceProxy::setAsReady()
+{
+ ASSERT(!m_isReady);
+ m_isReady = true;
+ if (m_callback)
+ m_callback({ });
+}
+
+void RemoteRealtimeMediaSourceProxy::didFail(String&& errorMessage)
+{
+ m_isReady = true;
+ m_errorMessage = WTFMove(errorMessage);
+ if (m_callback)
+ m_callback(m_errorMessage);
+}
+
+}
+
+#endif
Added: trunk/Source/WebKit/WebProcess/cocoa/RemoteRealtimeMediaSourceProxy.h (0 => 272855)
--- trunk/Source/WebKit/WebProcess/cocoa/RemoteRealtimeMediaSourceProxy.h (rev 0)
+++ trunk/Source/WebKit/WebProcess/cocoa/RemoteRealtimeMediaSourceProxy.h 2021-02-15 17:09:25 UTC (rev 272855)
@@ -0,0 +1,97 @@
+/*
+ * 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 PLATFORM(COCOA) && ENABLE(MEDIA_STREAM)
+
+#include "UserMediaCaptureManagerProxyMessages.h"
+#include <WebCore/RealtimeMediaSource.h>
+
+namespace IPC {
+class Connection;
+}
+
+namespace WebCore {
+class CAAudioStreamDescription;
+class ImageTransferSessionVT;
+struct MediaConstraints;
+class RemoteVideoSample;
+}
+
+namespace WebKit {
+
+class RemoteRealtimeMediaSourceProxy {
+public:
+ RemoteRealtimeMediaSourceProxy(WebCore::RealtimeMediaSourceIdentifier, const WebCore::CaptureDevice&, bool shouldCaptureInGPUProcess, const WebCore::MediaConstraints*);
+
+ IPC::Connection* connection();
+ WebCore::RealtimeMediaSourceIdentifier identifier() const { return m_identifier; }
+ WebCore::CaptureDevice::DeviceType deviceType() const { return m_device.type(); }
+ bool shouldCaptureInGPUProcess() const { return m_shouldCaptureInGPUProcess; }
+
+ using CreateCallback = CompletionHandler<void(bool, String&&, WebCore::RealtimeMediaSourceSettings&&, WebCore::RealtimeMediaSourceCapabilities&&, Vector<WebCore::VideoPresetData>&&, WebCore::IntSize, double)>;
+ void createRemoteMediaSource(const String&, CreateCallback&&);
+
+ void applyConstraintsSucceeded();
+ void applyConstraintsFailed(String&& failedConstraint, String&& errorMessage);
+ void failApplyConstraintCallbacks(const String& errorMessage);
+
+ void hasEnded();
+ void startProducingData();
+ void stopProducingData();
+ void applyConstraints(const WebCore::MediaConstraints&, WebCore::RealtimeMediaSource::ApplyConstraintsHandler&&);
+
+ void whenReady(CompletionHandler<void(String)>&&);
+ void setAsReady();
+ void resetReady() { m_isReady = false; }
+ bool isReady() const { return m_isReady; }
+
+ void didFail(String&& errorMessage);
+
+private:
+ WebCore::RealtimeMediaSourceIdentifier m_identifier;
+ WebCore::CaptureDevice m_device;
+ bool m_shouldCaptureInGPUProcess { false };
+
+ WebCore::MediaConstraints m_constraints;
+ Deque<WebCore::RealtimeMediaSource::ApplyConstraintsHandler> m_pendingApplyConstraintsCallbacks;
+ bool m_isReady { false };
+ CompletionHandler<void(String)> m_callback;
+ String m_errorMessage;
+};
+
+inline RemoteRealtimeMediaSourceProxy::RemoteRealtimeMediaSourceProxy(WebCore::RealtimeMediaSourceIdentifier identifier, const WebCore::CaptureDevice& device, bool shouldCaptureInGPUProcess, const WebCore::MediaConstraints* constraints)
+ : m_identifier(identifier)
+ , m_device(device)
+ , m_shouldCaptureInGPUProcess(shouldCaptureInGPUProcess)
+{
+ if (constraints)
+ m_constraints = *constraints;
+}
+
+} // namespace WebKit
+
+#endif
Modified: trunk/Source/WebKit/WebProcess/cocoa/RemoteRealtimeVideoSource.cpp (272854 => 272855)
--- trunk/Source/WebKit/WebProcess/cocoa/RemoteRealtimeVideoSource.cpp 2021-02-15 17:07:49 UTC (rev 272854)
+++ trunk/Source/WebKit/WebProcess/cocoa/RemoteRealtimeVideoSource.cpp 2021-02-15 17:09:25 UTC (rev 272855)
@@ -56,15 +56,11 @@
RemoteRealtimeVideoSource::RemoteRealtimeVideoSource(RealtimeMediaSourceIdentifier identifier, const CaptureDevice& device, const MediaConstraints* constraints, String&& name, String&& hashSalt, UserMediaCaptureManager& manager, bool shouldCaptureInGPUProcess)
: RealtimeVideoCaptureSource(WTFMove(name), String::number(identifier.toUInt64()), WTFMove(hashSalt))
- , m_identifier(identifier)
+ , m_proxy(identifier, device, shouldCaptureInGPUProcess, constraints)
, m_manager(manager)
- , m_device(device)
- , m_shouldCaptureInGPUProcess(shouldCaptureInGPUProcess)
{
- if (constraints)
- m_constraints = *constraints;
#if PLATFORM(IOS_FAMILY)
- if (m_device.type() == CaptureDevice::DeviceType::Camera)
+ if (deviceType() == CaptureDevice::DeviceType::Camera)
RealtimeMediaSourceCenter::singleton().videoCaptureFactory().setActiveSource(*this);
#endif
}
@@ -71,15 +67,12 @@
void RemoteRealtimeVideoSource::createRemoteMediaSource()
{
- connection()->sendWithAsyncReply(Messages::UserMediaCaptureManagerProxy::CreateMediaSourceForCaptureDeviceWithConstraints(identifier(), m_device, deviceIDHashSalt(), m_constraints), [this, protectedThis = makeRef(*this)](bool succeeded, auto&& errorMessage, auto&& settings, auto&& capabilities, auto&& presets, auto size, auto frameRate) mutable {
+ m_proxy.createRemoteMediaSource(deviceIDHashSalt(), [this, protectedThis = makeRef(*this)](bool succeeded, auto&& errorMessage, auto&& settings, auto&& capabilities, auto&& presets, auto size, auto frameRate) mutable {
if (!succeeded) {
- didFail(WTFMove(errorMessage));
+ m_proxy.didFail(WTFMove(errorMessage));
return;
}
- if (m_shouldCaptureInGPUProcess)
- WebProcess::singleton().ensureGPUProcessConnection().addClient(*this);
-
setSize(size);
setFrameRate(frameRate);
@@ -86,48 +79,25 @@
setSettings(WTFMove(settings));
setCapabilities(WTFMove(capabilities));
setSupportedPresets(WTFMove(presets));
+ setName(String { m_settings.label().string() });
- setAsReady();
+ m_proxy.setAsReady();
+ if (m_proxy.shouldCaptureInGPUProcess())
+ WebProcess::singleton().ensureGPUProcessConnection().addClient(*this);
});
}
RemoteRealtimeVideoSource::~RemoteRealtimeVideoSource()
{
- if (m_shouldCaptureInGPUProcess)
+ if (m_proxy.shouldCaptureInGPUProcess())
WebProcess::singleton().ensureGPUProcessConnection().removeClient(*this);
#if PLATFORM(IOS_FAMILY)
- if (m_device.type() == CaptureDevice::DeviceType::Camera)
+ if (deviceType() == CaptureDevice::DeviceType::Camera)
RealtimeMediaSourceCenter::singleton().videoCaptureFactory().unsetActiveSource(*this);
#endif
}
-void RemoteRealtimeVideoSource::whenReady(CompletionHandler<void(String)>&& callback)
-{
- if (m_isReady)
- return callback(WTFMove(m_errorMessage));
- m_callback = WTFMove(callback);
-}
-
-void RemoteRealtimeVideoSource::didFail(String&& errorMessage)
-{
- m_isReady = true;
- m_errorMessage = WTFMove(errorMessage);
- if (m_callback)
- m_callback(m_errorMessage);
-}
-
-void RemoteRealtimeVideoSource::setAsReady()
-{
- ASSERT(!m_isReady);
- m_isReady = true;
-
- setName(String { m_settings.label().string() });
-
- if (m_callback)
- m_callback({ });
-}
-
void RemoteRealtimeVideoSource::setCapabilities(RealtimeMediaSourceCapabilities&& capabilities)
{
m_capabilities = WTFMove(capabilities);
@@ -162,29 +132,9 @@
dispatchMediaSampleToObservers(sample);
}
-IPC::Connection* RemoteRealtimeVideoSource::connection()
-{
- ASSERT(isMainThread());
-#if ENABLE(GPU_PROCESS)
- if (m_shouldCaptureInGPUProcess)
- return &WebProcess::singleton().ensureGPUProcessConnection().connection();
-#endif
- return WebProcess::singleton().parentProcessConnection();
-}
-
-void RemoteRealtimeVideoSource::startProducingData()
-{
- connection()->send(Messages::UserMediaCaptureManagerProxy::StartProducingData { m_identifier }, 0);
-}
-
-void RemoteRealtimeVideoSource::stopProducingData()
-{
- connection()->send(Messages::UserMediaCaptureManagerProxy::StopProducingData { m_identifier }, 0);
-}
-
bool RemoteRealtimeVideoSource::setShouldApplyRotation(bool shouldApplyRotation)
{
- connection()->send(Messages::UserMediaCaptureManagerProxy::SetShouldApplyRotation { m_identifier, shouldApplyRotation }, 0);
+ connection()->send(Messages::UserMediaCaptureManagerProxy::SetShouldApplyRotation { identifier(), shouldApplyRotation }, 0);
return true;
}
@@ -195,8 +145,8 @@
void RemoteRealtimeVideoSource::hasEnded()
{
- connection()->send(Messages::UserMediaCaptureManagerProxy::End { m_identifier }, 0);
- m_manager.removeVideoSource(m_identifier);
+ m_proxy.hasEnded();
+ m_manager.removeVideoSource(identifier());
m_manager.remoteCaptureSampleManager().removeSource(identifier());
}
@@ -214,7 +164,7 @@
void RemoteRealtimeVideoSource::generatePresets()
{
- ASSERT(m_isReady);
+ ASSERT(m_proxy.isReady());
}
void RemoteRealtimeVideoSource::setFrameRateWithPreset(double frameRate, RefPtr<VideoPreset> preset)
@@ -236,7 +186,7 @@
constraints.mandatoryConstraints.set(MediaConstraintType::Height, heightConstraint);
}
- connection()->send(Messages::UserMediaCaptureManagerProxy::ApplyConstraints { m_identifier, constraints }, 0);
+ connection()->send(Messages::UserMediaCaptureManagerProxy::ApplyConstraints { identifier(), constraints }, 0);
}
bool RemoteRealtimeVideoSource::prefersPreset(VideoPreset&)
@@ -247,12 +197,12 @@
#if ENABLE(GPU_PROCESS)
void RemoteRealtimeVideoSource::gpuProcessConnectionDidClose(GPUProcessConnection&)
{
- ASSERT(m_shouldCaptureInGPUProcess);
+ ASSERT(m_proxy.shouldCaptureInGPUProcess());
if (isEnded())
return;
#if PLATFORM(IOS_FAMILY)
- if (m_device.type() == CaptureDevice::DeviceType::Camera && this != RealtimeMediaSourceCenter::singleton().videoCaptureFactory().activeSource()) {
+ if (deviceType() == CaptureDevice::DeviceType::Camera && this != RealtimeMediaSourceCenter::singleton().videoCaptureFactory().activeSource()) {
// Track is muted and has no chance of being unmuted, let's end it.
captureFailed();
return;
@@ -260,7 +210,7 @@
#endif
m_manager.remoteCaptureSampleManager().didUpdateSourceConnection(connection());
- m_isReady = false;
+ m_proxy.resetReady();
createRemoteMediaSource();
// FIXME: We should update the track according current settings.
if (isProducingData())
Modified: trunk/Source/WebKit/WebProcess/cocoa/RemoteRealtimeVideoSource.h (272854 => 272855)
--- trunk/Source/WebKit/WebProcess/cocoa/RemoteRealtimeVideoSource.h 2021-02-15 17:07:49 UTC (rev 272854)
+++ trunk/Source/WebKit/WebProcess/cocoa/RemoteRealtimeVideoSource.h 2021-02-15 17:09:25 UTC (rev 272855)
@@ -28,6 +28,7 @@
#if PLATFORM(COCOA) && ENABLE(MEDIA_STREAM)
#include "GPUProcessConnection.h"
+#include "RemoteRealtimeMediaSourceProxy.h"
#include <WebCore/CaptureDevice.h>
#include <WebCore/RealtimeMediaSourceIdentifier.h>
#include <WebCore/RealtimeVideoCaptureSource.h>
@@ -48,7 +49,7 @@
class UserMediaCaptureManager;
-class RemoteRealtimeVideoSource : public WebCore::RealtimeVideoCaptureSource
+class RemoteRealtimeVideoSource final : public WebCore::RealtimeVideoCaptureSource
#if ENABLE(GPU_PROCESS)
, public GPUProcessConnection::Client
#endif
@@ -57,8 +58,8 @@
static Ref<WebCore::RealtimeVideoCaptureSource> create(const WebCore::CaptureDevice&, const WebCore::MediaConstraints*, String&& name, String&& hashSalt, UserMediaCaptureManager&, bool shouldCaptureInGPUProcess);
~RemoteRealtimeVideoSource();
- WebCore::RealtimeMediaSourceIdentifier identifier() const { return m_identifier; }
- IPC::Connection* connection();
+ WebCore::RealtimeMediaSourceIdentifier identifier() const { return m_proxy.identifier(); }
+ IPC::Connection* connection() { return m_proxy.connection(); }
void setSettings(WebCore::RealtimeMediaSourceSettings&&);
@@ -71,8 +72,8 @@
RemoteRealtimeVideoSource(WebCore::RealtimeMediaSourceIdentifier, const WebCore::CaptureDevice&, const WebCore::MediaConstraints*, String&& name, String&& hashSalt, UserMediaCaptureManager&, bool shouldCaptureInGPUProcess);
// WebCore::RealtimeMediaSource
- void startProducingData() final;
- void stopProducingData() final;
+ void startProducingData() final { m_proxy.startProducingData(); }
+ void stopProducingData() final { m_proxy.stopProducingData(); }
bool isCaptureSource() const final { return true; }
void beginConfiguration() final { }
void commitConfiguration() final { }
@@ -80,8 +81,8 @@
void hasEnded() final;
const WebCore::RealtimeMediaSourceSettings& settings() final { return m_settings; }
const WebCore::RealtimeMediaSourceCapabilities& capabilities() final;
- void whenReady(CompletionHandler<void(String)>&&) final;
- WebCore::CaptureDevice::DeviceType deviceType() const final { return m_device.type(); }
+ void whenReady(CompletionHandler<void(String)>&& callback) final { m_proxy.whenReady(WTFMove(callback)); }
+ WebCore::CaptureDevice::DeviceType deviceType() const final { return m_proxy.deviceType(); }
// WebCore::RealtimeVideoCaptureSource
void generatePresets() final;
@@ -99,19 +100,12 @@
void setAsReady();
void setCapabilities(WebCore::RealtimeMediaSourceCapabilities&&);
- WebCore::RealtimeMediaSourceIdentifier m_identifier;
+ RemoteRealtimeMediaSourceProxy m_proxy;
UserMediaCaptureManager& m_manager;
+
WebCore::RealtimeMediaSourceCapabilities m_capabilities;
WebCore::RealtimeMediaSourceSettings m_settings;
-
- WebCore::CaptureDevice m_device;
- WebCore::MediaConstraints m_constraints;
-
WebCore::MediaSample::VideoRotation m_sampleRotation { WebCore::MediaSample::VideoRotation::None };
- bool m_shouldCaptureInGPUProcess { false };
- bool m_isReady { false };
- String m_errorMessage;
- CompletionHandler<void(String)> m_callback;
};
} // namespace WebKit