WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-237359-20220302130527.patch (text/plain), 132.10 KB, created by
youenn fablet
on 2022-03-02 04:05:29 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
youenn fablet
Created:
2022-03-02 04:05:29 PST
Size:
132.10 KB
patch
obsolete
>Subversion Revision: 290719 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 24de055e3da28d1e172ce02c9086ee17bb1b03ef..387059e8af0254278f6f4822530e988a4cdf36a8 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,48 @@ >+2022-03-02 Youenn Fablet <youenn@apple.com> >+ >+ Scope capture sources by page identifiers >+ https://bugs.webkit.org/show_bug.cgi?id=237359 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Per page sources >+ >+ No new tests (OOPS!). >+ >+ * Modules/mediastream/MediaDevices.cpp: >+ * Modules/mediastream/MediaStreamTrack.cpp: >+ * Modules/speech/SpeechRecognitionCaptureSource.cpp: >+ * Modules/speech/SpeechRecognitionCaptureSource.h: >+ * Sources.txt: >+ * WebCore.xcodeproj/project.pbxproj: >+ * platform/PageIdentifier.h: Renamed from Source/WebCore/page/PageIdentifier.h. >+ * platform/mediastream/MediaStreamRequest.h: >+ * platform/mediastream/RealtimeMediaSource.cpp: >+ * platform/mediastream/RealtimeMediaSource.h: >+ * platform/mediastream/RealtimeMediaSourceCenter.cpp: >+ * platform/mediastream/RealtimeMediaSourceFactory.cpp: Removed. >+ * platform/mediastream/RealtimeMediaSourceFactory.h: >+ * platform/mediastream/RealtimeVideoCaptureSource.cpp: >+ * platform/mediastream/RealtimeVideoCaptureSource.h: >+ * platform/mediastream/RealtimeVideoSource.cpp: >+ * platform/mediastream/cocoa/DisplayCaptureSourceCocoa.cpp: >+ * platform/mediastream/cocoa/DisplayCaptureSourceCocoa.h: >+ * platform/mediastream/ios/CoreAudioCaptureSourceIOS.h: >+ * platform/mediastream/ios/CoreAudioCaptureSourceIOS.mm: >+ * platform/mediastream/mac/AVVideoCaptureSource.h: >+ * platform/mediastream/mac/AVVideoCaptureSource.mm: >+ * platform/mediastream/mac/CoreAudioCaptureSource.cpp: >+ * platform/mediastream/mac/CoreAudioCaptureSource.h: >+ * platform/mediastream/mac/MockAudioSharedUnit.mm: >+ * platform/mediastream/mac/MockRealtimeVideoSourceMac.h: >+ * platform/mediastream/mac/MockRealtimeVideoSourceMac.mm: >+ * platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp: >+ * platform/mock/MockRealtimeAudioSource.cpp: >+ * platform/mock/MockRealtimeAudioSource.h: >+ * platform/mock/MockRealtimeMediaSourceCenter.cpp: >+ * platform/mock/MockRealtimeVideoSource.cpp: >+ * platform/mock/MockRealtimeVideoSource.h: >+ > 2022-03-01 Youenn Fablet <youenn@apple.com> > > Rename MediaSampleAVFObjC::createImageSample to MediaSampleAVFObjC::createFromPixelBuffer >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 81bf01241370f4a7aaede40edd1f28b89164fbf4..85adf562ae94706c57bf33016fd8d7ae9127ff5f 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,33 @@ >+2022-03-02 Youenn Fablet <youenn@apple.com> >+ >+ Scope capture sources by page identifiers >+ https://bugs.webkit.org/show_bug.cgi?id=237359 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Per page sources >+ >+ * UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp: >+ * UIProcess/Cocoa/UserMediaCaptureManagerProxy.h: >+ * UIProcess/Cocoa/UserMediaCaptureManagerProxy.messages.in: >+ * UIProcess/SpeechRecognitionRemoteRealtimeMediaSource.cpp: >+ * UIProcess/SpeechRecognitionRemoteRealtimeMediaSource.h: >+ * UIProcess/SpeechRecognitionRemoteRealtimeMediaSourceManager.cpp: >+ * UIProcess/WebPageProxy.cpp: >+ * WebProcess/Speech/SpeechRecognitionRealtimeMediaSourceManager.cpp: >+ * WebProcess/Speech/SpeechRecognitionRealtimeMediaSourceManager.h: >+ * WebProcess/Speech/SpeechRecognitionRealtimeMediaSourceManager.messages.in: >+ * WebProcess/cocoa/RemoteRealtimeAudioSource.cpp: >+ * WebProcess/cocoa/RemoteRealtimeAudioSource.h: >+ * WebProcess/cocoa/RemoteRealtimeDisplaySource.cpp: >+ * WebProcess/cocoa/RemoteRealtimeDisplaySource.h: >+ * WebProcess/cocoa/RemoteRealtimeMediaSourceProxy.cpp: >+ * WebProcess/cocoa/RemoteRealtimeMediaSourceProxy.h: >+ * WebProcess/cocoa/RemoteRealtimeVideoSource.cpp: >+ * WebProcess/cocoa/RemoteRealtimeVideoSource.h: >+ * WebProcess/cocoa/UserMediaCaptureManager.cpp: >+ * WebProcess/cocoa/UserMediaCaptureManager.h: >+ > 2022-03-01 Youenn Fablet <youenn@apple.com> > > Rename MediaSampleAVFObjC::createImageSample to MediaSampleAVFObjC::createFromPixelBuffer >diff --git a/Source/WebCore/Headers.cmake b/Source/WebCore/Headers.cmake >index 3cb4a49d98516c9cbd51dedcfac36af2dfd5d151..92c66388081ed499642f92a80cd7596bb8c543c6 100644 >--- a/Source/WebCore/Headers.cmake >+++ b/Source/WebCore/Headers.cmake >@@ -1135,7 +1135,6 @@ set(WebCore_PRIVATE_FRAMEWORK_HEADERS > page/PageConfiguration.h > page/PageConsoleClient.h > page/PageGroup.h >- page/PageIdentifier.h > page/PageInlines.h > page/PageOverlay.h > page/PageOverlayController.h >@@ -1292,6 +1291,7 @@ set(WebCore_PRIVATE_FRAMEWORK_HEADERS > platform/PODInterval.h > platform/PODIntervalTree.h > platform/PODRedBlackTree.h >+ platform/PageIdentifier.h > platform/Pasteboard.h > platform/PasteboardContext.h > platform/PasteboardCustomData.h >diff --git a/Source/WebCore/Modules/mediastream/MediaDevices.cpp b/Source/WebCore/Modules/mediastream/MediaDevices.cpp >index 506f3374b7e6d76d598f4953d849c38eaac727e9..0faa8bb55a1985e980f736b61da0d630d6cae3cd 100644 >--- a/Source/WebCore/Modules/mediastream/MediaDevices.cpp >+++ b/Source/WebCore/Modules/mediastream/MediaDevices.cpp >@@ -142,7 +142,7 @@ void MediaDevices::getUserMedia(const StreamConstraints& constraints, Promise&& > videoConstraints.setDefaultVideoConstraints(); > } > >- auto request = UserMediaRequest::create(*document, { MediaStreamRequest::Type::UserMedia, WTFMove(audioConstraints), WTFMove(videoConstraints), isUserGesturePriviledged }, WTFMove(promise)); >+ auto request = UserMediaRequest::create(*document, { MediaStreamRequest::Type::UserMedia, WTFMove(audioConstraints), WTFMove(videoConstraints), isUserGesturePriviledged, *document->pageID() }, WTFMove(promise)); > > if (!document->settings().getUserMediaRequiresFocus()) { > request->start(); >@@ -249,7 +249,7 @@ void MediaDevices::getDisplayMedia(const DisplayMediaStreamConstraints& constrai > return; > } > >- auto request = UserMediaRequest::create(*document, { MediaStreamRequest::Type::DisplayMedia, { }, WTFMove(videoConstraints), isUserGesturePriviledged }, WTFMove(promise)); >+ auto request = UserMediaRequest::create(*document, { MediaStreamRequest::Type::DisplayMedia, { }, WTFMove(videoConstraints), isUserGesturePriviledged, *document->pageID() }, WTFMove(promise)); > request->start(); > } > >diff --git a/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp b/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp >index a45d19e54739956db78063c7cabe8a8e0f104d4d..fc176156dd0fcd221dfb8272318142da70cf088c 100644 >--- a/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp >+++ b/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp >@@ -469,44 +469,12 @@ MediaProducerMediaStateFlags MediaStreamTrack::captureState(Document& document) > return state; > } > >-#if PLATFORM(IOS_FAMILY) >-static bool isSourceCapturingForTrackInDocument(RealtimeMediaSource& source, Document& document) >-{ >- for (auto* track : allCaptureTracks()) { >- if (track->document() != &document || track->ended()) >- continue; >- >- if (track->source().isSameAs(source)) >- return true; >- } >- return false; >-} >-#endif >- > void MediaStreamTrack::updateCaptureAccordingToMutedState(Document& document) > { >-#if PLATFORM(IOS_FAMILY) >- auto* page = document.page(); >- if (!page) >- return; >- >- auto* activeAudioSource = RealtimeMediaSourceCenter::singleton().audioCaptureFactory().activeSource(); >- if (activeAudioSource && isSourceCapturingForTrackInDocument(*activeAudioSource, document)) { >- bool pageMuted = page->mutedState().contains(MediaProducerMutedState::AudioCaptureIsMuted); >- activeAudioSource->setMuted(pageMuted || (document.hidden() && document.settings().interruptAudioOnPageVisibilityChangeEnabled())); >- } >- >- auto* activeVideoSource = RealtimeMediaSourceCenter::singleton().videoCaptureFactory().activeSource(); >- if (activeVideoSource && isSourceCapturingForTrackInDocument(*activeVideoSource, document)) { >- bool pageMuted = page->mutedState().contains(MediaProducerMutedState::VideoCaptureIsMuted); >- activeVideoSource->setMuted(pageMuted || document.hidden()); >- } >-#else > for (auto* captureTrack : allCaptureTracks()) { > if (captureTrack->document() == &document && !captureTrack->ended()) > captureTrack->updateToPageMutedState(); > } >-#endif > } > > void MediaStreamTrack::updateToPageMutedState() >diff --git a/Source/WebCore/Modules/speech/SpeechRecognitionCaptureSource.cpp b/Source/WebCore/Modules/speech/SpeechRecognitionCaptureSource.cpp >index 349adf6b42ccb3cc1d6c07a2e544c2bc593aca4b..afbce7a9f456f7d507687809cbe16e11be40e29b 100644 >--- a/Source/WebCore/Modules/speech/SpeechRecognitionCaptureSource.cpp >+++ b/Source/WebCore/Modules/speech/SpeechRecognitionCaptureSource.cpp >@@ -62,9 +62,9 @@ std::optional<CaptureDevice> SpeechRecognitionCaptureSource::findCaptureDevice() > return captureDevice; > } > >-CaptureSourceOrError SpeechRecognitionCaptureSource::createRealtimeMediaSource(const CaptureDevice& captureDevice) >+CaptureSourceOrError SpeechRecognitionCaptureSource::createRealtimeMediaSource(const CaptureDevice& captureDevice, PageIdentifier pageIdentifier) > { >- return RealtimeMediaSourceCenter::singleton().audioCaptureFactory().createAudioCaptureSource(captureDevice, "SpeechID"_s, { }); >+ return RealtimeMediaSourceCenter::singleton().audioCaptureFactory().createAudioCaptureSource(captureDevice, "SpeechID"_s, { }, pageIdentifier); > } > > SpeechRecognitionCaptureSource::SpeechRecognitionCaptureSource(SpeechRecognitionConnectionClientIdentifier clientIdentifier, DataCallback&& dataCallback, StateUpdateCallback&& stateUpdateCallback, Ref<RealtimeMediaSource>&& source) >diff --git a/Source/WebCore/Modules/speech/SpeechRecognitionCaptureSource.h b/Source/WebCore/Modules/speech/SpeechRecognitionCaptureSource.h >index ca903b12b7f221935f5dfa198dbb1a8c4c79d349..e328dc3c7cd30f6993027cb7d984c6617fb96c1b 100644 >--- a/Source/WebCore/Modules/speech/SpeechRecognitionCaptureSource.h >+++ b/Source/WebCore/Modules/speech/SpeechRecognitionCaptureSource.h >@@ -51,7 +51,7 @@ public: > using StateUpdateCallback = Function<void(const SpeechRecognitionUpdate&)>; > SpeechRecognitionCaptureSource(SpeechRecognitionConnectionClientIdentifier, DataCallback&&, StateUpdateCallback&&, Ref<RealtimeMediaSource>&&); > WEBCORE_EXPORT static std::optional<WebCore::CaptureDevice> findCaptureDevice(); >- WEBCORE_EXPORT static CaptureSourceOrError createRealtimeMediaSource(const CaptureDevice&); >+ WEBCORE_EXPORT static CaptureSourceOrError createRealtimeMediaSource(const CaptureDevice&, PageIdentifier); > #endif > > private: >diff --git a/Source/WebCore/Sources.txt b/Source/WebCore/Sources.txt >index a1d6b6fc63ad291f0728d51897e8b9c1797cb301..d85f0e738b60e1f03e9f474a3718d1eaf20b4339 100644 >--- a/Source/WebCore/Sources.txt >+++ b/Source/WebCore/Sources.txt >@@ -2192,7 +2192,6 @@ platform/mediastream/RealtimeIncomingAudioSource.cpp > platform/mediastream/RealtimeIncomingVideoSource.cpp > platform/mediastream/RealtimeMediaSource.cpp > platform/mediastream/RealtimeMediaSourceCenter.cpp >-platform/mediastream/RealtimeMediaSourceFactory.cpp > platform/mediastream/RealtimeMediaSourceSettings.cpp > platform/mediastream/RealtimeMediaSourceSupportedConstraints.cpp > platform/mediastream/RealtimeOutgoingAudioSource.cpp >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index ea5765ef68d3381d870645ff3e7fb75fbcd44de3..938ba5fbc4c376663790936db1f2fdfb5cc78981 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -1182,6 +1182,7 @@ > 418FCBE72715A28F00F96ECA /* RTCRtpCodecCapability.h in Headers */ = {isa = PBXBuildFile; fileRef = 41E0A7DC23BB63DB00561060 /* RTCRtpCodecCapability.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 4190F3A524A0B4EE00531C57 /* FrameRateMonitor.h in Headers */ = {isa = PBXBuildFile; fileRef = 4190F3A3249D152800531C57 /* FrameRateMonitor.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 419242492127B93E00634FCF /* RealtimeOutgoingVideoSourceCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 419242472127B7CC00634FCF /* RealtimeOutgoingVideoSourceCocoa.mm */; }; >+ 4192BB1327CF638600F29A46 /* PageIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 4192BB1227CF638300F29A46 /* PageIdentifier.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 419ACF921F97E7DA009F1A83 /* ServiceWorkerFetch.h in Headers */ = {isa = PBXBuildFile; fileRef = 419ACF8E1F97E7D5009F1A83 /* ServiceWorkerFetch.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 419BC2DF1685329900D64D6D /* VisitedLinkState.h in Headers */ = {isa = PBXBuildFile; fileRef = 419BC2DD1685329900D64D6D /* VisitedLinkState.h */; }; > 419BE7591BC7F42B00E1C85B /* WebCoreBuiltinNames.h in Headers */ = {isa = PBXBuildFile; fileRef = 419BE7521BC7F3DB00E1C85B /* WebCoreBuiltinNames.h */; }; >@@ -1363,7 +1364,6 @@ > 46A78B342799BD71001154FE /* WorkerOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C1B1D2626F18A4B00882DA2 /* WorkerOptions.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 46AAAA3D25D3632000BAF42F /* AudioFileReaderCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = 46AAAA3A25D3631400BAF42F /* AudioFileReaderCocoa.h */; }; > 46B63F6C1C6E8D19002E914B /* JSEventTargetCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = 46B63F6B1C6E8CDF002E914B /* JSEventTargetCustom.h */; settings = {ATTRIBUTES = (Private, ); }; }; >- 46B650DD2296262700FD8AA4 /* PageIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 46B650DB2296262700FD8AA4 /* PageIdentifier.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 46B8593C261672270019EDC6 /* ScriptBufferSourceProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 46B8593A2616720C0019EDC6 /* ScriptBufferSourceProvider.h */; }; > 46B95195207D633400A7D2DD /* AbstractDOMWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = 46B9518A207D632800A7D2DD /* AbstractDOMWindow.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 46B95196207D633A00A7D2DD /* AbstractFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 46B9518F207D632B00A7D2DD /* AbstractFrame.h */; settings = {ATTRIBUTES = (Private, ); }; }; >@@ -6103,7 +6103,6 @@ > 0753860014489E9800B78452 /* CachedTextTrack.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CachedTextTrack.cpp; sourceTree = "<group>"; }; > 0753860114489E9800B78452 /* CachedTextTrack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedTextTrack.h; sourceTree = "<group>"; }; > 0754A5E8215EA3B7002D3A99 /* RealtimeMediaSourceFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RealtimeMediaSourceFactory.h; sourceTree = "<group>"; }; >- 0754A5EB215EADF3002D3A99 /* RealtimeMediaSourceFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RealtimeMediaSourceFactory.cpp; sourceTree = "<group>"; }; > 0757B13C214AE79700794B0D /* VideoPreset.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VideoPreset.h; sourceTree = "<group>"; }; > 07611DB8243FB75C00D80704 /* MediaUsageInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaUsageInfo.h; sourceTree = "<group>"; }; > 07638A971884487200E15A1B /* MediaSessionManagerIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaSessionManagerIOS.h; sourceTree = "<group>"; }; >@@ -8858,6 +8857,7 @@ > 4190F3A1249D152700531C57 /* FrameRateMonitor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FrameRateMonitor.cpp; sourceTree = "<group>"; }; > 4190F3A3249D152800531C57 /* FrameRateMonitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FrameRateMonitor.h; sourceTree = "<group>"; }; > 419242472127B7CC00634FCF /* RealtimeOutgoingVideoSourceCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RealtimeOutgoingVideoSourceCocoa.mm; sourceTree = "<group>"; }; >+ 4192BB1227CF638300F29A46 /* PageIdentifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PageIdentifier.h; sourceTree = "<group>"; }; > 41945694203502A5004BA277 /* ApplicationCacheResourceLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ApplicationCacheResourceLoader.cpp; sourceTree = "<group>"; }; > 41945696203502A6004BA277 /* ApplicationCacheResourceLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApplicationCacheResourceLoader.h; sourceTree = "<group>"; }; > 419ACF8E1F97E7D5009F1A83 /* ServiceWorkerFetch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ServiceWorkerFetch.h; sourceTree = "<group>"; }; >@@ -9311,7 +9311,6 @@ > 46AAAA3C25D3631400BAF42F /* AudioFileReaderCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AudioFileReaderCocoa.cpp; sourceTree = "<group>"; }; > 46ACD8112701656A00EF8CED /* NavigationRequester.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NavigationRequester.cpp; sourceTree = "<group>"; }; > 46B63F6B1C6E8CDF002E914B /* JSEventTargetCustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSEventTargetCustom.h; sourceTree = "<group>"; }; >- 46B650DB2296262700FD8AA4 /* PageIdentifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PageIdentifier.h; sourceTree = "<group>"; }; > 46B8593A2616720C0019EDC6 /* ScriptBufferSourceProvider.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ScriptBufferSourceProvider.h; sourceTree = "<group>"; }; > 46B9518A207D632800A7D2DD /* AbstractDOMWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AbstractDOMWindow.h; sourceTree = "<group>"; }; > 46B9518C207D632900A7D2DD /* RemoteFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteFrame.cpp; sourceTree = "<group>"; }; >@@ -18690,7 +18689,6 @@ > 4A4F656D1AA997F100E38CDD /* RealtimeMediaSourceCapabilities.h */, > 4A0FFA9F1AAF5EA20062803B /* RealtimeMediaSourceCenter.cpp */, > 4A0FFAA01AAF5EA20062803B /* RealtimeMediaSourceCenter.h */, >- 0754A5EB215EADF3002D3A99 /* RealtimeMediaSourceFactory.cpp */, > 0754A5E8215EA3B7002D3A99 /* RealtimeMediaSourceFactory.h */, > 41B8776023DE1042003638B8 /* RealtimeMediaSourceIdentifier.h */, > 4A4F656E1AA997F100E38CDD /* RealtimeMediaSourceSettings.cpp */, >@@ -24255,7 +24253,6 @@ > 9302B0BE0D79F82C00C7EE83 /* PageGroup.h */, > 7A674BD90F9EBF4E006CF099 /* PageGroupLoadDeferrer.cpp */, > 7A674BDA0F9EBF4E006CF099 /* PageGroupLoadDeferrer.h */, >- 46B650DB2296262700FD8AA4 /* PageIdentifier.h */, > CDEFDA0D271229BA005559A7 /* PageInlines.h */, > 2D5C9CFB19C7B52E00B3C5C1 /* PageOverlay.cpp */, > 2D5C9CFC19C7B52E00B3C5C1 /* PageOverlay.h */, >@@ -30100,6 +30097,7 @@ > 4178EF1624125B6C00193C74 /* NowPlayingManager.cpp */, > 4178EF1424125B6C00193C74 /* NowPlayingManager.h */, > 4184F5151EAF059800F18BF0 /* OrientationNotifier.h */, >+ 4192BB1227CF638300F29A46 /* PageIdentifier.h */, > 2EE02A1E1F7324280006AF72 /* Pasteboard.cpp */, > 4B2708C50AF19EE40065127F /* Pasteboard.h */, > F40DAAEB25D9F25E0011B4FA /* PasteboardContext.h */, >@@ -34133,6 +34131,7 @@ > 9393E600151A99F200066F06 /* CSSImageSetValue.h in Headers */, > A80E6CFA0A1989CA007FB8C5 /* CSSImageValue.h in Headers */, > A80E6CF60A1989CA007FB8C5 /* CSSImportRule.h in Headers */, >+ 4192BB1327CF638600F29A46 /* PageIdentifier.h in Headers */, > 31288E730E3005D6003619AE /* CSSKeyframeRule.h in Headers */, > 31288E750E3005D6003619AE /* CSSKeyframesRule.h in Headers */, > 2A4107A426CB66F8003BF797 /* CSSKeywordValue.h in Headers */, >@@ -36553,7 +36552,6 @@ > 9302B0BF0D79F82C00C7EE83 /* PageGroup.h in Headers */, > 7A674BDC0F9EBF4E006CF099 /* PageGroupLoadDeferrer.h in Headers */, > A5B81CC41FAA44BC0037D1E6 /* PageHeapAgent.h in Headers */, >- 46B650DD2296262700FD8AA4 /* PageIdentifier.h in Headers */, > CDEFDA0E271229BA005559A7 /* PageInlines.h in Headers */, > A5CB05241FB51F3300089B97 /* PageNetworkAgent.h in Headers */, > 2D5C9D0019C7B52E00B3C5C1 /* PageOverlay.h in Headers */, >diff --git a/Source/WebCore/page/PageIdentifier.h b/Source/WebCore/page/PageIdentifier.h >deleted file mode 100644 >index 44d5f8d297563ee029c413e9cda7494c5fa4d8ae..0000000000000000000000000000000000000000 >--- a/Source/WebCore/page/PageIdentifier.h >+++ /dev/null >@@ -1,35 +0,0 @@ >-/* >- * Copyright (C) 2019 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >- * THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#pragma once >- >-#include <wtf/ObjectIdentifier.h> >- >-namespace WebCore { >- >-enum PageIdentifierType { }; >-using PageIdentifier = ObjectIdentifier<PageIdentifierType>; >- >-} >diff --git a/Source/WebCore/platform/PageIdentifier.h b/Source/WebCore/platform/PageIdentifier.h >new file mode 100644 >index 0000000000000000000000000000000000000000..44d5f8d297563ee029c413e9cda7494c5fa4d8ae >--- /dev/null >+++ b/Source/WebCore/platform/PageIdentifier.h >@@ -0,0 +1,35 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include <wtf/ObjectIdentifier.h> >+ >+namespace WebCore { >+ >+enum PageIdentifierType { }; >+using PageIdentifier = ObjectIdentifier<PageIdentifierType>; >+ >+} >diff --git a/Source/WebCore/platform/mediastream/MediaStreamRequest.h b/Source/WebCore/platform/mediastream/MediaStreamRequest.h >index a4d4b525be899c29216409c289476e19f46e771d..d07956f49aaca8b5c3519a2978b6920c841a16b1 100644 >--- a/Source/WebCore/platform/mediastream/MediaStreamRequest.h >+++ b/Source/WebCore/platform/mediastream/MediaStreamRequest.h >@@ -30,6 +30,7 @@ > #if ENABLE(MEDIA_STREAM) > > #include "MediaConstraints.h" >+#include "PageIdentifier.h" > > namespace WebCore { > >@@ -39,6 +40,7 @@ struct MediaStreamRequest { > MediaConstraints audioConstraints; > MediaConstraints videoConstraints; > bool isUserGesturePriviledged { false }; >+ PageIdentifier pageIdentifier; > > template<class Encoder> > void encode(Encoder& encoder) const >@@ -47,15 +49,20 @@ struct MediaStreamRequest { > encoder << audioConstraints; > encoder << videoConstraints; > encoder << isUserGesturePriviledged; >+ encoder << pageIdentifier; > } > > template <class Decoder> static std::optional<MediaStreamRequest> decode(Decoder& decoder) > { > MediaStreamRequest request; >- if (decoder.decode(request.type) && decoder.decode(request.audioConstraints) && decoder.decode(request.videoConstraints) && decoder.decode(request.isUserGesturePriviledged)) >- return request; >- >- return std::nullopt; >+ if (!decoder.decode(request.type) >+ || !decoder.decode(request.audioConstraints) >+ || !decoder.decode(request.videoConstraints) >+ || !decoder.decode(request.isUserGesturePriviledged) >+ || !decoder.decode(request.pageIdentifier)) >+ return std::nullopt; >+ >+ return request; > } > }; > >diff --git a/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp b/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp >index de0f1a7a4e635a139e4828b547fdcf06619b35ab..f1c9e602813a3bf6fb3141788b6604ca43b09b91 100644 >--- a/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp >+++ b/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp >@@ -48,8 +48,9 @@ > > namespace WebCore { > >-RealtimeMediaSource::RealtimeMediaSource(Type type, String&& name, String&& deviceID, String&& hashSalt) >- : m_idHashSalt(WTFMove(hashSalt)) >+RealtimeMediaSource::RealtimeMediaSource(Type type, String&& name, String&& deviceID, String&& hashSalt, PageIdentifier pageIdentifier) >+ : m_pageIdentifier(pageIdentifier) >+ , m_idHashSalt(WTFMove(hashSalt)) > , m_persistentID(WTFMove(deviceID)) > , m_type(type) > , m_name(WTFMove(name)) >diff --git a/Source/WebCore/platform/mediastream/RealtimeMediaSource.h b/Source/WebCore/platform/mediastream/RealtimeMediaSource.h >index b25937679ab9270f19b62ff40d5251143b69ab44..ac4fde935b7804da2ede5930959c42e12b9f70b0 100644 >--- a/Source/WebCore/platform/mediastream/RealtimeMediaSource.h >+++ b/Source/WebCore/platform/mediastream/RealtimeMediaSource.h >@@ -69,6 +69,7 @@ struct CaptureSourceOrError; > > class WEBCORE_EXPORT RealtimeMediaSource > : public ThreadSafeRefCounted<RealtimeMediaSource, WTF::DestructionThread::MainRunLoop> >+ , public CanMakeWeakPtr<RealtimeMediaSource> > #if !RELEASE_LOG_DISABLED > , public LoggerHelper > #endif >@@ -221,8 +222,10 @@ public: > > virtual bool setShouldApplyRotation(bool) { return false; } > >+ PageIdentifier pageIdentifier() const { return m_pageIdentifier; } >+ > protected: >- RealtimeMediaSource(Type, String&& name, String&& deviceID = { }, String&& hashSalt = { }); >+ RealtimeMediaSource(Type, String&& name, String&& deviceID = { }, String&& hashSalt = { }, PageIdentifier = { }); > > void scheduleDeferredTask(Function<void()>&&); > >@@ -273,6 +276,7 @@ private: > unsigned m_frameCount { 0 }; > #endif > >+ PageIdentifier m_pageIdentifier; > String m_idHashSalt; > String m_hashedID; > String m_persistentID; >diff --git a/Source/WebCore/platform/mediastream/RealtimeMediaSourceCenter.cpp b/Source/WebCore/platform/mediastream/RealtimeMediaSourceCenter.cpp >index 94526324bd48ab22e1940c11208f53b1b921c34a..0074d14495e9cf10ce054b9ef09b41b77d6b86de 100644 >--- a/Source/WebCore/platform/mediastream/RealtimeMediaSourceCenter.cpp >+++ b/Source/WebCore/platform/mediastream/RealtimeMediaSourceCenter.cpp >@@ -77,7 +77,7 @@ void RealtimeMediaSourceCenter::createMediaStream(Ref<const Logger>&& logger, Ne > > RefPtr<RealtimeMediaSource> audioSource; > if (audioDevice) { >- auto source = audioCaptureFactory().createAudioCaptureSource(WTFMove(audioDevice), String { hashSalt }, &request.audioConstraints); >+ auto source = audioCaptureFactory().createAudioCaptureSource(WTFMove(audioDevice), String { hashSalt }, &request.audioConstraints, request.pageIdentifier); > if (!source) { > completionHandler(makeUnexpected(makeString("Failed to create MediaStream audio source: ", source.errorMessage))); > return; >@@ -89,9 +89,9 @@ void RealtimeMediaSourceCenter::createMediaStream(Ref<const Logger>&& logger, Ne > if (videoDevice) { > CaptureSourceOrError source; > if (videoDevice.type() == CaptureDevice::DeviceType::Camera) >- source = videoCaptureFactory().createVideoCaptureSource(WTFMove(videoDevice), WTFMove(hashSalt), &request.videoConstraints); >+ source = videoCaptureFactory().createVideoCaptureSource(WTFMove(videoDevice), WTFMove(hashSalt), &request.videoConstraints, request.pageIdentifier); > else >- source = displayCaptureFactory().createDisplayCaptureSource(WTFMove(videoDevice), WTFMove(hashSalt), &request.videoConstraints); >+ source = displayCaptureFactory().createDisplayCaptureSource(WTFMove(videoDevice), WTFMove(hashSalt), &request.videoConstraints, request.pageIdentifier); > > if (!source) { > completionHandler(makeUnexpected(makeString("Failed to create MediaStream video source: ", source.errorMessage))); >@@ -204,7 +204,7 @@ void RealtimeMediaSourceCenter::getDisplayMediaDevices(const MediaStreamRequest& > if (!device.enabled()) > return; > >- auto sourceOrError = displayCaptureFactory().createDisplayCaptureSource(device, String { hashSalt }, &request.videoConstraints); >+ auto sourceOrError = displayCaptureFactory().createDisplayCaptureSource(device, String { hashSalt }, &request.videoConstraints, request.pageIdentifier); > if (sourceOrError && sourceOrError.captureSource->supportsConstraints(request.videoConstraints, invalidConstraint)) > displayDeviceInfo.append({ sourceOrError.captureSource->fitnessScore(), device }); > >@@ -221,7 +221,7 @@ void RealtimeMediaSourceCenter::getUserMediaDevices(const MediaStreamRequest& re > if (!device.enabled()) > continue; > >- auto sourceOrError = audioCaptureFactory().createAudioCaptureSource(device, String { hashSalt }, { }); >+ auto sourceOrError = audioCaptureFactory().createAudioCaptureSource(device, String { hashSalt }, { }, request.pageIdentifier); > if (sourceOrError && sourceOrError.captureSource->supportsConstraints(request.audioConstraints, invalidConstraint)) > audioDeviceInfo.append({sourceOrError.captureSource->fitnessScore(), device}); > >@@ -235,7 +235,7 @@ void RealtimeMediaSourceCenter::getUserMediaDevices(const MediaStreamRequest& re > if (!device.enabled()) > continue; > >- auto sourceOrError = videoCaptureFactory().createVideoCaptureSource(device, String { hashSalt }, { }); >+ auto sourceOrError = videoCaptureFactory().createVideoCaptureSource(device, String { hashSalt }, { }, request.pageIdentifier); > if (sourceOrError && sourceOrError.captureSource->supportsConstraints(request.videoConstraints, invalidConstraint)) > videoDeviceInfo.append({sourceOrError.captureSource->fitnessScore(), device}); > >diff --git a/Source/WebCore/platform/mediastream/RealtimeMediaSourceFactory.cpp b/Source/WebCore/platform/mediastream/RealtimeMediaSourceFactory.cpp >deleted file mode 100644 >index e8e55df27f4a3f6858f13b586a48e9655afe61fd..0000000000000000000000000000000000000000 >--- a/Source/WebCore/platform/mediastream/RealtimeMediaSourceFactory.cpp >+++ /dev/null >@@ -1,57 +0,0 @@ >-/* >- * Copyright (C) 2018 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#include "config.h" >-#include "RealtimeMediaSourceFactory.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 { >- >-void SingleSourceFactory::setActiveSource(RealtimeMediaSource& source) >-{ >- if (m_activeSource == &source) >- return; >- if (m_activeSource && m_activeSource->isProducingData()) >- m_activeSource->setMuted(true); >- m_activeSource = &source; >-} >- >-void SingleSourceFactory::unsetActiveSource(RealtimeMediaSource& source) >-{ >- if (m_activeSource == &source) >- m_activeSource = nullptr; >-} >- >-} // namespace WebCore >- >-#endif // ENABLE(MEDIA_STREAM) >diff --git a/Source/WebCore/platform/mediastream/RealtimeMediaSourceFactory.h b/Source/WebCore/platform/mediastream/RealtimeMediaSourceFactory.h >index ba0d903e629ed8abedf7cfcf1ef965113e3890bf..661d592eec20766866e9e2af803c24276f6d7096 100644 >--- a/Source/WebCore/platform/mediastream/RealtimeMediaSourceFactory.h >+++ b/Source/WebCore/platform/mediastream/RealtimeMediaSourceFactory.h >@@ -27,6 +27,7 @@ > > #if ENABLE(MEDIA_STREAM) > >+#include "PageIdentifier.h" > #include <wtf/CompletionHandler.h> > #include <wtf/WeakPtr.h> > #include <wtf/text/WTFString.h> >@@ -41,27 +42,10 @@ class RealtimeMediaSource; > struct CaptureSourceOrError; > struct MediaConstraints; > >-class WEBCORE_EXPORT SingleSourceFactory { >-public: >- virtual ~SingleSourceFactory() = default; >- >- virtual void setActiveSource(RealtimeMediaSource&); >- virtual void unsetActiveSource(RealtimeMediaSource&); >- >- virtual RealtimeMediaSource* activeSource() { return m_activeSource; } >- >-private: >- RealtimeMediaSource* m_activeSource { nullptr }; >-}; >- >-class AudioCaptureFactory >-#if PLATFORM(IOS_FAMILY) >- : public SingleSourceFactory >-#endif >-{ >+class AudioCaptureFactory { > public: > virtual ~AudioCaptureFactory() = default; >- virtual CaptureSourceOrError createAudioCaptureSource(const CaptureDevice&, String&&, const MediaConstraints*) = 0; >+ virtual CaptureSourceOrError createAudioCaptureSource(const CaptureDevice&, String&&, const MediaConstraints*, PageIdentifier) = 0; > virtual CaptureDeviceManager& audioCaptureDeviceManager() = 0; > virtual const Vector<CaptureDevice>& speakerDevices() const = 0; > virtual void computeSpeakerDevices(CompletionHandler<void()>&& callback) const { callback(); } >@@ -74,28 +58,20 @@ protected: > AudioCaptureFactory() = default; > }; > >-class VideoCaptureFactory >-#if PLATFORM(IOS_FAMILY) >- : public SingleSourceFactory >-#endif >-{ >+class VideoCaptureFactory { > public: > virtual ~VideoCaptureFactory() = default; >- virtual CaptureSourceOrError createVideoCaptureSource(const CaptureDevice&, String&&, const MediaConstraints*) = 0; >+ virtual CaptureSourceOrError createVideoCaptureSource(const CaptureDevice&, String&&, const MediaConstraints*, PageIdentifier) = 0; > virtual CaptureDeviceManager& videoCaptureDeviceManager() = 0; > > protected: > VideoCaptureFactory() = default; > }; > >-class DisplayCaptureFactory >-#if PLATFORM(IOS_FAMILY) >- : public SingleSourceFactory >-#endif >-{ >+class DisplayCaptureFactory { > public: > virtual ~DisplayCaptureFactory() = default; >- virtual CaptureSourceOrError createDisplayCaptureSource(const CaptureDevice&, String&&, const MediaConstraints*) = 0; >+ virtual CaptureSourceOrError createDisplayCaptureSource(const CaptureDevice&, String&&, const MediaConstraints*, PageIdentifier) = 0; > virtual DisplayCaptureManager& displayCaptureDeviceManager() = 0; > > protected: >diff --git a/Source/WebCore/platform/mediastream/RealtimeVideoCaptureSource.cpp b/Source/WebCore/platform/mediastream/RealtimeVideoCaptureSource.cpp >index 82de258bbc7b1a186dcb570dca0440d8ab4009e1..30b0a258d3ad009c83773ad69d6b1cc636babc5b 100644 >--- a/Source/WebCore/platform/mediastream/RealtimeVideoCaptureSource.cpp >+++ b/Source/WebCore/platform/mediastream/RealtimeVideoCaptureSource.cpp >@@ -35,25 +35,13 @@ > > namespace WebCore { > >-RealtimeVideoCaptureSource::RealtimeVideoCaptureSource(String&& name, String&& id, String&& hashSalt) >- : RealtimeMediaSource(Type::Video, WTFMove(name), WTFMove(id), WTFMove(hashSalt)) >+RealtimeVideoCaptureSource::RealtimeVideoCaptureSource(String&& name, String&& id, String&& hashSalt, PageIdentifier pageIdentifier) >+ : RealtimeMediaSource(Type::Video, WTFMove(name), WTFMove(id), WTFMove(hashSalt), pageIdentifier) > { > } > > RealtimeVideoCaptureSource::~RealtimeVideoCaptureSource() > { >-#if PLATFORM(IOS_FAMILY) >- RealtimeMediaSourceCenter::singleton().videoCaptureFactory().unsetActiveSource(*this); >-#endif >-} >- >-void RealtimeVideoCaptureSource::prepareToProduceData() >-{ >- ASSERT(frameRate()); >- >-#if PLATFORM(IOS_FAMILY) >- RealtimeMediaSourceCenter::singleton().videoCaptureFactory().setActiveSource(*this); >-#endif > } > > const Vector<Ref<VideoPreset>>& RealtimeVideoCaptureSource::presets() >@@ -369,6 +357,7 @@ void RealtimeVideoCaptureSource::setSizeAndFrameRate(std::optional<int> width, s > return; > } > >+ m_currentPreset = match->encodingPreset; > setFrameRateWithPreset(match->requestedFrameRate, match->encodingPreset); > > if (!match->requestedSize.isEmpty()) >@@ -412,6 +401,7 @@ void RealtimeVideoCaptureSource::clientUpdatedSizeAndFrameRate(std::optional<int > if (!match) > return; > >+ m_currentPreset = match->encodingPreset; > setFrameRateWithPreset(match->requestedFrameRate, match->encodingPreset); > setSize(match->encodingPreset->size); > setFrameRate(match->requestedFrameRate); >diff --git a/Source/WebCore/platform/mediastream/RealtimeVideoCaptureSource.h b/Source/WebCore/platform/mediastream/RealtimeVideoCaptureSource.h >index 70172aae56cd4fa5f5edff7fd448b5f395cd18ab..dc1c3d5eaa75114e2abf108a1588fca49aef9fdb 100644 >--- a/Source/WebCore/platform/mediastream/RealtimeVideoCaptureSource.h >+++ b/Source/WebCore/platform/mediastream/RealtimeVideoCaptureSource.h >@@ -53,10 +53,11 @@ public: > > void ensureIntrinsicSizeMaintainsAspectRatio(); > >+ const VideoPreset* currentPreset() const { return m_currentPreset.get(); } >+ > protected: >- RealtimeVideoCaptureSource(String&& name, String&& id, String&& hashSalt); >+ RealtimeVideoCaptureSource(String&& name, String&& id, String&& hashSalt, PageIdentifier); > >- void prepareToProduceData(); > void setSizeAndFrameRate(std::optional<int> width, std::optional<int> height, std::optional<double>) override; > > virtual bool prefersPreset(VideoPreset&) { return true; } >@@ -90,6 +91,7 @@ private: > const char* logClassName() const override { return "RealtimeVideoCaptureSource"; } > #endif > >+ RefPtr<VideoPreset> m_currentPreset; > Vector<Ref<VideoPreset>> m_presets; > Deque<double> m_observedFrameTimeStamps; > double m_observedFrameRate { 0 }; >diff --git a/Source/WebCore/platform/mediastream/RealtimeVideoSource.cpp b/Source/WebCore/platform/mediastream/RealtimeVideoSource.cpp >index ce6e003597a8b5dbd9d1aa85c45562b22a93f43c..1d4f99bf2b13aa66affc248bece5982eb30d4670 100644 >--- a/Source/WebCore/platform/mediastream/RealtimeVideoSource.cpp >+++ b/Source/WebCore/platform/mediastream/RealtimeVideoSource.cpp >@@ -36,7 +36,7 @@ > namespace WebCore { > > RealtimeVideoSource::RealtimeVideoSource(Ref<RealtimeVideoCaptureSource>&& source, bool shouldUseIOSurface) >- : RealtimeMediaSource(Type::Video, String { source->name() }, String { source->persistentID() }, String { source->deviceIDHashSalt() }) >+ : RealtimeMediaSource(Type::Video, String { source->name() }, String { source->persistentID() }, String { source->deviceIDHashSalt() }, source->pageIdentifier()) > , m_source(WTFMove(source)) > #if PLATFORM(COCOA) > , m_shouldUseIOSurface(shouldUseIOSurface) >@@ -95,12 +95,15 @@ void RealtimeVideoSource::setSizeAndFrameRate(std::optional<int> width, std::opt > ASSERT(sourceSize.height()); > ASSERT(sourceSize.width()); > >+ auto* currentPreset = m_source->currentPreset(); >+ auto intrinsicSize = currentPreset ? currentPreset->size : sourceSize; >+ > if (!width) >- width = sourceSize.width() * height.value() / sourceSize.height(); >+ width = intrinsicSize.width() * height.value() / intrinsicSize.height(); > m_currentSettings.setWidth(*width); > > if (!height) >- height = sourceSize.height() * width.value() / sourceSize.width(); >+ height = intrinsicSize.height() * width.value() / intrinsicSize.width(); > m_currentSettings.setHeight(*height); > > if (frameRate) >diff --git a/Source/WebCore/platform/mediastream/cocoa/DisplayCaptureSourceCocoa.cpp b/Source/WebCore/platform/mediastream/cocoa/DisplayCaptureSourceCocoa.cpp >index 554f8dd27a4be5ded6e5e16a52bcd4ad906f42b7..166a5307732b115e45d62070efa00a013828bfa8 100644 >--- a/Source/WebCore/platform/mediastream/cocoa/DisplayCaptureSourceCocoa.cpp >+++ b/Source/WebCore/platform/mediastream/cocoa/DisplayCaptureSourceCocoa.cpp >@@ -83,23 +83,23 @@ static RealtimeMediaSource::Type sourceTypeForDevice(CaptureDevice::DeviceType t > return RealtimeMediaSource::Type::None; > } > >-CaptureSourceOrError DisplayCaptureSourceCocoa::create(const CaptureDevice& device, String&& hashSalt, const MediaConstraints* constraints) >+CaptureSourceOrError DisplayCaptureSourceCocoa::create(const CaptureDevice& device, String&& hashSalt, const MediaConstraints* constraints, PageIdentifier pageIdentifier) > { > switch (device.type()) { > case CaptureDevice::DeviceType::Screen: > #if PLATFORM(IOS) >- return create(ReplayKitCaptureSource::create(device.persistentId()), device, WTFMove(hashSalt), constraints); >+ return create(ReplayKitCaptureSource::create(device.persistentId()), device, WTFMove(hashSalt), constraints, pageIdentifier); > #else > #if HAVE(SCREEN_CAPTURE_KIT) > if (ScreenCaptureKitCaptureSource::isAvailable()) >- return create(ScreenCaptureKitCaptureSource::create(device, constraints), device, WTFMove(hashSalt), constraints); >+ return create(ScreenCaptureKitCaptureSource::create(device, constraints), device, WTFMove(hashSalt), constraints, pageIdentifier); > #endif >- return create(CGDisplayStreamScreenCaptureSource::create(device.persistentId()), device, WTFMove(hashSalt), constraints); >+ return create(CGDisplayStreamScreenCaptureSource::create(device.persistentId()), device, WTFMove(hashSalt), constraints, pageIdentifier); > #endif > case CaptureDevice::DeviceType::Window: > #if HAVE(SCREEN_CAPTURE_KIT) > if (ScreenCaptureKitCaptureSource::isAvailable()) >- return create(ScreenCaptureKitCaptureSource::create(device, constraints), device, WTFMove(hashSalt), constraints); >+ return create(ScreenCaptureKitCaptureSource::create(device, constraints), device, WTFMove(hashSalt), constraints, pageIdentifier); > #endif > break; > case CaptureDevice::DeviceType::SystemAudio: >@@ -114,12 +114,12 @@ CaptureSourceOrError DisplayCaptureSourceCocoa::create(const CaptureDevice& devi > return { }; > } > >-CaptureSourceOrError DisplayCaptureSourceCocoa::create(Expected<UniqueRef<Capturer>, String>&& capturer, const CaptureDevice& device, String&& hashSalt, const MediaConstraints* constraints) >+CaptureSourceOrError DisplayCaptureSourceCocoa::create(Expected<UniqueRef<Capturer>, String>&& capturer, const CaptureDevice& device, String&& hashSalt, const MediaConstraints* constraints, PageIdentifier pageIdentifier) > { > if (!capturer.has_value()) > return CaptureSourceOrError { WTFMove(capturer.error()) }; > >- auto source = adoptRef(*new DisplayCaptureSourceCocoa(WTFMove(capturer.value()), String { device.label() }, String { device.persistentId() }, WTFMove(hashSalt))); >+ auto source = adoptRef(*new DisplayCaptureSourceCocoa(WTFMove(capturer.value()), String { device.label() }, String { device.persistentId() }, WTFMove(hashSalt), pageIdentifier)); > if (constraints) { > auto result = source->applyConstraints(*constraints); > if (result) >@@ -129,8 +129,8 @@ CaptureSourceOrError DisplayCaptureSourceCocoa::create(Expected<UniqueRef<Captur > return CaptureSourceOrError(WTFMove(source)); > } > >-DisplayCaptureSourceCocoa::DisplayCaptureSourceCocoa(UniqueRef<Capturer>&& capturer, String&& name, String&& deviceID, String&& hashSalt) >- : RealtimeMediaSource(sourceTypeForDevice(capturer->deviceType()), WTFMove(name), WTFMove(deviceID), WTFMove(hashSalt)) >+DisplayCaptureSourceCocoa::DisplayCaptureSourceCocoa(UniqueRef<Capturer>&& capturer, String&& name, String&& deviceID, String&& hashSalt, PageIdentifier pageIdentifier) >+ : RealtimeMediaSource(sourceTypeForDevice(capturer->deviceType()), WTFMove(name), WTFMove(deviceID), WTFMove(hashSalt), pageIdentifier) > , m_capturer(WTFMove(capturer)) > , m_timer(RunLoop::current(), this, &DisplayCaptureSourceCocoa::emitFrame) > { >diff --git a/Source/WebCore/platform/mediastream/cocoa/DisplayCaptureSourceCocoa.h b/Source/WebCore/platform/mediastream/cocoa/DisplayCaptureSourceCocoa.h >index 045c8cc435fcb29c5ded0b2f1aeca5242c5ae8c0..b9eb085d474934c5e051a75ab1dd03cc54e7f852 100644 >--- a/Source/WebCore/platform/mediastream/cocoa/DisplayCaptureSourceCocoa.h >+++ b/Source/WebCore/platform/mediastream/cocoa/DisplayCaptureSourceCocoa.h >@@ -112,14 +112,14 @@ public: > const void* m_logIdentifier; > }; > >- static CaptureSourceOrError create(const CaptureDevice&, String&&, const MediaConstraints*); >- static CaptureSourceOrError create(Expected<UniqueRef<Capturer>, String>&&, const CaptureDevice&, String&&, const MediaConstraints*); >+ static CaptureSourceOrError create(const CaptureDevice&, String&&, const MediaConstraints*, PageIdentifier); >+ static CaptureSourceOrError create(Expected<UniqueRef<Capturer>, String>&&, const CaptureDevice&, String&&, const MediaConstraints*, PageIdentifier); > > Seconds elapsedTime(); > void updateFrameSize(); > > private: >- DisplayCaptureSourceCocoa(UniqueRef<Capturer>&&, String&& name, String&& deviceID, String&& hashSalt); >+ DisplayCaptureSourceCocoa(UniqueRef<Capturer>&&, String&& name, String&& deviceID, String&& hashSalt, PageIdentifier); > virtual ~DisplayCaptureSourceCocoa(); > > // RealtimeMediaSource >diff --git a/Source/WebCore/platform/mediastream/gstreamer/GStreamerAudioCaptureSource.cpp b/Source/WebCore/platform/mediastream/gstreamer/GStreamerAudioCaptureSource.cpp >index 486b0e4486a3c64e3ac13f357bd014de03180df6..73ecd2403bc0f48bda19d51990147a3573b7ea32 100644 >--- a/Source/WebCore/platform/mediastream/gstreamer/GStreamerAudioCaptureSource.cpp >+++ b/Source/WebCore/platform/mediastream/gstreamer/GStreamerAudioCaptureSource.cpp >@@ -56,7 +56,7 @@ static void initializeDebugCategory() > > class GStreamerAudioCaptureSourceFactory : public AudioCaptureFactory { > public: >- CaptureSourceOrError createAudioCaptureSource(const CaptureDevice& device, String&& hashSalt, const MediaConstraints* constraints) final >+ CaptureSourceOrError createAudioCaptureSource(const CaptureDevice& device, String&& hashSalt, const MediaConstraints* constraints, PageIdentifier) final > { > return GStreamerAudioCaptureSource::create(String { device.persistentId() }, WTFMove(hashSalt), constraints); > } >diff --git a/Source/WebCore/platform/mediastream/gstreamer/GStreamerVideoCaptureSource.cpp b/Source/WebCore/platform/mediastream/gstreamer/GStreamerVideoCaptureSource.cpp >index e13d53b2b24dce9d5026da2372833e4e4213b1e0..cc81e3b01795f50419cc2a4efee8751f149b4c48 100644 >--- a/Source/WebCore/platform/mediastream/gstreamer/GStreamerVideoCaptureSource.cpp >+++ b/Source/WebCore/platform/mediastream/gstreamer/GStreamerVideoCaptureSource.cpp >@@ -62,7 +62,7 @@ public: > > class GStreamerVideoCaptureSourceFactory final : public VideoCaptureFactory { > public: >- CaptureSourceOrError createVideoCaptureSource(const CaptureDevice& device, String&& hashSalt, const MediaConstraints* constraints) final >+ CaptureSourceOrError createVideoCaptureSource(const CaptureDevice& device, String&& hashSalt, const MediaConstraints* constraints, PageIdentifier) final > { > return GStreamerVideoCaptureSource::create(String { device.persistentId() }, WTFMove(hashSalt), constraints); > } >@@ -72,7 +72,7 @@ private: > > class GStreamerDisplayCaptureSourceFactory final : public DisplayCaptureFactory { > public: >- CaptureSourceOrError createDisplayCaptureSource(const CaptureDevice& device, String&& hashSalt, const MediaConstraints* constraints) final >+ CaptureSourceOrError createDisplayCaptureSource(const CaptureDevice& device, String&& hashSalt, const MediaConstraints* constraints, PageIdentifier) final > { > auto& manager = GStreamerDisplayCaptureDeviceManager::singleton(); > return manager.createDisplayCaptureSource(device, WTFMove(hashSalt), constraints); >diff --git a/Source/WebCore/platform/mediastream/ios/CoreAudioCaptureSourceIOS.h b/Source/WebCore/platform/mediastream/ios/CoreAudioCaptureSourceIOS.h >index 66485e32b974b26b6db70ef31f415450c0c631ff..b105b3e10c809998ca11595680a4ae86637b3bbb 100644 >--- a/Source/WebCore/platform/mediastream/ios/CoreAudioCaptureSourceIOS.h >+++ b/Source/WebCore/platform/mediastream/ios/CoreAudioCaptureSourceIOS.h >@@ -45,7 +45,7 @@ private: > void beginAudioSessionInterruption() { beginInterruption(); } > void endAudioSessionInterruption(AudioSession::MayResume) { endInterruption(); } > >- CaptureSourceOrError createAudioCaptureSource(const CaptureDevice&, String&&, const MediaConstraints*) final; >+ CaptureSourceOrError createAudioCaptureSource(const CaptureDevice&, String&&, const MediaConstraints*, PageIdentifier) final; > void addExtensiveObserver(ExtensiveObserver&) final; > void removeExtensiveObserver(ExtensiveObserver&) final; > >diff --git a/Source/WebCore/platform/mediastream/ios/CoreAudioCaptureSourceIOS.mm b/Source/WebCore/platform/mediastream/ios/CoreAudioCaptureSourceIOS.mm >index 670592f35167f6b061996b01674eb9b548443a52..bb329fe0e1d857efb617174bc499136bac83e3cd 100644 >--- a/Source/WebCore/platform/mediastream/ios/CoreAudioCaptureSourceIOS.mm >+++ b/Source/WebCore/platform/mediastream/ios/CoreAudioCaptureSourceIOS.mm >@@ -116,13 +116,13 @@ void CoreAudioCaptureSourceFactoryIOS::removeExtensiveObserver(ExtensiveObserver > AVAudioSessionCaptureDeviceManager::singleton().disableAllDevicesQuery(); > } > >-CaptureSourceOrError CoreAudioCaptureSourceFactoryIOS::createAudioCaptureSource(const CaptureDevice& device, String&& hashSalt, const MediaConstraints* constraints) >+CaptureSourceOrError CoreAudioCaptureSourceFactoryIOS::createAudioCaptureSource(const CaptureDevice& device, String&& hashSalt, const MediaConstraints* constraints, PageIdentifier pageIdentifier) > { > // We enable exhaustive query to be sure to start capture with the right device. > // FIXME: We should stop the auxiliary session after starting capture. > if (m_observers.computesEmpty()) > AVAudioSessionCaptureDeviceManager::singleton().enableAllDevicesQuery(); >- return CoreAudioCaptureSource::create(String { device.persistentId() }, WTFMove(hashSalt), constraints); >+ return CoreAudioCaptureSource::create(String { device.persistentId() }, WTFMove(hashSalt), constraints, pageIdentifier); > } > > } >diff --git a/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.h b/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.h >index 8c4138e7338cefc691734207443aa49e562f9fef..4bafb58928ace01f3bae593e809cb4bb8eb1bce9 100644 >--- a/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.h >+++ b/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.h >@@ -54,7 +54,7 @@ class ImageTransferSessionVT; > > class AVVideoCaptureSource : public RealtimeVideoCaptureSource, private OrientationNotifier::Observer { > public: >- static CaptureSourceOrError create(String&& id, String&& hashSalt, const MediaConstraints*); >+ static CaptureSourceOrError create(String&& id, String&& hashSalt, const MediaConstraints*, PageIdentifier); > > WEBCORE_EXPORT static VideoCaptureFactory& factory(); > >@@ -70,7 +70,7 @@ public: > void captureDeviceSuspendedDidChange(); > > private: >- AVVideoCaptureSource(AVCaptureDevice*, String&& id, String&& hashSalt); >+ AVVideoCaptureSource(AVCaptureDevice*, String&& id, String&& hashSalt, PageIdentifier); > virtual ~AVVideoCaptureSource(); > > void clearSession(); >diff --git a/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm b/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm >index 6e743e5a945193077f2e60e2e1bd34cacffb3592..5a0ea778d528d3b14b9f7f83f87704b87845c73c 100644 >--- a/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm >+++ b/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm >@@ -108,13 +108,13 @@ public: > RetainPtr<AVCaptureDeviceFormat> format; > }; > >-CaptureSourceOrError AVVideoCaptureSource::create(String&& id, String&& hashSalt, const MediaConstraints* constraints) >+CaptureSourceOrError AVVideoCaptureSource::create(String&& id, String&& hashSalt, const MediaConstraints* constraints, PageIdentifier pageIdentifier) > { > AVCaptureDevice *device = [PAL::getAVCaptureDeviceClass() deviceWithUniqueID:id]; > if (!device) > return { "No AVVideoCaptureSource device"_s }; > >- auto source = adoptRef(*new AVVideoCaptureSource(device, WTFMove(id), WTFMove(hashSalt))); >+ auto source = adoptRef(*new AVVideoCaptureSource(device, WTFMove(id), WTFMove(hashSalt), pageIdentifier)); > if (constraints) { > auto result = source->applyConstraints(*constraints); > if (result) >@@ -124,8 +124,8 @@ CaptureSourceOrError AVVideoCaptureSource::create(String&& id, String&& hashSalt > return CaptureSourceOrError(RealtimeVideoSource::create(WTFMove(source))); > } > >-AVVideoCaptureSource::AVVideoCaptureSource(AVCaptureDevice* device, String&& id, String&& hashSalt) >- : RealtimeVideoCaptureSource(device.localizedName, WTFMove(id), WTFMove(hashSalt)) >+AVVideoCaptureSource::AVVideoCaptureSource(AVCaptureDevice* device, String&& id, String&& hashSalt, PageIdentifier pageIdentifier) >+ : RealtimeVideoCaptureSource(device.localizedName, WTFMove(id), WTFMove(hashSalt), pageIdentifier) > , m_objcObserver(adoptNS([[WebCoreAVVideoCaptureSourceObserver alloc] initWithCallback:this])) > , m_device(device) > , m_verifyCapturingTimer(*this, &AVVideoCaptureSource::verifyIsCapturing) >@@ -137,9 +137,6 @@ AVVideoCaptureSource::~AVVideoCaptureSource() > { > ALWAYS_LOG_IF(loggerPtr(), LOGIDENTIFIER); > >-#if PLATFORM(IOS_FAMILY) >- RealtimeMediaSourceCenter::singleton().videoCaptureFactory().unsetActiveSource(*this); >-#endif > [m_objcObserver disconnect]; > [m_device removeObserver:m_objcObserver.get() forKeyPath:@"suspended"]; > >@@ -469,10 +466,6 @@ bool AVVideoCaptureSource::setupCaptureSession() > { > ALWAYS_LOG_IF(loggerPtr(), LOGIDENTIFIER); > >-#if PLATFORM(IOS_FAMILY) >- RealtimeMediaSourceCenter::singleton().videoCaptureFactory().setActiveSource(*this); >-#endif >- > NSError *error = nil; > RetainPtr<AVCaptureDeviceInput> videoIn = adoptNS([PAL::allocAVCaptureDeviceInputInstance() initWithDevice:device() error:&error]); > if (error) { >diff --git a/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp b/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp >index 9a0b29edb1d1781565450f58de909f68c873ea03..d24d4b31fc54210ed8d5860ae677836cc540a9db 100644 >--- a/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp >+++ b/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp >@@ -668,27 +668,27 @@ static CaptureSourceOrError initializeCoreAudioCaptureSource(Ref<CoreAudioCaptur > return CaptureSourceOrError(WTFMove(source)); > } > >-CaptureSourceOrError CoreAudioCaptureSource::create(String&& deviceID, String&& hashSalt, const MediaConstraints* constraints) >+CaptureSourceOrError CoreAudioCaptureSource::create(String&& deviceID, String&& hashSalt, const MediaConstraints* constraints, PageIdentifier pageIdentifier) > { > #if PLATFORM(MAC) > auto device = CoreAudioCaptureDeviceManager::singleton().coreAudioDeviceWithUID(deviceID); > if (!device) > return { "No CoreAudioCaptureSource device"_s }; > >- auto source = adoptRef(*new CoreAudioCaptureSource(WTFMove(deviceID), String { device->label() }, WTFMove(hashSalt), device->deviceID())); >+ auto source = adoptRef(*new CoreAudioCaptureSource(WTFMove(deviceID), String { device->label() }, WTFMove(hashSalt), device->deviceID(), nullptr, pageIdentifier)); > #elif PLATFORM(IOS_FAMILY) > auto device = AVAudioSessionCaptureDeviceManager::singleton().audioSessionDeviceWithUID(WTFMove(deviceID)); > if (!device) > return { "No AVAudioSessionCaptureDevice device"_s }; > >- auto source = adoptRef(*new CoreAudioCaptureSource(WTFMove(deviceID), String { device->label() }, WTFMove(hashSalt), 0)); >+ auto source = adoptRef(*new CoreAudioCaptureSource(WTFMove(deviceID), String { device->label() }, WTFMove(hashSalt), 0, nullptr, pageIdentifier)); > #endif > return initializeCoreAudioCaptureSource(WTFMove(source), constraints); > } > >-CaptureSourceOrError CoreAudioCaptureSource::createForTesting(String&& deviceID, String&& label, String&& hashSalt, const MediaConstraints* constraints, BaseAudioSharedUnit& overrideUnit) >+CaptureSourceOrError CoreAudioCaptureSource::createForTesting(String&& deviceID, String&& label, String&& hashSalt, const MediaConstraints* constraints, BaseAudioSharedUnit& overrideUnit, PageIdentifier pageIdentifier) > { >- auto source = adoptRef(*new CoreAudioCaptureSource(WTFMove(deviceID), WTFMove(label), WTFMove(hashSalt), 0, &overrideUnit)); >+ auto source = adoptRef(*new CoreAudioCaptureSource(WTFMove(deviceID), WTFMove(label), WTFMove(hashSalt), 0, &overrideUnit, pageIdentifier)); > return initializeCoreAudioCaptureSource(WTFMove(source), constraints); > } > >@@ -780,8 +780,8 @@ void CoreAudioCaptureSourceFactory::whenAudioCaptureUnitIsNotRunning(Function<vo > return CoreAudioSharedUnit::unit().whenAudioCaptureUnitIsNotRunning(WTFMove(callback)); > } > >-CoreAudioCaptureSource::CoreAudioCaptureSource(String&& deviceID, String&& label, String&& hashSalt, uint32_t captureDeviceID, BaseAudioSharedUnit* overrideUnit) >- : RealtimeMediaSource(RealtimeMediaSource::Type::Audio, WTFMove(label), WTFMove(deviceID), WTFMove(hashSalt)) >+CoreAudioCaptureSource::CoreAudioCaptureSource(String&& deviceID, String&& label, String&& hashSalt, uint32_t captureDeviceID, BaseAudioSharedUnit* overrideUnit, PageIdentifier pageIdentifier) >+ : RealtimeMediaSource(RealtimeMediaSource::Type::Audio, WTFMove(label), WTFMove(deviceID), WTFMove(hashSalt), pageIdentifier) > , m_captureDeviceID(captureDeviceID) > , m_overrideUnit(overrideUnit) > { >@@ -821,19 +821,11 @@ void CoreAudioCaptureSource::initializeToStartProducingData() > > CoreAudioCaptureSource::~CoreAudioCaptureSource() > { >-#if PLATFORM(IOS_FAMILY) >- CoreAudioCaptureSourceFactory::singleton().unsetActiveSource(*this); >-#endif >- > unit().removeClient(*this); > } > > void CoreAudioCaptureSource::startProducingData() > { >-#if PLATFORM(IOS_FAMILY) >- CoreAudioCaptureSourceFactory::singleton().setActiveSource(*this); >-#endif >- > initializeToStartProducingData(); > unit().startProducingData(); > } >diff --git a/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.h b/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.h >index 33036e996f673e52702385b41e0a93f180351f99..0ec672bf9f1c3605624970c241f6a0a159352d97 100644 >--- a/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.h >+++ b/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.h >@@ -51,15 +51,15 @@ class WebAudioSourceProviderAVFObjC; > > class CoreAudioCaptureSource : public RealtimeMediaSource { > public: >- static CaptureSourceOrError create(String&& deviceID, String&& hashSalt, const MediaConstraints*); >- static CaptureSourceOrError createForTesting(String&& deviceID, String&& label, String&& hashSalt, const MediaConstraints*, BaseAudioSharedUnit& overrideUnit); >+ static CaptureSourceOrError create(String&& deviceID, String&& hashSalt, const MediaConstraints*, PageIdentifier); >+ static CaptureSourceOrError createForTesting(String&& deviceID, String&& label, String&& hashSalt, const MediaConstraints*, BaseAudioSharedUnit& overrideUnit, PageIdentifier); > > WEBCORE_EXPORT static AudioCaptureFactory& factory(); > > CMClockRef timebaseClock(); > > protected: >- CoreAudioCaptureSource(String&& deviceID, String&& label, String&& hashSalt, uint32_t persistentID, BaseAudioSharedUnit* = nullptr); >+ CoreAudioCaptureSource(String&& deviceID, String&& label, String&& hashSalt, uint32_t persistentID, BaseAudioSharedUnit*, PageIdentifier); > virtual ~CoreAudioCaptureSource(); > BaseAudioSharedUnit& unit(); > const BaseAudioSharedUnit& unit() const; >@@ -129,14 +129,14 @@ public: > WEBCORE_EXPORT void whenAudioCaptureUnitIsNotRunning(Function<void()>&&); > > private: >- CaptureSourceOrError createAudioCaptureSource(const CaptureDevice&, String&&, const MediaConstraints*) override; >+ CaptureSourceOrError createAudioCaptureSource(const CaptureDevice&, String&&, const MediaConstraints*, PageIdentifier) override; > CaptureDeviceManager& audioCaptureDeviceManager() final; > const Vector<CaptureDevice>& speakerDevices() const final; > }; > >-inline CaptureSourceOrError CoreAudioCaptureSourceFactory::createAudioCaptureSource(const CaptureDevice& device, String&& hashSalt, const MediaConstraints* constraints) >+inline CaptureSourceOrError CoreAudioCaptureSourceFactory::createAudioCaptureSource(const CaptureDevice& device, String&& hashSalt, const MediaConstraints* constraints, PageIdentifier pageIdentifier) > { >- return CoreAudioCaptureSource::create(String { device.persistentId() }, WTFMove(hashSalt), constraints); >+ return CoreAudioCaptureSource::create(String { device.persistentId() }, WTFMove(hashSalt), constraints, pageIdentifier); > } > > } // namespace WebCore >diff --git a/Source/WebCore/platform/mediastream/mac/MockAudioSharedUnit.mm b/Source/WebCore/platform/mediastream/mac/MockAudioSharedUnit.mm >index 0dd3d71cae7a63b637208f2838220e659e4213ce..34227423d89b0a049de69ace35f8f38f3d30c348 100644 >--- a/Source/WebCore/platform/mediastream/mac/MockAudioSharedUnit.mm >+++ b/Source/WebCore/platform/mediastream/mac/MockAudioSharedUnit.mm >@@ -83,7 +83,7 @@ static void addHum(float amplitude, float frequency, float sampleRate, uint64_t > } > } > >-CaptureSourceOrError MockRealtimeAudioSource::create(String&& deviceID, String&& name, String&& hashSalt, const MediaConstraints* constraints) >+CaptureSourceOrError MockRealtimeAudioSource::create(String&& deviceID, String&& name, String&& hashSalt, const MediaConstraints* constraints, PageIdentifier pageIdentifier) > { > auto device = MockRealtimeMediaSourceCenter::mockDeviceWithPersistentID(deviceID); > ASSERT(device); >@@ -91,7 +91,7 @@ CaptureSourceOrError MockRealtimeAudioSource::create(String&& deviceID, String&& > return { "No mock microphone device"_s }; > > MockAudioSharedUnit::singleton().setDeviceID(deviceID); >- return CoreAudioCaptureSource::createForTesting(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt), constraints, MockAudioSharedUnit::singleton()); >+ return CoreAudioCaptureSource::createForTesting(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt), constraints, MockAudioSharedUnit::singleton(), pageIdentifier); > } > > MockAudioSharedUnit& MockAudioSharedUnit::singleton() >diff --git a/Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.h b/Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.h >index 95cf35cd4eb1318d8683273a5d096c73644608b0..4829579d2fa1653cec00127c03f24ca30976cd33 100644 >--- a/Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.h >+++ b/Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.h >@@ -47,13 +47,13 @@ class ImageTransferSessionVT; > > class MockRealtimeVideoSourceMac final : public MockRealtimeVideoSource { > public: >- static Ref<MockRealtimeVideoSource> createForMockDisplayCapturer(String&& deviceID, String&& name, String&& hashSalt); >+ static Ref<MockRealtimeVideoSource> createForMockDisplayCapturer(String&& deviceID, String&& name, String&& hashSalt, PageIdentifier); > > ~MockRealtimeVideoSourceMac() = default; > > private: > friend class MockRealtimeVideoSource; >- MockRealtimeVideoSourceMac(String&& deviceID, String&& name, String&& hashSalt); >+ MockRealtimeVideoSourceMac(String&& deviceID, String&& name, String&& hashSalt, PageIdentifier); > > PlatformLayer* platformLayer() const; > void updateSampleBuffer() final; >diff --git a/Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.mm b/Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.mm >index fd194e619a44b8811dcb17e004671f44535e7a97..9e25f6d2d4313f90de9c0fb1d60dd88b09785d6e 100644 >--- a/Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.mm >+++ b/Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.mm >@@ -52,7 +52,7 @@ > > namespace WebCore { > >-CaptureSourceOrError MockRealtimeVideoSource::create(String&& deviceID, String&& name, String&& hashSalt, const MediaConstraints* constraints) >+CaptureSourceOrError MockRealtimeVideoSource::create(String&& deviceID, String&& name, String&& hashSalt, const MediaConstraints* constraints, PageIdentifier pageIdentifier) > { > #ifndef NDEBUG > auto device = MockRealtimeMediaSourceCenter::mockDeviceWithPersistentID(deviceID); >@@ -61,7 +61,7 @@ CaptureSourceOrError MockRealtimeVideoSource::create(String&& deviceID, String&& > return { "No mock camera device"_s }; > #endif > >- auto source = adoptRef(*new MockRealtimeVideoSourceMac(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt))); >+ auto source = adoptRef(*new MockRealtimeVideoSourceMac(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt), pageIdentifier)); > if (constraints) { > if (auto error = source->applyConstraints(*constraints)) > return WTFMove(error->message); >@@ -70,13 +70,13 @@ CaptureSourceOrError MockRealtimeVideoSource::create(String&& deviceID, String&& > return CaptureSourceOrError(RealtimeVideoSource::create(WTFMove(source))); > } > >-Ref<MockRealtimeVideoSource> MockRealtimeVideoSourceMac::createForMockDisplayCapturer(String&& deviceID, String&& name, String&& hashSalt) >+Ref<MockRealtimeVideoSource> MockRealtimeVideoSourceMac::createForMockDisplayCapturer(String&& deviceID, String&& name, String&& hashSalt, PageIdentifier pageIdentifier) > { >- return adoptRef(*new MockRealtimeVideoSourceMac(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt))); >+ return adoptRef(*new MockRealtimeVideoSourceMac(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt), pageIdentifier)); > } > >-MockRealtimeVideoSourceMac::MockRealtimeVideoSourceMac(String&& deviceID, String&& name, String&& hashSalt) >- : MockRealtimeVideoSource(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt)) >+MockRealtimeVideoSourceMac::MockRealtimeVideoSourceMac(String&& deviceID, String&& name, String&& hashSalt, PageIdentifier pageIdentifier) >+ : MockRealtimeVideoSource(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt), pageIdentifier) > , m_workQueue(WorkQueue::create("MockRealtimeVideoSource Render Queue", WorkQueue::QOS::UserInteractive)) > { > } >diff --git a/Source/WebCore/platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp b/Source/WebCore/platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp >index f367da1bd584fe459da2b75f2153d3adb59f965f..2d8f84d4a730ef01d907fa594f1224dbb6d8b9c6 100644 >--- a/Source/WebCore/platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp >+++ b/Source/WebCore/platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp >@@ -45,10 +45,10 @@ namespace WebCore { > > class VideoCaptureSourceFactoryMac final : public VideoCaptureFactory { > public: >- CaptureSourceOrError createVideoCaptureSource(const CaptureDevice& device, String&& hashSalt, const MediaConstraints* constraints) final >+ CaptureSourceOrError createVideoCaptureSource(const CaptureDevice& device, String&& hashSalt, const MediaConstraints* constraints, PageIdentifier pageIdentifier) final > { > ASSERT(device.type() == CaptureDevice::DeviceType::Camera); >- return AVVideoCaptureSource::create(String { device.persistentId() }, WTFMove(hashSalt), constraints); >+ return AVVideoCaptureSource::create(String { device.persistentId() }, WTFMove(hashSalt), constraints, pageIdentifier); > } > > private: >@@ -57,9 +57,9 @@ private: > > class DisplayCaptureSourceFactoryMac final : public DisplayCaptureFactory { > public: >- CaptureSourceOrError createDisplayCaptureSource(const CaptureDevice& device, String&& hashSalt, const MediaConstraints* constraints) final >+ CaptureSourceOrError createDisplayCaptureSource(const CaptureDevice& device, String&& hashSalt, const MediaConstraints* constraints, PageIdentifier pageIdentifier) final > { >- return DisplayCaptureSourceCocoa::create(device, WTFMove(hashSalt), constraints); >+ return DisplayCaptureSourceCocoa::create(device, WTFMove(hashSalt), constraints, pageIdentifier); > } > private: > DisplayCaptureManager& displayCaptureDeviceManager() { return DisplayCaptureManagerCocoa::singleton(); } >diff --git a/Source/WebCore/platform/mock/MockRealtimeAudioSource.cpp b/Source/WebCore/platform/mock/MockRealtimeAudioSource.cpp >index d0894d5d4fe825f8b06d6c928aaf0986377cc4b2..9e88ab1e59e7a72b78c755d82478babf9964ce15 100644 >--- a/Source/WebCore/platform/mock/MockRealtimeAudioSource.cpp >+++ b/Source/WebCore/platform/mock/MockRealtimeAudioSource.cpp >@@ -45,7 +45,7 @@ > namespace WebCore { > > #if !PLATFORM(MAC) && !PLATFORM(IOS_FAMILY) && !USE(GSTREAMER) >-CaptureSourceOrError MockRealtimeAudioSource::create(String&& deviceID, String&& name, String&& hashSalt, const MediaConstraints* constraints) >+CaptureSourceOrError MockRealtimeAudioSource::create(String&& deviceID, String&& name, String&& hashSalt, const MediaConstraints* constraints, PageIdentifier) > { > #ifndef NDEBUG > auto device = MockRealtimeMediaSourceCenter::mockDeviceWithPersistentID(deviceID); >@@ -62,8 +62,8 @@ CaptureSourceOrError MockRealtimeAudioSource::create(String&& deviceID, String&& > } > #endif > >-MockRealtimeAudioSource::MockRealtimeAudioSource(String&& deviceID, String&& name, String&& hashSalt) >- : RealtimeMediaSource(RealtimeMediaSource::Type::Audio, WTFMove(name), WTFMove(deviceID), WTFMove(hashSalt)) >+MockRealtimeAudioSource::MockRealtimeAudioSource(String&& deviceID, String&& name, String&& hashSalt, PageIdentifier pageIdentifier) >+ : RealtimeMediaSource(RealtimeMediaSource::Type::Audio, WTFMove(name), WTFMove(deviceID), WTFMove(hashSalt), pageIdentifier) > , m_workQueue(WorkQueue::create("MockRealtimeAudioSource Render Queue")) > , m_timer(RunLoop::current(), this, &MockRealtimeAudioSource::tick) > { >@@ -77,9 +77,6 @@ MockRealtimeAudioSource::MockRealtimeAudioSource(String&& deviceID, String&& nam > > MockRealtimeAudioSource::~MockRealtimeAudioSource() > { >-#if PLATFORM(IOS_FAMILY) >- RealtimeMediaSourceCenter::singleton().audioCaptureFactory().unsetActiveSource(*this); >-#endif > } > > const RealtimeMediaSourceSettings& MockRealtimeAudioSource::settings() >@@ -136,7 +133,6 @@ void MockRealtimeAudioSource::settingsDidChange(OptionSet<RealtimeMediaSourceSet > void MockRealtimeAudioSource::startProducingData() > { > #if PLATFORM(IOS_FAMILY) >- RealtimeMediaSourceCenter::singleton().audioCaptureFactory().setActiveSource(*this); > PlatformMediaSessionManager::sharedManager().sessionCanProduceAudioChanged(); > ASSERT(AudioSession::sharedSession().category() == AudioSession::CategoryType::PlayAndRecord); > #endif >diff --git a/Source/WebCore/platform/mock/MockRealtimeAudioSource.h b/Source/WebCore/platform/mock/MockRealtimeAudioSource.h >index f0dadf71d2d03535a682e50c79b94242d0868ff8..7a0f4d15b953f0a08e81fcc495df5e382f9a7e06 100644 >--- a/Source/WebCore/platform/mock/MockRealtimeAudioSource.h >+++ b/Source/WebCore/platform/mock/MockRealtimeAudioSource.h >@@ -42,13 +42,13 @@ namespace WebCore { > > class MockRealtimeAudioSource : public RealtimeMediaSource { > public: >- static CaptureSourceOrError create(String&& deviceID, String&& name, String&& hashSalt, const MediaConstraints*); >+ static CaptureSourceOrError create(String&& deviceID, String&& name, String&& hashSalt, const MediaConstraints*, PageIdentifier); > virtual ~MockRealtimeAudioSource(); > > WEBCORE_EXPORT void setChannelCount(unsigned); > > protected: >- MockRealtimeAudioSource(String&& deviceID, String&& name, String&& hashSalt); >+ MockRealtimeAudioSource(String&& deviceID, String&& name, String&& hashSalt, PageIdentifier); > > virtual void render(Seconds) = 0; > void settingsDidChange(OptionSet<RealtimeMediaSourceSettings::Flag>) override; >diff --git a/Source/WebCore/platform/mock/MockRealtimeMediaSourceCenter.cpp b/Source/WebCore/platform/mock/MockRealtimeMediaSourceCenter.cpp >index 092d2fe6119348f9865a88fb2791e3a2d714a401..6d12c6bf078da2f54ef467567a0fd355a069d172 100644 >--- a/Source/WebCore/platform/mock/MockRealtimeMediaSourceCenter.cpp >+++ b/Source/WebCore/platform/mock/MockRealtimeMediaSourceCenter.cpp >@@ -101,13 +101,13 @@ static inline Vector<MockMediaDevice> defaultDevices() > > class MockRealtimeVideoSourceFactory : public VideoCaptureFactory { > public: >- CaptureSourceOrError createVideoCaptureSource(const CaptureDevice& device, String&& hashSalt, const MediaConstraints* constraints) final >+ CaptureSourceOrError createVideoCaptureSource(const CaptureDevice& device, String&& hashSalt, const MediaConstraints* constraints, PageIdentifier pageIdentifier) final > { > ASSERT(device.type() == CaptureDevice::DeviceType::Camera); > if (!MockRealtimeMediaSourceCenter::captureDeviceWithPersistentID(CaptureDevice::DeviceType::Camera, device.persistentId())) > return { "Unable to find mock camera device with given persistentID"_s }; > >- return MockRealtimeVideoSource::create(String { device.persistentId() }, String { device.label() }, WTFMove(hashSalt), constraints); >+ return MockRealtimeVideoSource::create(String { device.persistentId() }, String { device.label() }, WTFMove(hashSalt), constraints, pageIdentifier); > } > > private: >@@ -117,7 +117,7 @@ private: > #if PLATFORM(MAC) > class MockDisplayCapturer final : public DisplayCaptureSourceCocoa::Capturer { > public: >- explicit MockDisplayCapturer(const CaptureDevice&); >+ MockDisplayCapturer(const CaptureDevice&, PageIdentifier); > > private: > bool start() final; >@@ -134,8 +134,8 @@ private: > RealtimeMediaSourceSettings m_settings; > }; > >-MockDisplayCapturer::MockDisplayCapturer(const CaptureDevice& device) >- : m_source(MockRealtimeVideoSourceMac::createForMockDisplayCapturer(String { device.persistentId() }, String { device.label() }, String { })) >+MockDisplayCapturer::MockDisplayCapturer(const CaptureDevice& device, PageIdentifier pageIdentifier) >+ : m_source(MockRealtimeVideoSourceMac::createForMockDisplayCapturer(String { device.persistentId() }, String { device.label() }, String { }, pageIdentifier)) > { > } > >@@ -177,7 +177,7 @@ IntSize MockDisplayCapturer::intrinsicSize() const > > class MockRealtimeDisplaySourceFactory : public DisplayCaptureFactory { > public: >- CaptureSourceOrError createDisplayCaptureSource(const CaptureDevice& device, String&& hashSalt, const MediaConstraints* constraints) final >+ CaptureSourceOrError createDisplayCaptureSource(const CaptureDevice& device, String&& hashSalt, const MediaConstraints* constraints, PageIdentifier pageIdentifier) final > { > if (!MockRealtimeMediaSourceCenter::captureDeviceWithPersistentID(device.type(), device.persistentId())) > return { "Unable to find mock display device with given persistentID"_s }; >@@ -186,11 +186,11 @@ public: > case CaptureDevice::DeviceType::Screen: > case CaptureDevice::DeviceType::Window: > #if PLATFORM(MAC) >- return DisplayCaptureSourceCocoa::create(UniqueRef<DisplayCaptureSourceCocoa::Capturer>(makeUniqueRef<MockDisplayCapturer>(device)), device, WTFMove(hashSalt), constraints); >+ return DisplayCaptureSourceCocoa::create(UniqueRef<DisplayCaptureSourceCocoa::Capturer>(makeUniqueRef<MockDisplayCapturer>(device, pageIdentifier)), device, WTFMove(hashSalt), constraints, pageIdentifier); > #elif USE(GSTREAMER) > return MockDisplayCaptureSourceGStreamer::create(device, WTFMove(hashSalt), constraints); > #else >- return MockRealtimeVideoSource::create(String { device.persistentId() }, String { device.label() }, WTFMove(hashSalt), constraints); >+ return MockRealtimeVideoSource::create(String { device.persistentId() }, String { device.label() }, WTFMove(hashSalt), constraints, pageIdentifier); > #endif > break; > case CaptureDevice::DeviceType::Microphone: >@@ -211,20 +211,15 @@ private: > > class MockRealtimeAudioSourceFactory final : public AudioCaptureFactory { > public: >- CaptureSourceOrError createAudioCaptureSource(const CaptureDevice& device, String&& hashSalt, const MediaConstraints* constraints) final >+ CaptureSourceOrError createAudioCaptureSource(const CaptureDevice& device, String&& hashSalt, const MediaConstraints* constraints, PageIdentifier pageIdentifier) final > { > ASSERT(device.type() == CaptureDevice::DeviceType::Microphone); > if (!MockRealtimeMediaSourceCenter::captureDeviceWithPersistentID(CaptureDevice::DeviceType::Microphone, device.persistentId())) > return { "Unable to find mock microphone device with given persistentID"_s }; > >- return MockRealtimeAudioSource::create(String { device.persistentId() }, String { device.label() }, WTFMove(hashSalt), constraints); >+ return MockRealtimeAudioSource::create(String { device.persistentId() }, String { device.label() }, WTFMove(hashSalt), constraints, pageIdentifier); > } > private: >-#if PLATFORM(IOS_FAMILY) >- void setActiveSource(RealtimeMediaSource& source) final { CoreAudioCaptureSourceFactory::singleton().setActiveSource(source); } >- void unsetActiveSource(RealtimeMediaSource& source) final { CoreAudioCaptureSourceFactory::singleton().unsetActiveSource(source); } >- RealtimeMediaSource* activeSource() final { return CoreAudioCaptureSourceFactory::singleton().activeSource(); } >-#endif > CaptureDeviceManager& audioCaptureDeviceManager() final { return MockRealtimeMediaSourceCenter::singleton().audioCaptureDeviceManager(); } > const Vector<CaptureDevice>& speakerDevices() const final { return MockRealtimeMediaSourceCenter::speakerDevices(); } > }; >diff --git a/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp b/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp >index 60c5a8cd6d50e900e4c1ebd1fd8e2ddae8b6db9d..3cf7460c80e3be1d5ba3f0ced7c19b25df29abf2 100644 >--- a/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp >+++ b/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp >@@ -50,7 +50,7 @@ > namespace WebCore { > > #if !PLATFORM(MAC) && !PLATFORM(IOS_FAMILY) && !USE(GSTREAMER) >-CaptureSourceOrError MockRealtimeVideoSource::create(String&& deviceID, String&& name, String&& hashSalt, const MediaConstraints* constraints) >+CaptureSourceOrError MockRealtimeVideoSource::create(String&& deviceID, String&& name, String&& hashSalt, const MediaConstraints* constraints, PageIdentifier pageIdentifier) > { > #ifndef NDEBUG > auto device = MockRealtimeMediaSourceCenter::mockDeviceWithPersistentID(deviceID); >@@ -59,7 +59,7 @@ CaptureSourceOrError MockRealtimeVideoSource::create(String&& deviceID, String&& > return { "No mock camera device"_s }; > #endif > >- auto source = adoptRef(*new MockRealtimeVideoSource(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt))); >+ auto source = adoptRef(*new MockRealtimeVideoSource(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt), pageIdentifier)); > if (constraints && source->applyConstraints(*constraints)) > return { }; > >@@ -73,8 +73,8 @@ static HashSet<MockRealtimeVideoSource*>& allMockRealtimeVideoSource() > return videoSources; > } > >-MockRealtimeVideoSource::MockRealtimeVideoSource(String&& deviceID, String&& name, String&& hashSalt) >- : RealtimeVideoCaptureSource(WTFMove(name), WTFMove(deviceID), WTFMove(hashSalt)) >+MockRealtimeVideoSource::MockRealtimeVideoSource(String&& deviceID, String&& name, String&& hashSalt, PageIdentifier pageIdentifier) >+ : RealtimeVideoCaptureSource(WTFMove(name), WTFMove(deviceID), WTFMove(hashSalt), pageIdentifier) > , m_emitFrameTimer(RunLoop::current(), this, &MockRealtimeVideoSource::generateFrame) > { > ASSERT(isMainThread()); >@@ -239,7 +239,6 @@ void MockRealtimeVideoSource::startCaptureTimer() > > void MockRealtimeVideoSource::startProducingData() > { >- prepareToProduceData(); > startCaptureTimer(); > m_startTime = MonotonicTime::now(); > } >diff --git a/Source/WebCore/platform/mock/MockRealtimeVideoSource.h b/Source/WebCore/platform/mock/MockRealtimeVideoSource.h >index 935c6ddecb8d458c9166f5b267ac5c494ff343b5..fc5fc7aa1cb76fa6d973905865bfafecede36bc7 100644 >--- a/Source/WebCore/platform/mock/MockRealtimeVideoSource.h >+++ b/Source/WebCore/platform/mock/MockRealtimeVideoSource.h >@@ -48,7 +48,7 @@ class GraphicsContext; > > class MockRealtimeVideoSource : public RealtimeVideoCaptureSource, private OrientationNotifier::Observer { > public: >- static CaptureSourceOrError create(String&& deviceID, String&& name, String&& hashSalt, const MediaConstraints*); >+ static CaptureSourceOrError create(String&& deviceID, String&& name, String&& hashSalt, const MediaConstraints*, PageIdentifier); > ~MockRealtimeVideoSource(); > > static void setIsInterrupted(bool); >@@ -56,7 +56,7 @@ public: > ImageBuffer* imageBuffer() const; > > protected: >- MockRealtimeVideoSource(String&& deviceID, String&& name, String&& hashSalt); >+ MockRealtimeVideoSource(String&& deviceID, String&& name, String&& hashSalt, PageIdentifier); > > virtual void updateSampleBuffer() = 0; > >diff --git a/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp b/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp >index ad07582175101357e055b114268892fa7c73c946..d7af917495c0b2ccea8be20aaf1995d8d69f30cb 100644 >--- a/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp >+++ b/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp >@@ -289,7 +289,70 @@ UserMediaCaptureManagerProxy::~UserMediaCaptureManagerProxy() > m_connectionProxy->removeMessageReceiver(Messages::UserMediaCaptureManagerProxy::messageReceiverName()); > } > >-void UserMediaCaptureManagerProxy::createMediaSourceForCaptureDeviceWithConstraints(RealtimeMediaSourceIdentifier id, const CaptureDevice& device, String&& hashSalt, const MediaConstraints& mediaConstraints, bool shouldUseGPUProcessRemoteFrames, CreateSourceCallback&& completionHandler) >+CaptureSourceOrError UserMediaCaptureManagerProxy::createMicrophoneSource(const CaptureDevice& device, String&& hashSalt, const MediaConstraints* mediaConstraints, PageIdentifier pageIdentifier) >+{ >+#if PLATFORM(COCOA) >+ auto sourceOrError = RealtimeMediaSourceCenter::singleton().audioCaptureFactory().createAudioCaptureSource(device, WTFMove(hashSalt), mediaConstraints, pageIdentifier); >+ if (!sourceOrError) >+ return sourceOrError; >+ >+ auto& perPageSources = m_pageSources.ensure(pageIdentifier, [] { return PageSources { }; }).iterator->value; >+ >+ // FIXME: Support multiple microphones simultaneously. >+ if (perPageSources.microphoneSource) { >+ auto& microphoneSource = *perPageSources.microphoneSource; >+ if (microphoneSource.persistentID() != device.persistentId() && !microphoneSource.captureDidFail()) { >+ // We cannot reuse the source so fail it. >+ microphoneSource.captureFailed(); >+ microphoneSource.stop(); >+ } >+ } >+ >+ auto source = sourceOrError.source(); >+ perPageSources.microphoneSource = WeakPtr { source.get() }; >+ return source; >+#else >+ return RealtimeMediaSourceCenter::singleton().audioCaptureFactory().createAudioCaptureSource(device, WTFMove(hashSalt), mediaConstraints, pageIdentifier); >+#endif >+} >+ >+CaptureSourceOrError UserMediaCaptureManagerProxy::createCameraSource(const CaptureDevice& device, String&& hashSalt, const MediaConstraints* mediaConstraints, PageIdentifier pageIdentifier) >+{ >+ auto& perPageSources = m_pageSources.ensure(pageIdentifier, [] { return PageSources { }; }).iterator->value; >+ if (perPageSources.cameraSource) { >+ auto& cameraSource = *perPageSources.cameraSource; >+ // FIXME: Optimize multiple concurrent cameras. >+ if (perPageSources.cameraSource->persistentID() == device.persistentId() && !cameraSource.captureDidFail()) { >+ // We can reuse the source, let's do it. >+ auto source = cameraSource.clone(); >+ if (mediaConstraints) { >+ auto error = source->applyConstraints(*mediaConstraints); >+ if (error) >+ return WTFMove(error->message); >+ } >+ return source; >+ } >+ } >+ >+ auto sourceOrError = RealtimeMediaSourceCenter::singleton().videoCaptureFactory().createVideoCaptureSource(device, WTFMove(hashSalt), mediaConstraints, pageIdentifier); >+ if (!sourceOrError) >+ return sourceOrError; >+ >+#if PLATFORM(IOS_FAMILY) >+ if (perPageSources.cameraSource) { >+ // We cannot reuse the source so fail it. >+ perPageSources.cameraSource->captureFailed(); >+ perPageSources.cameraSource->stop(); >+ } >+#endif >+ >+ auto source = sourceOrError.source(); >+ source->monitorOrientation(m_orientationNotifier); >+ perPageSources.cameraSource = WeakPtr { source.get() }; >+ return source; >+} >+ >+void UserMediaCaptureManagerProxy::createMediaSourceForCaptureDeviceWithConstraints(RealtimeMediaSourceIdentifier id, const CaptureDevice& device, String&& hashSalt, const MediaConstraints& mediaConstraints, bool shouldUseGPUProcessRemoteFrames, PageIdentifier pageIdentifier, CreateSourceCallback&& completionHandler) > { > if (!m_connectionProxy->willStartCapture(device.type())) > return completionHandler(false, "Request is not allowed"_s, RealtimeMediaSourceSettings { }, { }, { }, { }, 0); >@@ -299,16 +362,14 @@ void UserMediaCaptureManagerProxy::createMediaSourceForCaptureDeviceWithConstrai > CaptureSourceOrError sourceOrError; > switch (device.type()) { > case WebCore::CaptureDevice::DeviceType::Microphone: >- sourceOrError = RealtimeMediaSourceCenter::singleton().audioCaptureFactory().createAudioCaptureSource(device, WTFMove(hashSalt), constraints); >+ sourceOrError = createMicrophoneSource(device, WTFMove(hashSalt), constraints, pageIdentifier); > break; > case WebCore::CaptureDevice::DeviceType::Camera: >- sourceOrError = RealtimeMediaSourceCenter::singleton().videoCaptureFactory().createVideoCaptureSource(device, WTFMove(hashSalt), constraints); >- if (sourceOrError) >- sourceOrError.captureSource->monitorOrientation(m_orientationNotifier); >+ sourceOrError = createCameraSource(device, WTFMove(hashSalt), constraints, pageIdentifier); > break; > case WebCore::CaptureDevice::DeviceType::Screen: > case WebCore::CaptureDevice::DeviceType::Window: >- sourceOrError = RealtimeMediaSourceCenter::singleton().displayCaptureFactory().createDisplayCaptureSource(device, WTFMove(hashSalt), constraints); >+ sourceOrError = RealtimeMediaSourceCenter::singleton().displayCaptureFactory().createDisplayCaptureSource(device, WTFMove(hashSalt), constraints, pageIdentifier); > break; > case WebCore::CaptureDevice::DeviceType::SystemAudio: > case WebCore::CaptureDevice::DeviceType::Speaker: >diff --git a/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.h b/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.h >index 658b5b7d1886c48306f1803a38804b953d854f54..5bec1075c44f2a601ef585c58475bb757f22f4ec 100644 >--- a/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.h >+++ b/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.h >@@ -84,7 +84,7 @@ private: > void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final; > > using CreateSourceCallback = CompletionHandler<void(bool succeeded, String invalidConstraints, WebCore::RealtimeMediaSourceSettings&&, WebCore::RealtimeMediaSourceCapabilities&&, Vector<WebCore::VideoPresetData>&&, WebCore::IntSize, double)>; >- void createMediaSourceForCaptureDeviceWithConstraints(WebCore::RealtimeMediaSourceIdentifier, const WebCore::CaptureDevice& deviceID, String&&, const WebCore::MediaConstraints&, bool shouldUseGPUProcessRemoteFrames, CreateSourceCallback&&); >+ void createMediaSourceForCaptureDeviceWithConstraints(WebCore::RealtimeMediaSourceIdentifier, const WebCore::CaptureDevice& deviceID, String&&, const WebCore::MediaConstraints&, bool shouldUseGPUProcessRemoteFrames, WebCore::PageIdentifier, CreateSourceCallback&&); > void startProducingData(WebCore::RealtimeMediaSourceIdentifier); > void stopProducingData(WebCore::RealtimeMediaSourceIdentifier); > void end(WebCore::RealtimeMediaSourceIdentifier); >@@ -94,11 +94,21 @@ private: > void requestToEnd(WebCore::RealtimeMediaSourceIdentifier); > void setShouldApplyRotation(WebCore::RealtimeMediaSourceIdentifier, bool shouldApplyRotation); > >+ >+ WebCore::CaptureSourceOrError createMicrophoneSource(const WebCore::CaptureDevice&, String&& hashSalt, const WebCore::MediaConstraints*, WebCore::PageIdentifier); >+ WebCore::CaptureSourceOrError createCameraSource(const WebCore::CaptureDevice&, String&& hashSalt, const WebCore::MediaConstraints*, WebCore::PageIdentifier); >+ > class SourceProxy; > friend class SourceProxy; > HashMap<WebCore::RealtimeMediaSourceIdentifier, std::unique_ptr<SourceProxy>> m_proxies; > UniqueRef<ConnectionProxy> m_connectionProxy; > WebCore::OrientationNotifier m_orientationNotifier { 0 }; >+ >+ struct PageSources { >+ WeakPtr<WebCore::RealtimeMediaSource> microphoneSource; >+ WeakPtr<WebCore::RealtimeMediaSource> cameraSource; >+ }; >+ HashMap<WebCore::PageIdentifier, PageSources> m_pageSources; > }; > > } >diff --git a/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.messages.in b/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.messages.in >index 7bca453e73753769a7fc58e2e70732b857d9b829..ed7f4dab16bea79b421d9660ee1e49c3f690133e 100644 >--- a/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.messages.in >+++ b/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.messages.in >@@ -24,7 +24,7 @@ > #if ENABLE(MEDIA_STREAM) > > messages -> UserMediaCaptureManagerProxy NotRefCounted { >- CreateMediaSourceForCaptureDeviceWithConstraints(WebCore::RealtimeMediaSourceIdentifier id, WebCore::CaptureDevice device, String hashSalt, struct WebCore::MediaConstraints constraints, bool shouldUseGPUProcessRemoteFrames) -> (bool success, String invalidConstraints, WebCore::RealtimeMediaSourceSettings settings, WebCore::RealtimeMediaSourceCapabilities capabilities, Vector<WebCore::VideoPresetData> presets, WebCore::IntSize size, double frameRate) Async >+ CreateMediaSourceForCaptureDeviceWithConstraints(WebCore::RealtimeMediaSourceIdentifier id, WebCore::CaptureDevice device, String hashSalt, struct WebCore::MediaConstraints constraints, bool shouldUseGPUProcessRemoteFrames, WebCore::PageIdentifier pageIdentifier) -> (bool success, String invalidConstraints, WebCore::RealtimeMediaSourceSettings settings, WebCore::RealtimeMediaSourceCapabilities capabilities, Vector<WebCore::VideoPresetData> presets, WebCore::IntSize size, double frameRate) Async > StartProducingData(WebCore::RealtimeMediaSourceIdentifier id) > StopProducingData(WebCore::RealtimeMediaSourceIdentifier id) > End(WebCore::RealtimeMediaSourceIdentifier id) >diff --git a/Source/WebKit/UIProcess/SpeechRecognitionRemoteRealtimeMediaSource.cpp b/Source/WebKit/UIProcess/SpeechRecognitionRemoteRealtimeMediaSource.cpp >index f5a6164e831c968995e332ef0269c0b8c18cf9f2..88fda8491460b77750d7da3501bea05e0f033079 100644 >--- a/Source/WebKit/UIProcess/SpeechRecognitionRemoteRealtimeMediaSource.cpp >+++ b/Source/WebKit/UIProcess/SpeechRecognitionRemoteRealtimeMediaSource.cpp >@@ -39,13 +39,13 @@ > > namespace WebKit { > >-Ref<WebCore::RealtimeMediaSource> SpeechRecognitionRemoteRealtimeMediaSource::create(SpeechRecognitionRemoteRealtimeMediaSourceManager& manager, const WebCore::CaptureDevice& captureDevice) >+Ref<WebCore::RealtimeMediaSource> SpeechRecognitionRemoteRealtimeMediaSource::create(SpeechRecognitionRemoteRealtimeMediaSourceManager& manager, const WebCore::CaptureDevice& captureDevice, WebCore::PageIdentifier pageIdentifier) > { >- return adoptRef(*new SpeechRecognitionRemoteRealtimeMediaSource(WebCore::RealtimeMediaSourceIdentifier::generate(), manager, captureDevice)); >+ return adoptRef(*new SpeechRecognitionRemoteRealtimeMediaSource(WebCore::RealtimeMediaSourceIdentifier::generate(), manager, captureDevice, pageIdentifier)); > } > >-SpeechRecognitionRemoteRealtimeMediaSource::SpeechRecognitionRemoteRealtimeMediaSource(WebCore::RealtimeMediaSourceIdentifier identifier, SpeechRecognitionRemoteRealtimeMediaSourceManager& manager, const WebCore::CaptureDevice& captureDevice) >- : WebCore::RealtimeMediaSource(WebCore::RealtimeMediaSource::Type::Audio, String { captureDevice.label() }, String { captureDevice.persistentId() }) >+SpeechRecognitionRemoteRealtimeMediaSource::SpeechRecognitionRemoteRealtimeMediaSource(WebCore::RealtimeMediaSourceIdentifier identifier, SpeechRecognitionRemoteRealtimeMediaSourceManager& manager, const WebCore::CaptureDevice& captureDevice, WebCore::PageIdentifier pageIdentifier) >+: WebCore::RealtimeMediaSource(WebCore::RealtimeMediaSource::Type::Audio, String { captureDevice.label() }, String { captureDevice.persistentId() }, { }, pageIdentifier) > , m_identifier(identifier) > , m_manager(manager) > #if PLATFORM(COCOA) >diff --git a/Source/WebKit/UIProcess/SpeechRecognitionRemoteRealtimeMediaSource.h b/Source/WebKit/UIProcess/SpeechRecognitionRemoteRealtimeMediaSource.h >index 78bfe5b64b20dd0901b99aa73c35c907021d9b06..9afff28035a0d0325f26c0d2e9c6daddaeba5c35 100644 >--- a/Source/WebKit/UIProcess/SpeechRecognitionRemoteRealtimeMediaSource.h >+++ b/Source/WebKit/UIProcess/SpeechRecognitionRemoteRealtimeMediaSource.h >@@ -46,9 +46,9 @@ class WebAudioBufferList; > namespace WebKit { > class SpeechRecognitionRemoteRealtimeMediaSourceManager; > >-class SpeechRecognitionRemoteRealtimeMediaSource : public WebCore::RealtimeMediaSource, public CanMakeWeakPtr<SpeechRecognitionRemoteRealtimeMediaSource> { >+class SpeechRecognitionRemoteRealtimeMediaSource : public WebCore::RealtimeMediaSource { > public: >- static Ref<WebCore::RealtimeMediaSource> create(SpeechRecognitionRemoteRealtimeMediaSourceManager&, const WebCore::CaptureDevice&); >+ static Ref<WebCore::RealtimeMediaSource> create(SpeechRecognitionRemoteRealtimeMediaSourceManager&, const WebCore::CaptureDevice&, WebCore::PageIdentifier); > ~SpeechRecognitionRemoteRealtimeMediaSource(); > > WebCore::RealtimeMediaSourceIdentifier identifier() const { return m_identifier; } >@@ -62,7 +62,7 @@ public: > void remoteSourceStopped(); > > private: >- SpeechRecognitionRemoteRealtimeMediaSource(WebCore::RealtimeMediaSourceIdentifier, SpeechRecognitionRemoteRealtimeMediaSourceManager&, const WebCore::CaptureDevice&); >+ SpeechRecognitionRemoteRealtimeMediaSource(WebCore::RealtimeMediaSourceIdentifier, SpeechRecognitionRemoteRealtimeMediaSourceManager&, const WebCore::CaptureDevice&, WebCore::PageIdentifier); > > // WebCore::RealtimeMediaSource > void startProducingData() final; >diff --git a/Source/WebKit/UIProcess/SpeechRecognitionRemoteRealtimeMediaSourceManager.cpp b/Source/WebKit/UIProcess/SpeechRecognitionRemoteRealtimeMediaSourceManager.cpp >index 68dc115f169f19ef89f66fe5c8f241c85b978d71..e3a704e1bc226ed481a0d75d18705fa3b9a5292e 100644 >--- a/Source/WebKit/UIProcess/SpeechRecognitionRemoteRealtimeMediaSourceManager.cpp >+++ b/Source/WebKit/UIProcess/SpeechRecognitionRemoteRealtimeMediaSourceManager.cpp >@@ -59,7 +59,7 @@ void SpeechRecognitionRemoteRealtimeMediaSourceManager::addSource(SpeechRecognit > } > #endif > >- send(Messages::SpeechRecognitionRealtimeMediaSourceManager::CreateSource(identifier, captureDevice)); >+ send(Messages::SpeechRecognitionRealtimeMediaSourceManager::CreateSource(identifier, captureDevice, source.pageIdentifier())); > } > > void SpeechRecognitionRemoteRealtimeMediaSourceManager::removeSource(SpeechRecognitionRemoteRealtimeMediaSource& source) >diff --git a/Source/WebKit/UIProcess/WebPageProxy.cpp b/Source/WebKit/UIProcess/WebPageProxy.cpp >index 259ae73ecb92135f09a96501b33ed2a41d353319..c9af5c6f96cb71dc822ce0390ba7c40d442acd9d 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.cpp >+++ b/Source/WebKit/UIProcess/WebPageProxy.cpp >@@ -10996,12 +10996,12 @@ WebCore::CaptureSourceOrError WebPageProxy::createRealtimeMediaSourceForSpeechRe > return CaptureSourceOrError { "No device is available for capture" }; > > if (preferences().captureAudioInGPUProcessEnabled()) >- return CaptureSourceOrError { SpeechRecognitionRemoteRealtimeMediaSource::create(m_process->ensureSpeechRecognitionRemoteRealtimeMediaSourceManager(), *captureDevice) }; >+ return CaptureSourceOrError { SpeechRecognitionRemoteRealtimeMediaSource::create(m_process->ensureSpeechRecognitionRemoteRealtimeMediaSourceManager(), *captureDevice, m_webPageID) }; > > #if PLATFORM(IOS_FAMILY) >- return CaptureSourceOrError { SpeechRecognitionRemoteRealtimeMediaSource::create(m_process->ensureSpeechRecognitionRemoteRealtimeMediaSourceManager(), *captureDevice) }; >+ return CaptureSourceOrError { SpeechRecognitionRemoteRealtimeMediaSource::create(m_process->ensureSpeechRecognitionRemoteRealtimeMediaSourceManager(), *captureDevice, m_webPageID) }; > #else >- return SpeechRecognitionCaptureSource::createRealtimeMediaSource(*captureDevice); >+ return SpeechRecognitionCaptureSource::createRealtimeMediaSource(*captureDevice, m_webPageID); > #endif > } > >diff --git a/Source/WebKit/WebProcess/Speech/SpeechRecognitionRealtimeMediaSourceManager.cpp b/Source/WebKit/WebProcess/Speech/SpeechRecognitionRealtimeMediaSourceManager.cpp >index b81dbb23eff4533a07255788a26eea7c33e05ae3..9f09f6226282683c260b534516f9808da4b7c406 100644 >--- a/Source/WebKit/WebProcess/Speech/SpeechRecognitionRealtimeMediaSourceManager.cpp >+++ b/Source/WebKit/WebProcess/Speech/SpeechRecognitionRealtimeMediaSourceManager.cpp >@@ -208,9 +208,9 @@ void SpeechRecognitionRealtimeMediaSourceManager::revokeSandboxExtensions() > > #endif > >-void SpeechRecognitionRealtimeMediaSourceManager::createSource(RealtimeMediaSourceIdentifier identifier, const CaptureDevice& device) >+void SpeechRecognitionRealtimeMediaSourceManager::createSource(RealtimeMediaSourceIdentifier identifier, const CaptureDevice& device, PageIdentifier pageIdentifier) > { >- auto result = SpeechRecognitionCaptureSource::createRealtimeMediaSource(device); >+ auto result = SpeechRecognitionCaptureSource::createRealtimeMediaSource(device, pageIdentifier); > if (!result) { > RELEASE_LOG_ERROR(Media, "Failed to create realtime source"); > send(Messages::SpeechRecognitionRemoteRealtimeMediaSourceManager::RemoteCaptureFailed(identifier), 0); >diff --git a/Source/WebKit/WebProcess/Speech/SpeechRecognitionRealtimeMediaSourceManager.h b/Source/WebKit/WebProcess/Speech/SpeechRecognitionRealtimeMediaSourceManager.h >index 1884771a87b7f6699190a5de569116cc47f861b3..623448fba9dd7f85ab7335906d48ba96948f336c 100644 >--- a/Source/WebKit/WebProcess/Speech/SpeechRecognitionRealtimeMediaSourceManager.h >+++ b/Source/WebKit/WebProcess/Speech/SpeechRecognitionRealtimeMediaSourceManager.h >@@ -30,6 +30,7 @@ > #include "MessageReceiver.h" > #include "MessageSender.h" > #include "SandboxExtension.h" >+#include <WebCore/PageIdentifier.h> > #include <WebCore/RealtimeMediaSourceIdentifier.h> > > namespace WebCore { >@@ -46,7 +47,7 @@ public: > > private: > // Messages::SpeechRecognitionRealtimeMediaSourceManager >- void createSource(WebCore::RealtimeMediaSourceIdentifier, const WebCore::CaptureDevice&); >+ void createSource(WebCore::RealtimeMediaSourceIdentifier, const WebCore::CaptureDevice&, WebCore::PageIdentifier); > void deleteSource(WebCore::RealtimeMediaSourceIdentifier); > void start(WebCore::RealtimeMediaSourceIdentifier); > void stop(WebCore::RealtimeMediaSourceIdentifier); >diff --git a/Source/WebKit/WebProcess/Speech/SpeechRecognitionRealtimeMediaSourceManager.messages.in b/Source/WebKit/WebProcess/Speech/SpeechRecognitionRealtimeMediaSourceManager.messages.in >index 2382df1d8e59f0a8f6801e2646a87f0d750d661d..ab5e98e49719aaded5e91bbd373807e10d0173ae 100644 >--- a/Source/WebKit/WebProcess/Speech/SpeechRecognitionRealtimeMediaSourceManager.messages.in >+++ b/Source/WebKit/WebProcess/Speech/SpeechRecognitionRealtimeMediaSourceManager.messages.in >@@ -24,7 +24,7 @@ > #if ENABLE(MEDIA_STREAM) > > messages -> SpeechRecognitionRealtimeMediaSourceManager NotRefCounted { >- CreateSource(WebCore::RealtimeMediaSourceIdentifier identifier, WebCore::CaptureDevice device) >+ CreateSource(WebCore::RealtimeMediaSourceIdentifier identifier, WebCore::CaptureDevice device, WebCore::PageIdentifier pageIdentifier) > DeleteSource(WebCore::RealtimeMediaSourceIdentifier identifier) > Start(WebCore::RealtimeMediaSourceIdentifier identifier); > Stop(WebCore::RealtimeMediaSourceIdentifier identifier); >diff --git a/Source/WebKit/WebProcess/cocoa/RemoteRealtimeAudioSource.cpp b/Source/WebKit/WebProcess/cocoa/RemoteRealtimeAudioSource.cpp >index 2ce954f48bffe1f9410555c5e49c656aed97e138..87296916672119f1bbd3928c601832e36ce34f91 100644 >--- a/Source/WebKit/WebProcess/cocoa/RemoteRealtimeAudioSource.cpp >+++ b/Source/WebKit/WebProcess/cocoa/RemoteRealtimeAudioSource.cpp >@@ -43,29 +43,26 @@ > namespace WebKit { > using namespace WebCore; > >-Ref<RealtimeMediaSource> RemoteRealtimeAudioSource::create(const CaptureDevice& device, const MediaConstraints* constraints, String&& name, String&& hashSalt, UserMediaCaptureManager& manager, bool shouldCaptureInGPUProcess) >+Ref<RealtimeMediaSource> RemoteRealtimeAudioSource::create(const CaptureDevice& device, const MediaConstraints* constraints, String&& name, String&& hashSalt, UserMediaCaptureManager& manager, bool shouldCaptureInGPUProcess, PageIdentifier pageIdentifier) > { >- auto source = adoptRef(*new RemoteRealtimeAudioSource(RealtimeMediaSourceIdentifier::generate(), device, constraints, WTFMove(name), WTFMove(hashSalt), manager, shouldCaptureInGPUProcess)); >+ auto source = adoptRef(*new RemoteRealtimeAudioSource(RealtimeMediaSourceIdentifier::generate(), device, constraints, WTFMove(name), WTFMove(hashSalt), manager, shouldCaptureInGPUProcess, pageIdentifier)); > manager.addSource(source.copyRef()); > manager.remoteCaptureSampleManager().addSource(source.copyRef()); > source->createRemoteMediaSource(); > return source; > } > >-RemoteRealtimeAudioSource::RemoteRealtimeAudioSource(RealtimeMediaSourceIdentifier identifier, const CaptureDevice& device, const MediaConstraints* constraints, String&& name, String&& hashSalt, UserMediaCaptureManager& manager, bool shouldCaptureInGPUProcess) >- : RealtimeMediaSource(RealtimeMediaSource::Type::Audio, WTFMove(name), String { device.persistentId() }, WTFMove(hashSalt)) >+RemoteRealtimeAudioSource::RemoteRealtimeAudioSource(RealtimeMediaSourceIdentifier identifier, const CaptureDevice& device, const MediaConstraints* constraints, String&& name, String&& hashSalt, UserMediaCaptureManager& manager, bool shouldCaptureInGPUProcess, PageIdentifier pageIdentifier) >+ : RealtimeMediaSource(RealtimeMediaSource::Type::Audio, WTFMove(name), String { device.persistentId() }, WTFMove(hashSalt), pageIdentifier) > , m_proxy(identifier, device, shouldCaptureInGPUProcess, constraints) > , m_manager(manager) > { > ASSERT(device.type() == CaptureDevice::DeviceType::Microphone); >-#if PLATFORM(IOS_FAMILY) >- RealtimeMediaSourceCenter::singleton().audioCaptureFactory().setActiveSource(*this); >-#endif > } > > void RemoteRealtimeAudioSource::createRemoteMediaSource() > { >- m_proxy.createRemoteMediaSource(deviceIDHashSalt(), [this, protectedThis = Ref { *this }](bool succeeded, auto&& errorMessage, auto&& settings, auto&& capabilities, auto&&, auto, auto) { >+ m_proxy.createRemoteMediaSource(deviceIDHashSalt(), pageIdentifier(), [this, protectedThis = Ref { *this }](bool succeeded, auto&& errorMessage, auto&& settings, auto&& capabilities, auto&&, auto, auto) { > if (!succeeded) { > m_proxy.didFail(WTFMove(errorMessage)); > return; >@@ -87,10 +84,6 @@ RemoteRealtimeAudioSource::~RemoteRealtimeAudioSource() > if (auto* connection = WebProcess::singleton().existingGPUProcessConnection()) > connection->removeClient(*this); > } >- >-#if PLATFORM(IOS_FAMILY) >- RealtimeMediaSourceCenter::singleton().audioCaptureFactory().unsetActiveSource(*this); >-#endif > } > > void RemoteRealtimeAudioSource::setCapabilities(RealtimeMediaSourceCapabilities&& capabilities) >@@ -119,9 +112,10 @@ void RemoteRealtimeAudioSource::remoteAudioSamplesAvailable(const MediaTime& tim > > void RemoteRealtimeAudioSource::hasEnded() > { >- m_proxy.hasEnded(); >- m_manager.removeSource(identifier()); >- m_manager.remoteCaptureSampleManager().removeSource(identifier()); >+ if (m_proxy.hasEnded()) { >+ m_manager.removeSource(identifier()); >+ m_manager.remoteCaptureSampleManager().removeSource(identifier()); >+ } > } > > void RemoteRealtimeAudioSource::captureStopped() >@@ -149,14 +143,6 @@ void RemoteRealtimeAudioSource::gpuProcessConnectionDidClose(GPUProcessConnectio > if (isEnded()) > return; > >-#if PLATFORM(IOS_FAMILY) >- if (this != RealtimeMediaSourceCenter::singleton().audioCaptureFactory().activeSource()) { >- // Track is muted and has no chance of being unmuted, let's end it. >- captureFailed(); >- return; >- } >-#endif >- > m_manager.remoteCaptureSampleManager().didUpdateSourceConnection(connection()); > m_proxy.resetReady(); > createRemoteMediaSource(); >diff --git a/Source/WebKit/WebProcess/cocoa/RemoteRealtimeAudioSource.h b/Source/WebKit/WebProcess/cocoa/RemoteRealtimeAudioSource.h >index a3c41dc04aace5dd4ea739a60f2a530e5e3d075e..88aaba08b565bee9ae4fa4a73a78886590871e03 100644 >--- a/Source/WebKit/WebProcess/cocoa/RemoteRealtimeAudioSource.h >+++ b/Source/WebKit/WebProcess/cocoa/RemoteRealtimeAudioSource.h >@@ -53,7 +53,7 @@ class RemoteRealtimeAudioSource final : public WebCore::RealtimeMediaSource > #endif > { > public: >- static Ref<WebCore::RealtimeMediaSource> create(const WebCore::CaptureDevice&, const WebCore::MediaConstraints*, String&& name, String&& hashSalt, UserMediaCaptureManager&, bool shouldCaptureInGPUProcess); >+ static Ref<WebCore::RealtimeMediaSource> create(const WebCore::CaptureDevice&, const WebCore::MediaConstraints*, String&& name, String&& hashSalt, UserMediaCaptureManager&, bool shouldCaptureInGPUProcess, WebCore::PageIdentifier); > ~RemoteRealtimeAudioSource(); > > WebCore::RealtimeMediaSourceIdentifier identifier() const { return m_proxy.identifier(); } >@@ -71,7 +71,7 @@ public: > void sourceMutedChanged(bool value) { notifyMutedChange(value); } > > private: >- RemoteRealtimeAudioSource(WebCore::RealtimeMediaSourceIdentifier, const WebCore::CaptureDevice&, const WebCore::MediaConstraints*, String&& name, String&& hashSalt, UserMediaCaptureManager&, bool shouldCaptureInGPUProcess); >+ RemoteRealtimeAudioSource(WebCore::RealtimeMediaSourceIdentifier, const WebCore::CaptureDevice&, const WebCore::MediaConstraints*, String&& name, String&& hashSalt, UserMediaCaptureManager&, bool shouldCaptureInGPUProcess, WebCore::PageIdentifier); > > // RealtimeMediaSource > void startProducingData() final { m_proxy.startProducingData(); } >diff --git a/Source/WebKit/WebProcess/cocoa/RemoteRealtimeDisplaySource.cpp b/Source/WebKit/WebProcess/cocoa/RemoteRealtimeDisplaySource.cpp >index c5533533ac55b1f5c2adaee18896f3614f7cee35..b490a7a57f16473b745cd6bf206e31c105be9128 100644 >--- a/Source/WebKit/WebProcess/cocoa/RemoteRealtimeDisplaySource.cpp >+++ b/Source/WebKit/WebProcess/cocoa/RemoteRealtimeDisplaySource.cpp >@@ -38,17 +38,17 @@ > namespace WebKit { > using namespace WebCore; > >-Ref<RealtimeMediaSource> RemoteRealtimeDisplaySource::create(const CaptureDevice& device, const MediaConstraints* constraints, String&& hashSalt, UserMediaCaptureManager& manager, bool shouldCaptureInGPUProcess) >+Ref<RealtimeMediaSource> RemoteRealtimeDisplaySource::create(const CaptureDevice& device, const MediaConstraints* constraints, String&& hashSalt, UserMediaCaptureManager& manager, bool shouldCaptureInGPUProcess, PageIdentifier pageIdentifier) > { >- auto source = adoptRef(*new RemoteRealtimeDisplaySource(RealtimeMediaSourceIdentifier::generate(), device, constraints, WTFMove(hashSalt), manager, shouldCaptureInGPUProcess)); >+ auto source = adoptRef(*new RemoteRealtimeDisplaySource(RealtimeMediaSourceIdentifier::generate(), device, constraints, WTFMove(hashSalt), manager, shouldCaptureInGPUProcess, pageIdentifier)); > manager.addSource(source.copyRef()); > manager.remoteCaptureSampleManager().addSource(source.copyRef()); > source->createRemoteMediaSource(); > return source; > } > >-RemoteRealtimeDisplaySource::RemoteRealtimeDisplaySource(RealtimeMediaSourceIdentifier identifier, const CaptureDevice& device, const MediaConstraints* constraints, String&& hashSalt, UserMediaCaptureManager& manager, bool shouldCaptureInGPUProcess) >- : RealtimeMediaSource(RealtimeMediaSource::Type::Video, String { device.label() }, String { device.persistentId() }, WTFMove(hashSalt)) >+RemoteRealtimeDisplaySource::RemoteRealtimeDisplaySource(RealtimeMediaSourceIdentifier identifier, const CaptureDevice& device, const MediaConstraints* constraints, String&& hashSalt, UserMediaCaptureManager& manager, bool shouldCaptureInGPUProcess, PageIdentifier pageIdentifier) >+ : RealtimeMediaSource(RealtimeMediaSource::Type::Video, String { device.label() }, String { device.persistentId() }, WTFMove(hashSalt), pageIdentifier) > , m_proxy(identifier, device, shouldCaptureInGPUProcess, constraints) > , m_manager(manager) > { >@@ -57,7 +57,7 @@ RemoteRealtimeDisplaySource::RemoteRealtimeDisplaySource(RealtimeMediaSourceIden > > void RemoteRealtimeDisplaySource::createRemoteMediaSource() > { >- m_proxy.createRemoteMediaSource(deviceIDHashSalt(), [this, protectedThis = Ref { *this }](bool succeeded, auto&& errorMessage, auto&& settings, auto&& capabilities, auto&&, auto, auto) { >+ m_proxy.createRemoteMediaSource(deviceIDHashSalt(), pageIdentifier(), [this, protectedThis = Ref { *this }](bool succeeded, auto&& errorMessage, auto&& settings, auto&& capabilities, auto&&, auto, auto) { > if (!succeeded) { > m_proxy.didFail(WTFMove(errorMessage)); > return; >@@ -100,9 +100,10 @@ void RemoteRealtimeDisplaySource::applyConstraintsSucceeded(WebCore::RealtimeMed > > void RemoteRealtimeDisplaySource::hasEnded() > { >- m_proxy.hasEnded(); >- m_manager.removeSource(identifier()); >- m_manager.remoteCaptureSampleManager().removeSource(identifier()); >+ if (m_proxy.hasEnded()) { >+ m_manager.removeSource(identifier()); >+ m_manager.remoteCaptureSampleManager().removeSource(identifier()); >+ } > } > > void RemoteRealtimeDisplaySource::captureStopped() >diff --git a/Source/WebKit/WebProcess/cocoa/RemoteRealtimeDisplaySource.h b/Source/WebKit/WebProcess/cocoa/RemoteRealtimeDisplaySource.h >index 52f535b3d73d689778b95f1947f8e72d8298d6a1..8d82fb59749ea85dc0bd465c485c2479202c0f3c 100644 >--- a/Source/WebKit/WebProcess/cocoa/RemoteRealtimeDisplaySource.h >+++ b/Source/WebKit/WebProcess/cocoa/RemoteRealtimeDisplaySource.h >@@ -47,7 +47,7 @@ class RemoteRealtimeDisplaySource final : public WebCore::RealtimeMediaSource > #endif > { > public: >- static Ref<WebCore::RealtimeMediaSource> create(const WebCore::CaptureDevice&, const WebCore::MediaConstraints*, String&& hashSalt, UserMediaCaptureManager&, bool shouldCaptureInGPUProcess); >+ static Ref<WebCore::RealtimeMediaSource> create(const WebCore::CaptureDevice&, const WebCore::MediaConstraints*, String&& hashSalt, UserMediaCaptureManager&, bool shouldCaptureInGPUProcess, WebCore::PageIdentifier); > ~RemoteRealtimeDisplaySource(); > > WebCore::RealtimeMediaSourceIdentifier identifier() const { return m_proxy.identifier(); } >@@ -65,7 +65,7 @@ public: > void sourceMutedChanged(bool value) { notifyMutedChange(value); } > > private: >- RemoteRealtimeDisplaySource(WebCore::RealtimeMediaSourceIdentifier, const WebCore::CaptureDevice&, const WebCore::MediaConstraints*, String&& hashSalt, UserMediaCaptureManager&, bool shouldCaptureInGPUProcess); >+ RemoteRealtimeDisplaySource(WebCore::RealtimeMediaSourceIdentifier, const WebCore::CaptureDevice&, const WebCore::MediaConstraints*, String&& hashSalt, UserMediaCaptureManager&, bool shouldCaptureInGPUProcess, WebCore::PageIdentifier); > > // RealtimeMediaSource > void startProducingData() final { m_proxy.startProducingData(); } >diff --git a/Source/WebKit/WebProcess/cocoa/RemoteRealtimeMediaSourceProxy.cpp b/Source/WebKit/WebProcess/cocoa/RemoteRealtimeMediaSourceProxy.cpp >index 4a294d8c54171e6e1005b3a406656b26c159c04d..be75455818b535e5ef2d6c8854617400b3c0c940 100644 >--- a/Source/WebKit/WebProcess/cocoa/RemoteRealtimeMediaSourceProxy.cpp >+++ b/Source/WebKit/WebProcess/cocoa/RemoteRealtimeMediaSourceProxy.cpp >@@ -68,9 +68,9 @@ void RemoteRealtimeMediaSourceProxy::stopProducingData() > connection()->send(Messages::UserMediaCaptureManagerProxy::StopProducingData { m_identifier }, 0); > } > >-void RemoteRealtimeMediaSourceProxy::createRemoteMediaSource(const String& deviceIDHashSalt, CreateCallback&& callback, bool shouldUseRemoteFrame) >+void RemoteRealtimeMediaSourceProxy::createRemoteMediaSource(const String& deviceIDHashSalt, WebCore::PageIdentifier pageIdentifier, CreateCallback&& callback, bool shouldUseRemoteFrame) > { >- connection()->sendWithAsyncReply(Messages::UserMediaCaptureManagerProxy::CreateMediaSourceForCaptureDeviceWithConstraints(identifier(), m_device, deviceIDHashSalt, m_constraints, shouldUseRemoteFrame), WTFMove(callback)); >+ connection()->sendWithAsyncReply(Messages::UserMediaCaptureManagerProxy::CreateMediaSourceForCaptureDeviceWithConstraints(identifier(), m_device, deviceIDHashSalt, m_constraints, shouldUseRemoteFrame, pageIdentifier), WTFMove(callback)); > } > > void RemoteRealtimeMediaSourceProxy::applyConstraints(const MediaConstraints& constraints, RealtimeMediaSource::ApplyConstraintsHandler&& completionHandler) >@@ -99,9 +99,14 @@ void RemoteRealtimeMediaSourceProxy::failApplyConstraintCallbacks(const String& > callbacks.takeFirst()(RealtimeMediaSource::ApplyConstraintsError { { }, errorMessage }); > } > >-void RemoteRealtimeMediaSourceProxy::hasEnded() >+bool RemoteRealtimeMediaSourceProxy::hasEnded() > { >+ if (m_isEnded) >+ return false; >+ >+ m_isEnded = true; > connection()->send(Messages::UserMediaCaptureManagerProxy::End { m_identifier }, 0); >+ return true; > } > > void RemoteRealtimeMediaSourceProxy::whenReady(CompletionHandler<void(String)>&& callback) >diff --git a/Source/WebKit/WebProcess/cocoa/RemoteRealtimeMediaSourceProxy.h b/Source/WebKit/WebProcess/cocoa/RemoteRealtimeMediaSourceProxy.h >index 03c1d712227cd5b51a804198f4959c2298fda362..206f6f9178ac9b84a367f02706a063e44d758e7b 100644 >--- a/Source/WebKit/WebProcess/cocoa/RemoteRealtimeMediaSourceProxy.h >+++ b/Source/WebKit/WebProcess/cocoa/RemoteRealtimeMediaSourceProxy.h >@@ -53,13 +53,13 @@ public: > bool shouldCaptureInGPUProcess() const { return m_shouldCaptureInGPUProcess; } > > using CreateCallback = CompletionHandler<void(bool, String&&, WebCore::RealtimeMediaSourceSettings&&, WebCore::RealtimeMediaSourceCapabilities&&, Vector<WebCore::VideoPresetData>&&, WebCore::IntSize, double)>; >- void createRemoteMediaSource(const String&, CreateCallback&&, bool shouldUseRemoteFrame = false); >+ void createRemoteMediaSource(const String&, WebCore::PageIdentifier, CreateCallback&&, bool shouldUseRemoteFrame = false); > > void applyConstraintsSucceeded(); > void applyConstraintsFailed(String&& failedConstraint, String&& errorMessage); > void failApplyConstraintCallbacks(const String& errorMessage); > >- void hasEnded(); >+ bool hasEnded(); > void startProducingData(); > void stopProducingData(); > void applyConstraints(const WebCore::MediaConstraints&, WebCore::RealtimeMediaSource::ApplyConstraintsHandler&&); >@@ -75,12 +75,14 @@ private: > WebCore::RealtimeMediaSourceIdentifier m_identifier; > WebCore::CaptureDevice m_device; > bool m_shouldCaptureInGPUProcess { false }; >+ WebCore::PageIdentifier m_pageIdentifier; > > WebCore::MediaConstraints m_constraints; > Deque<WebCore::RealtimeMediaSource::ApplyConstraintsHandler> m_pendingApplyConstraintsCallbacks; > bool m_isReady { false }; > CompletionHandler<void(String)> m_callback; > String m_errorMessage; >+ bool m_isEnded { false }; > }; > > inline RemoteRealtimeMediaSourceProxy::RemoteRealtimeMediaSourceProxy(WebCore::RealtimeMediaSourceIdentifier identifier, const WebCore::CaptureDevice& device, bool shouldCaptureInGPUProcess, const WebCore::MediaConstraints* constraints) >diff --git a/Source/WebKit/WebProcess/cocoa/RemoteRealtimeVideoSource.cpp b/Source/WebKit/WebProcess/cocoa/RemoteRealtimeVideoSource.cpp >index d2d24abab9ec34a0da22eb65a8ad3cb5f007d97c..88b8ec76ba487647bedfe2998085be71c75398d8 100644 >--- a/Source/WebKit/WebProcess/cocoa/RemoteRealtimeVideoSource.cpp >+++ b/Source/WebKit/WebProcess/cocoa/RemoteRealtimeVideoSource.cpp >@@ -45,29 +45,25 @@ namespace WebKit { > using namespace PAL; > using namespace WebCore; > >-Ref<RealtimeVideoCaptureSource> RemoteRealtimeVideoSource::create(const CaptureDevice& device, const MediaConstraints* constraints, String&& name, String&& hashSalt, UserMediaCaptureManager& manager, bool shouldCaptureInGPUProcess) >+Ref<RealtimeVideoCaptureSource> RemoteRealtimeVideoSource::create(const CaptureDevice& device, const MediaConstraints* constraints, String&& name, String&& hashSalt, UserMediaCaptureManager& manager, bool shouldCaptureInGPUProcess, PageIdentifier pageIdentifier) > { >- auto source = adoptRef(*new RemoteRealtimeVideoSource(RealtimeMediaSourceIdentifier::generate(), device, constraints, WTFMove(name), WTFMove(hashSalt), manager, shouldCaptureInGPUProcess)); >+ auto source = adoptRef(*new RemoteRealtimeVideoSource(RealtimeMediaSourceIdentifier::generate(), device, constraints, WTFMove(name), WTFMove(hashSalt), manager, shouldCaptureInGPUProcess, pageIdentifier)); > manager.addSource(source.copyRef()); > manager.remoteCaptureSampleManager().addSource(source.copyRef()); > source->createRemoteMediaSource(); > return source; > } > >-RemoteRealtimeVideoSource::RemoteRealtimeVideoSource(RealtimeMediaSourceIdentifier identifier, const CaptureDevice& device, const MediaConstraints* constraints, String&& name, String&& hashSalt, UserMediaCaptureManager& manager, bool shouldCaptureInGPUProcess) >- : RealtimeVideoCaptureSource(WTFMove(name), String { device.persistentId() }, WTFMove(hashSalt)) >+RemoteRealtimeVideoSource::RemoteRealtimeVideoSource(RealtimeMediaSourceIdentifier identifier, const CaptureDevice& device, const MediaConstraints* constraints, String&& name, String&& hashSalt, UserMediaCaptureManager& manager, bool shouldCaptureInGPUProcess, PageIdentifier pageIdentifier) >+ : RealtimeVideoCaptureSource(WTFMove(name), String { device.persistentId() }, WTFMove(hashSalt), pageIdentifier) > , m_proxy(identifier, device, shouldCaptureInGPUProcess, constraints) > , m_manager(manager) > { >-#if PLATFORM(IOS_FAMILY) >- if (deviceType() == CaptureDevice::DeviceType::Camera) >- RealtimeMediaSourceCenter::singleton().videoCaptureFactory().setActiveSource(*this); >-#endif > } > > void RemoteRealtimeVideoSource::createRemoteMediaSource() > { >- m_proxy.createRemoteMediaSource(deviceIDHashSalt(), [this, protectedThis = Ref { *this }](bool succeeded, auto&& errorMessage, auto&& settings, auto&& capabilities, auto&& presets, auto size, auto frameRate) mutable { >+ m_proxy.createRemoteMediaSource(deviceIDHashSalt(), pageIdentifier(), [this, protectedThis = Ref { *this }](bool succeeded, auto&& errorMessage, auto&& settings, auto&& capabilities, auto&& presets, auto size, auto frameRate) mutable { > if (!succeeded) { > m_proxy.didFail(WTFMove(errorMessage)); > return; >@@ -93,11 +89,6 @@ RemoteRealtimeVideoSource::~RemoteRealtimeVideoSource() > if (auto* connection = WebProcess::singleton().existingGPUProcessConnection()) > connection->removeClient(*this); > } >- >-#if PLATFORM(IOS_FAMILY) >- if (deviceType() == CaptureDevice::DeviceType::Camera) >- RealtimeMediaSourceCenter::singleton().videoCaptureFactory().unsetActiveSource(*this); >-#endif > } > > void RemoteRealtimeVideoSource::setCapabilities(RealtimeMediaSourceCapabilities&& capabilities) >@@ -147,9 +138,10 @@ const RealtimeMediaSourceCapabilities& RemoteRealtimeVideoSource::capabilities() > > void RemoteRealtimeVideoSource::hasEnded() > { >- m_proxy.hasEnded(); >- m_manager.removeSource(identifier()); >- m_manager.remoteCaptureSampleManager().removeSource(identifier()); >+ if (m_proxy.hasEnded()) { >+ m_manager.removeSource(identifier()); >+ m_manager.remoteCaptureSampleManager().removeSource(identifier()); >+ } > } > > void RemoteRealtimeVideoSource::captureStopped() >@@ -204,14 +196,6 @@ void RemoteRealtimeVideoSource::gpuProcessConnectionDidClose(GPUProcessConnectio > if (isEnded()) > return; > >-#if PLATFORM(IOS_FAMILY) >- if (deviceType() == CaptureDevice::DeviceType::Camera && this != RealtimeMediaSourceCenter::singleton().videoCaptureFactory().activeSource()) { >- // Track is muted and has no chance of being unmuted, let's end it. >- captureFailed(); >- return; >- } >-#endif >- > m_manager.remoteCaptureSampleManager().didUpdateSourceConnection(connection()); > m_proxy.resetReady(); > createRemoteMediaSource(); >diff --git a/Source/WebKit/WebProcess/cocoa/RemoteRealtimeVideoSource.h b/Source/WebKit/WebProcess/cocoa/RemoteRealtimeVideoSource.h >index 32a8a115464b0b65b7eaf3bf0db817fe1b8f9a97..fb301b5a431b3ed2763c2ba2045324269d9499c5 100644 >--- a/Source/WebKit/WebProcess/cocoa/RemoteRealtimeVideoSource.h >+++ b/Source/WebKit/WebProcess/cocoa/RemoteRealtimeVideoSource.h >@@ -55,7 +55,7 @@ class RemoteRealtimeVideoSource final : public WebCore::RealtimeVideoCaptureSour > #endif > { > public: >- static Ref<WebCore::RealtimeVideoCaptureSource> create(const WebCore::CaptureDevice&, const WebCore::MediaConstraints*, String&& name, String&& hashSalt, UserMediaCaptureManager&, bool shouldCaptureInGPUProcess); >+ static Ref<WebCore::RealtimeVideoCaptureSource> create(const WebCore::CaptureDevice&, const WebCore::MediaConstraints*, String&& name, String&& hashSalt, UserMediaCaptureManager&, bool shouldCaptureInGPUProcess, WebCore::PageIdentifier); > ~RemoteRealtimeVideoSource(); > > WebCore::RealtimeMediaSourceIdentifier identifier() const { return m_proxy.identifier(); } >@@ -70,7 +70,7 @@ public: > void sourceMutedChanged(bool value) { notifyMutedChange(value); } > > private: >- RemoteRealtimeVideoSource(WebCore::RealtimeMediaSourceIdentifier, const WebCore::CaptureDevice&, const WebCore::MediaConstraints*, String&& name, String&& hashSalt, UserMediaCaptureManager&, bool shouldCaptureInGPUProcess); >+ RemoteRealtimeVideoSource(WebCore::RealtimeMediaSourceIdentifier, const WebCore::CaptureDevice&, const WebCore::MediaConstraints*, String&& name, String&& hashSalt, UserMediaCaptureManager&, bool shouldCaptureInGPUProcess, WebCore::PageIdentifier); > > // WebCore::RealtimeMediaSource > void startProducingData() final { m_proxy.startProducingData(); } >diff --git a/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.cpp b/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.cpp >index f687d8d9fbe030237f4fca40730a1a45bd4c04c3..3cf2278f4e931514bdc26a7d749a3fa6c96702ee 100644 >--- a/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.cpp >+++ b/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.cpp >@@ -212,7 +212,7 @@ void UserMediaCaptureManager::applyConstraintsFailed(RealtimeMediaSourceIdentifi > }, [](std::nullptr_t) { }); > } > >-CaptureSourceOrError UserMediaCaptureManager::AudioFactory::createAudioCaptureSource(const CaptureDevice& device, String&& hashSalt, const MediaConstraints* constraints) >+CaptureSourceOrError UserMediaCaptureManager::AudioFactory::createAudioCaptureSource(const CaptureDevice& device, String&& hashSalt, const MediaConstraints* constraints, PageIdentifier pageIdentifier) > { > #if !ENABLE(GPU_PROCESS) > if (m_shouldCaptureInGPUProcess) >@@ -225,7 +225,7 @@ CaptureSourceOrError UserMediaCaptureManager::AudioFactory::createAudioCaptureSo > DeprecatedGlobalSettings::setShouldManageAudioSessionCategory(true); > #endif > >- return RemoteRealtimeAudioSource::create(device, constraints, { }, WTFMove(hashSalt), m_manager, m_shouldCaptureInGPUProcess); >+ return RemoteRealtimeAudioSource::create(device, constraints, { }, WTFMove(hashSalt), m_manager, m_shouldCaptureInGPUProcess, pageIdentifier); > } > > void UserMediaCaptureManager::AudioFactory::setShouldCaptureInGPUProcess(bool value) >@@ -238,7 +238,7 @@ void UserMediaCaptureManager::VideoFactory::setShouldCaptureInGPUProcess(bool va > m_shouldCaptureInGPUProcess = value; > } > >-CaptureSourceOrError UserMediaCaptureManager::VideoFactory::createVideoCaptureSource(const CaptureDevice& device, String&& hashSalt, const MediaConstraints* constraints) >+CaptureSourceOrError UserMediaCaptureManager::VideoFactory::createVideoCaptureSource(const CaptureDevice& device, String&& hashSalt, const MediaConstraints* constraints, PageIdentifier pageIdentifier) > { > #if !ENABLE(GPU_PROCESS) > if (m_shouldCaptureInGPUProcess) >@@ -248,10 +248,10 @@ CaptureSourceOrError UserMediaCaptureManager::VideoFactory::createVideoCaptureSo > m_manager.m_remoteCaptureSampleManager.setVideoFrameObjectHeapProxy(&WebProcess::singleton().ensureGPUProcessConnection().videoFrameObjectHeapProxy()); > > bool shouldUseIOSurface = !m_manager.m_shouldUseGPUProcessRemoteFrames; >- return CaptureSourceOrError(RealtimeVideoSource::create(RemoteRealtimeVideoSource::create(device, constraints, { }, WTFMove(hashSalt), m_manager, m_shouldCaptureInGPUProcess), shouldUseIOSurface)); >+ return CaptureSourceOrError(RealtimeVideoSource::create(RemoteRealtimeVideoSource::create(device, constraints, { }, WTFMove(hashSalt), m_manager, m_shouldCaptureInGPUProcess, pageIdentifier), shouldUseIOSurface)); > } > >-CaptureSourceOrError UserMediaCaptureManager::DisplayFactory::createDisplayCaptureSource(const CaptureDevice& device, String&& hashSalt, const MediaConstraints* constraints) >+CaptureSourceOrError UserMediaCaptureManager::DisplayFactory::createDisplayCaptureSource(const CaptureDevice& device, String&& hashSalt, const MediaConstraints* constraints, PageIdentifier pageIdentifier) > { > #if !ENABLE(GPU_PROCESS) > if (m_shouldCaptureInGPUProcess) >@@ -260,7 +260,7 @@ CaptureSourceOrError UserMediaCaptureManager::DisplayFactory::createDisplayCaptu > if (m_shouldCaptureInGPUProcess) > m_manager.m_remoteCaptureSampleManager.setVideoFrameObjectHeapProxy(&WebProcess::singleton().ensureGPUProcessConnection().videoFrameObjectHeapProxy()); > >- return RemoteRealtimeDisplaySource::create(device, constraints, WTFMove(hashSalt), m_manager, m_shouldCaptureInGPUProcess); >+ return RemoteRealtimeDisplaySource::create(device, constraints, WTFMove(hashSalt), m_manager, m_shouldCaptureInGPUProcess, pageIdentifier); > } > > void UserMediaCaptureManager::DisplayFactory::setShouldCaptureInGPUProcess(bool value) >diff --git a/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.h b/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.h >index 8cc5b4f9269b244db5995b7b7444b91597f16a82..8d22cd302b6ce8690a9888497e3090c2053a89ca 100644 >--- a/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.h >+++ b/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.h >@@ -74,7 +74,7 @@ private: > void setShouldCaptureInGPUProcess(bool); > > private: >- WebCore::CaptureSourceOrError createAudioCaptureSource(const WebCore::CaptureDevice&, String&& hashSalt, const WebCore::MediaConstraints*) final; >+ WebCore::CaptureSourceOrError createAudioCaptureSource(const WebCore::CaptureDevice&, String&& hashSalt, const WebCore::MediaConstraints*, WebCore::PageIdentifier) final; > WebCore::CaptureDeviceManager& audioCaptureDeviceManager() final { return m_manager.m_noOpCaptureDeviceManager; } > const Vector<WebCore::CaptureDevice>& speakerDevices() const final { return m_speakerDevices; } > >@@ -88,7 +88,7 @@ private: > void setShouldCaptureInGPUProcess(bool); > > private: >- WebCore::CaptureSourceOrError createVideoCaptureSource(const WebCore::CaptureDevice&, String&& hashSalt, const WebCore::MediaConstraints*) final; >+ WebCore::CaptureSourceOrError createVideoCaptureSource(const WebCore::CaptureDevice&, String&& hashSalt, const WebCore::MediaConstraints*, WebCore::PageIdentifier) final; > WebCore::CaptureDeviceManager& videoCaptureDeviceManager() final { return m_manager.m_noOpCaptureDeviceManager; } > > UserMediaCaptureManager& m_manager; >@@ -100,7 +100,7 @@ private: > void setShouldCaptureInGPUProcess(bool); > > private: >- WebCore::CaptureSourceOrError createDisplayCaptureSource(const WebCore::CaptureDevice&, String&&, const WebCore::MediaConstraints*) final; >+ WebCore::CaptureSourceOrError createDisplayCaptureSource(const WebCore::CaptureDevice&, String&&, const WebCore::MediaConstraints*, WebCore::PageIdentifier) final; > WebCore::DisplayCaptureManager& displayCaptureDeviceManager() final { return m_manager.m_noOpCaptureDeviceManager; } > > UserMediaCaptureManager& m_manager; >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index dfa6f9536a4f310f447182a0f61bd6b5c60f4d3f..523c24788a535707f4ca704e6b92ddd3d3013215 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,15 @@ >+2022-03-02 Youenn Fablet <youenn@apple.com> >+ >+ Scope capture sources by page identifiers >+ https://bugs.webkit.org/show_bug.cgi?id=237359 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Per page sources >+ >+ * fast/mediastream/device-change-event-2-expected.txt: >+ * fast/mediastream/get-user-media-device-id-expected.txt: >+ > 2022-03-01 Matteo Flores <matteo_flores@apple.com> > > [ iOS ] pointerevents/mouse/* 10 pointer event tests are constant timeouts or failures on iOS. >diff --git a/LayoutTests/fast/mediastream/device-change-event-2-expected.txt b/LayoutTests/fast/mediastream/device-change-event-2-expected.txt >index 0483c70ddbd7de91fcda0568d23fcc0f1e8e9363..daa674a7f97765c2413fe395c28d5f282dff3893 100644 >--- a/LayoutTests/fast/mediastream/device-change-event-2-expected.txt >+++ b/LayoutTests/fast/mediastream/device-change-event-2-expected.txt >@@ -1,3 +1,5 @@ >+CONSOLE MESSAGE: A MediaStreamTrack ended due to a capture failure >+CONSOLE MESSAGE: A MediaStreamTrack ended due to a capture failure > > PASS 'devicechange' event fired when device list changes > PASS 'devicechange' events fired quickly are coalesced >diff --git a/LayoutTests/fast/mediastream/get-user-media-device-id-expected.txt b/LayoutTests/fast/mediastream/get-user-media-device-id-expected.txt >index 5024cef653f36a46b5ab786301985410d32109d5..d2fa6687df45efcb282f619cbd2483b81a3d841a 100644 >--- a/LayoutTests/fast/mediastream/get-user-media-device-id-expected.txt >+++ b/LayoutTests/fast/mediastream/get-user-media-device-id-expected.txt >@@ -1,3 +1,6 @@ >+CONSOLE MESSAGE: A MediaStreamTrack ended due to a capture failure >+CONSOLE MESSAGE: A MediaStreamTrack ended due to a capture failure >+CONSOLE MESSAGE: A MediaStreamTrack ended due to a capture failure > > PASS Device IDs should be empty initially > PASS Collect device IDs
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
ews-feeder
:
commit-queue-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 237359
:
453585
|
453586
|
453587
|
453591
|
453592
|
453596
|
453828
|
453829
|
453846
|
453946
|
454101
|
454102
|
454111