Title: [291167] trunk
Revision
291167
Author
[email protected]
Date
2022-03-11 07:33:07 -0800 (Fri, 11 Mar 2022)

Log Message

Do capture video frame downsampling in GPUProcess
https://bugs.webkit.org/show_bug.cgi?id=237316
<rdar://problem/89959777>

Reviewed by Eric Carlson.

Source/WebCore:

To prevent some flakinesses, we now compute the video frame size from MediaSample given to rvfc metadata.
We stop making requestToEnd as virtual by introducing a virtual endProducingData method.
RealtimeMediaSource::end calls the new endProducingData virtual method, which is stop by default.
RealtimeVideoSource::endProducingData is implemented by calling requestToEnd on the underlying source.
This makes sure that ending a source will not end a related cloned source.

Covered by existing tests.

* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
* platform/mediastream/RealtimeMediaSource.cpp:
* platform/mediastream/RealtimeMediaSource.h:
* platform/mediastream/RealtimeVideoSource.cpp:
* platform/mediastream/RealtimeVideoSource.h:

Source/WebKit:

Instead of cloning within WebProcess, we know clone in GPUProcess for camera tracks.
This allows to keep using IOSurfaces when several tracks are using the same device with different resolutions.
Since display tracks are already cloned remotely, we can merge RemoteRealtimeDisplaySource and RemoteRealtimeVideoSource.

We no longer need to stop the source in ~SourceProxy given we are removing ourselves from observing the source.
We rename UserMediaCaptureManagerProxy end to remove  and requestToEnd to endProducingData.

* SourcesCocoa.txt:
* UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp:
* UIProcess/Cocoa/UserMediaCaptureManagerProxy.h:
* UIProcess/Cocoa/UserMediaCaptureManagerProxy.messages.in:
* WebKit.xcodeproj/project.pbxproj:
* WebProcess/cocoa/RemoteCaptureSampleManager.cpp:
* WebProcess/cocoa/RemoteCaptureSampleManager.h:
* WebProcess/cocoa/RemoteRealtimeDisplaySource.cpp: Removed.
* WebProcess/cocoa/RemoteRealtimeDisplaySource.h: Removed.
* WebProcess/cocoa/RemoteRealtimeMediaSourceProxy.cpp:
* WebProcess/cocoa/RemoteRealtimeMediaSourceProxy.h:
* WebProcess/cocoa/RemoteRealtimeVideoSource.cpp:
* WebProcess/cocoa/RemoteRealtimeVideoSource.h:
* WebProcess/cocoa/UserMediaCaptureManager.cpp:
* WebProcess/cocoa/UserMediaCaptureManager.h:

LayoutTests:

* fast/mediastream/getDisplayMedia-size.html:
Remove potential race condition by restarting playing the stream to compute the size.

Modified Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (291166 => 291167)


--- trunk/LayoutTests/ChangeLog	2022-03-11 14:30:09 UTC (rev 291166)
+++ trunk/LayoutTests/ChangeLog	2022-03-11 15:33:07 UTC (rev 291167)
@@ -1,3 +1,14 @@
+2022-03-11  Youenn Fablet  <[email protected]>
+
+        Do capture video frame downsampling in GPUProcess
+        https://bugs.webkit.org/show_bug.cgi?id=237316
+        <rdar://problem/89959777>
+
+        Reviewed by Eric Carlson.
+
+        * fast/mediastream/getDisplayMedia-size.html:
+        Remove potential race condition by restarting playing the stream to compute the size.
+
 2022-03-10  Frédéric Wang  <[email protected]>
 
         [ iOS ] editing/inserting/insert-paragraph-separator-with-inline-table-bold-crash.html is a flaky timeout

Modified: trunk/LayoutTests/fast/mediastream/getDisplayMedia-size.html (291166 => 291167)


--- trunk/LayoutTests/fast/mediastream/getDisplayMedia-size.html	2022-03-11 14:30:09 UTC (rev 291166)
+++ trunk/LayoutTests/fast/mediastream/getDisplayMedia-size.html	2022-03-11 15:33:07 UTC (rev 291167)
@@ -25,6 +25,10 @@
 
     assert_equals(video2.videoWidth, 320);
 
+    video1.srcObject = null;
+    video1.srcObject = stream1;
+    await video1.play();
+
     test(() => {
         assert_equals(video1.videoWidth, 640);
     }, "original source should stay at a small size");
@@ -44,6 +48,10 @@
 
     assert_equals(video2.videoWidth, 1280);
 
+    video1.srcObject = null;
+    video1.srcObject = stream1;
+    await video1.play();
+
     test(() => {
         assert_equals(video1.videoWidth, 640);
     }, "original source should stay at a big size");

Modified: trunk/Source/WebCore/ChangeLog (291166 => 291167)


--- trunk/Source/WebCore/ChangeLog	2022-03-11 14:30:09 UTC (rev 291166)
+++ trunk/Source/WebCore/ChangeLog	2022-03-11 15:33:07 UTC (rev 291167)
@@ -1,3 +1,26 @@
+2022-03-11  Youenn Fablet  <[email protected]>
+
+        Do capture video frame downsampling in GPUProcess
+        https://bugs.webkit.org/show_bug.cgi?id=237316
+        <rdar://problem/89959777>
+
+        Reviewed by Eric Carlson.
+
+        To prevent some flakinesses, we now compute the video frame size from MediaSample given to rvfc metadata.
+        We stop making requestToEnd as virtual by introducing a virtual endProducingData method.
+        RealtimeMediaSource::end calls the new endProducingData virtual method, which is stop by default.
+        RealtimeVideoSource::endProducingData is implemented by calling requestToEnd on the underlying source.
+        This makes sure that ending a source will not end a related cloned source.
+
+        Covered by existing tests.
+
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h:
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
+        * platform/mediastream/RealtimeMediaSource.cpp:
+        * platform/mediastream/RealtimeMediaSource.h:
+        * platform/mediastream/RealtimeVideoSource.cpp:
+        * platform/mediastream/RealtimeVideoSource.h:
+
 2022-03-11  Antoine Quint  <[email protected]>
 
         [web-animations] text-anchor should support discrete animation

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h (291166 => 291167)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h	2022-03-11 14:30:09 UTC (rev 291166)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h	2022-03-11 15:33:07 UTC (rev 291167)
@@ -287,6 +287,7 @@
     uint64_t m_sampleCount { 0 };
     uint64_t m_lastVideoFrameMetadataSampleCount { 0 };
     Seconds m_presentationTime { 0 };
+    FloatSize m_videoFrameSize;
     VideoSampleMetadata m_sampleMetadata;
 };
     

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm (291166 => 291167)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm	2022-03-11 14:30:09 UTC (rev 291166)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm	2022-03-11 15:33:07 UTC (rev 291167)
@@ -324,6 +324,9 @@
     }
 
     m_presentationTime = presentationTime;
+    m_videoFrameSize = sample.presentationSize();
+    if (sample.videoRotation() == MediaSample::VideoRotation::Left || sample.videoRotation() == MediaSample::VideoRotation::Right)
+        m_videoFrameSize = { m_videoFrameSize.height(), m_videoFrameSize.width() };
     m_sampleMetadata = metadata;
     ++m_sampleCount;
 
@@ -1131,8 +1134,8 @@
     m_lastVideoFrameMetadataSampleCount = m_sampleCount;
 
     VideoFrameMetadata metadata;
-    metadata.width = m_intrinsicSize.width();
-    metadata.height = m_intrinsicSize.height();
+    metadata.width = m_videoFrameSize.width();
+    metadata.height = m_videoFrameSize.height();
     metadata.presentedFrames = m_sampleCount;
     metadata.presentationTime = m_presentationTime.seconds();
     metadata.expectedDisplayTime = m_presentationTime.seconds();

Modified: trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp (291166 => 291167)


--- trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp	2022-03-11 14:30:09 UTC (rev 291166)
+++ trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp	2022-03-11 15:33:07 UTC (rev 291167)
@@ -278,7 +278,7 @@
 
     Ref protectedThis { *this };
 
-    stop();
+    endProducingData();
     m_isEnded = true;
     hasEnded();
 
@@ -293,11 +293,7 @@
     ERROR_LOG_IF(m_logger, LOGIDENTIFIER);
 
     m_captureDidFailed = true;
-
-    stop();
-    forEachObserver([](auto& observer) {
-        observer.sourceStopped();
-    });
+    end();
 }
 
 bool RealtimeMediaSource::supportsSizeAndFrameRate(std::optional<int>, std::optional<int>, std::optional<double>)

Modified: trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.h (291166 => 291167)


--- trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.h	2022-03-11 14:30:09 UTC (rev 291166)
+++ trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.h	2022-03-11 15:33:07 UTC (rev 291167)
@@ -262,6 +262,7 @@
 private:
     virtual void startProducingData() { }
     virtual void stopProducingData() { }
+    virtual void endProducingData() { stop(); }
     virtual void settingsDidChange(OptionSet<RealtimeMediaSourceSettings::Flag>) { }
 
     virtual void stopBeingObserved() { stop(); }

Modified: trunk/Source/WebCore/platform/mediastream/RealtimeVideoSource.cpp (291166 => 291167)


--- trunk/Source/WebCore/platform/mediastream/RealtimeVideoSource.cpp	2022-03-11 14:30:09 UTC (rev 291166)
+++ trunk/Source/WebCore/platform/mediastream/RealtimeVideoSource.cpp	2022-03-11 15:33:07 UTC (rev 291167)
@@ -78,6 +78,12 @@
     m_source->stop();
 }
 
+void RealtimeVideoSource::endProducingData()
+{
+    m_source->removeVideoSampleObserver(*this);
+    m_source->requestToEnd(*this);
+}
+
 bool RealtimeVideoSource::supportsSizeAndFrameRate(std::optional<int> width, std::optional<int> height, std::optional<double> frameRate)
 {
     return m_source->supportsSizeAndFrameRate(width, height, frameRate);
@@ -148,11 +154,6 @@
     return hasObserverPreventingStopping;
 }
 
-void RealtimeVideoSource::requestToEnd(RealtimeMediaSource::Observer&)
-{
-    m_source->requestToEnd(*this);
-}
-
 void RealtimeVideoSource::stopBeingObserved()
 {
     m_source->requestToEnd(*this);

Modified: trunk/Source/WebCore/platform/mediastream/RealtimeVideoSource.h (291166 => 291167)


--- trunk/Source/WebCore/platform/mediastream/RealtimeVideoSource.h	2022-03-11 14:30:09 UTC (rev 291166)
+++ trunk/Source/WebCore/platform/mediastream/RealtimeVideoSource.h	2022-03-11 15:33:07 UTC (rev 291167)
@@ -52,7 +52,7 @@
     bool supportsSizeAndFrameRate(std::optional<int> width, std::optional<int> height, std::optional<double> frameRate) final;
     void setSizeAndFrameRate(std::optional<int> width, std::optional<int> height, std::optional<double> frameRate) final;
     Ref<RealtimeMediaSource> clone() final;
-    void requestToEnd(RealtimeMediaSource::Observer& callingObserver) final;
+    void endProducingData() final;
     void stopBeingObserved() final;
 
     const RealtimeMediaSourceCapabilities& capabilities() final { return m_source->capabilities(); }

Modified: trunk/Source/WebKit/ChangeLog (291166 => 291167)


--- trunk/Source/WebKit/ChangeLog	2022-03-11 14:30:09 UTC (rev 291166)
+++ trunk/Source/WebKit/ChangeLog	2022-03-11 15:33:07 UTC (rev 291167)
@@ -1,3 +1,34 @@
+2022-03-11  Youenn Fablet  <[email protected]>
+
+        Do capture video frame downsampling in GPUProcess
+        https://bugs.webkit.org/show_bug.cgi?id=237316
+        <rdar://problem/89959777>
+
+        Reviewed by Eric Carlson.
+
+        Instead of cloning within WebProcess, we know clone in GPUProcess for camera tracks.
+        This allows to keep using IOSurfaces when several tracks are using the same device with different resolutions.
+        Since display tracks are already cloned remotely, we can merge RemoteRealtimeDisplaySource and RemoteRealtimeVideoSource.
+
+        We no longer need to stop the source in ~SourceProxy given we are removing ourselves from observing the source.
+        We rename UserMediaCaptureManagerProxy end to remove  and requestToEnd to endProducingData.
+
+        * SourcesCocoa.txt:
+        * UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp:
+        * UIProcess/Cocoa/UserMediaCaptureManagerProxy.h:
+        * UIProcess/Cocoa/UserMediaCaptureManagerProxy.messages.in:
+        * WebKit.xcodeproj/project.pbxproj:
+        * WebProcess/cocoa/RemoteCaptureSampleManager.cpp:
+        * WebProcess/cocoa/RemoteCaptureSampleManager.h:
+        * WebProcess/cocoa/RemoteRealtimeDisplaySource.cpp: Removed.
+        * WebProcess/cocoa/RemoteRealtimeDisplaySource.h: Removed.
+        * 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-10  Carlos Garcia Campos  <[email protected]>
 
         [GTK] Add a unit tests to check the remote inspector HTTP server

Modified: trunk/Source/WebKit/SourcesCocoa.txt (291166 => 291167)


--- trunk/Source/WebKit/SourcesCocoa.txt	2022-03-11 14:30:09 UTC (rev 291166)
+++ trunk/Source/WebKit/SourcesCocoa.txt	2022-03-11 15:33:07 UTC (rev 291167)
@@ -618,7 +618,6 @@
 WebProcess/cocoa/PlaybackSessionManager.mm
 WebProcess/cocoa/RemoteCaptureSampleManager.cpp
 WebProcess/cocoa/RemoteRealtimeAudioSource.cpp
-WebProcess/cocoa/RemoteRealtimeDisplaySource.cpp
 WebProcess/cocoa/RemoteRealtimeMediaSourceProxy.cpp
 WebProcess/cocoa/RemoteRealtimeVideoSource.cpp
 WebProcess/cocoa/UserMediaCaptureManager.cpp

Modified: trunk/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp (291166 => 291167)


--- trunk/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp	2022-03-11 14:30:09 UTC (rev 291166)
+++ trunk/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp	2022-03-11 15:33:07 UTC (rev 291167)
@@ -83,9 +83,6 @@
 
     ~SourceProxy()
     {
-        // Make sure the rendering thread is stopped before we proceed with the destruction.
-        stop();
-
         switch (m_source->type()) {
         case RealtimeMediaSource::Type::Audio:
         case RealtimeMediaSource::Type::SystemAudio:
@@ -117,19 +114,19 @@
     void start()
     {
         m_shouldReset = true;
-        m_isEnded = false;
+        m_isStopped = false;
         m_source->start();
     }
 
     void stop()
     {
-        m_isEnded = true;
+        m_isStopped = true;
         m_source->stop();
     }
 
-    void requestToEnd()
+    void end()
     {
-        m_isEnded = true;
+        m_isStopped = true;
         m_source->requestToEnd(*this);
     }
 
@@ -247,7 +244,7 @@
     bool preventSourceFromStopping()
     {
         // Do not allow the source to stop if we are still using it.
-        return !m_isEnded;
+        return !m_isStopped;
     }
 
     RealtimeMediaSourceIdentifier m_id;
@@ -258,7 +255,7 @@
     std::unique_ptr<CARingBuffer> m_ringBuffer;
     CAAudioStreamDescription m_description { };
     int64_t m_numberOfFrames { 0 };
-    bool m_isEnded { false };
+    bool m_isStopped { false };
     std::unique_ptr<ImageRotationSessionVT> m_rotationSession;
     bool m_shouldApplyRotation { false };
     std::unique_ptr<IPC::Semaphore> m_captureSemaphore;
@@ -427,7 +424,7 @@
         proxy->stop();
 }
 
-void UserMediaCaptureManagerProxy::end(RealtimeMediaSourceIdentifier id)
+void UserMediaCaptureManagerProxy::removeSource(RealtimeMediaSourceIdentifier id)
 {
     m_proxies.remove(id);
 }
@@ -464,10 +461,10 @@
         m_proxies.add(newSourceID, makeUnique<SourceProxy>(newSourceID, m_connectionProxy->connection(), ProcessIdentity { m_connectionProxy->resourceOwner() }, proxy->source().clone(), m_connectionProxy->remoteVideoFrameObjectHeap()));
 }
 
-void UserMediaCaptureManagerProxy::requestToEnd(RealtimeMediaSourceIdentifier sourceID)
+void UserMediaCaptureManagerProxy::endProducingData(RealtimeMediaSourceIdentifier sourceID)
 {
     if (auto* proxy = m_proxies.get(sourceID))
-        proxy->requestToEnd();
+        proxy->end();
 }
 
 void UserMediaCaptureManagerProxy::setShouldApplyRotation(RealtimeMediaSourceIdentifier sourceID, bool shouldApplyRotation)

Modified: trunk/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.h (291166 => 291167)


--- trunk/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.h	2022-03-11 14:30:09 UTC (rev 291166)
+++ trunk/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.h	2022-03-11 15:33:07 UTC (rev 291167)
@@ -87,11 +87,11 @@
     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);
+    void removeSource(WebCore::RealtimeMediaSourceIdentifier);
     void capabilities(WebCore::RealtimeMediaSourceIdentifier, CompletionHandler<void(WebCore::RealtimeMediaSourceCapabilities&&)>&&);
     void applyConstraints(WebCore::RealtimeMediaSourceIdentifier, const WebCore::MediaConstraints&);
     void clone(WebCore::RealtimeMediaSourceIdentifier clonedID, WebCore::RealtimeMediaSourceIdentifier cloneID);
-    void requestToEnd(WebCore::RealtimeMediaSourceIdentifier);
+    void endProducingData(WebCore::RealtimeMediaSourceIdentifier);
     void setShouldApplyRotation(WebCore::RealtimeMediaSourceIdentifier, bool shouldApplyRotation);
 
     WebCore::CaptureSourceOrError createMicrophoneSource(const WebCore::CaptureDevice&, String&& hashSalt, const WebCore::MediaConstraints*, WebCore::PageIdentifier);

Modified: trunk/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.messages.in (291166 => 291167)


--- trunk/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.messages.in	2022-03-11 14:30:09 UTC (rev 291166)
+++ trunk/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.messages.in	2022-03-11 15:33:07 UTC (rev 291167)
@@ -27,10 +27,10 @@
     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)
+    RemoveSource(WebCore::RealtimeMediaSourceIdentifier id)
     ApplyConstraints(WebCore::RealtimeMediaSourceIdentifier id, struct WebCore::MediaConstraints constraints)
     Clone(WebCore::RealtimeMediaSourceIdentifier clonedID, WebCore::RealtimeMediaSourceIdentifier cloneID)
-    RequestToEnd(WebCore::RealtimeMediaSourceIdentifier sourceID)
+    EndProducingData(WebCore::RealtimeMediaSourceIdentifier sourceID)
     SetShouldApplyRotation(WebCore::RealtimeMediaSourceIdentifier sourceID, bool shouldApplyRotation)
 }
 

Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (291166 => 291167)


--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2022-03-11 14:30:09 UTC (rev 291166)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2022-03-11 15:33:07 UTC (rev 291167)
@@ -4143,8 +4143,6 @@
 		41684C4D24643BFA001CE8ED /* RemoteCaptureSampleManager.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = RemoteCaptureSampleManager.messages.in; sourceTree = "<group>"; };
 		41684C4E24643C81001CE8ED /* RemoteCaptureSampleManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteCaptureSampleManager.h; sourceTree = "<group>"; };
 		41684C4F24643D3F001CE8ED /* RemoteCaptureSampleManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteCaptureSampleManager.cpp; sourceTree = "<group>"; };
-		41684C50246450FD001CE8ED /* RemoteRealtimeVideoSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteRealtimeVideoSource.cpp; sourceTree = "<group>"; };
-		41684C51246450FD001CE8ED /* RemoteRealtimeVideoSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteRealtimeVideoSource.h; sourceTree = "<group>"; };
 		416CD74523FB178B00661D99 /* MDNSRegisterIdentifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MDNSRegisterIdentifier.h; path = Network/webrtc/MDNSRegisterIdentifier.h; sourceTree = "<group>"; };
 		416EDC052600F6B000092675 /* RTCDataChannelRemoteManager.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = RTCDataChannelRemoteManager.cpp; path = Network/webrtc/RTCDataChannelRemoteManager.cpp; sourceTree = "<group>"; };
 		416EDC062600F6B000092675 /* RTCDataChannelRemoteManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = RTCDataChannelRemoteManager.h; path = Network/webrtc/RTCDataChannelRemoteManager.h; sourceTree = "<group>"; };
@@ -4182,8 +4180,8 @@
 		41897ED41F415D850016FA42 /* CacheStorageEngineConnection.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CacheStorageEngineConnection.h; sourceTree = "<group>"; };
 		41897ED51F415D850016FA42 /* CacheStorageEngineConnection.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = CacheStorageEngineConnection.messages.in; sourceTree = "<group>"; };
 		41897ED61F415D860016FA42 /* CacheStorageEngine.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CacheStorageEngine.cpp; sourceTree = "<group>"; };
-		418FCBE3271049DB00F96ECA /* RemoteRealtimeDisplaySource.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteRealtimeDisplaySource.cpp; sourceTree = "<group>"; };
-		418FCBE4271049DC00F96ECA /* RemoteRealtimeDisplaySource.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteRealtimeDisplaySource.h; sourceTree = "<group>"; };
+		418FCBE3271049DB00F96ECA /* RemoteRealtimeVideoSource.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteRealtimeVideoSource.cpp; sourceTree = "<group>"; };
+		418FCBE4271049DC00F96ECA /* RemoteRealtimeVideoSource.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteRealtimeVideoSource.h; sourceTree = "<group>"; };
 		419ACF9B1F981D26009F1A83 /* WebServiceWorkerFetchTaskClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebServiceWorkerFetchTaskClient.h; sourceTree = "<group>"; };
 		41A5F7B9226ECF7C00671764 /* AuthenticationChallengeDispositionCocoa.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AuthenticationChallengeDispositionCocoa.h; sourceTree = "<group>"; };
 		41A5F7BA226ECF7C00671764 /* AuthenticationChallengeDispositionCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = AuthenticationChallengeDispositionCocoa.mm; sourceTree = "<group>"; };
@@ -5173,7 +5171,6 @@
 		7B50E97F2771F6CE003DAAC4 /* IPCTester.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = IPCTester.cpp; sourceTree = "<group>"; };
 		7B50E9802771F6CF003DAAC4 /* IPCTester.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IPCTester.h; sourceTree = "<group>"; };
 		7B5A3DA027A7DC1A006C6F97 /* RemoteVideoFrameIdentifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteVideoFrameIdentifier.h; sourceTree = "<group>"; };
-		7B5A3DA127A7DC1A006C6F97 /* RemoteVideoFrameProxy.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = RemoteVideoFrameProxy.messages.in; sourceTree = "<group>"; };
 		7B5A3DA227A7DC1A006C6F97 /* RemoteVideoFrameProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteVideoFrameProxy.h; sourceTree = "<group>"; };
 		7B5A3DA327A7DC6C006C6F97 /* RemoteVideoFrameProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteVideoFrameProxy.cpp; sourceTree = "<group>"; };
 		7B5A3DA727A7DCBC006C6F97 /* RemoteVideoFrameObjectHeap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteVideoFrameObjectHeap.h; sourceTree = "<group>"; };
@@ -6877,7 +6874,6 @@
 				7B5A3DA027A7DC1A006C6F97 /* RemoteVideoFrameIdentifier.h */,
 				7B5A3DA327A7DC6C006C6F97 /* RemoteVideoFrameProxy.cpp */,
 				7B5A3DA227A7DC1A006C6F97 /* RemoteVideoFrameProxy.h */,
-				7B5A3DA127A7DC1A006C6F97 /* RemoteVideoFrameProxy.messages.in */,
 				1DD2A63A255DE6D100FF7B6F /* SourceBufferPrivateRemote.cpp */,
 				1DD2A639255DE6D100FF7B6F /* SourceBufferPrivateRemote.h */,
 				1DD2A66F25622F1100FF7B6F /* SourceBufferPrivateRemote.messages.in */,
@@ -10456,12 +10452,10 @@
 				41684C4D24643BFA001CE8ED /* RemoteCaptureSampleManager.messages.in */,
 				41E67A8D25D2CFD0007B0A4C /* RemoteRealtimeAudioSource.cpp */,
 				41E67A8C25D2CFD0007B0A4C /* RemoteRealtimeAudioSource.h */,
-				418FCBE3271049DB00F96ECA /* RemoteRealtimeDisplaySource.cpp */,
-				418FCBE4271049DC00F96ECA /* RemoteRealtimeDisplaySource.h */,
 				416008B225DA895B00E892FE /* RemoteRealtimeMediaSourceProxy.cpp */,
 				416008B125DA86B900E892FE /* RemoteRealtimeMediaSourceProxy.h */,
-				41684C50246450FD001CE8ED /* RemoteRealtimeVideoSource.cpp */,
-				41684C51246450FD001CE8ED /* RemoteRealtimeVideoSource.h */,
+				418FCBE3271049DB00F96ECA /* RemoteRealtimeVideoSource.cpp */,
+				418FCBE4271049DC00F96ECA /* RemoteRealtimeVideoSource.h */,
 				CD491B051E70D05F00009066 /* UserMediaCaptureManager.cpp */,
 				CD491B061E70D05F00009066 /* UserMediaCaptureManager.h */,
 				CD491B0A1E732D1200009066 /* UserMediaCaptureManager.messages.in */,

Modified: trunk/Source/WebKit/WebProcess/cocoa/RemoteCaptureSampleManager.cpp (291166 => 291167)


--- trunk/Source/WebKit/WebProcess/cocoa/RemoteCaptureSampleManager.cpp	2022-03-11 14:30:09 UTC (rev 291166)
+++ trunk/Source/WebKit/WebProcess/cocoa/RemoteCaptureSampleManager.cpp	2022-03-11 15:33:07 UTC (rev 291167)
@@ -102,23 +102,10 @@
         auto identifier = source->identifier();
 
         ASSERT(!m_videoSources.contains(identifier));
-        m_videoSources.add(identifier, makeUnique<RemoteVideo>(WTFMove(source)));
+        m_videoSources.add(identifier, WTFMove(source));
     });
 }
 
-void RemoteCaptureSampleManager::addSource(Ref<RemoteRealtimeDisplaySource>&& source)
-{
-    ASSERT(WTF::isMainRunLoop());
-    setConnection(source->connection());
-
-    m_queue->dispatch([this, protectedThis = Ref { *this }, source = WTFMove(source)]() mutable {
-        auto identifier = source->identifier();
-
-        ASSERT(!m_videoSources.contains(identifier));
-        m_videoSources.add(identifier, makeUnique<RemoteVideo>(WTFMove(source)));
-    });
-}
-
 void RemoteCaptureSampleManager::removeSource(WebCore::RealtimeMediaSourceIdentifier identifier)
 {
     ASSERT(WTF::isMainRunLoop());
@@ -169,7 +156,7 @@
     }();
     auto iterator = m_videoSources.find(identifier);
     if (iterator == m_videoSources.end()) {
-        RELEASE_LOG_ERROR(WebRTC, "Unable to find source %llu for remoteVideoSampleAvailable", identifier.toUInt64());
+        RELEASE_LOG_ERROR(WebRTC, "Unable to find source %llu for videoFrameAvailable", identifier.toUInt64());
         return;
     }
     auto videoFrameSize = videoFrame->size();
@@ -181,7 +168,7 @@
     ASSERT(!WTF::isMainRunLoop());
     auto iterator = m_videoSources.find(identifier);
     if (iterator == m_videoSources.end()) {
-        RELEASE_LOG_ERROR(WebRTC, "Unable to find source %llu for remoteVideoSampleAvailable", identifier.toUInt64());
+        RELEASE_LOG_ERROR(WebRTC, "Unable to find source %llu for videoFrameAvailableCV", identifier.toUInt64());
         return;
     }
 
@@ -255,20 +242,6 @@
     startThread();
 }
 
-RemoteCaptureSampleManager::RemoteVideo::RemoteVideo(Source&& source)
-    : m_source(WTFMove(source))
-{
 }
 
-void RemoteCaptureSampleManager::RemoteVideo::videoFrameAvailable(Ref<MediaSample>&& sample, IntSize size, VideoSampleMetadata metadata)
-{
-    switchOn(m_source, [&](Ref<RemoteRealtimeVideoSource>& source) {
-        source->videoSampleAvailable(sample.get(), size, metadata);
-    }, [&](Ref<RemoteRealtimeDisplaySource>& source) {
-        source->remoteVideoSampleAvailable(sample.get(), metadata);
-    });
-}
-
-}
-
 #endif

Modified: trunk/Source/WebKit/WebProcess/cocoa/RemoteCaptureSampleManager.h (291166 => 291167)


--- trunk/Source/WebKit/WebProcess/cocoa/RemoteCaptureSampleManager.h	2022-03-11 14:30:09 UTC (rev 291166)
+++ trunk/Source/WebKit/WebProcess/cocoa/RemoteCaptureSampleManager.h	2022-03-11 15:33:07 UTC (rev 291167)
@@ -31,7 +31,6 @@
 #include "IPCSemaphore.h"
 #include "MessageReceiver.h"
 #include "RemoteRealtimeAudioSource.h"
-#include "RemoteRealtimeDisplaySource.h"
 #include "RemoteRealtimeVideoSource.h"
 #include "RemoteVideoFrameIdentifier.h"
 #include "RemoteVideoFrameProxy.h"
@@ -59,7 +58,6 @@
 
     void addSource(Ref<RemoteRealtimeAudioSource>&&);
     void addSource(Ref<RemoteRealtimeVideoSource>&&);
-    void addSource(Ref<RemoteRealtimeDisplaySource>&&);
     void removeSource(WebCore::RealtimeMediaSourceIdentifier);
 
     void didUpdateSourceConnection(IPC::Connection*);
@@ -105,24 +103,12 @@
         std::atomic<bool> m_shouldStopThread { false };
     };
 
-    class RemoteVideo {
-        WTF_MAKE_FAST_ALLOCATED;
-    public:
-        using Source = std::variant<Ref<RemoteRealtimeVideoSource>, Ref<RemoteRealtimeDisplaySource>>;
-        explicit RemoteVideo(Source&&);
-
-        void videoFrameAvailable(Ref<WebCore::MediaSample>&&, WebCore::IntSize, WebCore::VideoSampleMetadata);
-
-    private:
-        Source m_source;
-    };
-
     bool m_isRegisteredToParentProcessConnection { false };
     Ref<WorkQueue> m_queue;
     RefPtr<IPC::Connection> m_connection;
     // background thread member
     HashMap<WebCore::RealtimeMediaSourceIdentifier, std::unique_ptr<RemoteAudio>> m_audioSources;
-    HashMap<WebCore::RealtimeMediaSourceIdentifier, std::unique_ptr<RemoteVideo>> m_videoSources;
+    HashMap<WebCore::RealtimeMediaSourceIdentifier, Ref<RemoteRealtimeVideoSource>> m_videoSources;
 
     Lock m_videoFrameObjectHeapProxyLock;
     RefPtr<RemoteVideoFrameObjectHeapProxy> m_videoFrameObjectHeapProxy WTF_GUARDED_BY_LOCK(m_videoFrameObjectHeapProxyLock);

Deleted: trunk/Source/WebKit/WebProcess/cocoa/RemoteRealtimeDisplaySource.cpp (291166 => 291167)


--- trunk/Source/WebKit/WebProcess/cocoa/RemoteRealtimeDisplaySource.cpp	2022-03-11 14:30:09 UTC (rev 291166)
+++ trunk/Source/WebKit/WebProcess/cocoa/RemoteRealtimeDisplaySource.cpp	2022-03-11 15:33:07 UTC (rev 291167)
@@ -1,149 +0,0 @@
-/*
- * Copyright (C) 2021 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "RemoteRealtimeDisplaySource.h"
-
-#if PLATFORM(COCOA) && ENABLE(MEDIA_STREAM)
-
-#include "UserMediaCaptureManager.h"
-#include "UserMediaCaptureManagerMessages.h"
-#include "UserMediaCaptureManagerProxyMessages.h"
-#include "WebCoreArgumentCoders.h"
-#include "WebProcess.h"
-#include <WebCore/MediaConstraints.h>
-
-namespace WebKit {
-using namespace WebCore;
-
-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, 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, PageIdentifier pageIdentifier)
-    : RealtimeMediaSource(RealtimeMediaSource::Type::Video, String { device.label() }, String { device.persistentId() }, WTFMove(hashSalt), pageIdentifier)
-    , m_proxy(identifier, device, shouldCaptureInGPUProcess, constraints)
-    , m_manager(manager)
-{
-    ASSERT(device.type() == CaptureDevice::DeviceType::Screen || device.type() == CaptureDevice::DeviceType::Window);
-}
-
-void RemoteRealtimeDisplaySource::createRemoteMediaSource()
-{
-    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;
-        }
-
-        setSettings(WTFMove(settings));
-        setCapabilities(WTFMove(capabilities));
-
-        m_proxy.setAsReady();
-        if (m_proxy.shouldCaptureInGPUProcess())
-            WebProcess::singleton().ensureGPUProcessConnection().addClient(*this);
-    });
-}
-
-RemoteRealtimeDisplaySource::~RemoteRealtimeDisplaySource()
-{
-    if (m_proxy.shouldCaptureInGPUProcess()) {
-        if (auto* connection = WebProcess::singleton().existingGPUProcessConnection())
-            connection->removeClient(*this);
-    }
-}
-
-void RemoteRealtimeDisplaySource::setCapabilities(RealtimeMediaSourceCapabilities&& capabilities)
-{
-    m_capabilities = WTFMove(capabilities);
-}
-
-void RemoteRealtimeDisplaySource::setSettings(RealtimeMediaSourceSettings&& settings)
-{
-    auto changed = m_settings.difference(settings);
-    m_settings = WTFMove(settings);
-    notifySettingsDidChangeObservers(changed);
-}
-
-void RemoteRealtimeDisplaySource::applyConstraintsSucceeded(WebCore::RealtimeMediaSourceSettings&& settings)
-{
-    setSettings(WTFMove(settings));
-    m_proxy.applyConstraintsSucceeded();
-}
-
-void RemoteRealtimeDisplaySource::hasEnded()
-{
-    if (m_proxy.isEnded())
-        return;
-
-    m_proxy.end();
-    m_manager.removeSource(identifier());
-    m_manager.remoteCaptureSampleManager().removeSource(identifier());
-}
-
-void RemoteRealtimeDisplaySource::captureStopped(bool didFail)
-{
-    if (didFail)
-        captureFailed();
-    else
-        end();
-    hasEnded();
-}
-
-void RemoteRealtimeDisplaySource::applyConstraints(const MediaConstraints& constraints, ApplyConstraintsHandler&& callback)
-{
-    m_constraints = constraints;
-    m_proxy.applyConstraints(constraints, WTFMove(callback));
-}
-
-#if ENABLE(GPU_PROCESS)
-void RemoteRealtimeDisplaySource::gpuProcessConnectionDidClose(GPUProcessConnection&)
-{
-    ASSERT(m_proxy.shouldCaptureInGPUProcess());
-    if (isEnded())
-        return;
-
-    m_manager.remoteCaptureSampleManager().didUpdateSourceConnection(connection());
-    m_proxy.resetReady();
-    createRemoteMediaSource();
-
-    m_proxy.failApplyConstraintCallbacks("GPU Process terminated"_s);
-    if (m_constraints)
-        m_proxy.applyConstraints(*m_constraints, [](auto) { });
-
-    if (isProducingData())
-        startProducingData();
-
-}
-#endif
-
-}
-
-#endif

Deleted: trunk/Source/WebKit/WebProcess/cocoa/RemoteRealtimeDisplaySource.h (291166 => 291167)


--- trunk/Source/WebKit/WebProcess/cocoa/RemoteRealtimeDisplaySource.h	2022-03-11 14:30:09 UTC (rev 291166)
+++ trunk/Source/WebKit/WebProcess/cocoa/RemoteRealtimeDisplaySource.h	2022-03-11 15:33:07 UTC (rev 291167)
@@ -1,106 +0,0 @@
-/*
- * Copyright (C) 2021 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#if PLATFORM(COCOA) && ENABLE(MEDIA_STREAM)
-
-#include "GPUProcessConnection.h"
-#include "RemoteRealtimeMediaSourceProxy.h"
-#include <WebCore/CaptureDevice.h>
-#include <WebCore/RealtimeMediaSource.h>
-#include <WebCore/RealtimeMediaSourceIdentifier.h>
-
-namespace WebCore {
-struct MediaConstraints;
-}
-
-namespace WebKit {
-
-class UserMediaCaptureManager;
-
-class RemoteRealtimeDisplaySource final : public WebCore::RealtimeMediaSource
-#if ENABLE(GPU_PROCESS)
-    , public GPUProcessConnection::Client
-#endif
-{
-public:
-    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(); }
-    IPC::Connection* connection() { return m_proxy.connection(); }
-
-    void setSettings(WebCore::RealtimeMediaSourceSettings&&);
-
-    void applyConstraintsSucceeded(WebCore::RealtimeMediaSourceSettings&&);
-    void applyConstraintsFailed(String&& failedConstraint, String&& errorMessage) { m_proxy.applyConstraintsFailed(WTFMove(failedConstraint), WTFMove(errorMessage)); }
-
-    void captureStopped(bool didFail);
-
-    void remoteVideoSampleAvailable(WebCore::MediaSample& sample, WebCore::VideoSampleMetadata metadata) { videoSampleAvailable(sample, metadata); }
-    void sourceMutedChanged(bool value, bool interrupted);
-
-private:
-    RemoteRealtimeDisplaySource(WebCore::RealtimeMediaSourceIdentifier, const WebCore::CaptureDevice&, const WebCore::MediaConstraints*, String&& hashSalt, UserMediaCaptureManager&, bool shouldCaptureInGPUProcess, WebCore::PageIdentifier);
-
-    // RealtimeMediaSource
-    void startProducingData() final { m_proxy.startProducingData(); }
-    void stopProducingData() final { m_proxy.stopProducingData(); }
-    bool isCaptureSource() const final { return true; }
-    void beginConfiguration() final { }
-    void commitConfiguration() final { }
-    void applyConstraints(const WebCore::MediaConstraints&, ApplyConstraintsHandler&&) final;
-    void hasEnded() final;
-    const WebCore::RealtimeMediaSourceSettings& settings() final { return m_settings; }
-    const WebCore::RealtimeMediaSourceCapabilities& capabilities() final { return m_capabilities; }
-    void whenReady(CompletionHandler<void(String)>&& callback) final { m_proxy.whenReady(WTFMove(callback)); }
-    WebCore::CaptureDevice::DeviceType deviceType() const final { return m_proxy.deviceType(); }
-    bool interrupted() const final { return m_proxy.interrupted(); }
-
-#if ENABLE(GPU_PROCESS)
-    // GPUProcessConnection::Client
-    void gpuProcessConnectionDidClose(GPUProcessConnection&) final;
-#endif
-
-    void createRemoteMediaSource();
-    void setCapabilities(WebCore::RealtimeMediaSourceCapabilities&&);
-
-    RemoteRealtimeMediaSourceProxy m_proxy;
-    UserMediaCaptureManager& m_manager;
-    std::optional<WebCore::MediaConstraints> m_constraints;
-    WebCore::RealtimeMediaSourceCapabilities m_capabilities;
-    WebCore::RealtimeMediaSourceSettings m_settings;
-};
-
-inline void RemoteRealtimeDisplaySource::sourceMutedChanged(bool muted, bool interrupted)
-{
-    m_proxy.setInterrupted(interrupted);
-    notifyMutedChange(muted);
-}
-
-} // namespace WebKit
-
-#endif

Modified: trunk/Source/WebKit/WebProcess/cocoa/RemoteRealtimeMediaSourceProxy.cpp (291166 => 291167)


--- trunk/Source/WebKit/WebProcess/cocoa/RemoteRealtimeMediaSourceProxy.cpp	2022-03-11 14:30:09 UTC (rev 291166)
+++ trunk/Source/WebKit/WebProcess/cocoa/RemoteRealtimeMediaSourceProxy.cpp	2022-03-11 15:33:07 UTC (rev 291167)
@@ -70,11 +70,26 @@
     connection()->send(Messages::UserMediaCaptureManagerProxy::StopProducingData { m_identifier }, 0);
 }
 
+void RemoteRealtimeMediaSourceProxy::endProducingData()
+{
+    connection()->send(Messages::UserMediaCaptureManagerProxy::EndProducingData { m_identifier }, 0);
+}
+
 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, pageIdentifier), WTFMove(callback));
 }
 
+RemoteRealtimeMediaSourceProxy RemoteRealtimeMediaSourceProxy::clone()
+{
+    return { RealtimeMediaSourceIdentifier::generate(), m_device, m_shouldCaptureInGPUProcess, &m_constraints };
+}
+
+void RemoteRealtimeMediaSourceProxy::createRemoteCloneSource(WebCore::RealtimeMediaSourceIdentifier cloneIdentifier)
+{
+    connection()->send(Messages::UserMediaCaptureManagerProxy::Clone { m_identifier, cloneIdentifier }, 0);
+}
+
 void RemoteRealtimeMediaSourceProxy::applyConstraints(const MediaConstraints& constraints, RealtimeMediaSource::ApplyConstraintsHandler&& completionHandler)
 {
     m_pendingApplyConstraintsCallbacks.append(WTFMove(completionHandler));
@@ -105,7 +120,7 @@
 {
     ASSERT(!m_isEnded);
     m_isEnded = true;
-    connection()->send(Messages::UserMediaCaptureManagerProxy::End { m_identifier }, 0);
+    connection()->send(Messages::UserMediaCaptureManagerProxy::RemoveSource { m_identifier }, 0);
 }
 
 void RemoteRealtimeMediaSourceProxy::whenReady(CompletionHandler<void(String)>&& callback)

Modified: trunk/Source/WebKit/WebProcess/cocoa/RemoteRealtimeMediaSourceProxy.h (291166 => 291167)


--- trunk/Source/WebKit/WebProcess/cocoa/RemoteRealtimeMediaSourceProxy.h	2022-03-11 14:30:09 UTC (rev 291166)
+++ trunk/Source/WebKit/WebProcess/cocoa/RemoteRealtimeMediaSourceProxy.h	2022-03-11 15:33:07 UTC (rev 291167)
@@ -47,14 +47,21 @@
     RemoteRealtimeMediaSourceProxy(WebCore::RealtimeMediaSourceIdentifier, const WebCore::CaptureDevice&, bool shouldCaptureInGPUProcess, const WebCore::MediaConstraints*);
     ~RemoteRealtimeMediaSourceProxy();
 
+    RemoteRealtimeMediaSourceProxy(RemoteRealtimeMediaSourceProxy&&) = default;
+    RemoteRealtimeMediaSourceProxy& operator=(RemoteRealtimeMediaSourceProxy&&) = default;
+
     IPC::Connection* connection();
     WebCore::RealtimeMediaSourceIdentifier identifier() const { return m_identifier; }
     WebCore::CaptureDevice::DeviceType deviceType() const { return m_device.type(); }
+    const WebCore::CaptureDevice& device() const { return m_device; }
     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&, WebCore::PageIdentifier, CreateCallback&&, bool shouldUseRemoteFrame = false);
 
+    RemoteRealtimeMediaSourceProxy clone();
+    void createRemoteCloneSource(WebCore::RealtimeMediaSourceIdentifier);
+
     void applyConstraintsSucceeded();
     void applyConstraintsFailed(String&& failedConstraint, String&& errorMessage);
     void failApplyConstraintCallbacks(const String& errorMessage);
@@ -63,6 +70,7 @@
     void end();
     void startProducingData();
     void stopProducingData();
+    void endProducingData();
     void applyConstraints(const WebCore::MediaConstraints&, WebCore::RealtimeMediaSource::ApplyConstraintsHandler&&);
 
     void whenReady(CompletionHandler<void(String)>&&);

Modified: trunk/Source/WebKit/WebProcess/cocoa/RemoteRealtimeVideoSource.cpp (291166 => 291167)


--- trunk/Source/WebKit/WebProcess/cocoa/RemoteRealtimeVideoSource.cpp	2022-03-11 14:30:09 UTC (rev 291166)
+++ trunk/Source/WebKit/WebProcess/cocoa/RemoteRealtimeVideoSource.cpp	2022-03-11 15:33:07 UTC (rev 291167)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2020 Apple Inc. All rights reserved.
+ * Copyright (C) 2020-2022 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -28,8 +28,6 @@
 
 #if PLATFORM(COCOA) && ENABLE(MEDIA_STREAM)
 
-#include "GPUProcessConnection.h"
-#include "SharedRingBufferStorage.h"
 #include "UserMediaCaptureManager.h"
 #include "UserMediaCaptureManagerMessages.h"
 #include "UserMediaCaptureManagerProxyMessages.h"
@@ -36,17 +34,13 @@
 #include "WebCoreArgumentCoders.h"
 #include "WebProcess.h"
 #include <WebCore/MediaConstraints.h>
-#include <WebCore/RealtimeMediaSource.h>
-#include <WebCore/RealtimeMediaSourceCenter.h>
-#include <WebCore/WebAudioBufferList.h>
 
 namespace WebKit {
-using namespace PAL;
 using namespace WebCore;
 
-Ref<RealtimeVideoCaptureSource> RemoteRealtimeVideoSource::create(const CaptureDevice& device, const MediaConstraints* constraints, String&& name, String&& hashSalt, UserMediaCaptureManager& manager, bool shouldCaptureInGPUProcess, PageIdentifier pageIdentifier)
+Ref<RealtimeMediaSource> RemoteRealtimeVideoSource::create(const CaptureDevice& device, const MediaConstraints* constraints, String&& hashSalt, UserMediaCaptureManager& manager, bool shouldCaptureInGPUProcess, PageIdentifier pageIdentifier)
 {
-    auto source = adoptRef(*new RemoteRealtimeVideoSource(RealtimeMediaSourceIdentifier::generate(), device, constraints, WTFMove(name), WTFMove(hashSalt), manager, shouldCaptureInGPUProcess, pageIdentifier));
+    auto source = adoptRef(*new RemoteRealtimeVideoSource(RealtimeMediaSourceIdentifier::generate(), device, constraints, WTFMove(hashSalt), manager, shouldCaptureInGPUProcess, pageIdentifier));
     manager.addSource(source.copyRef());
     manager.remoteCaptureSampleManager().addSource(source.copyRef());
     source->createRemoteMediaSource();
@@ -53,33 +47,35 @@
     return source;
 }
 
-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)
+RemoteRealtimeVideoSource::RemoteRealtimeVideoSource(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)
 {
 }
 
+RemoteRealtimeVideoSource::RemoteRealtimeVideoSource(RemoteRealtimeMediaSourceProxy&& proxy, String&& hashSalt, UserMediaCaptureManager& manager, PageIdentifier pageIdentifier)
+    : RealtimeMediaSource(RealtimeMediaSource::Type::Video, String { proxy.device().label() }, String { proxy.device().persistentId() }, WTFMove(hashSalt), pageIdentifier)
+    , m_proxy(WTFMove(proxy))
+    , m_manager(manager)
+{
+}
+
 void RemoteRealtimeVideoSource::createRemoteMediaSource()
 {
-    m_proxy.createRemoteMediaSource(deviceIDHashSalt(), pageIdentifier(), [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&&, auto, auto) {
         if (!succeeded) {
             m_proxy.didFail(WTFMove(errorMessage));
             return;
         }
 
-        setSize(size);
-        setFrameRate(frameRate);
-
         setSettings(WTFMove(settings));
         setCapabilities(WTFMove(capabilities));
-        setSupportedPresets(WTFMove(presets));
-        setName(String { m_settings.label().string() });
 
         m_proxy.setAsReady();
         if (m_proxy.shouldCaptureInGPUProcess())
             WebProcess::singleton().ensureGPUProcessConnection().addClient(*this);
-    }, m_manager.shouldUseGPUProcessRemoteFrames());
+    }, m_proxy.shouldCaptureInGPUProcess() && m_manager.shouldUseGPUProcessRemoteFrames());
 }
 
 RemoteRealtimeVideoSource::~RemoteRealtimeVideoSource()
@@ -90,6 +86,11 @@
     }
 }
 
+void RemoteRealtimeVideoSource::endProducingData()
+{
+    m_proxy.endProducingData();
+}
+
 void RemoteRealtimeVideoSource::setCapabilities(RealtimeMediaSourceCapabilities&& capabilities)
 {
     m_capabilities = WTFMove(capabilities);
@@ -102,28 +103,6 @@
     notifySettingsDidChangeObservers(changed);
 }
 
-void RemoteRealtimeVideoSource::videoSampleAvailable(MediaSample& sample, IntSize sampleSize, VideoSampleMetadata metadata)
-{
-    ASSERT(type() == Type::Video);
-
-    setIntrinsicSize(sampleSize);
-
-    if (m_sampleRotation != sample.videoRotation()) {
-        m_sampleRotation = sample.videoRotation();
-
-        auto size = this->size();
-        if (m_sampleRotation == MediaSample::VideoRotation::Left || m_sampleRotation == MediaSample::VideoRotation::Right) {
-            size = size.transposedSize();
-            m_settings.setWidth(size.width());
-            m_settings.setHeight(size.height());
-        }
-        scheduleDeferredTask([this] {
-            notifySettingsDidChangeObservers({ RealtimeMediaSourceSettings::Flag::Width, RealtimeMediaSourceSettings::Flag::Height });
-        });
-    }
-    dispatchMediaSampleToObservers(sample, metadata);
-}
-
 bool RemoteRealtimeVideoSource::setShouldApplyRotation(bool shouldApplyRotation)
 {
     connection()->send(Messages::UserMediaCaptureManagerProxy::SetShouldApplyRotation { identifier(), shouldApplyRotation }, 0);
@@ -130,9 +109,10 @@
     return true;
 }
 
-const RealtimeMediaSourceCapabilities& RemoteRealtimeVideoSource::capabilities()
+void RemoteRealtimeVideoSource::applyConstraintsSucceeded(WebCore::RealtimeMediaSourceSettings&& settings)
 {
-    return m_capabilities;
+    setSettings(WTFMove(settings));
+    m_proxy.applyConstraintsSucceeded();
 }
 
 void RemoteRealtimeVideoSource::hasEnded()
@@ -145,6 +125,24 @@
     m_manager.remoteCaptureSampleManager().removeSource(identifier());
 }
 
+Ref<RealtimeMediaSource> RemoteRealtimeVideoSource::clone()
+{
+    if (isEnded() || m_proxy.isEnded())
+        return *this;
+
+    auto source = adoptRef(*new RemoteRealtimeVideoSource(m_proxy.clone(), deviceIDHashSalt(), m_manager, pageIdentifier()));
+
+    source->setSettings(RealtimeMediaSourceSettings { settings() });
+    source->setCapabilities(RealtimeMediaSourceCapabilities { capabilities() });
+
+    m_manager.addSource(source.copyRef());
+    m_manager.remoteCaptureSampleManager().addSource(source.copyRef());
+
+    m_proxy.createRemoteCloneSource(source->identifier());
+
+    return source;
+}
+
 void RemoteRealtimeVideoSource::captureStopped(bool didFail)
 {
     if (didFail)
@@ -154,39 +152,12 @@
     hasEnded();
 }
 
-void RemoteRealtimeVideoSource::generatePresets()
+void RemoteRealtimeVideoSource::applyConstraints(const MediaConstraints& constraints, ApplyConstraintsHandler&& callback)
 {
-    ASSERT(m_proxy.isReady());
+    m_constraints = constraints;
+    m_proxy.applyConstraints(constraints, WTFMove(callback));
 }
 
-void RemoteRealtimeVideoSource::setFrameRateWithPreset(double frameRate, RefPtr<VideoPreset> preset)
-{
-    MediaConstraints constraints;
-
-    constraints.isValid = true;
-    DoubleConstraint frameRateConstraint("frameRate"_s, MediaConstraintType::FrameRate);
-    frameRateConstraint.setIdeal(frameRate);
-    constraints.mandatoryConstraints.set(MediaConstraintType::FrameRate, frameRateConstraint);
-
-    if (preset) {
-        IntConstraint widthConstraint("width"_s, MediaConstraintType::Width);
-        widthConstraint.setIdeal(preset->size.width());
-        constraints.mandatoryConstraints.set(MediaConstraintType::Width, widthConstraint);
-
-        IntConstraint heightConstraint("height"_s, MediaConstraintType::Height);
-        heightConstraint.setIdeal(preset->size.height());
-        constraints.mandatoryConstraints.set(MediaConstraintType::Height, heightConstraint);
-    }
-
-    m_sizeConstraints = constraints;
-    m_proxy.applyConstraints(constraints, [](auto) { });
-}
-
-bool RemoteRealtimeVideoSource::prefersPreset(VideoPreset&)
-{
-    return true;
-}
-
 #if ENABLE(GPU_PROCESS)
 void RemoteRealtimeVideoSource::gpuProcessConnectionDidClose(GPUProcessConnection&)
 {
@@ -199,8 +170,8 @@
     createRemoteMediaSource();
 
     m_proxy.failApplyConstraintCallbacks("GPU Process terminated"_s);
-    if (m_sizeConstraints)
-        m_proxy.applyConstraints(*m_sizeConstraints, [](auto) { });
+    if (m_constraints)
+        m_proxy.applyConstraints(*m_constraints, [](auto) { });
 
     if (isProducingData())
         startProducingData();

Modified: trunk/Source/WebKit/WebProcess/cocoa/RemoteRealtimeVideoSource.h (291166 => 291167)


--- trunk/Source/WebKit/WebProcess/cocoa/RemoteRealtimeVideoSource.h	2022-03-11 14:30:09 UTC (rev 291166)
+++ trunk/Source/WebKit/WebProcess/cocoa/RemoteRealtimeVideoSource.h	2022-03-11 15:33:07 UTC (rev 291167)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2020 Apple Inc. All rights reserved.
+ * Copyright (C) 2020-2022 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -30,19 +30,12 @@
 #include "GPUProcessConnection.h"
 #include "RemoteRealtimeMediaSourceProxy.h"
 #include <WebCore/CaptureDevice.h>
+#include <WebCore/RealtimeMediaSource.h>
 #include <WebCore/RealtimeMediaSourceIdentifier.h>
-#include <WebCore/RealtimeVideoCaptureSource.h>
-#include <wtf/Deque.h>
+#include <WebCore/VideoFrame.h>
 
-namespace IPC {
-class Connection;
-}
-
 namespace WebCore {
-class CAAudioStreamDescription;
-class ImageTransferSessionVT;
 struct MediaConstraints;
-class MediaSample;
 }
 
 namespace WebKit {
@@ -49,13 +42,13 @@
 
 class UserMediaCaptureManager;
 
-class RemoteRealtimeVideoSource final : public WebCore::RealtimeVideoCaptureSource
+class RemoteRealtimeVideoSource final : public WebCore::RealtimeMediaSource
 #if ENABLE(GPU_PROCESS)
     , public GPUProcessConnection::Client
 #endif
 {
 public:
-    static Ref<WebCore::RealtimeVideoCaptureSource> create(const WebCore::CaptureDevice&, const WebCore::MediaConstraints*, String&& name, String&& hashSalt, UserMediaCaptureManager&, bool shouldCaptureInGPUProcess, WebCore::PageIdentifier);
+    static Ref<WebCore::RealtimeMediaSource> create(const WebCore::CaptureDevice&, const WebCore::MediaConstraints*, String&& hashSalt, UserMediaCaptureManager&, bool shouldCaptureInGPUProcess, WebCore::PageIdentifier);
     ~RemoteRealtimeVideoSource();
 
     WebCore::RealtimeMediaSourceIdentifier identifier() const { return m_proxy.identifier(); }
@@ -65,32 +58,32 @@
 
     void captureStopped(bool didFail);
 
-    void videoSampleAvailable(WebCore::MediaSample&, WebCore::IntSize, WebCore::VideoSampleMetadata);
+    void videoFrameAvailable(WebCore::VideoFrame& frame, WebCore::IntSize, WebCore::VideoSampleMetadata metadata) { videoSampleAvailable(frame, metadata); }
     void sourceMutedChanged(bool value, bool interrupted);
 
+    void applyConstraintsSucceeded(WebCore::RealtimeMediaSourceSettings&&);
+    void applyConstraintsFailed(String&& failedConstraint, String&& errorMessage) { m_proxy.applyConstraintsFailed(WTFMove(failedConstraint), WTFMove(errorMessage)); }
+
 private:
-    RemoteRealtimeVideoSource(WebCore::RealtimeMediaSourceIdentifier, const WebCore::CaptureDevice&, const WebCore::MediaConstraints*, String&& name, String&& hashSalt, UserMediaCaptureManager&, bool shouldCaptureInGPUProcess, WebCore::PageIdentifier);
+    RemoteRealtimeVideoSource(WebCore::RealtimeMediaSourceIdentifier, const WebCore::CaptureDevice&, const WebCore::MediaConstraints*, String&& hashSalt, UserMediaCaptureManager&, bool shouldCaptureInGPUProcess, WebCore::PageIdentifier);
+    RemoteRealtimeVideoSource(RemoteRealtimeMediaSourceProxy&&, String&& hashSalt, UserMediaCaptureManager&, WebCore::PageIdentifier);
 
-    // WebCore::RealtimeMediaSource
+    // RealtimeMediaSource
     void startProducingData() final { m_proxy.startProducingData(); }
     void stopProducingData() final { m_proxy.stopProducingData(); }
     bool isCaptureSource() const final { return true; }
     void beginConfiguration() final { }
     void commitConfiguration() final { }
-    bool setShouldApplyRotation(bool /* shouldApplyRotation */) final;
+    void applyConstraints(const WebCore::MediaConstraints&, ApplyConstraintsHandler&&) final;
     void hasEnded() final;
     const WebCore::RealtimeMediaSourceSettings& settings() final { return m_settings; }
-    const WebCore::RealtimeMediaSourceCapabilities& capabilities() final;
+    const WebCore::RealtimeMediaSourceCapabilities& capabilities() final { return m_capabilities; }
     void whenReady(CompletionHandler<void(String)>&& callback) final { m_proxy.whenReady(WTFMove(callback)); }
     WebCore::CaptureDevice::DeviceType deviceType() const final { return m_proxy.deviceType(); }
+    Ref<RealtimeMediaSource> clone() final;
+    void endProducingData() final;
+    bool setShouldApplyRotation(bool) final;
 
-    // WebCore::RealtimeVideoCaptureSource
-    void generatePresets() final;
-    WebCore::MediaSample::VideoRotation sampleRotation() const final { return m_sampleRotation; }
-    void setFrameRateWithPreset(double, RefPtr<WebCore::VideoPreset>) final;
-    bool prefersPreset(WebCore::VideoPreset&) final;
-    bool interrupted() const final { return m_proxy.interrupted(); }
-
 #if ENABLE(GPU_PROCESS)
     // GPUProcessConnection::Client
     void gpuProcessConnectionDidClose(GPUProcessConnection&) final;
@@ -97,17 +90,13 @@
 #endif
 
     void createRemoteMediaSource();
-    void didFail(String&& errorMessage);
-    void setAsReady();
     void setCapabilities(WebCore::RealtimeMediaSourceCapabilities&&);
 
     RemoteRealtimeMediaSourceProxy m_proxy;
     UserMediaCaptureManager& m_manager;
-
-    std::optional<WebCore::MediaConstraints> m_sizeConstraints;
+    std::optional<WebCore::MediaConstraints> m_constraints;
     WebCore::RealtimeMediaSourceCapabilities m_capabilities;
     WebCore::RealtimeMediaSourceSettings m_settings;
-    WebCore::MediaSample::VideoRotation m_sampleRotation { WebCore::MediaSample::VideoRotation::None };
 };
 
 inline void RemoteRealtimeVideoSource::sourceMutedChanged(bool muted, bool interrupted)

Modified: trunk/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.cpp (291166 => 291167)


--- trunk/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.cpp	2022-03-11 14:30:09 UTC (rev 291166)
+++ trunk/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.cpp	2022-03-11 15:33:07 UTC (rev 291167)
@@ -31,7 +31,6 @@
 #include "AudioMediaStreamTrackRendererInternalUnitManager.h"
 #include "GPUProcessConnection.h"
 #include "RemoteRealtimeAudioSource.h"
-#include "RemoteRealtimeDisplaySource.h"
 #include "RemoteRealtimeVideoSource.h"
 #include "RemoteVideoFrameObjectHeapProxy.h"
 #include "UserMediaCaptureManagerMessages.h"
@@ -111,13 +110,6 @@
     m_sources.add(identifier, Source(WTFMove(source)));
 }
 
-void UserMediaCaptureManager::addSource(Ref<RemoteRealtimeDisplaySource>&& source)
-{
-    auto identifier = source->identifier();
-    ASSERT(!m_sources.contains(identifier));
-    m_sources.add(identifier, Source(WTFMove(source)));
-}
-
 void UserMediaCaptureManager::removeSource(RealtimeMediaSourceIdentifier identifier)
 {
     ASSERT(m_sources.contains(identifier));
@@ -134,8 +126,6 @@
         source->captureStopped(didFail);
     }, [didFail](Ref<RemoteRealtimeVideoSource>& source) {
         source->captureStopped(didFail);
-    }, [didFail](Ref<RemoteRealtimeDisplaySource>& source) {
-        source->captureStopped(didFail);
     }, [](std::nullptr_t) { });
 }
 
@@ -149,8 +139,6 @@
         source->sourceMutedChanged(muted, interrupted);
     }, [muted, interrupted](Ref<RemoteRealtimeVideoSource>& source) {
         source->sourceMutedChanged(muted, interrupted);
-    }, [muted, interrupted](Ref<RemoteRealtimeDisplaySource>& source) {
-        source->sourceMutedChanged(muted, interrupted);
     }, [](std::nullptr_t) { });
 }
 
@@ -164,8 +152,6 @@
         source->setSettings(WTFMove(settings));
     }, [&](Ref<RemoteRealtimeVideoSource>& source) {
         source->setSettings(WTFMove(settings));
-    }, [&](Ref<RemoteRealtimeDisplaySource>& source) {
-        source->setSettings(WTFMove(settings));
     }, [](std::nullptr_t) { });
 }
 
@@ -178,7 +164,6 @@
     switchOn(iterator->value, [&](Ref<RemoteRealtimeAudioSource>& source) {
         source->applyConstraintsSucceeded(WTFMove(settings));
     }, [&](Ref<RemoteRealtimeVideoSource>& source) {
-    }, [&](Ref<RemoteRealtimeDisplaySource>& source) {
         source->applyConstraintsSucceeded(WTFMove(settings));
     }, [](std::nullptr_t) { });
 }
@@ -192,7 +177,6 @@
     switchOn(iterator->value, [&](Ref<RemoteRealtimeAudioSource>& source) {
         source->applyConstraintsFailed(WTFMove(failedConstraint), WTFMove(message));
     }, [&](Ref<RemoteRealtimeVideoSource>& source) {
-    }, [&](Ref<RemoteRealtimeDisplaySource>& source) {
         source->applyConstraintsFailed(WTFMove(failedConstraint), WTFMove(message));
     }, [](std::nullptr_t) { });
 }
@@ -232,8 +216,7 @@
     if (m_shouldCaptureInGPUProcess)
         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, pageIdentifier), shouldUseIOSurface));
+    return RemoteRealtimeVideoSource::create(device, constraints, WTFMove(hashSalt), m_manager, m_shouldCaptureInGPUProcess, pageIdentifier);
 }
 
 CaptureSourceOrError UserMediaCaptureManager::DisplayFactory::createDisplayCaptureSource(const CaptureDevice& device, String&& hashSalt, const MediaConstraints* constraints, PageIdentifier pageIdentifier)
@@ -245,7 +228,7 @@
     if (m_shouldCaptureInGPUProcess)
         m_manager.m_remoteCaptureSampleManager.setVideoFrameObjectHeapProxy(&WebProcess::singleton().ensureGPUProcessConnection().videoFrameObjectHeapProxy());
 
-    return RemoteRealtimeDisplaySource::create(device, constraints, WTFMove(hashSalt), m_manager, m_shouldCaptureInGPUProcess, pageIdentifier);
+    return RemoteRealtimeVideoSource::create(device, constraints, WTFMove(hashSalt), m_manager, m_shouldCaptureInGPUProcess, pageIdentifier);
 }
 
 void UserMediaCaptureManager::DisplayFactory::setShouldCaptureInGPUProcess(bool value)

Modified: trunk/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.h (291166 => 291167)


--- trunk/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.h	2022-03-11 14:30:09 UTC (rev 291166)
+++ trunk/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.h	2022-03-11 15:33:07 UTC (rev 291167)
@@ -43,7 +43,6 @@
 namespace WebKit {
 
 class RemoteRealtimeAudioSource;
-class RemoteRealtimeDisplaySource;
 class RemoteRealtimeVideoSource;
 class WebProcess;
 
@@ -60,7 +59,6 @@
 
     void addSource(Ref<RemoteRealtimeAudioSource>&&);
     void addSource(Ref<RemoteRealtimeVideoSource>&&);
-    void addSource(Ref<RemoteRealtimeDisplaySource>&&);
     void removeSource(WebCore::RealtimeMediaSourceIdentifier);
 
     RemoteCaptureSampleManager& remoteCaptureSampleManager() { return m_remoteCaptureSampleManager; }
@@ -131,7 +129,7 @@
     void applyConstraintsSucceeded(WebCore::RealtimeMediaSourceIdentifier, WebCore::RealtimeMediaSourceSettings&&);
     void applyConstraintsFailed(WebCore::RealtimeMediaSourceIdentifier, String&&, String&&);
 
-    using Source = std::variant<std::nullptr_t, Ref<RemoteRealtimeAudioSource>, Ref<RemoteRealtimeVideoSource>, Ref<RemoteRealtimeDisplaySource>>;
+    using Source = std::variant<std::nullptr_t, Ref<RemoteRealtimeAudioSource>, Ref<RemoteRealtimeVideoSource>>;
     HashMap<WebCore::RealtimeMediaSourceIdentifier, Source> m_sources;
     WebProcess& m_process;
     NoOpCaptureDeviceManager m_noOpCaptureDeviceManager;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to