[MediaStream] RealtimeMediaSource should be able to vend hashed IDs
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 2 Oct 2018 11:18:49 +0000 (11:18 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 2 Oct 2018 11:18:49 +0000 (11:18 +0000)
https://bugs.webkit.org/show_bug.cgi?id=190142
<rdar://problem/44911109>

Reviewed by Youenn Fablet.

Source/WebCore:

No new tests, covered by existing tests.

* Modules/mediastream/CanvasCaptureMediaStreamTrack.cpp:
(WebCore::CanvasCaptureMediaStreamTrack::Source::Source): Update order of parameters passed
to base class.

* Modules/mediastream/MediaDevicesRequest.cpp:
(WebCore::MediaDevicesRequest::start): ASSERT if document.deviceIDHashSalt is not the same
as passed salt.

* Modules/mediastream/MediaStreamTrack.cpp:
(WebCore::MediaStreamTrack::getSettings const): Don't need to hash ID.
(WebCore::MediaStreamTrack::getCapabilities const): Ditto.
* Modules/mediastream/MediaStreamTrack.h:
* Modules/mediastream/MediaStreamTrack.idl:

* Modules/mediastream/UserMediaRequest.cpp:
(WebCore::UserMediaRequest::allow): Pass hash salt to createMediaStream.

* Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:
(WebCore::LibWebRTCPeerConnectionBackend::createReceiverForSource): Update order of parameters passed
to base class.

* Modules/webaudio/MediaStreamAudioSource.cpp:
(WebCore::MediaStreamAudioSource::MediaStreamAudioSource): Ditto.
* platform/mediastream/MediaConstraints.h:

* platform/mediastream/RealtimeIncomingAudioSource.cpp:
(WebCore::RealtimeIncomingAudioSource::RealtimeIncomingAudioSource): Ditto.

* platform/mediastream/RealtimeIncomingVideoSource.cpp:
(WebCore::RealtimeIncomingVideoSource::RealtimeIncomingVideoSource): Ditto.

* platform/mediastream/RealtimeMediaSource.cpp:
(WebCore::RealtimeMediaSource::RealtimeMediaSource): Calculate hashed ID.
(WebCore::RealtimeMediaSource::selectSettings): Use m_hashedID.
(WebCore::RealtimeMediaSource::hashedId const): New.
(WebCore::RealtimeMediaSource::deviceIDHashSalt const): New.
* platform/mediastream/RealtimeMediaSource.h:

* platform/mediastream/RealtimeMediaSourceCenter.cpp:
(WebCore::RealtimeMediaSourceCenter::createMediaStream): Take hash salt, pass it when creating
a source.
(WebCore::RealtimeMediaSourceCenter::getUserMediaDevices): Ditto.
(WebCore::RealtimeMediaSourceCenter::validateRequestConstraints): Ditto.
* platform/mediastream/RealtimeMediaSourceCenter.h:

* platform/mediastream/RealtimeMediaSourceFactory.h:
* platform/mediastream/RealtimeVideoSource.cpp:
(WebCore::RealtimeVideoSource::RealtimeVideoSource): Update parameters.
* platform/mediastream/RealtimeVideoSource.h:

* platform/mediastream/gstreamer/GStreamerAudioCaptureSource.cpp:
(WebCore::GStreamerAudioCaptureSource::create): Ditto.
(WebCore::GStreamerAudioCaptureSource::GStreamerAudioCaptureSource): Ditto.
* platform/mediastream/gstreamer/GStreamerAudioCaptureSource.h:

* platform/mediastream/gstreamer/GStreamerVideoCaptureSource.cpp:
(WebCore::GStreamerVideoCaptureSource::create): Ditto.
(WebCore::GStreamerVideoCaptureSource::GStreamerVideoCaptureSource): Ditto.
* platform/mediastream/gstreamer/GStreamerVideoCaptureSource.h:

* platform/mediastream/gstreamer/MockGStreamerAudioCaptureSource.cpp:
(WebCore::WrappedMockRealtimeAudioSource::WrappedMockRealtimeAudioSource): Ditto.
(WebCore::MockRealtimeAudioSource::create): Ditto.
(WebCore::MockGStreamerAudioCaptureSource::MockGStreamerAudioCaptureSource): Ditto.
* platform/mediastream/gstreamer/MockGStreamerAudioCaptureSource.h:

* platform/mediastream/gstreamer/MockGStreamerVideoCaptureSource.cpp:
(WebCore::MockRealtimeVideoSource::create): Ditto.
(WebCore::MockGStreamerVideoCaptureSource::MockGStreamerVideoCaptureSource): Ditto.
* platform/mediastream/gstreamer/MockGStreamerVideoCaptureSource.h:

* platform/mediastream/mac/AVVideoCaptureSource.h:
* platform/mediastream/mac/AVVideoCaptureSource.mm:
(WebCore::AVVideoCaptureSource::create): Ditto.
(WebCore::AVVideoCaptureSource::AVVideoCaptureSource): Ditto.
(WebCore::AVVideoCaptureSource::settings): Use hashedId to set device ID.
(WebCore::AVVideoCaptureSource::capabilities): Ditto.

* platform/mediastream/mac/CoreAudioCaptureSource.cpp:
(WebCore::CoreAudioCaptureSource::create): Update parameters.
(WebCore::CoreAudioCaptureSource::CoreAudioCaptureSource): Ditto.
(WebCore::CoreAudioCaptureSource::capabilities): Use hashedId to set device ID.
(WebCore::CoreAudioCaptureSource::settings): Ditto.
* platform/mediastream/mac/CoreAudioCaptureSource.h:

* platform/mediastream/mac/DisplayCaptureSourceCocoa.cpp:
(WebCore::DisplayCaptureSourceCocoa::DisplayCaptureSourceCocoa): Update parameters.
* platform/mediastream/mac/DisplayCaptureSourceCocoa.h:

* platform/mediastream/mac/MockRealtimeAudioSourceMac.h:
* platform/mediastream/mac/MockRealtimeAudioSourceMac.mm:
(WebCore::MockRealtimeAudioSource::create): Ditto.
(WebCore::MockRealtimeAudioSourceMac::MockRealtimeAudioSourceMac): Ditto.

* platform/mediastream/mac/MockRealtimeVideoSourceMac.h:
* platform/mediastream/mac/MockRealtimeVideoSourceMac.mm:
(WebCore::MockRealtimeVideoSource::create): Ditto.
(WebCore::MockRealtimeVideoSourceMac::MockRealtimeVideoSourceMac): Ditto.

* platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp:

* platform/mediastream/mac/ScreenDisplayCaptureSourceMac.h:
* platform/mediastream/mac/ScreenDisplayCaptureSourceMac.mm:
(WebCore::ScreenDisplayCaptureSourceMac::create): Ditto.
(WebCore::ScreenDisplayCaptureSourceMac::ScreenDisplayCaptureSourceMac): Ditto.
(WebCore::ScreenDisplayCaptureSourceMac::createDisplayStream): Update logging.
(WebCore::ScreenDisplayCaptureSourceMac::startDisplayStream): Ditto.
(WebCore::ScreenDisplayCaptureSourceMac::frameAvailable): Ditto.

* platform/mediastream/mac/WindowDisplayCaptureSourceMac.h:
* platform/mediastream/mac/WindowDisplayCaptureSourceMac.mm:
(WebCore::WindowDisplayCaptureSourceMac::create): Update parameters.

* platform/mock/MockRealtimeAudioSource.cpp:
(WebCore::MockRealtimeAudioSource::create): Ditto.
(WebCore::MockRealtimeAudioSource::MockRealtimeAudioSource): Ditto.
(WebCore::MockRealtimeAudioSource::settings): Use hashedId to set device ID.
(WebCore::MockRealtimeAudioSource::capabilities): Ditto.
* platform/mock/MockRealtimeAudioSource.h:

* platform/mock/MockRealtimeMediaSourceCenter.cpp:

* platform/mock/MockRealtimeVideoSource.cpp:
(WebCore::MockRealtimeVideoSource::create): Update parameters.
(WebCore::MockRealtimeVideoSource::MockRealtimeVideoSource): Ditto.
(WebCore::MockRealtimeVideoSource::capabilities): Use hashedId to set device ID.
(WebCore::MockRealtimeVideoSource::settings): Ditto.
* platform/mock/MockRealtimeVideoSource.h:

Source/WebKit:

* Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<MediaConstraints>::encode):
(IPC::ArgumentCoder<MediaConstraints>::decode):
* UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp:
(WebKit::UserMediaCaptureManagerProxy::createMediaSourceForCaptureDeviceWithConstraints):
* UIProcess/Cocoa/UserMediaCaptureManagerProxy.h:
* UIProcess/Cocoa/UserMediaCaptureManagerProxy.messages.in:
* UIProcess/UserMediaPermissionRequestManagerProxy.cpp:
(WebKit::UserMediaPermissionRequestManagerProxy::requestUserMediaPermissionForFrame):
* WebProcess/cocoa/UserMediaCaptureManager.cpp:
(WebKit::UserMediaCaptureManager::Source::Source):
(WebKit::UserMediaCaptureManager::createCaptureSource):
* WebProcess/cocoa/UserMediaCaptureManager.h:

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

58 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/CanvasCaptureMediaStreamTrack.cpp
Source/WebCore/Modules/mediastream/MediaDevicesRequest.cpp
Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp
Source/WebCore/Modules/mediastream/MediaStreamTrack.h
Source/WebCore/Modules/mediastream/MediaStreamTrack.idl
Source/WebCore/Modules/mediastream/UserMediaRequest.cpp
Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp
Source/WebCore/Modules/webaudio/MediaStreamAudioSource.cpp
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/platform/mediastream/MediaConstraints.h
Source/WebCore/platform/mediastream/RealtimeIncomingAudioSource.cpp
Source/WebCore/platform/mediastream/RealtimeIncomingVideoSource.cpp
Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp
Source/WebCore/platform/mediastream/RealtimeMediaSource.h
Source/WebCore/platform/mediastream/RealtimeMediaSourceCenter.cpp
Source/WebCore/platform/mediastream/RealtimeMediaSourceCenter.h
Source/WebCore/platform/mediastream/RealtimeMediaSourceFactory.cpp
Source/WebCore/platform/mediastream/RealtimeMediaSourceFactory.h
Source/WebCore/platform/mediastream/RealtimeVideoSource.cpp
Source/WebCore/platform/mediastream/RealtimeVideoSource.h
Source/WebCore/platform/mediastream/gstreamer/GStreamerAudioCaptureSource.cpp
Source/WebCore/platform/mediastream/gstreamer/GStreamerAudioCaptureSource.h
Source/WebCore/platform/mediastream/gstreamer/GStreamerVideoCaptureSource.cpp
Source/WebCore/platform/mediastream/gstreamer/GStreamerVideoCaptureSource.h
Source/WebCore/platform/mediastream/gstreamer/MockGStreamerAudioCaptureSource.cpp
Source/WebCore/platform/mediastream/gstreamer/MockGStreamerAudioCaptureSource.h
Source/WebCore/platform/mediastream/gstreamer/MockGStreamerVideoCaptureSource.cpp
Source/WebCore/platform/mediastream/gstreamer/MockGStreamerVideoCaptureSource.h
Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.h
Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm
Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp
Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.h
Source/WebCore/platform/mediastream/mac/DisplayCaptureSourceCocoa.cpp
Source/WebCore/platform/mediastream/mac/DisplayCaptureSourceCocoa.h
Source/WebCore/platform/mediastream/mac/MockRealtimeAudioSourceMac.h
Source/WebCore/platform/mediastream/mac/MockRealtimeAudioSourceMac.mm
Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.h
Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.mm
Source/WebCore/platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp
Source/WebCore/platform/mediastream/mac/ScreenDisplayCaptureSourceMac.h
Source/WebCore/platform/mediastream/mac/ScreenDisplayCaptureSourceMac.mm
Source/WebCore/platform/mediastream/mac/WindowDisplayCaptureSourceMac.h
Source/WebCore/platform/mediastream/mac/WindowDisplayCaptureSourceMac.mm
Source/WebCore/platform/mock/MockRealtimeAudioSource.cpp
Source/WebCore/platform/mock/MockRealtimeAudioSource.h
Source/WebCore/platform/mock/MockRealtimeMediaSourceCenter.cpp
Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp
Source/WebCore/platform/mock/MockRealtimeVideoSource.h
Source/WebKit/ChangeLog
Source/WebKit/Shared/WebCoreArgumentCoders.cpp
Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp
Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.h
Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.messages.in
Source/WebKit/UIProcess/UserMediaPermissionRequestManagerProxy.cpp
Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.cpp
Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.h

index 6bcf624..bd0084b 100644 (file)
@@ -1,3 +1,142 @@
+2018-10-02  Eric Carlson  <eric.carlson@apple.com>
+
+        [MediaStream] RealtimeMediaSource should be able to vend hashed IDs
+        https://bugs.webkit.org/show_bug.cgi?id=190142
+        <rdar://problem/44911109>
+
+        Reviewed by Youenn Fablet.
+
+        No new tests, covered by existing tests.
+
+        * Modules/mediastream/CanvasCaptureMediaStreamTrack.cpp:
+        (WebCore::CanvasCaptureMediaStreamTrack::Source::Source): Update order of parameters passed
+        to base class.
+
+        * Modules/mediastream/MediaDevicesRequest.cpp:
+        (WebCore::MediaDevicesRequest::start): ASSERT if document.deviceIDHashSalt is not the same
+        as passed salt.
+
+        * Modules/mediastream/MediaStreamTrack.cpp:
+        (WebCore::MediaStreamTrack::getSettings const): Don't need to hash ID.
+        (WebCore::MediaStreamTrack::getCapabilities const): Ditto.
+        * Modules/mediastream/MediaStreamTrack.h:
+        * Modules/mediastream/MediaStreamTrack.idl:
+
+        * Modules/mediastream/UserMediaRequest.cpp:
+        (WebCore::UserMediaRequest::allow): Pass hash salt to createMediaStream.
+
+        * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:
+        (WebCore::LibWebRTCPeerConnectionBackend::createReceiverForSource): Update order of parameters passed
+        to base class.
+
+        * Modules/webaudio/MediaStreamAudioSource.cpp:
+        (WebCore::MediaStreamAudioSource::MediaStreamAudioSource): Ditto.
+        * platform/mediastream/MediaConstraints.h:
+
+        * platform/mediastream/RealtimeIncomingAudioSource.cpp:
+        (WebCore::RealtimeIncomingAudioSource::RealtimeIncomingAudioSource): Ditto.
+
+        * platform/mediastream/RealtimeIncomingVideoSource.cpp:
+        (WebCore::RealtimeIncomingVideoSource::RealtimeIncomingVideoSource): Ditto.
+
+        * platform/mediastream/RealtimeMediaSource.cpp:
+        (WebCore::RealtimeMediaSource::RealtimeMediaSource): Calculate hashed ID.
+        (WebCore::RealtimeMediaSource::selectSettings): Use m_hashedID.
+        (WebCore::RealtimeMediaSource::hashedId const): New.
+        (WebCore::RealtimeMediaSource::deviceIDHashSalt const): New.
+        * platform/mediastream/RealtimeMediaSource.h:
+
+        * platform/mediastream/RealtimeMediaSourceCenter.cpp:
+        (WebCore::RealtimeMediaSourceCenter::createMediaStream): Take hash salt, pass it when creating
+        a source.
+        (WebCore::RealtimeMediaSourceCenter::getUserMediaDevices): Ditto.
+        (WebCore::RealtimeMediaSourceCenter::validateRequestConstraints): Ditto.
+        * platform/mediastream/RealtimeMediaSourceCenter.h:
+
+        * platform/mediastream/RealtimeMediaSourceFactory.h:
+        * platform/mediastream/RealtimeVideoSource.cpp:
+        (WebCore::RealtimeVideoSource::RealtimeVideoSource): Update parameters.
+        * platform/mediastream/RealtimeVideoSource.h:
+
+        * platform/mediastream/gstreamer/GStreamerAudioCaptureSource.cpp:
+        (WebCore::GStreamerAudioCaptureSource::create): Ditto.
+        (WebCore::GStreamerAudioCaptureSource::GStreamerAudioCaptureSource): Ditto.
+        * platform/mediastream/gstreamer/GStreamerAudioCaptureSource.h:
+
+        * platform/mediastream/gstreamer/GStreamerVideoCaptureSource.cpp:
+        (WebCore::GStreamerVideoCaptureSource::create): Ditto.
+        (WebCore::GStreamerVideoCaptureSource::GStreamerVideoCaptureSource): Ditto.
+        * platform/mediastream/gstreamer/GStreamerVideoCaptureSource.h:
+
+        * platform/mediastream/gstreamer/MockGStreamerAudioCaptureSource.cpp:
+        (WebCore::WrappedMockRealtimeAudioSource::WrappedMockRealtimeAudioSource): Ditto.
+        (WebCore::MockRealtimeAudioSource::create): Ditto.
+        (WebCore::MockGStreamerAudioCaptureSource::MockGStreamerAudioCaptureSource): Ditto.
+        * platform/mediastream/gstreamer/MockGStreamerAudioCaptureSource.h:
+
+        * platform/mediastream/gstreamer/MockGStreamerVideoCaptureSource.cpp:
+        (WebCore::MockRealtimeVideoSource::create): Ditto.
+        (WebCore::MockGStreamerVideoCaptureSource::MockGStreamerVideoCaptureSource): Ditto.
+        * platform/mediastream/gstreamer/MockGStreamerVideoCaptureSource.h:
+
+        * platform/mediastream/mac/AVVideoCaptureSource.h:
+        * platform/mediastream/mac/AVVideoCaptureSource.mm:
+        (WebCore::AVVideoCaptureSource::create): Ditto.
+        (WebCore::AVVideoCaptureSource::AVVideoCaptureSource): Ditto.
+        (WebCore::AVVideoCaptureSource::settings): Use hashedId to set device ID.
+        (WebCore::AVVideoCaptureSource::capabilities): Ditto.
+
+        * platform/mediastream/mac/CoreAudioCaptureSource.cpp:
+        (WebCore::CoreAudioCaptureSource::create): Update parameters.
+        (WebCore::CoreAudioCaptureSource::CoreAudioCaptureSource): Ditto.
+        (WebCore::CoreAudioCaptureSource::capabilities): Use hashedId to set device ID.
+        (WebCore::CoreAudioCaptureSource::settings): Ditto.
+        * platform/mediastream/mac/CoreAudioCaptureSource.h:
+
+        * platform/mediastream/mac/DisplayCaptureSourceCocoa.cpp:
+        (WebCore::DisplayCaptureSourceCocoa::DisplayCaptureSourceCocoa): Update parameters.
+        * platform/mediastream/mac/DisplayCaptureSourceCocoa.h:
+
+        * platform/mediastream/mac/MockRealtimeAudioSourceMac.h:
+        * platform/mediastream/mac/MockRealtimeAudioSourceMac.mm:
+        (WebCore::MockRealtimeAudioSource::create): Ditto.
+        (WebCore::MockRealtimeAudioSourceMac::MockRealtimeAudioSourceMac): Ditto.
+
+        * platform/mediastream/mac/MockRealtimeVideoSourceMac.h:
+        * platform/mediastream/mac/MockRealtimeVideoSourceMac.mm:
+        (WebCore::MockRealtimeVideoSource::create): Ditto.
+        (WebCore::MockRealtimeVideoSourceMac::MockRealtimeVideoSourceMac): Ditto.
+
+        * platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp:
+
+        * platform/mediastream/mac/ScreenDisplayCaptureSourceMac.h:
+        * platform/mediastream/mac/ScreenDisplayCaptureSourceMac.mm:
+        (WebCore::ScreenDisplayCaptureSourceMac::create): Ditto.
+        (WebCore::ScreenDisplayCaptureSourceMac::ScreenDisplayCaptureSourceMac): Ditto.
+        (WebCore::ScreenDisplayCaptureSourceMac::createDisplayStream): Update logging.
+        (WebCore::ScreenDisplayCaptureSourceMac::startDisplayStream): Ditto.
+        (WebCore::ScreenDisplayCaptureSourceMac::frameAvailable): Ditto.
+
+        * platform/mediastream/mac/WindowDisplayCaptureSourceMac.h:
+        * platform/mediastream/mac/WindowDisplayCaptureSourceMac.mm:
+        (WebCore::WindowDisplayCaptureSourceMac::create): Update parameters.
+
+        * platform/mock/MockRealtimeAudioSource.cpp:
+        (WebCore::MockRealtimeAudioSource::create): Ditto.
+        (WebCore::MockRealtimeAudioSource::MockRealtimeAudioSource): Ditto.
+        (WebCore::MockRealtimeAudioSource::settings): Use hashedId to set device ID.
+        (WebCore::MockRealtimeAudioSource::capabilities): Ditto.
+        * platform/mock/MockRealtimeAudioSource.h:
+
+        * platform/mock/MockRealtimeMediaSourceCenter.cpp:
+
+        * platform/mock/MockRealtimeVideoSource.cpp:
+        (WebCore::MockRealtimeVideoSource::create): Update parameters.
+        (WebCore::MockRealtimeVideoSource::MockRealtimeVideoSource): Ditto.
+        (WebCore::MockRealtimeVideoSource::capabilities): Use hashedId to set device ID.
+        (WebCore::MockRealtimeVideoSource::settings): Ditto.
+        * platform/mock/MockRealtimeVideoSource.h:
+
 2018-10-02  Philippe Normand  <pnormand@igalia.com>
 
         [GStreamer][playbin3] Stream tag lists leaks
index 78f9fb2..56df8a6 100644 (file)
@@ -66,7 +66,7 @@ Ref<CanvasCaptureMediaStreamTrack::Source> CanvasCaptureMediaStreamTrack::Source
 
 // FIXME: Give source id and name
 CanvasCaptureMediaStreamTrack::Source::Source(HTMLCanvasElement& canvas, std::optional<double>&& frameRequestRate)
-    : RealtimeMediaSource(String(), Type::Video, String())
+    : RealtimeMediaSource(Type::Video, "CanvasCaptureMediaStreamTrack"_s)
     , m_frameRequestRate(WTFMove(frameRequestRate))
     , m_requestFrameTimer(*this, &Source::requestFrameTimerFired)
     , m_canvasChangedTimer(*this, &Source::captureCanvas)
index e2c5bf7..be51ae3 100644 (file)
@@ -117,7 +117,7 @@ void MediaDevicesRequest::start()
         if (!scriptExecutionContext())
             return;
 
-        Document& document = downcast<Document>(*scriptExecutionContext());
+        auto& document = downcast<Document>(*scriptExecutionContext());
         document.setDeviceIDHashSalt(deviceIdentifierHashSalt);
 
         Vector<Ref<MediaDeviceInfo>> devices;
index acfecf8..70533ad 100644 (file)
@@ -197,7 +197,7 @@ void MediaStreamTrack::stopTrack(StopMode mode)
     configureTrackRendering();
 }
 
-MediaStreamTrack::TrackSettings MediaStreamTrack::getSettings(Document& document) const
+MediaStreamTrack::TrackSettings MediaStreamTrack::getSettings() const
 {
     auto& settings = m_private->settings();
     TrackSettings result;
@@ -220,9 +220,9 @@ MediaStreamTrack::TrackSettings MediaStreamTrack::getSettings(Document& document
     if (settings.supportsEchoCancellation())
         result.echoCancellation = settings.echoCancellation();
     if (settings.supportsDeviceId())
-        result.deviceId = RealtimeMediaSourceCenter::singleton().hashStringWithSalt(settings.deviceId(), document.deviceIDHashSalt());
+        result.deviceId = settings.deviceId();
     if (settings.supportsGroupId())
-        result.groupId = RealtimeMediaSourceCenter::singleton().hashStringWithSalt(settings.groupId(), document.deviceIDHashSalt());
+        result.groupId = settings.groupId();
 
     // FIXME: shouldn't this include displaySurface and logicalSurface?
 
@@ -287,7 +287,7 @@ static Vector<bool> capabilityBooleanVector(RealtimeMediaSourceCapabilities::Ech
     return result;
 }
 
-MediaStreamTrack::TrackCapabilities MediaStreamTrack::getCapabilities(Document& document) const
+MediaStreamTrack::TrackCapabilities MediaStreamTrack::getCapabilities() const
 {
     auto capabilities = m_private->capabilities();
     TrackCapabilities result;
@@ -310,9 +310,9 @@ MediaStreamTrack::TrackCapabilities MediaStreamTrack::getCapabilities(Document&
     if (capabilities.supportsEchoCancellation())
         result.echoCancellation = capabilityBooleanVector(capabilities.echoCancellation());
     if (capabilities.supportsDeviceId())
-        result.deviceId = RealtimeMediaSourceCenter::singleton().hashStringWithSalt(capabilities.deviceId(), document.deviceIDHashSalt());
+        result.deviceId = capabilities.deviceId();
     if (capabilities.supportsGroupId())
-        result.groupId = RealtimeMediaSourceCenter::singleton().hashStringWithSalt(capabilities.groupId(), document.deviceIDHashSalt());
+        result.groupId = capabilities.groupId();
     return result;
 }
 
index 4b00e04..e346f81 100644 (file)
@@ -105,7 +105,7 @@ public:
         String deviceId;
         String groupId;
     };
-    TrackSettings getSettings(Document&) const;
+    TrackSettings getSettings() const;
 
     struct TrackCapabilities {
         std::optional<LongRange> width;
@@ -120,7 +120,7 @@ public:
         String deviceId;
         String groupId;
     };
-    TrackCapabilities getCapabilities(Document&) const;
+    TrackCapabilities getCapabilities() const;
 
     const MediaTrackConstraints& getConstraints() const { return m_constraints; }
     void applyConstraints(const std::optional<MediaTrackConstraints>&, DOMPromiseDeferred<void>&&);
index 2b71cce..bcfac8f 100644 (file)
@@ -47,9 +47,9 @@ enum MediaStreamTrackState { "live", "ended" };
     MediaStreamTrack clone();
     [ImplementedAs=stopTrack] void stop();
 
-    [CallWith=Document] MediaTrackCapabilities getCapabilities();
+    MediaTrackCapabilities getCapabilities();
     MediaTrackConstraints getConstraints();
-    [CallWith=Document] MediaTrackSettings getSettings();
+    MediaTrackSettings getSettings();
     Promise<void> applyConstraints(optional MediaTrackConstraints constraints);
 
     attribute EventHandler onoverconstrained;
index 125d6d1..e823f75 100644 (file)
@@ -300,16 +300,15 @@ void UserMediaRequest::allow(CaptureDevice&& audioDevice, CaptureDevice&& videoD
         m_pendingActivationMediaStream = PendingActivationMediaStream::create(WTFMove(protector), *this, WTFMove(stream));
     };
 
-    m_request.audioConstraints.deviceIDHashSalt = deviceIdentifierHashSalt;
-    m_request.videoConstraints.deviceIDHashSalt = WTFMove(deviceIdentifierHashSalt);
+    auto& document = downcast<Document>(*scriptExecutionContext());
+    document.setDeviceIDHashSalt(deviceIdentifierHashSalt);
 
-    RealtimeMediaSourceCenter::singleton().createMediaStream(WTFMove(callback), WTFMove(audioDevice), WTFMove(videoDevice), m_request);
+    RealtimeMediaSourceCenter::singleton().createMediaStream(WTFMove(callback), WTFMove(deviceIdentifierHashSalt), WTFMove(audioDevice), WTFMove(videoDevice), m_request);
 
     if (!m_scriptExecutionContext)
         return;
 
 #if ENABLE(WEB_RTC)
-    auto& document = downcast<Document>(*m_scriptExecutionContext);
     if (auto* page = document.page())
         page->rtcController().disableICECandidateFilteringForDocument(document);
 #endif
index 605f2e7..51bfea0 100644 (file)
@@ -231,7 +231,8 @@ void LibWebRTCPeerConnectionBackend::doAddIceCandidate(RTCIceCandidate& candidat
 
 Ref<RTCRtpReceiver> LibWebRTCPeerConnectionBackend::createReceiverForSource(Ref<RealtimeMediaSource>&& source, std::unique_ptr<RTCRtpReceiverBackend>&& backend)
 {
-    auto remoteTrackPrivate = MediaStreamTrackPrivate::create(WTFMove(source), String { source->id() });
+    String trackID = source->persistentID();
+    auto remoteTrackPrivate = MediaStreamTrackPrivate::create(WTFMove(source), WTFMove(trackID));
     auto remoteTrack = MediaStreamTrack::create(*m_peerConnection.scriptExecutionContext(), WTFMove(remoteTrackPrivate));
 
     return RTCRtpReceiver::create(*this, WTFMove(remoteTrack), WTFMove(backend));
index 56f37c1..fc8ae66 100644 (file)
@@ -34,7 +34,7 @@
 namespace WebCore {
 
 MediaStreamAudioSource::MediaStreamAudioSource(float sampleRate)
-    : RealtimeMediaSource(makeString("WebAudio-"_s, createCanonicalUUIDString()), RealtimeMediaSource::Type::Audio, "MediaStreamAudioDestinationNode")
+    : RealtimeMediaSource(RealtimeMediaSource::Type::Audio, "MediaStreamAudioDestinationNode"_s)
 {
     m_currentSettings.setSampleRate(sampleRate);
 }
index 19590b0..0dcb8e7 100644 (file)
@@ -7736,6 +7736,13 @@ void Document::mediaStreamCaptureStateChanged()
     for (auto* mediaElement : m_mediaStreamStateChangeElements)
         mediaElement->mediaStreamCaptureStarted();
 }
+
+void Document::setDeviceIDHashSalt(const String& salt)
+{
+    ASSERT(m_idHashSalt.isEmpty() || m_idHashSalt == salt);
+    m_idHashSalt = salt;
+}
+
 #endif
 
 void Document::addApplicationStateChangeListener(ApplicationStateChangeListener& listener)
index 13543b3..a796b49 100644 (file)
@@ -1387,7 +1387,7 @@ public:
 #if ENABLE(MEDIA_STREAM)
     void setHasCaptureMediaStreamTrack() { m_hasHadCaptureMediaStreamTrack = true; }
     bool hasHadCaptureMediaStreamTrack() const { return m_hasHadCaptureMediaStreamTrack; }
-    void setDeviceIDHashSalt(const String& salt) { m_idHashSalt = salt; }
+    void setDeviceIDHashSalt(const String&);
     String deviceIDHashSalt() const { return m_idHashSalt; }
     void stopMediaCapture();
     void registerForMediaStreamStateChangeCallbacks(HTMLMediaElement&);
index 30ec41a..b42710a 100644 (file)
@@ -879,7 +879,6 @@ struct MediaConstraints {
 
     MediaTrackConstraintSetMap mandatoryConstraints;
     Vector<MediaTrackConstraintSetMap> advancedConstraints;
-    String deviceIDHashSalt;
     bool isValid { false };
 };
     
index b376294..c63bf79 100644 (file)
 namespace WebCore {
 
 RealtimeIncomingAudioSource::RealtimeIncomingAudioSource(rtc::scoped_refptr<webrtc::AudioTrackInterface>&& audioTrack, String&& audioTrackId)
-    : RealtimeMediaSource(WTFMove(audioTrackId), RealtimeMediaSource::Type::Audio, String())
+    : RealtimeMediaSource(RealtimeMediaSource::Type::Audio, "remote audio"_s, WTFMove(audioTrackId))
     , m_audioTrack(WTFMove(audioTrack))
 {
-    setName("remote audio");
     notifyMutedChange(!m_audioTrack);
 }
 
index 79f3f9a..d5b4964 100644 (file)
 namespace WebCore {
 
 RealtimeIncomingVideoSource::RealtimeIncomingVideoSource(rtc::scoped_refptr<webrtc::VideoTrackInterface>&& videoTrack, String&& videoTrackId)
-    : RealtimeMediaSource(WTFMove(videoTrackId), RealtimeMediaSource::Type::Video, String())
+    : RealtimeMediaSource(RealtimeMediaSource::Type::Video, "remote video"_s, WTFMove(videoTrackId))
     , m_videoTrack(WTFMove(videoTrack))
 {
-    setName("remote video");
     notifyMutedChange(!m_videoTrack);
 }
 
index 4c18f4f..8050432 100644 (file)
 
 namespace WebCore {
 
-RealtimeMediaSource::RealtimeMediaSource(const String& id, Type type, const String& name)
-    : m_id(id)
+RealtimeMediaSource::RealtimeMediaSource(Type type, String&& name, String&& deviceID, String&& hashSalt)
+    : m_idHashSalt(WTFMove(hashSalt))
+    , m_persistentID(WTFMove(deviceID))
     , m_type(type)
-    , m_name(name)
+    , m_name(WTFMove(name))
 {
-    if (m_id.isEmpty())
-        m_id = createCanonicalUUIDString();
-    m_persistentID = m_id;
+    if (m_persistentID.isEmpty())
+        m_persistentID = createCanonicalUUIDString();
+    else
+        m_hashedID = RealtimeMediaSourceCenter::singleton().hashStringWithSalt(m_persistentID, m_idHashSalt);
 }
 
 void RealtimeMediaSource::addObserver(RealtimeMediaSource::Observer& observer)
@@ -608,10 +610,9 @@ bool RealtimeMediaSource::selectSettings(const MediaConstraints& constraints, Fl
                 return false;
 
             ASSERT(constraint.isString());
-            ASSERT(!constraints.deviceIDHashSalt.isEmpty());
+            ASSERT(!m_hashedID.isEmpty());
 
-            auto hashedID = RealtimeMediaSourceCenter::singleton().hashStringWithSalt(m_persistentID, constraints.deviceIDHashSalt);
-            double constraintDistance = downcast<StringConstraint>(constraint).fitnessDistance(hashedID);
+            double constraintDistance = downcast<StringConstraint>(constraint).fitnessDistance(m_hashedID);
             if (std::isinf(constraintDistance)) {
                 failedConstraint = constraint.name();
                 return true;
@@ -958,6 +959,17 @@ void RealtimeMediaSource::scheduleDeferredTask(WTF::Function<void()>&& function)
     });
 }
 
+const String& RealtimeMediaSource::hashedId() const
+{
+    ASSERT(!m_hashedID.isEmpty());
+    return m_hashedID;
+}
+
+String RealtimeMediaSource::deviceIDHashSalt() const
+{
+    return m_idHashSalt;
+}
+
 RealtimeMediaSource::Observer::~Observer()
 {
 }
index 77da308..bcef569 100644 (file)
@@ -88,10 +88,10 @@ public:
 
     virtual ~RealtimeMediaSource() = default;
 
-    const String& id() const { return m_id; }
+    const String& hashedId() const;
+    String deviceIDHashSalt() const;
 
     const String& persistentID() const { return m_persistentID; }
-    virtual void setPersistentID(String&& persistentID) { m_persistentID = WTFMove(persistentID); }
 
     enum class Type { None, Audio, Video };
     Type type() const { return m_type; }
@@ -166,7 +166,7 @@ public:
     virtual void delaySamples(Seconds) { };
 
 protected:
-    RealtimeMediaSource(const String& id, Type, const String& name);
+    RealtimeMediaSource(Type, String&& name, String&& deviceID = { }, String&& hashSalt = { });
 
     void scheduleDeferredTask(WTF::Function<void()>&&);
 
@@ -204,7 +204,8 @@ private:
 
     bool m_muted { false };
 
-    String m_id;
+    String m_idHashSalt;
+    String m_hashedID;
     String m_persistentID;
     Type m_type;
     String m_name;
index 5e1b5a5..a6f8ff3 100644 (file)
@@ -79,14 +79,14 @@ RealtimeMediaSourceCenter::RealtimeMediaSourceCenter()
 
 RealtimeMediaSourceCenter::~RealtimeMediaSourceCenter() = default;
 
-void RealtimeMediaSourceCenter::createMediaStream(NewMediaStreamHandler&& completionHandler, CaptureDevice&& audioDevice, CaptureDevice&& videoDevice, const MediaStreamRequest& request)
+void RealtimeMediaSourceCenter::createMediaStream(NewMediaStreamHandler&& completionHandler, String&& hashSalt, CaptureDevice&& audioDevice, CaptureDevice&& videoDevice, const MediaStreamRequest& request)
 {
     Vector<Ref<RealtimeMediaSource>> audioSources;
     Vector<Ref<RealtimeMediaSource>> videoSources;
     String invalidConstraint;
 
     if (audioDevice) {
-        auto audioSource = audioFactory().createAudioCaptureSource(WTFMove(audioDevice), &request.audioConstraints);
+        auto audioSource = audioFactory().createAudioCaptureSource(WTFMove(audioDevice), String { hashSalt }, &request.audioConstraints);
         if (audioSource)
             audioSources.append(audioSource.source());
         else {
@@ -102,7 +102,7 @@ void RealtimeMediaSourceCenter::createMediaStream(NewMediaStreamHandler&& comple
     if (videoDevice) {
         CaptureSourceOrError videoSource;
         if (videoDevice.type() == CaptureDevice::DeviceType::Camera)
-            videoSource = videoFactory().createVideoCaptureSource(WTFMove(videoDevice), &request.videoConstraints);
+            videoSource = videoFactory().createVideoCaptureSource(WTFMove(videoDevice), WTFMove(hashSalt), &request.videoConstraints);
         else
             videoSource = displayCaptureFactory().createDisplayCaptureSource(WTFMove(videoDevice), &request.videoConstraints);
 
@@ -231,7 +231,7 @@ void RealtimeMediaSourceCenter::getDisplayMediaDevices(const MediaStreamRequest&
     }
 }
 
-void RealtimeMediaSourceCenter::getUserMediaDevices(const MediaStreamRequest& request, Vector<DeviceInfo>& audioDeviceInfo, Vector<DeviceInfo>& videoDeviceInfo, String& firstInvalidConstraint)
+void RealtimeMediaSourceCenter::getUserMediaDevices(const MediaStreamRequest& request, String&& hashSalt, Vector<DeviceInfo>& audioDeviceInfo, Vector<DeviceInfo>& videoDeviceInfo, String& firstInvalidConstraint)
 {
     String invalidConstraint;
     if (request.audioConstraints.isValid) {
@@ -239,7 +239,7 @@ void RealtimeMediaSourceCenter::getUserMediaDevices(const MediaStreamRequest& re
             if (!device.enabled())
                 continue;
 
-            auto sourceOrError = audioFactory().createAudioCaptureSource(device, { });
+            auto sourceOrError = audioFactory().createAudioCaptureSource(device, String { hashSalt }, { });
             if (sourceOrError && sourceOrError.captureSource->supportsConstraints(request.audioConstraints, invalidConstraint))
                 audioDeviceInfo.append({sourceOrError.captureSource->fitnessScore(), device});
 
@@ -253,7 +253,7 @@ void RealtimeMediaSourceCenter::getUserMediaDevices(const MediaStreamRequest& re
             if (!device.enabled())
                 continue;
 
-            auto sourceOrError = videoFactory().createVideoCaptureSource(device, { });
+            auto sourceOrError = videoFactory().createVideoCaptureSource(device, String { hashSalt }, { });
             if (sourceOrError && sourceOrError.captureSource->supportsConstraints(request.videoConstraints, invalidConstraint))
                 videoDeviceInfo.append({sourceOrError.captureSource->fitnessScore(), device});
 
@@ -279,7 +279,7 @@ void RealtimeMediaSourceCenter::validateRequestConstraints(ValidConstraintsHandl
     if (request.type == MediaStreamRequest::Type::DisplayMedia)
         getDisplayMediaDevices(request, videoDeviceInfo, firstInvalidConstraint);
     else
-        getUserMediaDevices(request, audioDeviceInfo, videoDeviceInfo, firstInvalidConstraint);
+        getUserMediaDevices(request, String { deviceIdentifierHashSalt }, audioDeviceInfo, videoDeviceInfo, firstInvalidConstraint);
 
     if ((request.audioConstraints.isValid && audioDeviceInfo.isEmpty()) || (request.videoConstraints.isValid && videoDeviceInfo.isEmpty())) {
         invalidHandler(firstInvalidConstraint);
index 81fb85c..4e17027 100644 (file)
@@ -65,7 +65,7 @@ public:
     virtual void validateRequestConstraints(ValidConstraintsHandler&&, InvalidConstraintsHandler&&, const MediaStreamRequest&, String&&);
 
     using NewMediaStreamHandler = WTF::Function<void(RefPtr<MediaStreamPrivate>&&)>;
-    virtual void createMediaStream(NewMediaStreamHandler&&, CaptureDevice&& audioDevice, CaptureDevice&& videoDevice, const MediaStreamRequest&);
+    virtual void createMediaStream(NewMediaStreamHandler&&, String&&, CaptureDevice&& audioDevice, CaptureDevice&& videoDevice, const MediaStreamRequest&);
 
     WEBCORE_EXPORT virtual Vector<CaptureDevice> getMediaStreamDevices();
     WEBCORE_EXPORT std::optional<CaptureDevice> captureDeviceWithPersistentID(CaptureDevice::DeviceType, const String&);
@@ -110,7 +110,7 @@ private:
     };
 
     void getDisplayMediaDevices(const MediaStreamRequest&, Vector<DeviceInfo>&, String&);
-    void getUserMediaDevices(const MediaStreamRequest&, Vector<DeviceInfo>& audioDevices, Vector<DeviceInfo>& videoDevices, String&);
+    void getUserMediaDevices(const MediaStreamRequest&, String&&, Vector<DeviceInfo>& audioDevices, Vector<DeviceInfo>& videoDevices, String&);
 
     WTF::Function<void()> m_deviceChangedObserver;
 };
index 9725d7f..e8e55df 100644 (file)
 #include "config.h"
 #include "RealtimeMediaSourceFactory.h"
 
-#include "CaptureDevice.h"
-#include "RealtimeMediaSource.h"
-
 #if ENABLE(MEDIA_STREAM)
 
+#include "CaptureDevice.h"
 #include "CaptureDeviceManager.h"
 #include "Logging.h"
 #include "MediaStreamPrivate.h"
+#include "RealtimeMediaSource.h"
 #include <wtf/SHA1.h>
 
 namespace WebCore {
index f9c47ca..9be050e 100644 (file)
 
 #if ENABLE(MEDIA_STREAM)
 
+#include <wtf/text/WTFString.h>
+
 namespace WebCore {
 
 class CaptureDevice;
 class RealtimeMediaSource;
 
-struct MediaConstraints;
-
 struct CaptureSourceOrError;
+struct MediaConstraints;
 
 class SingleSourceFactory {
 public:
@@ -53,7 +54,7 @@ class AudioCaptureFactory
 {
 public:
     virtual ~AudioCaptureFactory() = default;
-    virtual CaptureSourceOrError createAudioCaptureSource(const CaptureDevice&, const MediaConstraints*) = 0;
+    virtual CaptureSourceOrError createAudioCaptureSource(const CaptureDevice&, String&&, const MediaConstraints*) = 0;
 
 protected:
     AudioCaptureFactory() = default;
@@ -66,7 +67,7 @@ class VideoCaptureFactory
 {
 public:
     virtual ~VideoCaptureFactory() = default;
-    virtual CaptureSourceOrError createVideoCaptureSource(const CaptureDevice&, const MediaConstraints*) = 0;
+    virtual CaptureSourceOrError createVideoCaptureSource(const CaptureDevice&, String&&, const MediaConstraints*) = 0;
     virtual void setVideoCapturePageState(bool, bool) { }
 
 protected:
index f5db9b0..5664b09 100644 (file)
@@ -34,8 +34,8 @@
 
 namespace WebCore {
 
-RealtimeVideoSource::RealtimeVideoSource(const String& id, const String& name)
-    : RealtimeMediaSource(id, Type::Video, name)
+RealtimeVideoSource::RealtimeVideoSource(String&& name, String&& id, String&& hashSalt)
+    : RealtimeMediaSource(Type::Video, WTFMove(name), WTFMove(id), WTFMove(hashSalt))
 {
 }
 
index 87ab80a..a49cf6c 100644 (file)
@@ -42,7 +42,7 @@ public:
     virtual ~RealtimeVideoSource();
 
 protected:
-    RealtimeVideoSource(const String& id, const String& name);
+    RealtimeVideoSource(String&& name, String&& id, String&& hashSalt);
 
     void prepareToProduceData();
     bool supportsSizeAndFrameRate(std::optional<int> width, std::optional<int> height, std::optional<double>) override;
index 74fa39c..2b754d7 100644 (file)
@@ -53,9 +53,9 @@ static void initializeGStreamerDebug()
 
 class GStreamerAudioCaptureSourceFactory : public AudioCaptureFactory {
 public:
-    CaptureSourceOrError createAudioCaptureSource(const CaptureDevice& device, const MediaConstraints* constraints) final
+    CaptureSourceOrError createAudioCaptureSource(const CaptureDevice& device, String&& hashSalt, const MediaConstraints* constraints) final
     {
-        return GStreamerAudioCaptureSource::create(device.persistentId(), constraints);
+        return GStreamerAudioCaptureSource::create(String { device.persistentId() }, WTFMove(hashSalt), constraints);
     }
 };
 
@@ -65,7 +65,7 @@ static GStreamerAudioCaptureSourceFactory& libWebRTCAudioCaptureSourceFactory()
     return factory.get();
 }
 
-CaptureSourceOrError GStreamerAudioCaptureSource::create(const String& deviceID, const MediaConstraints* constraints)
+CaptureSourceOrError GStreamerAudioCaptureSource::create(String&& deviceID, String&& hashSalt, const MediaConstraints* constraints)
 {
     auto device = GStreamerAudioCaptureDeviceManager::singleton().gstreamerDeviceWithUID(deviceID);
     if (!device) {
@@ -73,7 +73,7 @@ CaptureSourceOrError GStreamerAudioCaptureSource::create(const String& deviceID,
         return CaptureSourceOrError(WTFMove(errorMessage));
     }
 
-    auto source = adoptRef(*new GStreamerAudioCaptureSource(device.value()));
+    auto source = adoptRef(*new GStreamerAudioCaptureSource(device.value(), WTFMove(hashSalt)));
 
     if (constraints) {
         auto result = source->applyConstraints(*constraints);
@@ -88,15 +88,15 @@ AudioCaptureFactory& GStreamerAudioCaptureSource::factory()
     return libWebRTCAudioCaptureSourceFactory();
 }
 
-GStreamerAudioCaptureSource::GStreamerAudioCaptureSource(GStreamerCaptureDevice device)
-    : RealtimeMediaSource(device.persistentId(), RealtimeMediaSource::Type::Audio, device.label())
+GStreamerAudioCaptureSource::GStreamerAudioCaptureSource(GStreamerCaptureDevice device, String&& hashSalt)
+    : RealtimeMediaSource(RealtimeMediaSource::Type::Audio, String { device.persistentId() }, String { device.label() }, WTFMove(hashSalt))
     , m_capturer(std::make_unique<GStreamerAudioCapturer>(device))
 {
     initializeGStreamerDebug();
 }
 
-GStreamerAudioCaptureSource::GStreamerAudioCaptureSource(const String& deviceID, const String& name)
-    : RealtimeMediaSource(deviceID, RealtimeMediaSource::Type::Audio, name)
+GStreamerAudioCaptureSource::GStreamerAudioCaptureSource(String&& deviceID, String&& name, String&& hashSalt)
+    : RealtimeMediaSource(RealtimeMediaSource::Type::Audio, WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt))
     , m_capturer(std::make_unique<GStreamerAudioCapturer>())
 {
     initializeGStreamerDebug();
@@ -163,7 +163,7 @@ const RealtimeMediaSourceCapabilities& GStreamerAudioCaptureSource::capabilities
     }
 
     RealtimeMediaSourceCapabilities capabilities(settings().supportedConstraints());
-    capabilities.setDeviceId(id());
+    capabilities.setDeviceId(hashedId());
     capabilities.setEchoCancellation(defaultEchoCancellationCapability);
     capabilities.setVolume(defaultVolumeCapability());
     capabilities.setSampleRate(CapabilityValueOrRange(minSampleRate, maxSampleRate));
@@ -182,7 +182,7 @@ const RealtimeMediaSourceSettings& GStreamerAudioCaptureSource::settings()
 {
     if (!m_currentSettings) {
         RealtimeMediaSourceSettings settings;
-        settings.setDeviceId(id());
+        settings.setDeviceId(hashedId());
 
         RealtimeMediaSourceSupportedConstraints supportedConstraints;
         supportedConstraints.setSupportsDeviceId(true);
index 759e814..fa34194 100644 (file)
@@ -30,7 +30,7 @@ namespace WebCore {
 
 class GStreamerAudioCaptureSource : public RealtimeMediaSource {
 public:
-    static CaptureSourceOrError create(const String& deviceID, const MediaConstraints*);
+    static CaptureSourceOrError create(String&& deviceID, String&& hashSalt, const MediaConstraints*);
     WEBCORE_EXPORT static AudioCaptureFactory& factory();
 
     const RealtimeMediaSourceCapabilities& capabilities() override;
@@ -40,8 +40,8 @@ public:
     GStreamerCapturer* capturer() { return m_capturer.get(); }
 
 protected:
-    GStreamerAudioCaptureSource(GStreamerCaptureDevice);
-    GStreamerAudioCaptureSource(const String& deviceID, const String& name);
+    GStreamerAudioCaptureSource(GStreamerCaptureDevice, String&& hashSalt);
+    GStreamerAudioCaptureSource(String&& deviceID, String&& name, String&& hashSalt);
     virtual ~GStreamerAudioCaptureSource();
     void startProducingData() override;
     void stopProducingData() override;
index 209db65..e79a357 100644 (file)
@@ -54,9 +54,9 @@ static void initializeGStreamerDebug()
 
 class GStreamerVideoCaptureSourceFactory final : public VideoCaptureFactory {
 public:
-    CaptureSourceOrError createVideoCaptureSource(const CaptureDevice& device, const MediaConstraints* constraints) final
+    CaptureSourceOrError createVideoCaptureSource(const CaptureDevice& device, String&& hashSalt, const MediaConstraints* constraints) final
     {
-        return GStreamerVideoCaptureSource::create(device.persistentId(), constraints);
+        return GStreamerVideoCaptureSource::create(String { device.persistentId() }, WTFMove(hashSalt), constraints);
     }
 };
 
@@ -81,7 +81,7 @@ DisplayCaptureFactory& libWebRTCDisplayCaptureSourceFactory()
     return factory.get();
 }
 
-CaptureSourceOrError GStreamerVideoCaptureSource::create(const String& deviceID, const MediaConstraints* constraints)
+CaptureSourceOrError GStreamerVideoCaptureSource::create(String&& deviceID, String&& hashSalt, const MediaConstraints* constraints)
 {
     auto device = GStreamerVideoCaptureDeviceManager::singleton().gstreamerDeviceWithUID(deviceID);
     if (!device) {
@@ -89,7 +89,7 @@ CaptureSourceOrError GStreamerVideoCaptureSource::create(const String& deviceID,
         return CaptureSourceOrError(WTFMove(errorMessage));
     }
 
-    auto source = adoptRef(*new GStreamerVideoCaptureSource(device.value()));
+    auto source = adoptRef(*new GStreamerVideoCaptureSource(device.value(), WTFMove(hashSalt)));
 
     if (constraints) {
         auto result = source->applyConstraints(*constraints);
@@ -109,15 +109,15 @@ DisplayCaptureFactory& GStreamerVideoCaptureSource::displayFactory()
     return libWebRTCDisplayCaptureSourceFactory();
 }
 
-GStreamerVideoCaptureSource::GStreamerVideoCaptureSource(const String& deviceID, const String& name, const gchar *source_factory)
-    : RealtimeMediaSource(deviceID, RealtimeMediaSource::Type::Video, name)
+GStreamerVideoCaptureSource::GStreamerVideoCaptureSource(String&& deviceID, String&& name, String&& hashSalt, const gchar *source_factory)
+    : RealtimeMediaSource(RealtimeMediaSource::Type::Video, WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt))
     , m_capturer(std::make_unique<GStreamerVideoCapturer>(source_factory))
 {
     initializeGStreamerDebug();
 }
 
-GStreamerVideoCaptureSource::GStreamerVideoCaptureSource(GStreamerCaptureDevice device)
-    : RealtimeMediaSource(device.persistentId(), RealtimeMediaSource::Type::Video, device.label())
+GStreamerVideoCaptureSource::GStreamerVideoCaptureSource(GStreamerCaptureDevice device, String&& hashSalt)
+    : RealtimeMediaSource(RealtimeMediaSource::Type::Video, String { device.persistentId() }, String { device.label() }, WTFMove(hashSalt))
     , m_capturer(std::make_unique<GStreamerVideoCapturer>(device))
 {
     initializeGStreamerDebug();
@@ -242,7 +242,7 @@ const RealtimeMediaSourceCapabilities& GStreamerVideoCaptureSource::capabilities
             }
         }
 
-        capabilities.setDeviceId(id());
+        capabilities.setDeviceId(hashedId());
         capabilities.setWidth(CapabilityValueOrRange(minWidth, maxWidth));
         capabilities.setHeight(CapabilityValueOrRange(minHeight, maxHeight));
         capabilities.setFrameRate(CapabilityValueOrRange(minFramerate, maxFramerate));
@@ -256,7 +256,7 @@ const RealtimeMediaSourceSettings& GStreamerVideoCaptureSource::settings()
 {
     if (!m_currentSettings) {
         RealtimeMediaSourceSettings settings;
-        settings.setDeviceId(id());
+        settings.setDeviceId(hashedId());
 
         RealtimeMediaSourceSupportedConstraints supportedConstraints;
         supportedConstraints.setSupportsDeviceId(true);
index 67bcd1a..231ed4a 100644 (file)
@@ -29,7 +29,7 @@ namespace WebCore {
 
 class GStreamerVideoCaptureSource : public RealtimeMediaSource {
 public:
-    static CaptureSourceOrError create(const String& deviceID, const MediaConstraints*);
+    static CaptureSourceOrError create(String&& deviceID, String&& hashSalt, const MediaConstraints*);
     WEBCORE_EXPORT static VideoCaptureFactory& factory();
 
     // FIXME: Implement this.
@@ -41,8 +41,8 @@ public:
     GStreamerCapturer* capturer() { return m_capturer.get(); }
 
 protected:
-    GStreamerVideoCaptureSource(const String& deviceID, const String& name, const gchar * source_factory);
-    GStreamerVideoCaptureSource(GStreamerCaptureDevice);
+    GStreamerVideoCaptureSource(String&& deviceID, String&& name, String&& hashSalt, const gchar * source_factory);
+    GStreamerVideoCaptureSource(GStreamerCaptureDevice, String&& hashSalt);
     virtual ~GStreamerVideoCaptureSource();
     void startProducingData() override;
     void stopProducingData() override;
index 9f01e67..fd52ebf 100644 (file)
@@ -30,16 +30,16 @@ namespace WebCore {
 
 class WrappedMockRealtimeAudioSource : public MockRealtimeAudioSource {
 public:
-    WrappedMockRealtimeAudioSource(const String& deviceID, const String& name)
-        : MockRealtimeAudioSource(deviceID, name)
+    WrappedMockRealtimeAudioSource(String&& deviceID, String&& name, String&& hashSalt)
+        : MockRealtimeAudioSource(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt))
     {
     }
 };
 
-CaptureSourceOrError MockRealtimeAudioSource::create(const String& deviceID,
-    const String& name, const MediaConstraints* constraints)
+CaptureSourceOrError MockRealtimeAudioSource::create(String&& deviceID,
+    String&& name, String&& hashSalt, const MediaConstraints* constraints)
 {
-    auto source = adoptRef(*new MockGStreamerAudioCaptureSource(deviceID, name));
+    auto source = adoptRef(*new MockGStreamerAudioCaptureSource(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt)));
 
     if (constraints && source->applyConstraints(*constraints))
         return { };
@@ -58,9 +58,9 @@ void MockGStreamerAudioCaptureSource::applyConstraints(const MediaConstraints& c
     m_wrappedSource->applyConstraints(constraints, WTFMove(successHandler), WTFMove(failureHandler));
 }
 
-MockGStreamerAudioCaptureSource::MockGStreamerAudioCaptureSource(const String& deviceID, const String& name)
-    : GStreamerAudioCaptureSource(deviceID, name)
-    , m_wrappedSource(std::make_unique<WrappedMockRealtimeAudioSource>(deviceID, name))
+MockGStreamerAudioCaptureSource::MockGStreamerAudioCaptureSource(String&& deviceID, String&& name, String&& hashSalt)
+    : GStreamerAudioCaptureSource(String { deviceID }, String { name }, String { hashSalt })
+    , m_wrappedSource(std::make_unique<WrappedMockRealtimeAudioSource>(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt)))
 {
     m_wrappedSource->addObserver(*this);
 }
index b57181d..8a4bbe8 100644 (file)
@@ -29,7 +29,7 @@ namespace WebCore {
 
 class MockGStreamerAudioCaptureSource final : public GStreamerAudioCaptureSource, RealtimeMediaSource::Observer {
 public:
-    MockGStreamerAudioCaptureSource(const String& deviceID, const String& name);
+    MockGStreamerAudioCaptureSource(String&& deviceID, String&& name, String&& hashSalt);
     ~MockGStreamerAudioCaptureSource();
     std::optional<std::pair<String, String>> applyConstraints(const MediaConstraints&);
     void applyConstraints(const MediaConstraints&, SuccessHandler&&, FailureHandler&&) final;
index 44d94cc..cb30696 100644 (file)
@@ -33,8 +33,8 @@ namespace WebCore {
 
 class WrappedMockRealtimeVideoSource : public MockRealtimeVideoSource {
 public:
-    WrappedMockRealtimeVideoSource(const String& deviceID, const String& name)
-        : MockRealtimeVideoSource(deviceID, name)
+    WrappedMockRealtimeVideoSource(String&& deviceID, String&& name, String&& hashSalt)
+        : MockRealtimeVideoSource(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt))
     {
     }
 
@@ -61,10 +61,10 @@ public:
     }
 };
 
-CaptureSourceOrError MockRealtimeVideoSource::create(const String& deviceID,
-    const String& name, const MediaConstraints* constraints)
+CaptureSourceOrError MockRealtimeVideoSource::create(String&& deviceID,
+    String&& name, String&& hashSalt, const MediaConstraints* constraints)
 {
-    auto source = adoptRef(*new MockGStreamerVideoCaptureSource(deviceID, name));
+    auto source = adoptRef(*new MockGStreamerVideoCaptureSource(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt)));
 
     if (constraints && source->applyConstraints(*constraints))
         return { };
@@ -95,9 +95,9 @@ void MockGStreamerVideoCaptureSource::videoSampleAvailable(MediaSample& sample)
     }
 }
 
-MockGStreamerVideoCaptureSource::MockGStreamerVideoCaptureSource(const String& deviceID, const String& name)
-    : GStreamerVideoCaptureSource(deviceID, name, "appsrc")
-    , m_wrappedSource(std::make_unique<WrappedMockRealtimeVideoSource>(deviceID, name))
+MockGStreamerVideoCaptureSource::MockGStreamerVideoCaptureSource(String&& deviceID, String&& name, String&& hashSalt)
+    : GStreamerVideoCaptureSource(String { deviceID }, String { name }, String { hashSalt }, "appsrc")
+    , m_wrappedSource(std::make_unique<WrappedMockRealtimeVideoSource>(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt)))
 {
     m_wrappedSource->addObserver(*this);
 }
index d08aa48..c248632 100644 (file)
@@ -34,7 +34,7 @@ class WrappedMockRealtimeVideoSource;
 // to the MockRealtimeMediaSource class by wrapping our own subclass of it.
 class MockGStreamerVideoCaptureSource final : public GStreamerVideoCaptureSource, RealtimeMediaSource::Observer {
 public:
-    MockGStreamerVideoCaptureSource(const String& deviceID, const String& name);
+    MockGStreamerVideoCaptureSource(String&& deviceID, String&& name, String&& hashSalt);
     ~MockGStreamerVideoCaptureSource();
     std::optional<std::pair<String, String>> applyConstraints(const MediaConstraints&);
     void applyConstraints(const MediaConstraints&, SuccessHandler&&, FailureHandler&&) final;
index d38e1ae..3b49f46 100644 (file)
@@ -53,7 +53,7 @@ class PixelBufferResizer;
 
 class AVVideoCaptureSource : public RealtimeVideoSource, private OrientationNotifier::Observer {
 public:
-    static CaptureSourceOrError create(const AtomicString&, const MediaConstraints*);
+    static CaptureSourceOrError create(String&& id, String&& hashSalt, const MediaConstraints*);
 
     WEBCORE_EXPORT static VideoCaptureFactory& factory();
 
@@ -71,7 +71,7 @@ public:
     void captureOutputDidOutputSampleBufferFromConnection(AVCaptureOutput*, CMSampleBufferRef, AVCaptureConnection*);
 
 private:
-    AVVideoCaptureSource(AVCaptureDevice*, const AtomicString&);
+    AVVideoCaptureSource(AVCaptureDevice*, String&& id, String&& hashSalt);
     virtual ~AVVideoCaptureSource();
 
     bool setupSession();
index 4cb2f93..5196082 100644 (file)
@@ -150,13 +150,13 @@ public:
     RetainPtr<AVCaptureDeviceFormatType> format;
 };
 
-CaptureSourceOrError AVVideoCaptureSource::create(const AtomicString& id, const MediaConstraints* constraints)
+CaptureSourceOrError AVVideoCaptureSource::create(String&& id, String&& hashSalt, const MediaConstraints* constraints)
 {
     AVCaptureDeviceTypedef *device = [getAVCaptureDeviceClass() deviceWithUniqueID:id];
     if (!device)
         return { };
 
-    auto source = adoptRef(*new AVVideoCaptureSource(device, id));
+    auto source = adoptRef(*new AVVideoCaptureSource(device, WTFMove(id), WTFMove(hashSalt)));
     if (constraints) {
         auto result = source->applyConstraints(*constraints);
         if (result)
@@ -166,8 +166,8 @@ CaptureSourceOrError AVVideoCaptureSource::create(const AtomicString& id, const
     return CaptureSourceOrError(WTFMove(source));
 }
 
-AVVideoCaptureSource::AVVideoCaptureSource(AVCaptureDeviceTypedef* device, const AtomicString& id)
-    : RealtimeVideoSource(id, device.localizedName)
+AVVideoCaptureSource::AVVideoCaptureSource(AVCaptureDeviceTypedef* device, String&& id, String&& hashSalt)
+    : RealtimeVideoSource(device.localizedName, WTFMove(id), WTFMove(hashSalt))
     , m_objcObserver(adoptNS([[WebCoreAVVideoCaptureSourceObserver alloc] initWithCallback:this]))
     , m_device(device)
 {
@@ -177,8 +177,6 @@ AVVideoCaptureSource::AVVideoCaptureSource(AVCaptureDeviceTypedef* device, const
     static_assert(static_cast<int>(InterruptionReason::VideoInUse) == AVCaptureSessionInterruptionReasonVideoDeviceInUseByAnotherClient, "InterruptionReason::VideoInUse is not AVCaptureSessionInterruptionReasonVideoDeviceInUseByAnotherClient as expected");
     static_assert(static_cast<int>(InterruptionReason::AudioInUse) == AVCaptureSessionInterruptionReasonAudioDeviceInUseByAnotherClient, "InterruptionReason::AudioInUse is not AVCaptureSessionInterruptionReasonAudioDeviceInUseByAnotherClient as expected");
 #endif
-
-    setPersistentID(String(device.uniqueID));
 }
 
 AVVideoCaptureSource::~AVVideoCaptureSource()
@@ -260,7 +258,7 @@ const RealtimeMediaSourceSettings& AVVideoCaptureSource::settings()
     auto& size = this->size();
     settings.setWidth(size.width());
     settings.setHeight(size.height());
-    settings.setDeviceId(id());
+    settings.setDeviceId(hashedId());
 
     RealtimeMediaSourceSupportedConstraints supportedConstraints;
     supportedConstraints.setSupportsDeviceId(true);
@@ -283,7 +281,7 @@ const RealtimeMediaSourceCapabilities& AVVideoCaptureSource::capabilities()
         return *m_capabilities;
 
     RealtimeMediaSourceCapabilities capabilities(settings().supportedConstraints());
-    capabilities.setDeviceId(id());
+    capabilities.setDeviceId(hashedId());
 
     AVCaptureDeviceTypedef *videoDevice = device();
     if ([videoDevice position] == AVCaptureDevicePositionFront)
index 859d738..c9ea588 100644 (file)
@@ -694,20 +694,20 @@ OSStatus CoreAudioSharedUnit::defaultOutputDevice(uint32_t* deviceID)
     return err;
 }
 
-CaptureSourceOrError CoreAudioCaptureSource::create(const String& deviceID, const MediaConstraints* constraints)
+CaptureSourceOrError CoreAudioCaptureSource::create(String&& deviceID, String&& hashSalt, const MediaConstraints* constraints)
 {
 #if PLATFORM(MAC)
     auto device = CoreAudioCaptureDeviceManager::singleton().coreAudioDeviceWithUID(deviceID);
     if (!device)
         return { };
 
-    auto source = adoptRef(*new CoreAudioCaptureSource(deviceID, device->label(), device->deviceID()));
+    auto source = adoptRef(*new CoreAudioCaptureSource(WTFMove(deviceID), String { device->label() }, WTFMove(hashSalt), device->deviceID()));
 #elif PLATFORM(IOS)
-    auto device = AVAudioSessionCaptureDeviceManager::singleton().audioSessionDeviceWithUID(deviceID);
+    auto device = AVAudioSessionCaptureDeviceManager::singleton().audioSessionDeviceWithUID(WTFMove(deviceID));
     if (!device)
         return { };
 
-    auto source = adoptRef(*new CoreAudioCaptureSource(deviceID, device->label(), 0));
+    auto source = adoptRef(*new CoreAudioCaptureSource(WTFMove(deviceID), String { device->label() }, WTFMove(hashSalt), 0));
 #endif
 
     if (constraints) {
@@ -774,8 +774,8 @@ AudioCaptureFactory& CoreAudioCaptureSource::factory()
     return CoreAudioCaptureSourceFactory::singleton();
 }
 
-CoreAudioCaptureSource::CoreAudioCaptureSource(const String& deviceID, const String& label, uint32_t persistentID)
-    : RealtimeMediaSource(deviceID, RealtimeMediaSource::Type::Audio, label)
+CoreAudioCaptureSource::CoreAudioCaptureSource(String&& deviceID, String&& label, String&& hashSalt, uint32_t persistentID)
+    : RealtimeMediaSource(RealtimeMediaSource::Type::Audio, WTFMove(label), WTFMove(deviceID), WTFMove(hashSalt))
     , m_captureDeviceID(persistentID)
 {
     auto& unit = CoreAudioSharedUnit::singleton();
@@ -845,7 +845,7 @@ const RealtimeMediaSourceCapabilities& CoreAudioCaptureSource::capabilities()
 {
     if (!m_capabilities) {
         RealtimeMediaSourceCapabilities capabilities(settings().supportedConstraints());
-        capabilities.setDeviceId(id());
+        capabilities.setDeviceId(hashedId());
         capabilities.setEchoCancellation(RealtimeMediaSourceCapabilities::EchoCancellation::ReadWrite);
         capabilities.setVolume(CapabilityValueOrRange(0.0, 1.0));
         capabilities.setSampleRate(CapabilityValueOrRange(8000, 96000));
@@ -860,7 +860,7 @@ const RealtimeMediaSourceSettings& CoreAudioCaptureSource::settings()
         RealtimeMediaSourceSettings settings;
         settings.setVolume(volume());
         settings.setSampleRate(sampleRate());
-        settings.setDeviceId(id());
+        settings.setDeviceId(hashedId());
         settings.setLabel(name());
         settings.setEchoCancellation(echoCancellation());
 
index e5f1a4f..06b5f64 100644 (file)
@@ -55,7 +55,7 @@ class WebAudioSourceProviderAVFObjC;
 class CoreAudioCaptureSource : public RealtimeMediaSource {
 public:
 
-    static CaptureSourceOrError create(const String& deviceID, const MediaConstraints*);
+    static CaptureSourceOrError create(String&& deviceID, String&& hashSalt, const MediaConstraints*);
 
     WEBCORE_EXPORT static AudioCaptureFactory& factory();
 
@@ -74,7 +74,7 @@ public:
     void scheduleReconfiguration();
 
 protected:
-    CoreAudioCaptureSource(const String& deviceID, const String& label, uint32_t persistentID);
+    CoreAudioCaptureSource(String&& deviceID, String&& label, String&& hashSalt, uint32_t persistentID);
     virtual ~CoreAudioCaptureSource();
 
 private:
@@ -126,9 +126,9 @@ public:
 #endif
 
 private:
-    CaptureSourceOrError createAudioCaptureSource(const CaptureDevice& device, const MediaConstraints* constraints) final
+    CaptureSourceOrError createAudioCaptureSource(const CaptureDevice& device, String&& hashSalt, const MediaConstraints* constraints) final
     {
-        return CoreAudioCaptureSource::create(device.persistentId(), constraints);
+        return CoreAudioCaptureSource::create(String { device.persistentId() }, WTFMove(hashSalt), constraints);
     }
 };
 
index dc6a18b..373d0f8 100644 (file)
@@ -52,7 +52,7 @@ namespace WebCore {
 using namespace PAL;
 
 DisplayCaptureSourceCocoa::DisplayCaptureSourceCocoa(String&& name)
-    : RealtimeMediaSource("", Type::Video, WTFMove(name))
+    : RealtimeMediaSource(Type::Video, WTFMove(name))
     , m_timer(RunLoop::current(), this, &DisplayCaptureSourceCocoa::emitFrame)
 {
 }
index 24ddc67..bfe40b8 100644 (file)
@@ -51,7 +51,7 @@ class DisplayCaptureSourceCocoa : public RealtimeMediaSource {
 public:
 
 protected:
-    DisplayCaptureSourceCocoa(String&&);
+    DisplayCaptureSourceCocoa(String&& name);
     virtual ~DisplayCaptureSourceCocoa();
 
     virtual RetainPtr<CVPixelBufferRef> generateFrame() = 0;
index 99d78ee..5208b26 100644 (file)
@@ -48,7 +48,7 @@ class WebAudioSourceProviderAVFObjC;
 class MockRealtimeAudioSourceMac final : public MockRealtimeAudioSource {
 private:
     friend class MockRealtimeAudioSource;
-    MockRealtimeAudioSourceMac(const String& deviceID, const String& name);
+    MockRealtimeAudioSourceMac(String&& deviceID, String&& name, String&& hashSalt);
 
     void settingsDidChange(OptionSet<RealtimeMediaSourceSettings::Flag>) final;
     std::optional<Vector<int>> discreteSampleRates() const final { return { { 44100, 48000 } }; }
index 0c8a4bd..7676606 100644 (file)
@@ -86,9 +86,16 @@ static void addHum(float amplitude, float frequency, float sampleRate, uint64_t
     }
 }
 
-CaptureSourceOrError MockRealtimeAudioSource::create(const String& deviceID, const String& name, const MediaConstraints* constraints)
+CaptureSourceOrError MockRealtimeAudioSource::create(String&& deviceID, String&& name, String&& hashSalt, const MediaConstraints* constraints)
 {
-    auto source = adoptRef(*new MockRealtimeAudioSourceMac(deviceID, name));
+#ifndef NDEBUG
+    auto device = MockRealtimeMediaSourceCenter::mockDeviceWithPersistentID(deviceID);
+    ASSERT(device);
+    if (!device)
+        return { };
+#endif
+
+    auto source = adoptRef(*new MockRealtimeAudioSourceMac(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt)));
     // FIXME: We should report error messages
     if (constraints && source->applyConstraints(*constraints))
         return { };
@@ -96,8 +103,8 @@ CaptureSourceOrError MockRealtimeAudioSource::create(const String& deviceID, con
     return CaptureSourceOrError(WTFMove(source));
 }
 
-MockRealtimeAudioSourceMac::MockRealtimeAudioSourceMac(const String& deviceID, const String& name)
-    : MockRealtimeAudioSource(deviceID, name)
+MockRealtimeAudioSourceMac::MockRealtimeAudioSourceMac(String&& deviceID, String&& name, String&& hashSalt)
+    : MockRealtimeAudioSource(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt))
 {
 }
 
index 0b6e0ab..9c74dde 100644 (file)
@@ -51,7 +51,7 @@ public:
 
 private:
     friend class MockRealtimeVideoSource;
-    MockRealtimeVideoSourceMac(const String& deviceID, const String& name);
+    MockRealtimeVideoSourceMac(String&& deviceID, String&& name, String&& hashSalt);
 
     RetainPtr<CMSampleBufferRef> CMSampleBufferFromPixelBuffer(CVPixelBufferRef);
     RetainPtr<CVPixelBufferRef> pixelBufferFromCGImage(CGImageRef) const;
index 43163a9..23a1696 100644 (file)
@@ -53,9 +53,16 @@ using namespace PAL;
 
 static const int videoSampleRate = 90000;
 
-CaptureSourceOrError MockRealtimeVideoSource::create(const String& deviceID, const String& name, const MediaConstraints* constraints)
+CaptureSourceOrError MockRealtimeVideoSource::create(String&& deviceID, String&& name, String&& hashSalt, const MediaConstraints* constraints)
 {
-    auto source = adoptRef(*new MockRealtimeVideoSourceMac(deviceID, name));
+#ifndef NDEBUG
+    auto device = MockRealtimeMediaSourceCenter::mockDeviceWithPersistentID(deviceID);
+    ASSERT(device);
+    if (!device)
+        return { };
+#endif
+
+    auto source = adoptRef(*new MockRealtimeVideoSourceMac(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt)));
     // FIXME: We should report error messages
     if (constraints && source->applyConstraints(*constraints))
         return { };
@@ -63,8 +70,8 @@ CaptureSourceOrError MockRealtimeVideoSource::create(const String& deviceID, con
     return CaptureSourceOrError(WTFMove(source));
 }
 
-MockRealtimeVideoSourceMac::MockRealtimeVideoSourceMac(const String& deviceID, const String& name)
-    : MockRealtimeVideoSource(deviceID, name)
+MockRealtimeVideoSourceMac::MockRealtimeVideoSourceMac(String&& deviceID, String&& name, String&& hashSalt)
+    : MockRealtimeVideoSource(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt))
 {
 }
 
index f8ec6c8..8be4022 100644 (file)
@@ -48,10 +48,10 @@ namespace WebCore {
 
 class VideoCaptureSourceFactoryMac final : public VideoCaptureFactory {
 public:
-    CaptureSourceOrError createVideoCaptureSource(const CaptureDevice& device, const MediaConstraints* constraints) final
+    CaptureSourceOrError createVideoCaptureSource(const CaptureDevice& device, String&& hashSalt, const MediaConstraints* constraints) final
     {
         ASSERT(device.type() == CaptureDevice::DeviceType::Camera);
-        return AVVideoCaptureSource::create(device.persistentId(), constraints);
+        return AVVideoCaptureSource::create(String { device.persistentId() }, WTFMove(hashSalt), constraints);
     }
 
 #if PLATFORM(IOS)
@@ -75,11 +75,11 @@ public:
         switch (device.type()) {
         case CaptureDevice::DeviceType::Screen:
 #if PLATFORM(MAC)
-            return ScreenDisplayCaptureSourceMac::create(device.persistentId(), constraints);
+            return ScreenDisplayCaptureSourceMac::create(String { device.persistentId() }, constraints);
 #endif
         case CaptureDevice::DeviceType::Window:
 #if PLATFORM(MAC)
-            return WindowDisplayCaptureSourceMac::create(device.persistentId(), constraints);
+            return WindowDisplayCaptureSourceMac::create(String { device.persistentId() }, constraints);
 #endif
         case CaptureDevice::DeviceType::Application:
         case CaptureDevice::DeviceType::Browser:
index 6e2eab8..ec920f0 100644 (file)
@@ -41,13 +41,13 @@ namespace WebCore {
 
 class ScreenDisplayCaptureSourceMac : public DisplayCaptureSourceCocoa {
 public:
-    static CaptureSourceOrError create(const String&, const MediaConstraints*);
+    static CaptureSourceOrError create(String&&, const MediaConstraints*);
 
     static std::optional<CaptureDevice> screenCaptureDeviceWithPersistentID(const String&);
     static void screenCaptureDevices(Vector<CaptureDevice>&);
 
 private:
-    ScreenDisplayCaptureSourceMac(uint32_t);
+    ScreenDisplayCaptureSourceMac(uint32_t, String&&);
     virtual ~ScreenDisplayCaptureSourceMac();
 
     static void displayReconfigurationCallBack(CGDirectDisplayID, CGDisplayChangeSummaryFlags, void*);
index bf6d72a..a238f28 100644 (file)
@@ -76,12 +76,12 @@ static std::optional<CGDirectDisplayID> updateDisplayID(CGDirectDisplayID displa
     return std::nullopt;
 }
 
-CaptureSourceOrError ScreenDisplayCaptureSourceMac::create(const String& deviceID, const MediaConstraints* constraints)
+CaptureSourceOrError ScreenDisplayCaptureSourceMac::create(String&& deviceID, const MediaConstraints* constraints)
 {
     bool ok;
     auto displayID = deviceID.toUIntStrict(&ok);
     if (!ok) {
-        RELEASE_LOG(Media, "Display ID does not convert to 32-bit integer");
+        RELEASE_LOG(Media, "ScreenDisplayCaptureSourceMac::create: Display ID does not convert to 32-bit integer");
         return { };
     }
 
@@ -89,15 +89,15 @@ CaptureSourceOrError ScreenDisplayCaptureSourceMac::create(const String& deviceI
     if (!actualDisplayID)
         return { };
 
-    auto source = adoptRef(*new ScreenDisplayCaptureSourceMac(actualDisplayID.value()));
+    auto source = adoptRef(*new ScreenDisplayCaptureSourceMac(actualDisplayID.value(), "Screen"_s)); // FIXME: figure out what title to use
     if (constraints && source->applyConstraints(*constraints))
         return { };
 
     return CaptureSourceOrError(WTFMove(source));
 }
 
-ScreenDisplayCaptureSourceMac::ScreenDisplayCaptureSourceMac(uint32_t displayID)
-    : DisplayCaptureSourceCocoa("Screen") // FIXME: figure out what to call this
+ScreenDisplayCaptureSourceMac::ScreenDisplayCaptureSourceMac(uint32_t displayID, String&& title)
+    : DisplayCaptureSourceCocoa(WTFMove(title))
     , m_displayID(displayID)
 {
 }
@@ -122,7 +122,7 @@ bool ScreenDisplayCaptureSourceMac::createDisplayStream()
 
     if (m_displayID != actualDisplayID.value()) {
         m_displayID = actualDisplayID.value();
-        RELEASE_LOG(Media, "ScreenDisplayCaptureSourceMac::createDisplayStream(%p), display ID changed to %d", this, static_cast<int>(m_displayID));
+        RELEASE_LOG(Media, "ScreenDisplayCaptureSourceMac::createDisplayStream: display ID changed to %d", static_cast<int>(m_displayID));
     }
 
     if (!m_displayStream) {
@@ -130,7 +130,7 @@ bool ScreenDisplayCaptureSourceMac::createDisplayStream()
         auto screenWidth = CGDisplayModeGetPixelsWide(displayMode.get());
         auto screenHeight = CGDisplayModeGetPixelsHigh(displayMode.get());
         if (!screenWidth || !screenHeight) {
-            RELEASE_LOG(Media, "ScreenDisplayCaptureSourceMac::createDisplayStream(%p), unable to get screen width/height", this);
+            RELEASE_LOG(Media, "ScreenDisplayCaptureSourceMac::createDisplayStream: unable to get screen width/height");
             captureFailed();
             return false;
         }
@@ -168,7 +168,7 @@ bool ScreenDisplayCaptureSourceMac::createDisplayStream()
         auto size = frameSize();
         m_displayStream = adoptCF(CGDisplayStreamCreateWithDispatchQueue(m_displayID, size.width(), size.height(), kCVPixelFormatType_420YpCbCr8Planar, streamOptions.get(), m_captureQueue.get(), m_frameAvailableBlock));
         if (!m_displayStream) {
-            RELEASE_LOG(Media, "ScreenDisplayCaptureSourceMac::createDisplayStream(%p), CGDisplayStreamCreate failed", this);
+            RELEASE_LOG(Media, "ScreenDisplayCaptureSourceMac::createDisplayStream: CGDisplayStreamCreate failed");
             captureFailed();
             return false;
         }
@@ -227,7 +227,7 @@ void ScreenDisplayCaptureSourceMac::startDisplayStream()
 
     if (m_displayID != actualDisplayID.value()) {
         m_displayID = actualDisplayID.value();
-        RELEASE_LOG(Media, "ScreenDisplayCaptureSourceMac::startDisplayStream(%p), display ID changed to %d", this, static_cast<int>(m_displayID));
+        RELEASE_LOG(Media, "ScreenDisplayCaptureSourceMac::startDisplayStream: display ID changed to %d", static_cast<int>(m_displayID));
     }
 
     if (!m_displayStream && !createDisplayStream())
@@ -235,7 +235,7 @@ void ScreenDisplayCaptureSourceMac::startDisplayStream()
 
     auto err = CGDisplayStreamStart(m_displayStream.get());
     if (err) {
-        RELEASE_LOG(Media, "ScreenDisplayCaptureSourceMac::startDisplayStream(%p), CGDisplayStreamStart failed with error %d", this, static_cast<int>(err));
+        RELEASE_LOG(Media, "ScreenDisplayCaptureSourceMac::startDisplayStream: CGDisplayStreamStart failed with error %d", static_cast<int>(err));
         captureFailed();
         return;
     }
@@ -278,11 +278,11 @@ void ScreenDisplayCaptureSourceMac::frameAvailable(CGDisplayStreamFrameStatus st
         break;
 
     case kCGDisplayStreamFrameStatusFrameBlank:
-        RELEASE_LOG(Media, "ScreenDisplayCaptureSourceMac::frameAvailable(%p), kCGDisplayStreamFrameStatusFrameBlank", this);
+        RELEASE_LOG(Media, "ScreenDisplayCaptureSourceMac::frameAvailable: kCGDisplayStreamFrameStatusFrameBlank");
         break;
 
     case kCGDisplayStreamFrameStatusStopped:
-        RELEASE_LOG(Media, "ScreenDisplayCaptureSourceMac::frameAvailable(%p), kCGDisplayStreamFrameStatusStopped", this);
+        RELEASE_LOG(Media, "ScreenDisplayCaptureSourceMac::frameAvailable: kCGDisplayStreamFrameStatusStopped");
         break;
     }
 
index d0533ff..1c4d376 100644 (file)
@@ -40,13 +40,13 @@ class PixelBufferConformerCV;
 
 class WindowDisplayCaptureSourceMac : public DisplayCaptureSourceCocoa {
 public:
-    static CaptureSourceOrError create(const String&, const MediaConstraints*);
+    static CaptureSourceOrError create(String&&, const MediaConstraints*);
 
     static std::optional<CaptureDevice> windowCaptureDeviceWithPersistentID(const String&);
     static void windowCaptureDevices(Vector<CaptureDevice>&);
 
 private:
-    WindowDisplayCaptureSourceMac(uint32_t windowID, String&&);
+    WindowDisplayCaptureSourceMac(uint32_t, String&&);
     virtual ~WindowDisplayCaptureSourceMac() = default;
 
     RetainPtr<CVPixelBufferRef> generateFrame() final;
index e1aa0bf..1d6a17c 100644 (file)
@@ -102,7 +102,7 @@ static RetainPtr<CFDictionaryRef> windowDescription(CGWindowID id)
     return checked_cf_cast<CFDictionaryRef>(CFArrayGetValueAtIndex(windows.get(), 0));
 }
 
-CaptureSourceOrError WindowDisplayCaptureSourceMac::create(const String& windowID, const MediaConstraints* constraints)
+CaptureSourceOrError WindowDisplayCaptureSourceMac::create(String&& windowID, const MediaConstraints* constraints)
 {
     bool ok;
     auto actualID = windowID.toUIntStrict(&ok);
index cc35461..3f44fd6 100644 (file)
 namespace WebCore {
 
 #if !PLATFORM(MAC) && !PLATFORM(IOS) && !(USE(GSTREAMER) && USE(LIBWEBRTC))
-CaptureSourceOrError MockRealtimeAudioSource::create(const String& deviceID, const String& name, const MediaConstraints* constraints)
+CaptureSourceOrError MockRealtimeAudioSource::create(String&& deviceID, String&& name, String&& hashSalt, const MediaConstraints* constraints)
 {
+#ifndef NDEBUG
     auto device = MockRealtimeMediaSourceCenter::mockDeviceWithPersistentID(deviceID);
     ASSERT(device);
     if (!device)
         return { };
+#endif
 
-    auto source = adoptRef(*new MockRealtimeAudioSource(WTFMove(device), deviceID, name));
+    auto source = adoptRef(*new MockRealtimeAudioSource(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt)));
     if (constraints && source->applyConstraints(*constraints))
         return { };
 
@@ -58,11 +60,11 @@ CaptureSourceOrError MockRealtimeAudioSource::create(const String& deviceID, con
 }
 #endif
 
-MockRealtimeAudioSource::MockRealtimeAudioSource(const String& deviceID, const String& name)
-    : RealtimeMediaSource(deviceID, RealtimeMediaSource::Type::Audio, name)
+MockRealtimeAudioSource::MockRealtimeAudioSource(String&& deviceID, String&& name, String&& hashSalt)
+    : RealtimeMediaSource(RealtimeMediaSource::Type::Audio, WTFMove(name), WTFMove(deviceID), WTFMove(hashSalt))
     , m_timer(RunLoop::current(), this, &MockRealtimeAudioSource::tick)
 {
-    auto device = MockRealtimeMediaSourceCenter::mockDeviceWithPersistentID(deviceID);
+    auto device = MockRealtimeMediaSourceCenter::mockDeviceWithPersistentID(persistentID());
     ASSERT(device);
     m_device = *device;
 }
@@ -78,7 +80,7 @@ const RealtimeMediaSourceSettings& MockRealtimeAudioSource::settings()
 {
     if (!m_currentSettings) {
         RealtimeMediaSourceSettings settings;
-        settings.setDeviceId(id());
+        settings.setDeviceId(hashedId());
         settings.setVolume(volume());
         settings.setEchoCancellation(echoCancellation());
         settings.setSampleRate(sampleRate());
@@ -100,7 +102,7 @@ const RealtimeMediaSourceCapabilities& MockRealtimeAudioSource::capabilities()
     if (!m_capabilities) {
         RealtimeMediaSourceCapabilities capabilities(settings().supportedConstraints());
 
-        capabilities.setDeviceId(id());
+        capabilities.setDeviceId(hashedId());
         capabilities.setVolume(CapabilityValueOrRange(0.0, 1.0));
         capabilities.setEchoCancellation(RealtimeMediaSourceCapabilities::EchoCancellation::ReadWrite);
         capabilities.setSampleRate(CapabilityValueOrRange(44100, 48000));
index 91e8c03..1d1d5b1 100644 (file)
@@ -42,12 +42,12 @@ namespace WebCore {
 class MockRealtimeAudioSource : public RealtimeMediaSource {
 public:
 
-    static CaptureSourceOrError create(const String& deviceID, const String& name, const MediaConstraints*);
+    static CaptureSourceOrError create(String&& deviceID, String&& name, String&& hashSalt, const MediaConstraints*);
 
     virtual ~MockRealtimeAudioSource();
 
 protected:
-    MockRealtimeAudioSource(const String& deviceID, const String& name);
+    MockRealtimeAudioSource(String&& deviceID, String&& name, String&& hashSalt);
 
     void startProducingData() final;
     void stopProducingData() final;
index f697285..29ee3b0 100644 (file)
@@ -83,15 +83,14 @@ static inline Vector<MockMediaDevice> defaultDevices()
     };
 }
 
-
 class MockRealtimeVideoSourceFactory : public VideoCaptureFactory {
 public:
-    CaptureSourceOrError createVideoCaptureSource(const CaptureDevice& device, const MediaConstraints* constraints) final
+    CaptureSourceOrError createVideoCaptureSource(const CaptureDevice& device, String&& hashSalt, const MediaConstraints* constraints) final
     {
         ASSERT(device.type() == CaptureDevice::DeviceType::Camera);
         ASSERT(MockRealtimeMediaSourceCenter::captureDeviceWithPersistentID(CaptureDevice::DeviceType::Camera, device.persistentId()));
 
-        return MockRealtimeVideoSource::create(device.persistentId(), device.label(), constraints);
+        return MockRealtimeVideoSource::create(String { device.persistentId() }, String { device.label() }, WTFMove(hashSalt), constraints);
     }
 
 #if PLATFORM(IOS)
@@ -113,7 +112,7 @@ public:
         switch (device.type()) {
         case CaptureDevice::DeviceType::Screen:
         case CaptureDevice::DeviceType::Window:
-            return MockRealtimeVideoSource::create(device.persistentId(), device.label(), constraints);
+            return MockRealtimeVideoSource::create(String { device.persistentId() }, String { }, String { device.label() }, constraints);
             break;
         case CaptureDevice::DeviceType::Application:
         case CaptureDevice::DeviceType::Browser:
@@ -130,12 +129,12 @@ public:
 
 class MockRealtimeAudioSourceFactory : public AudioCaptureFactory {
 public:
-    CaptureSourceOrError createAudioCaptureSource(const CaptureDevice& device, const MediaConstraints* constraints) final
+    CaptureSourceOrError createAudioCaptureSource(const CaptureDevice& device, String&& hashSalt, const MediaConstraints* constraints) final
     {
         ASSERT(device.type() == CaptureDevice::DeviceType::Microphone);
         ASSERT(MockRealtimeMediaSourceCenter::captureDeviceWithPersistentID(CaptureDevice::DeviceType::Microphone, device.persistentId()));
 
-        return MockRealtimeAudioSource::create(device.persistentId(), device.label(), constraints);
+        return MockRealtimeAudioSource::create(String { device.persistentId() }, String { device.label() }, WTFMove(hashSalt), constraints);
     }
 };
 
index 5d3fb91..d4706bc 100644 (file)
 namespace WebCore {
 
 #if !PLATFORM(MAC) && !PLATFORM(IOS) && !(USE(GSTREAMER) && USE(LIBWEBRTC))
-CaptureSourceOrError MockRealtimeVideoSource::create(const String& deviceID, const String& name, const MediaConstraints* constraints)
+CaptureSourceOrError MockRealtimeVideoSource::create(String&& deviceID, String&& name, String&& hashSalt, const MediaConstraints* constraints)
 {
+#ifndef NDEBUG
     auto device = MockRealtimeMediaSourceCenter::mockDeviceWithPersistentID(deviceID);
     ASSERT(device);
     if (!device)
         return { };
+#endif
 
-    auto source = adoptRef(*new MockRealtimeVideoSource(WTFMove(device), deviceID, name));
+    auto source = adoptRef(*new MockRealtimeVideoSource(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt)));
     if (constraints && source->applyConstraints(*constraints))
         return { };
 
@@ -64,11 +66,11 @@ CaptureSourceOrError MockRealtimeVideoSource::create(const String& deviceID, con
 }
 #endif
 
-MockRealtimeVideoSource::MockRealtimeVideoSource(const String& deviceID, const String& name)
-    : RealtimeVideoSource(deviceID, name)
+MockRealtimeVideoSource::MockRealtimeVideoSource(String&& deviceID, String&& name, String&& hashSalt)
+    : RealtimeVideoSource(WTFMove(name), WTFMove(deviceID), WTFMove(hashSalt))
     , m_emitFrameTimer(RunLoop::current(), this, &MockRealtimeVideoSource::generateFrame)
 {
-    auto device = MockRealtimeMediaSourceCenter::mockDeviceWithPersistentID(deviceID);
+    auto device = MockRealtimeMediaSourceCenter::mockDeviceWithPersistentID(persistentID());
     ASSERT(device);
     m_device = *device;
 
@@ -120,7 +122,7 @@ const RealtimeMediaSourceCapabilities& MockRealtimeVideoSource::capabilities()
     if (!m_capabilities) {
         RealtimeMediaSourceCapabilities capabilities(settings().supportedConstraints());
 
-        capabilities.setDeviceId(id());
+        capabilities.setDeviceId(hashedId());
         if (mockCamera()) {
             capabilities.addFacingMode(WTF::get<MockCameraProperties>(m_device.properties).facingMode);
             updateCapabilities(capabilities);
@@ -154,7 +156,7 @@ const RealtimeMediaSourceSettings& MockRealtimeVideoSource::settings()
     settings.setHeight(size.height());
     if (aspectRatio())
         settings.setAspectRatio(aspectRatio());
-    settings.setDeviceId(id());
+    settings.setDeviceId(hashedId());
 
     RealtimeMediaSourceSupportedConstraints supportedConstraints;
     supportedConstraints.setSupportsDeviceId(true);
index 146d1aa..bd3c3e4 100644 (file)
@@ -48,10 +48,10 @@ class GraphicsContext;
 class MockRealtimeVideoSource : public RealtimeVideoSource {
 public:
 
-    static CaptureSourceOrError create(const String& deviceID, const String& name, const MediaConstraints*);
+    static CaptureSourceOrError create(String&& deviceID, String&& name, String&& hashSalt, const MediaConstraints*);
 
 protected:
-    MockRealtimeVideoSource(const String& deviceID, const String& name);
+    MockRealtimeVideoSource(String&& deviceID, String&& name, String&& hashSalt);
 
     virtual void updateSampleBuffer() = 0;
 
index 86b8294..f95d744 100644 (file)
@@ -1,3 +1,25 @@
+2018-10-02  Eric Carlson  <eric.carlson@apple.com>
+
+        [MediaStream] RealtimeMediaSource should be able to vend hashed IDs
+        https://bugs.webkit.org/show_bug.cgi?id=190142
+        <rdar://problem/44911109>
+
+        Reviewed by Youenn Fablet.
+
+        * Shared/WebCoreArgumentCoders.cpp:
+        (IPC::ArgumentCoder<MediaConstraints>::encode):
+        (IPC::ArgumentCoder<MediaConstraints>::decode):
+        * UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp:
+        (WebKit::UserMediaCaptureManagerProxy::createMediaSourceForCaptureDeviceWithConstraints):
+        * UIProcess/Cocoa/UserMediaCaptureManagerProxy.h:
+        * UIProcess/Cocoa/UserMediaCaptureManagerProxy.messages.in:
+        * UIProcess/UserMediaPermissionRequestManagerProxy.cpp:
+        (WebKit::UserMediaPermissionRequestManagerProxy::requestUserMediaPermissionForFrame):
+        * WebProcess/cocoa/UserMediaCaptureManager.cpp:
+        (WebKit::UserMediaCaptureManager::Source::Source):
+        (WebKit::UserMediaCaptureManager::createCaptureSource):
+        * WebProcess/cocoa/UserMediaCaptureManager.h:
+
 2018-10-02  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         [macOS] Implement a way for the UI process to request typing attributes at the current selection
index 86348fd..e507bf8 100644 (file)
@@ -2761,7 +2761,6 @@ void ArgumentCoder<MediaConstraints>::encode(Encoder& encoder, const WebCore::Me
 {
     encoder << constraint.mandatoryConstraints
         << constraint.advancedConstraints
-        << constraint.deviceIDHashSalt
         << constraint.isValid;
 }
 
@@ -2773,7 +2772,6 @@ bool ArgumentCoder<MediaConstraints>::decode(Decoder& decoder, WebCore::MediaCon
         return false;
     constraints.mandatoryConstraints = WTFMove(*mandatoryConstraints);
     return decoder.decode(constraints.advancedConstraints)
-        && decoder.decode(constraints.deviceIDHashSalt)
         && decoder.decode(constraints.isValid);
 }
 #endif
index 71a691f..38aab26 100644 (file)
@@ -125,15 +125,15 @@ UserMediaCaptureManagerProxy::~UserMediaCaptureManagerProxy()
     m_process.removeMessageReceiver(Messages::UserMediaCaptureManagerProxy::messageReceiverName());
 }
 
-void UserMediaCaptureManagerProxy::createMediaSourceForCaptureDeviceWithConstraints(uint64_t id, const CaptureDevice& device, WebCore::RealtimeMediaSource::Type type, const MediaConstraints& constraints, bool& succeeded, String& invalidConstraints, WebCore::RealtimeMediaSourceSettings& settings)
+void UserMediaCaptureManagerProxy::createMediaSourceForCaptureDeviceWithConstraints(uint64_t id, const CaptureDevice& device, WebCore::RealtimeMediaSource::Type type, String&& hashSalt, const MediaConstraints& constraints, bool& succeeded, String& invalidConstraints, WebCore::RealtimeMediaSourceSettings& settings)
 {
     CaptureSourceOrError sourceOrError;
     switch (type) {
     case WebCore::RealtimeMediaSource::Type::Audio:
-        sourceOrError = RealtimeMediaSourceCenter::singleton().audioFactory().createAudioCaptureSource(device, &constraints);
+        sourceOrError = RealtimeMediaSourceCenter::singleton().audioFactory().createAudioCaptureSource(device, WTFMove(hashSalt), &constraints);
         break;
     case WebCore::RealtimeMediaSource::Type::Video:
-        sourceOrError = RealtimeMediaSourceCenter::singleton().videoFactory().createVideoCaptureSource(device, &constraints);
+        sourceOrError = RealtimeMediaSourceCenter::singleton().videoFactory().createVideoCaptureSource(device, WTFMove(hashSalt), &constraints);
         break;
     case WebCore::RealtimeMediaSource::Type::None:
         ASSERT_NOT_REACHED();
index ff0ae8b..ecaeae2 100644 (file)
@@ -49,7 +49,7 @@ private:
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;
     void didReceiveSyncMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&) final;
 
-    void createMediaSourceForCaptureDeviceWithConstraints(uint64_t id, const WebCore::CaptureDevice& deviceID, WebCore::RealtimeMediaSource::Type, const WebCore::MediaConstraints&, bool& succeeded, String& invalidConstraints, WebCore::RealtimeMediaSourceSettings&);
+    void createMediaSourceForCaptureDeviceWithConstraints(uint64_t id, const WebCore::CaptureDevice& deviceID, WebCore::RealtimeMediaSource::Type, String&&, const WebCore::MediaConstraints&, bool& succeeded, String& invalidConstraints, WebCore::RealtimeMediaSourceSettings&);
     void startProducingData(uint64_t);
     void stopProducingData(uint64_t);
     void capabilities(uint64_t, WebCore::RealtimeMediaSourceCapabilities&);
index 248c40f..bd219bc 100644 (file)
@@ -24,7 +24,7 @@
 #if ENABLE(MEDIA_STREAM)
 
 messages -> UserMediaCaptureManagerProxy {
-    CreateMediaSourceForCaptureDeviceWithConstraints(uint64_t id, WebCore::CaptureDevice device, WebCore::RealtimeMediaSource::Type type, struct WebCore::MediaConstraints constraints) -> (bool success, String invalidConstraints, WebCore::RealtimeMediaSourceSettings settings)
+    CreateMediaSourceForCaptureDeviceWithConstraints(uint64_t id, WebCore::CaptureDevice device, WebCore::RealtimeMediaSource::Type type, String hashSalt, struct WebCore::MediaConstraints constraints) -> (bool success, String invalidConstraints, WebCore::RealtimeMediaSourceSettings settings)
     StartProducingData(uint64_t id)
     StopProducingData(uint64_t id)
     Capabilities(uint64_t id) -> (WebCore::RealtimeMediaSourceCapabilities capabilities)
index 185c074..62774c9 100644 (file)
@@ -336,9 +336,6 @@ void UserMediaPermissionRequestManagerProxy::requestUserMediaPermissionForFrame(
         if (!m_page.isValid())
             return;
         
-        localUserRequest.audioConstraints.deviceIDHashSalt = deviceIdentifierHashSalt;
-        localUserRequest.videoConstraints.deviceIDHashSalt = deviceIdentifierHashSalt;
-
         syncWithWebCorePrefs();
         
         RealtimeMediaSourceCenter::singleton().validateRequestConstraints(WTFMove(validHandler), WTFMove(invalidHandler), WTFMove(localUserRequest), WTFMove(deviceIdentifierHashSalt));
index 7c7f667..cb6d6c7 100644 (file)
@@ -51,8 +51,8 @@ static uint64_t nextSessionID()
 
 class UserMediaCaptureManager::Source : public RealtimeMediaSource {
 public:
-    Source(const String& sourceID, Type type, const String& name, uint64_t id, UserMediaCaptureManager& manager)
-        : RealtimeMediaSource(sourceID, type, name)
+    Source(String&& sourceID, Type type, String&& name, String&& hashSalt, uint64_t id, UserMediaCaptureManager& manager)
+        : RealtimeMediaSource(type, WTFMove(name), WTFMove(sourceID), WTFMove(hashSalt))
         , m_id(id)
         , m_manager(manager)
         , m_ringBuffer(makeUniqueRef<SharedRingBufferStorage>(nullptr))
@@ -177,7 +177,7 @@ void UserMediaCaptureManager::initialize(const WebProcessCreationParameters& par
         RealtimeMediaSourceCenter::singleton().setAudioFactory(*this);
 }
 
-WebCore::CaptureSourceOrError UserMediaCaptureManager::createCaptureSource(const CaptureDevice& device, WebCore::RealtimeMediaSource::Type sourceType, const WebCore::MediaConstraints* constraints)
+WebCore::CaptureSourceOrError UserMediaCaptureManager::createCaptureSource(const CaptureDevice& device, WebCore::RealtimeMediaSource::Type sourceType, String&& hashSalt, const WebCore::MediaConstraints* constraints)
 {
     if (!constraints)
         return { };
@@ -186,10 +186,10 @@ WebCore::CaptureSourceOrError UserMediaCaptureManager::createCaptureSource(const
     RealtimeMediaSourceSettings settings;
     String errorMessage;
     bool succeeded;
-    if (!m_process.sendSync(Messages::UserMediaCaptureManagerProxy::CreateMediaSourceForCaptureDeviceWithConstraints(id, device, sourceType, *constraints), Messages::UserMediaCaptureManagerProxy::CreateMediaSourceForCaptureDeviceWithConstraints::Reply(succeeded, errorMessage, settings), 0))
+    if (!m_process.sendSync(Messages::UserMediaCaptureManagerProxy::CreateMediaSourceForCaptureDeviceWithConstraints(id, device, sourceType, hashSalt, *constraints), Messages::UserMediaCaptureManagerProxy::CreateMediaSourceForCaptureDeviceWithConstraints::Reply(succeeded, errorMessage, settings), 0))
         return WTFMove(errorMessage);
 
-    auto source = adoptRef(*new Source(String::number(id), sourceType, settings.label(), id, *this));
+    auto source = adoptRef(*new Source(String::number(id), sourceType, String { settings.label() }, WTFMove(hashSalt), id, *this));
     source->setSettings(WTFMove(settings));
     m_sources.set(id, source.copyRef());
     return WebCore::CaptureSourceOrError(WTFMove(source));
index 6a7d0d2..37632d5 100644 (file)
@@ -55,9 +55,9 @@ private:
     void initialize(const WebProcessCreationParameters&) final;
 
     // WebCore::RealtimeMediaSource factories
-    WebCore::CaptureSourceOrError createAudioCaptureSource(const WebCore::CaptureDevice& device, const WebCore::MediaConstraints* constraints) final { return createCaptureSource(device, WebCore::RealtimeMediaSource::Type::Audio, constraints); }
-    WebCore::CaptureSourceOrError createVideoCaptureSource(const WebCore::CaptureDevice& device, const WebCore::MediaConstraints* constraints) final { return createCaptureSource(device, WebCore::RealtimeMediaSource::Type::Video, constraints); }
-    WebCore::CaptureSourceOrError createCaptureSource(const WebCore::CaptureDevice&, WebCore::RealtimeMediaSource::Type, const WebCore::MediaConstraints*);
+    WebCore::CaptureSourceOrError createAudioCaptureSource(const WebCore::CaptureDevice& device, String&& hashSalt, const WebCore::MediaConstraints* constraints) final { return createCaptureSource(device, WebCore::RealtimeMediaSource::Type::Audio, WTFMove(hashSalt), constraints); }
+    WebCore::CaptureSourceOrError createVideoCaptureSource(const WebCore::CaptureDevice& device, String&& hashSalt, const WebCore::MediaConstraints* constraints) final { return createCaptureSource(device, WebCore::RealtimeMediaSource::Type::Video, WTFMove(hashSalt), constraints); }
+    WebCore::CaptureSourceOrError createCaptureSource(const WebCore::CaptureDevice&, WebCore::RealtimeMediaSource::Type, String&&, const WebCore::MediaConstraints*);
 
     // IPC::MessageReceiver
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;