Title: [290820] trunk/Source/WebCore
Revision
290820
Author
you...@apple.com
Date
2022-03-04 00:07:31 -0800 (Fri, 04 Mar 2022)

Log Message

AVVideoCaptureSource should reuse CaptureDevice label
https://bugs.webkit.org/show_bug.cgi?id=237363
<rdar://88301613>

Reviewed by Eric Carlson.

We are getting AV device name through AVCaptureDevice.localizedName, first in UIProcess, then in GPUProcess.
To make sure we always use the ones from UIProcess (which are the ones exposed through mediaDevices.enumerateDevices),
We make sure to use CaptureDevice.label when creating an AVVideoCaptureSource.

Manually tested.

* platform/mediastream/mac/AVVideoCaptureSource.h:
* platform/mediastream/mac/AVVideoCaptureSource.mm:
(WebCore::AVVideoCaptureSource::create):
(WebCore::AVVideoCaptureSource::AVVideoCaptureSource):
* platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (290819 => 290820)


--- trunk/Source/WebCore/ChangeLog	2022-03-04 07:55:10 UTC (rev 290819)
+++ trunk/Source/WebCore/ChangeLog	2022-03-04 08:07:31 UTC (rev 290820)
@@ -1,3 +1,23 @@
+2022-03-04  Youenn Fablet  <you...@apple.com>
+
+        AVVideoCaptureSource should reuse CaptureDevice label
+        https://bugs.webkit.org/show_bug.cgi?id=237363
+        <rdar://88301613>
+
+        Reviewed by Eric Carlson.
+
+        We are getting AV device name through AVCaptureDevice.localizedName, first in UIProcess, then in GPUProcess.
+        To make sure we always use the ones from UIProcess (which are the ones exposed through mediaDevices.enumerateDevices),
+        We make sure to use CaptureDevice.label when creating an AVVideoCaptureSource.
+
+        Manually tested.
+
+        * platform/mediastream/mac/AVVideoCaptureSource.h:
+        * platform/mediastream/mac/AVVideoCaptureSource.mm:
+        (WebCore::AVVideoCaptureSource::create):
+        (WebCore::AVVideoCaptureSource::AVVideoCaptureSource):
+        * platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp:
+
 2022-03-03  Kimmo Kinnunen  <kkinnu...@apple.com>
 
         WebGL context count is not limited for GPU process

Modified: trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.h (290819 => 290820)


--- trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.h	2022-03-04 07:55:10 UTC (rev 290819)
+++ trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.h	2022-03-04 08:07:31 UTC (rev 290820)
@@ -54,7 +54,7 @@
 
 class AVVideoCaptureSource : public RealtimeVideoCaptureSource, private OrientationNotifier::Observer {
 public:
-    static CaptureSourceOrError create(String&& id, String&& hashSalt, const MediaConstraints*);
+    static CaptureSourceOrError create(const CaptureDevice&, String&& hashSalt, const MediaConstraints*);
 
     WEBCORE_EXPORT static VideoCaptureFactory& factory();
 
@@ -70,7 +70,7 @@
     void captureDeviceSuspendedDidChange();
 
 private:
-    AVVideoCaptureSource(AVCaptureDevice*, String&& id, String&& hashSalt);
+    AVVideoCaptureSource(AVCaptureDevice*, const CaptureDevice&, String&& hashSalt);
     virtual ~AVVideoCaptureSource();
 
     void clearSession();

Modified: trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm (290819 => 290820)


--- trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm	2022-03-04 07:55:10 UTC (rev 290819)
+++ trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm	2022-03-04 08:07:31 UTC (rev 290820)
@@ -108,13 +108,13 @@
     RetainPtr<AVCaptureDeviceFormat> format;
 };
 
-CaptureSourceOrError AVVideoCaptureSource::create(String&& id, String&& hashSalt, const MediaConstraints* constraints)
+CaptureSourceOrError AVVideoCaptureSource::create(const CaptureDevice& device, String&& hashSalt, const MediaConstraints* constraints)
 {
-    AVCaptureDevice *device = [PAL::getAVCaptureDeviceClass() deviceWithUniqueID:id];
-    if (!device)
+    auto *avDevice = [PAL::getAVCaptureDeviceClass() deviceWithUniqueID:device.persistentId()];
+    if (!avDevice)
         return { "No AVVideoCaptureSource device"_s };
 
-    auto source = adoptRef(*new AVVideoCaptureSource(device, WTFMove(id), WTFMove(hashSalt)));
+    auto source = adoptRef(*new AVVideoCaptureSource(avDevice, device, WTFMove(hashSalt)));
     if (constraints) {
         auto result = source->applyConstraints(*constraints);
         if (result)
@@ -124,10 +124,10 @@
     return CaptureSourceOrError(RealtimeVideoSource::create(WTFMove(source)));
 }
 
-AVVideoCaptureSource::AVVideoCaptureSource(AVCaptureDevice* device, String&& id, String&& hashSalt)
-    : RealtimeVideoCaptureSource(device.localizedName, WTFMove(id), WTFMove(hashSalt))
+AVVideoCaptureSource::AVVideoCaptureSource(AVCaptureDevice* avDevice, const CaptureDevice& device, String&& hashSalt)
+    : RealtimeVideoCaptureSource(String(device.label()), String(device.persistentId()), WTFMove(hashSalt))
     , m_objcObserver(adoptNS([[WebCoreAVVideoCaptureSourceObserver alloc] initWithCallback:this]))
-    , m_device(device)
+    , m_device(avDevice)
     , m_verifyCapturingTimer(*this, &AVVideoCaptureSource::verifyIsCapturing)
 {
     [m_device addObserver:m_objcObserver.get() forKeyPath:@"suspended" options:NSKeyValueObservingOptionNew context:(void *)nil];

Modified: trunk/Source/WebCore/platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp (290819 => 290820)


--- trunk/Source/WebCore/platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp	2022-03-04 07:55:10 UTC (rev 290819)
+++ trunk/Source/WebCore/platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp	2022-03-04 08:07:31 UTC (rev 290820)
@@ -48,7 +48,7 @@
     CaptureSourceOrError createVideoCaptureSource(const CaptureDevice& device, String&& hashSalt, const MediaConstraints* constraints) final
     {
         ASSERT(device.type() == CaptureDevice::DeviceType::Camera);
-        return AVVideoCaptureSource::create(String { device.persistentId() }, WTFMove(hashSalt), constraints);
+        return AVVideoCaptureSource::create(device, WTFMove(hashSalt), constraints);
     }
 
 private:
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to