Title: [247596] branches/safari-608-branch/Source/WebCore
Revision
247596
Author
kocsen_ch...@apple.com
Date
2019-07-18 13:24:03 -0700 (Thu, 18 Jul 2019)

Log Message

Cherry-pick r247489. rdar://problem/53229754

    [iOS] Make sure the first camera device in the list is the front camera
    https://bugs.webkit.org/show_bug.cgi?id=199811
    <rdar://problem/53125157>

    Reviewed by Jer Noble.

    Some websites call getUserMedia with a deviceId constraint and theey pick the
    first deviceId in the list provided by enumerateDevices.
    On iOS, this is the back camera which is often not what is expected by WebRTC applications.
    Instead, make sure the first camera device is the front camera.

    Manually tested.

    * platform/mediastream/mac/AVCaptureDeviceManager.mm:

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

Modified Paths

Diff

Modified: branches/safari-608-branch/Source/WebCore/ChangeLog (247595 => 247596)


--- branches/safari-608-branch/Source/WebCore/ChangeLog	2019-07-18 20:24:01 UTC (rev 247595)
+++ branches/safari-608-branch/Source/WebCore/ChangeLog	2019-07-18 20:24:03 UTC (rev 247596)
@@ -1,5 +1,44 @@
 2019-07-17  Kocsen Chung  <kocsen_ch...@apple.com>
 
+        Cherry-pick r247489. rdar://problem/53229754
+
+    [iOS] Make sure the first camera device in the list is the front camera
+    https://bugs.webkit.org/show_bug.cgi?id=199811
+    <rdar://problem/53125157>
+    
+    Reviewed by Jer Noble.
+    
+    Some websites call getUserMedia with a deviceId constraint and theey pick the
+    first deviceId in the list provided by enumerateDevices.
+    On iOS, this is the back camera which is often not what is expected by WebRTC applications.
+    Instead, make sure the first camera device is the front camera.
+    
+    Manually tested.
+    
+    * platform/mediastream/mac/AVCaptureDeviceManager.mm:
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247489 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-07-16  Youenn Fablet  <you...@apple.com>
+
+            [iOS] Make sure the first camera device in the list is the front camera
+            https://bugs.webkit.org/show_bug.cgi?id=199811
+            <rdar://problem/53125157>
+
+            Reviewed by Jer Noble.
+
+            Some websites call getUserMedia with a deviceId constraint and theey pick the
+            first deviceId in the list provided by enumerateDevices.
+            On iOS, this is the back camera which is often not what is expected by WebRTC applications.
+            Instead, make sure the first camera device is the front camera.
+
+            Manually tested.
+
+            * platform/mediastream/mac/AVCaptureDeviceManager.mm:
+
+2019-07-17  Kocsen Chung  <kocsen_ch...@apple.com>
+
         Cherry-pick r247487. rdar://problem/53229629
 
     Remove "GraphicsContext 0x7ffd8765f6b0 stack changed by" logging

Modified: branches/safari-608-branch/Source/WebCore/platform/mediastream/mac/AVCaptureDeviceManager.mm (247595 => 247596)


--- branches/safari-608-branch/Source/WebCore/platform/mediastream/mac/AVCaptureDeviceManager.mm	2019-07-18 20:24:01 UTC (rev 247595)
+++ branches/safari-608-branch/Source/WebCore/platform/mediastream/mac/AVCaptureDeviceManager.mm	2019-07-18 20:24:03 UTC (rev 247596)
@@ -145,6 +145,11 @@
     return devices[0].persistentId() == defaultDeviceID;
 }
 
+static inline bool isVideoDevice(AVCaptureDevice *device)
+{
+    return [device hasMediaType:AVMediaTypeVideo] || [device hasMediaType:AVMediaTypeMuxed];
+}
+
 void AVCaptureDeviceManager::refreshCaptureDevices()
 {
     if (!m_avCaptureDevices) {
@@ -158,7 +163,21 @@
     Vector<CaptureDevice> deviceList;
 
     auto* defaultVideoDevice = [PAL::getAVCaptureDeviceClass() defaultDeviceWithMediaType: AVMediaTypeVideo];
+#if PLATFORM(IOS)
+    if ([defaultVideoDevice position] != AVCaptureDevicePositionFront) {
+        defaultVideoDevice = nullptr;
+        for (AVCaptureDevice *platformDevice in currentDevices) {
+            if (!isVideoDevice(platformDevice))
+                continue;
 
+            if ([platformDevice position] == AVCaptureDevicePositionFront) {
+                defaultVideoDevice = platformDevice;
+                break;
+            }
+        }
+    }
+#endif
+
     bool deviceHasChanged = false;
     if (defaultVideoDevice) {
         deviceList.append(toCaptureDevice(defaultVideoDevice));
@@ -165,7 +184,7 @@
         deviceHasChanged = !isDefaultVideoCaptureDeviceFirst(captureDevices(), defaultVideoDevice.uniqueID);
     }
     for (AVCaptureDevice *platformDevice in currentDevices) {
-        if (![platformDevice hasMediaType:AVMediaTypeVideo] && ![platformDevice hasMediaType:AVMediaTypeMuxed])
+        if (!isVideoDevice(platformDevice))
             continue;
 
         if (!deviceHasChanged && !isMatchingExistingCaptureDevice(platformDevice))
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to