Diff
Modified: trunk/Source/WebCore/ChangeLog (258200 => 258201)
--- trunk/Source/WebCore/ChangeLog 2020-03-10 12:49:58 UTC (rev 258200)
+++ trunk/Source/WebCore/ChangeLog 2020-03-10 12:53:39 UTC (rev 258201)
@@ -1,3 +1,21 @@
+2020-03-10 youenn fablet <[email protected]>
+
+ Remove sync IPC when creating a remote capture source
+ https://bugs.webkit.org/show_bug.cgi?id=208816
+
+ Reviewed by Eric Carlson.
+
+ Add a whenInitialized method to allow for async creation of realtime media source.
+ Use this method when creating a MediaStream for getUserMedia/getDisplayMedia.
+ Covered by existing tests.
+
+ * platform/mediastream/MediaStreamPrivate.cpp:
+ (WebCore::MediaStreamPrivate::create):
+ * platform/mediastream/MediaStreamPrivate.h:
+ * platform/mediastream/RealtimeMediaSource.h:
+ * platform/mediastream/RealtimeMediaSourceCenter.cpp:
+ (WebCore::RealtimeMediaSourceCenter::createMediaStream):
+
2020-03-10 Philippe Normand <[email protected]>
Unreviewed, !USE(GSTREAMER_GL) build fix after r258197.
Modified: trunk/Source/WebCore/platform/mediastream/MediaStreamPrivate.cpp (258200 => 258201)
--- trunk/Source/WebCore/platform/mediastream/MediaStreamPrivate.cpp 2020-03-10 12:49:58 UTC (rev 258200)
+++ trunk/Source/WebCore/platform/mediastream/MediaStreamPrivate.cpp 2020-03-10 12:53:39 UTC (rev 258201)
@@ -51,17 +51,16 @@
return MediaStreamPrivate::create(WTFMove(logger), MediaStreamTrackPrivateVector::from(MediaStreamTrackPrivate::create(WTFMove(loggerCopy), WTFMove(source))));
}
-Ref<MediaStreamPrivate> MediaStreamPrivate::create(Ref<const Logger>&& logger, const Vector<Ref<RealtimeMediaSource>>& audioSources, const Vector<Ref<RealtimeMediaSource>>& videoSources)
+Ref<MediaStreamPrivate> MediaStreamPrivate::create(Ref<const Logger>&& logger, RefPtr<RealtimeMediaSource>&& audioSource, RefPtr<RealtimeMediaSource>&& videoSource)
{
MediaStreamTrackPrivateVector tracks;
- tracks.reserveInitialCapacity(audioSources.size() + videoSources.size());
+ tracks.reserveInitialCapacity(2);
- for (auto& source : audioSources)
- tracks.uncheckedAppend(MediaStreamTrackPrivate::create(logger.copyRef(), source.copyRef()));
+ if (audioSource)
+ tracks.uncheckedAppend(MediaStreamTrackPrivate::create(logger.copyRef(), audioSource.releaseNonNull()));
+ if (videoSource)
+ tracks.uncheckedAppend(MediaStreamTrackPrivate::create(logger.copyRef(), videoSource.releaseNonNull()));
- for (auto& source : videoSources)
- tracks.uncheckedAppend(MediaStreamTrackPrivate::create(logger.copyRef(), source.copyRef()));
-
return MediaStreamPrivate::create(WTFMove(logger), tracks);
}
Modified: trunk/Source/WebCore/platform/mediastream/MediaStreamPrivate.h (258200 => 258201)
--- trunk/Source/WebCore/platform/mediastream/MediaStreamPrivate.h 2020-03-10 12:49:58 UTC (rev 258200)
+++ trunk/Source/WebCore/platform/mediastream/MediaStreamPrivate.h 2020-03-10 12:53:39 UTC (rev 258201)
@@ -69,7 +69,7 @@
};
static Ref<MediaStreamPrivate> create(Ref<const Logger>&&, Ref<RealtimeMediaSource>&&);
- static Ref<MediaStreamPrivate> create(Ref<const Logger>&&, const Vector<Ref<RealtimeMediaSource>>& audioSources, const Vector<Ref<RealtimeMediaSource>>& videoSources);
+ static Ref<MediaStreamPrivate> create(Ref<const Logger>&&, RefPtr<RealtimeMediaSource>&& audioSource, RefPtr<RealtimeMediaSource>&& videoSource);
static Ref<MediaStreamPrivate> create(Ref<const Logger>&& logger, const MediaStreamTrackPrivateVector& tracks, String&& id = createCanonicalUUIDString()) { return adoptRef(*new MediaStreamPrivate(WTFMove(logger), tracks, WTFMove(id))); }
virtual ~MediaStreamPrivate();
Modified: trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.h (258200 => 258201)
--- trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.h 2020-03-10 12:49:58 UTC (rev 258200)
+++ trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.h 2020-03-10 12:53:39 UTC (rev 258201)
@@ -42,6 +42,7 @@
#include "PlatformLayer.h"
#include "RealtimeMediaSourceCapabilities.h"
#include "RealtimeMediaSourceFactory.h"
+#include <wtf/CompletionHandler.h>
#include <wtf/LoggerHelper.h>
#include <wtf/RecursiveLockAdapter.h>
#include <wtf/ThreadSafeRefCounted.h>
@@ -107,6 +108,8 @@
enum class Type { None, Audio, Video };
Type type() const { return m_type; }
+ virtual void whenReady(CompletionHandler<void(String)>&&);
+
bool isProducingData() const { return m_isProducingData; }
void start();
void stop();
@@ -283,6 +286,11 @@
String convertEnumerationToString(RealtimeMediaSource::Type);
+inline void RealtimeMediaSource::whenReady(CompletionHandler<void(String)>&& callback)
+{
+ callback({ });
+}
+
} // namespace WebCore
namespace WTF {
Modified: trunk/Source/WebCore/platform/mediastream/RealtimeMediaSourceCenter.cpp (258200 => 258201)
--- trunk/Source/WebCore/platform/mediastream/RealtimeMediaSourceCenter.cpp 2020-03-10 12:49:58 UTC (rev 258200)
+++ trunk/Source/WebCore/platform/mediastream/RealtimeMediaSourceCenter.cpp 2020-03-10 12:53:39 UTC (rev 258201)
@@ -70,40 +70,47 @@
Vector<Ref<RealtimeMediaSource>> videoSources;
String invalidConstraint;
+ RefPtr<RealtimeMediaSource> audioSource;
if (audioDevice) {
- auto audioSource = audioCaptureFactory().createAudioCaptureSource(WTFMove(audioDevice), String { hashSalt }, &request.audioConstraints);
- if (audioSource)
- audioSources.append(audioSource.source());
- else {
-#if !LOG_DISABLED
- if (!audioSource.errorMessage.isEmpty())
- LOG(Media, "RealtimeMediaSourceCenter::createMediaStream(%p), audio constraints failed to apply: %s", this, audioSource.errorMessage.utf8().data());
-#endif
- completionHandler(makeUnexpected(makeString("Failed to create MediaStream audio source: ", audioSource.errorMessage)));
+ auto source = audioCaptureFactory().createAudioCaptureSource(WTFMove(audioDevice), String { hashSalt }, &request.audioConstraints);
+ if (!source) {
+ completionHandler(makeUnexpected(makeString("Failed to create MediaStream audio source: ", source.errorMessage)));
return;
}
+ audioSource = source.source();
}
+ RefPtr<RealtimeMediaSource> videoSource;
if (videoDevice) {
- CaptureSourceOrError videoSource;
+ CaptureSourceOrError source;
if (videoDevice.type() == CaptureDevice::DeviceType::Camera)
- videoSource = videoCaptureFactory().createVideoCaptureSource(WTFMove(videoDevice), WTFMove(hashSalt), &request.videoConstraints);
+ source = videoCaptureFactory().createVideoCaptureSource(WTFMove(videoDevice), WTFMove(hashSalt), &request.videoConstraints);
else
- videoSource = displayCaptureFactory().createDisplayCaptureSource(WTFMove(videoDevice), &request.videoConstraints);
+ source = displayCaptureFactory().createDisplayCaptureSource(WTFMove(videoDevice), &request.videoConstraints);
- if (videoSource)
- videoSources.append(videoSource.source());
- else {
-#if !LOG_DISABLED
- if (!videoSource.errorMessage.isEmpty())
- LOG(Media, "RealtimeMediaSourceCenter::createMediaStream(%p), video constraints failed to apply: %s", this, videoSource.errorMessage.utf8().data());
-#endif
- completionHandler(makeUnexpected(makeString("Failed to create MediaStream video source: ", videoSource.errorMessage)));
+ if (!source) {
+ completionHandler(makeUnexpected(makeString("Failed to create MediaStream video source: ", source.errorMessage)));
return;
}
+ videoSource = source.source();
}
- completionHandler(MediaStreamPrivate::create(WTFMove(logger), audioSources, videoSources));
+ CompletionHandler<void(String&&)> whenAudioSourceReady = [audioSource, videoSource = WTFMove(videoSource), logger = WTFMove(logger), completionHandler = WTFMove(completionHandler)](auto&& errorMessage) mutable {
+ if (!errorMessage.isEmpty())
+ return completionHandler(makeUnexpected(makeString("Failed to create MediaStream audio source: ", errorMessage)));
+ if (!videoSource)
+ return completionHandler(MediaStreamPrivate::create(WTFMove(logger), WTFMove(audioSource), WTFMove(videoSource)));
+
+ CompletionHandler<void(String&&)> whenVideoSourceReady = [audioSource = WTFMove(audioSource), videoSource, logger = WTFMove(logger), completionHandler = WTFMove(completionHandler)](auto&& errorMessage) mutable {
+ if (!errorMessage.isEmpty())
+ return completionHandler(makeUnexpected(makeString("Failed to create MediaStream video source: ", errorMessage)));
+ completionHandler(MediaStreamPrivate::create(WTFMove(logger), WTFMove(audioSource), WTFMove(videoSource)));
+ };
+ videoSource->whenReady(WTFMove(whenVideoSourceReady));
+ };
+ if (!audioSource)
+ return whenAudioSourceReady({ });
+ audioSource->whenReady(WTFMove(whenAudioSourceReady));
}
Vector<CaptureDevice> RealtimeMediaSourceCenter::getMediaStreamDevices()
Modified: trunk/Source/WebKit/ChangeLog (258200 => 258201)
--- trunk/Source/WebKit/ChangeLog 2020-03-10 12:49:58 UTC (rev 258200)
+++ trunk/Source/WebKit/ChangeLog 2020-03-10 12:53:39 UTC (rev 258201)
@@ -1,5 +1,28 @@
2020-03-10 youenn fablet <[email protected]>
+ Remove sync IPC when creating a remote capture source
+ https://bugs.webkit.org/show_bug.cgi?id=208816
+
+ Reviewed by Eric Carlson.
+
+ Use whenInitialized to wait for the async IPC that tells whether the remote source was created successfully.
+ Use the async response to gather the capabilities so as to remove the corresponding sync IPC.
+
+ * Platform/IPC/Connection.h:
+ (IPC::AsyncReplyError::create):
+ * UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp:
+ (WebKit::UserMediaCaptureManagerProxy::createMediaSourceForCaptureDeviceWithConstraints):
+ * UIProcess/Cocoa/UserMediaCaptureManagerProxy.h:
+ * UIProcess/Cocoa/UserMediaCaptureManagerProxy.messages.in:
+ * WebProcess/cocoa/UserMediaCaptureManager.cpp:
+ (WebKit::UserMediaCaptureManager::Source::didFail):
+ (WebKit::UserMediaCaptureManager::Source::setAsReady):
+ (WebKit::UserMediaCaptureManager::Source::setCapabilities):
+ (WebKit::UserMediaCaptureManager::createCaptureSource):
+ (WebKit::UserMediaCaptureManager::Source::capabilities):
+
+2020-03-10 youenn fablet <[email protected]>
+
Do not process RTC Network messages coming from NetworkProcess if LibWebRTCNetwork is not active
https://bugs.webkit.org/show_bug.cgi?id=207376
Modified: trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp (258200 => 258201)
--- trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp 2020-03-10 12:49:58 UTC (rev 258200)
+++ trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp 2020-03-10 12:53:39 UTC (rev 258201)
@@ -431,11 +431,6 @@
remoteMediaPlayerManagerProxy().didReceiveSyncPlayerMessage(connection, decoder, replyEncoder);
return true;
}
-#if ENABLE(MEDIA_STREAM)
- if (decoder.messageReceiverName() == Messages::UserMediaCaptureManagerProxy::messageReceiverName()) {
- userMediaCaptureManagerProxy().didReceiveSyncMessageFromGPUProcess(connection, decoder, replyEncoder);
- return true;
- }
#if PLATFORM(COCOA) && ENABLE(VIDEO_TRACK)
if (decoder.messageReceiverName() == Messages::RemoteSampleBufferDisplayLayerManager::messageReceiverName()) {
sampleBufferDisplayLayerManager().didReceiveSyncMessageFromWebProcess(connection, decoder, replyEncoder);
@@ -442,7 +437,6 @@
return true;
}
#endif
-#endif
#if ENABLE(ENCRYPTED_MEDIA)
if (decoder.messageReceiverName() == Messages::RemoteCDMFactoryProxy::messageReceiverName()) {
cdmFactoryProxy().didReceiveSyncMessageFromWebProcess(connection, decoder, replyEncoder);
Modified: trunk/Source/WebKit/Platform/IPC/Connection.h (258200 => 258201)
--- trunk/Source/WebKit/Platform/IPC/Connection.h 2020-03-10 12:49:58 UTC (rev 258200)
+++ trunk/Source/WebKit/Platform/IPC/Connection.h 2020-03-10 12:53:39 UTC (rev 258201)
@@ -85,7 +85,7 @@
while (0)
template<typename AsyncReplyResult> struct AsyncReplyError {
- static AsyncReplyResult create() { return { }; };
+ static AsyncReplyResult create() { return AsyncReplyResult { }; };
};
class MachMessage;
Modified: trunk/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp (258200 => 258201)
--- trunk/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp 2020-03-10 12:49:58 UTC (rev 258200)
+++ trunk/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp 2020-03-10 12:53:39 UTC (rev 258201)
@@ -177,7 +177,7 @@
m_connectionProxy->removeMessageReceiver(Messages::UserMediaCaptureManagerProxy::messageReceiverName());
}
-void UserMediaCaptureManagerProxy::createMediaSourceForCaptureDeviceWithConstraints(RealtimeMediaSourceIdentifier id, const CaptureDevice& device, String&& hashSalt, const MediaConstraints& constraints, CompletionHandler<void(bool succeeded, String invalidConstraints, WebCore::RealtimeMediaSourceSettings&&)>&& completionHandler)
+void UserMediaCaptureManagerProxy::createMediaSourceForCaptureDeviceWithConstraints(RealtimeMediaSourceIdentifier id, const CaptureDevice& device, String&& hashSalt, const MediaConstraints& constraints, CompletionHandler<void(bool succeeded, String invalidConstraints, WebCore::RealtimeMediaSourceSettings&&, WebCore::RealtimeMediaSourceCapabilities&&)>&& completionHandler)
{
CaptureSourceOrError sourceOrError;
switch (device.type()) {
@@ -203,6 +203,7 @@
bool succeeded = !!sourceOrError;
String invalidConstraints;
WebCore::RealtimeMediaSourceSettings settings;
+ WebCore::RealtimeMediaSourceCapabilities capabilities;
if (sourceOrError) {
auto source = sourceOrError.source();
#if !RELEASE_LOG_DISABLED
@@ -209,11 +210,12 @@
source->setLogger(m_connectionProxy->logger(), LoggerHelper::uniqueLogIdentifier());
#endif
settings = source->settings();
+ capabilities = source->capabilities();
ASSERT(!m_proxies.contains(id));
m_proxies.add(id, makeUnique<SourceProxy>(id, m_connectionProxy->connection(), WTFMove(source)));
} else
invalidConstraints = WTFMove(sourceOrError.errorMessage);
- completionHandler(succeeded, invalidConstraints, WTFMove(settings));
+ completionHandler(succeeded, invalidConstraints, WTFMove(settings), WTFMove(capabilities));
}
void UserMediaCaptureManagerProxy::startProducingData(RealtimeMediaSourceIdentifier id)
Modified: trunk/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.h (258200 => 258201)
--- trunk/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.h 2020-03-10 12:49:58 UTC (rev 258200)
+++ trunk/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.h 2020-03-10 12:53:39 UTC (rev 258201)
@@ -64,14 +64,12 @@
void setOrientation(uint64_t);
void didReceiveMessageFromGPUProcess(IPC::Connection& connection, IPC::Decoder& decoder) { didReceiveMessage(connection, decoder); }
- void didReceiveSyncMessageFromGPUProcess(IPC::Connection& connection, IPC::Decoder& decoder, std::unique_ptr<IPC::Encoder>& encoder) { didReceiveSyncMessage(connection, decoder, encoder); }
private:
// IPC::MessageReceiver
void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;
- void didReceiveSyncMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&) final;
- void createMediaSourceForCaptureDeviceWithConstraints(WebCore::RealtimeMediaSourceIdentifier, const WebCore::CaptureDevice& deviceID, String&&, const WebCore::MediaConstraints&, CompletionHandler<void(bool succeeded, String invalidConstraints, WebCore::RealtimeMediaSourceSettings&&)>&&);
+ void createMediaSourceForCaptureDeviceWithConstraints(WebCore::RealtimeMediaSourceIdentifier, const WebCore::CaptureDevice& deviceID, String&&, const WebCore::MediaConstraints&, CompletionHandler<void(bool succeeded, String invalidConstraints, WebCore::RealtimeMediaSourceSettings&&, WebCore::RealtimeMediaSourceCapabilities&&)>&&);
void startProducingData(WebCore::RealtimeMediaSourceIdentifier);
void stopProducingData(WebCore::RealtimeMediaSourceIdentifier);
void end(WebCore::RealtimeMediaSourceIdentifier);
Modified: trunk/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.messages.in (258200 => 258201)
--- trunk/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.messages.in 2020-03-10 12:49:58 UTC (rev 258200)
+++ trunk/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.messages.in 2020-03-10 12:53:39 UTC (rev 258201)
@@ -24,11 +24,10 @@
#if ENABLE(MEDIA_STREAM)
messages -> UserMediaCaptureManagerProxy NotRefCounted {
- CreateMediaSourceForCaptureDeviceWithConstraints(WebCore::RealtimeMediaSourceIdentifier id, WebCore::CaptureDevice device, String hashSalt, struct WebCore::MediaConstraints constraints) -> (bool success, String invalidConstraints, WebCore::RealtimeMediaSourceSettings settings) Synchronous
+ CreateMediaSourceForCaptureDeviceWithConstraints(WebCore::RealtimeMediaSourceIdentifier id, WebCore::CaptureDevice device, String hashSalt, struct WebCore::MediaConstraints constraints) -> (bool success, String invalidConstraints, WebCore::RealtimeMediaSourceSettings settings, WebCore::RealtimeMediaSourceCapabilities capabilities) Async
StartProducingData(WebCore::RealtimeMediaSourceIdentifier id)
StopProducingData(WebCore::RealtimeMediaSourceIdentifier id)
End(WebCore::RealtimeMediaSourceIdentifier id)
- Capabilities(WebCore::RealtimeMediaSourceIdentifier id) -> (WebCore::RealtimeMediaSourceCapabilities capabilities) Synchronous
SetMuted(WebCore::RealtimeMediaSourceIdentifier id, bool muted)
ApplyConstraints(WebCore::RealtimeMediaSourceIdentifier id, struct WebCore::MediaConstraints constraints)
Clone(WebCore::RealtimeMediaSourceIdentifier clonedID, WebCore::RealtimeMediaSourceIdentifier cloneID)
Modified: trunk/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.cpp (258200 => 258201)
--- trunk/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.cpp 2020-03-10 12:49:58 UTC (rev 258200)
+++ trunk/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.cpp 2020-03-10 12:53:39 UTC (rev 258201)
@@ -101,6 +101,28 @@
}
}
+ void whenReady(CompletionHandler<void(String)>&& callback) final
+ {
+ if (m_isReady)
+ return callback(WTFMove(m_errorMessage));
+ m_callback = WTFMove(callback);
+ }
+
+ void didFail(String&& errorMessage)
+ {
+ m_isReady = true;
+ m_errorMessage = WTFMove(errorMessage);
+ if (m_callback)
+ m_callback(String(errorMessage));
+ }
+
+ void setAsReady()
+ {
+ m_isReady = true;
+ if (m_callback)
+ m_callback({ });
+ }
+
SharedRingBufferStorage& storage()
{
ASSERT(type() == Type::Audio);
@@ -123,6 +145,10 @@
}
const RealtimeMediaSourceCapabilities& capabilities() final;
+ void setCapabilities(RealtimeMediaSourceCapabilities&& capabilities)
+ {
+ m_capabilities = WTFMove(capabilities);
+ }
const RealtimeMediaSourceSettings& settings() final { return m_settings; }
void setSettings(RealtimeMediaSourceSettings&& settings)
@@ -231,7 +257,7 @@
RealtimeMediaSourceIdentifier m_id;
UserMediaCaptureManager& m_manager;
- mutable Optional<RealtimeMediaSourceCapabilities> m_capabilities;
+ RealtimeMediaSourceCapabilities m_capabilities;
RealtimeMediaSourceSettings m_settings;
CAAudioStreamDescription m_description;
@@ -242,6 +268,9 @@
Deque<ApplyConstraintsHandler> m_pendingApplyConstraintsCallbacks;
bool m_shouldCaptureInGPUProcess { false };
+ bool m_isReady { false };
+ String m_errorMessage;
+ CompletionHandler<void(String)> m_callback;
};
UserMediaCaptureManager::UserMediaCaptureManager(WebProcess& process)
@@ -292,9 +321,7 @@
return { };
auto id = RealtimeMediaSourceIdentifier::generate();
- RealtimeMediaSourceSettings settings;
- String errorMessage;
- bool succeeded;
+
#if ENABLE(GPU_PROCESS)
auto* connection = shouldCaptureInGPUProcess ? &m_process.ensureGPUProcessConnection().connection() : m_process.parentProcessConnection();
#else
@@ -301,18 +328,24 @@
ASSERT(!shouldCaptureInGPUProcess);
auto* connection = m_process.parentProcessConnection();
#endif
- if (!connection->sendSync(Messages::UserMediaCaptureManagerProxy::CreateMediaSourceForCaptureDeviceWithConstraints(id, device, hashSalt, *constraints), Messages::UserMediaCaptureManagerProxy::CreateMediaSourceForCaptureDeviceWithConstraints::Reply(succeeded, errorMessage, settings), 0))
- return WTFMove(errorMessage);
-
- if (!succeeded)
- return WTFMove(errorMessage);
-
+
auto type = device.type() == CaptureDevice::DeviceType::Microphone ? WebCore::RealtimeMediaSource::Type::Audio : WebCore::RealtimeMediaSource::Type::Video;
- auto source = adoptRef(*new Source(String::number(id.toUInt64()), type, device.type(), String { settings.label().string() }, WTFMove(hashSalt), id, *this));
+ auto source = adoptRef(*new Source(String::number(id.toUInt64()), type, device.type(), String { }, String { hashSalt }, id, *this));
if (shouldCaptureInGPUProcess)
source->setShouldCaptureInGPUProcess(shouldCaptureInGPUProcess);
- source->setSettings(WTFMove(settings));
m_sources.add(id, source.copyRef());
+
+ connection->sendWithAsyncReply(Messages::UserMediaCaptureManagerProxy::CreateMediaSourceForCaptureDeviceWithConstraints(id, device, hashSalt, *constraints), [source = source.copyRef()](bool succeeded, auto&& errorMessage, auto&& settings, auto&& capabilities) {
+ if (!succeeded) {
+ source->didFail(WTFMove(errorMessage));
+ return;
+ }
+ source->setName(String { settings.label().string() });
+ source->setSettings(WTFMove(settings));
+ source->setCapabilities(WTFMove(capabilities));
+ source->setAsReady();
+ });
+
return WebCore::CaptureSourceOrError(WTFMove(source));
}
@@ -398,13 +431,7 @@
const WebCore::RealtimeMediaSourceCapabilities& UserMediaCaptureManager::Source::capabilities()
{
- if (!m_capabilities) {
- RealtimeMediaSourceCapabilities capabilities;
- connection()->sendSync(Messages::UserMediaCaptureManagerProxy::Capabilities { m_id }, Messages::UserMediaCaptureManagerProxy::Capabilities::Reply(capabilities), 0);
- m_capabilities = WTFMove(capabilities);
- }
-
- return m_capabilities.value();
+ return m_capabilities;
}
void UserMediaCaptureManager::Source::applyConstraints(const WebCore::MediaConstraints& constraints, ApplyConstraintsHandler&& completionHandler)