Changeset 258837 in webkit


Ignore:
Timestamp:
Mar 23, 2020 7:24:19 AM (4 years ago)
Author:
youenn@apple.com
Message:

MediaDevices::refreshDevices should take device type into account
https://bugs.webkit.org/show_bug.cgi?id=209417
<rdar://problem/60521332>

Reviewed by Eric Carlson.

Source/WebCore:

Now that we set deviceId to the empty string when media capture is not granted,
we can have two devices with the same ID. We also need to handle the device type.

  • Modules/mediastream/MediaDevices.cpp:

(WebCore::MediaDevices::refreshDevices):

LayoutTests:

  • fast/mediastream/media-device-info-expected.txt:
  • fast/mediastream/media-device-info.html:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r258826 r258837  
     12020-03-23  youenn fablet  <youenn@apple.com>
     2
     3        MediaDevices::refreshDevices should take device type into account
     4        https://bugs.webkit.org/show_bug.cgi?id=209417
     5        <rdar://problem/60521332>
     6
     7        Reviewed by Eric Carlson.
     8
     9        * fast/mediastream/media-device-info-expected.txt:
     10        * fast/mediastream/media-device-info.html:
     11
    1122020-03-22  Antoine Quint  <graouts@apple.com>
    213
  • trunk/LayoutTests/fast/mediastream/media-device-info-expected.txt

    r217476 r258837  
    11
    22PASS Test properties of MediaDeviceInfo
     3PASS Ensure enumerateDevices exposes both microphone and camera
    34
  • trunk/LayoutTests/fast/mediastream/media-device-info.html

    r217476 r258837  
    77    <script src="../../resources/testharnessreport.js"></script>
    88    <script>
    9     var devices = [];
    10 
    11     if (window.testRunner)
    12         testRunner.setUserMediaPermission(true);
    13 
    149    promise_test((test) => {
    1510        return navigator.mediaDevices.enumerateDevices()
     
    3429    }, "Test properties of MediaDeviceInfo");
    3530
     31    promise_test(async (test) => {
     32        await navigator.mediaDevices.enumerateDevices();
     33        const devices = await navigator.mediaDevices.enumerateDevices();
     34        assert_equals(devices.length, 2);
     35        assert_equals(devices[0].kind, "audioinput");
     36        assert_equals(devices[1].kind, "videoinput");
     37    }, "Ensure enumerateDevices exposes both microphone and camera");
    3638    </script>
    3739</head>
  • trunk/Source/WebCore/ChangeLog

    r258836 r258837  
     12020-03-23  youenn fablet  <youenn@apple.com>
     2
     3        MediaDevices::refreshDevices should take device type into account
     4        https://bugs.webkit.org/show_bug.cgi?id=209417
     5        <rdar://problem/60521332>
     6
     7        Reviewed by Eric Carlson.
     8
     9        Now that we set deviceId to the empty string when media capture is not granted,
     10        we can have two devices with the same ID. We also need to handle the device type.
     11
     12        * Modules/mediastream/MediaDevices.cpp:
     13        (WebCore::MediaDevices::refreshDevices):
     14
    1152020-03-23  Zalan Bujtas  <zalan@apple.com>
    216
  • trunk/Source/WebCore/Modules/mediastream/MediaDevices.cpp

    r256034 r258837  
    182182            continue;
    183183
    184         auto index = m_devices.findMatching([&newDevice](auto& oldDevice) {
    185             return oldDevice->deviceId() == newDevice.persistentId();
     184        auto deviceKind = newDevice.type() == CaptureDevice::DeviceType::Microphone ? MediaDeviceInfo::Kind::Audioinput : MediaDeviceInfo::Kind::Videoinput;
     185        auto index = m_devices.findMatching([deviceKind, &newDevice](auto& oldDevice) {
     186            return oldDevice->deviceId() == newDevice.persistentId() && oldDevice->kind() == deviceKind;
    186187        });
    187188        if (index != notFound) {
     
    190191        }
    191192
    192         auto deviceType = newDevice.type() == CaptureDevice::DeviceType::Microphone ? MediaDeviceInfo::Kind::Audioinput : MediaDeviceInfo::Kind::Videoinput;
    193         devices.append(MediaDeviceInfo::create(newDevice.label(), newDevice.persistentId(), newDevice.groupId(), deviceType));
     193        devices.append(MediaDeviceInfo::create(newDevice.label(), newDevice.persistentId(), newDevice.groupId(), deviceKind));
    194194    }
    195195    m_devices = WTFMove(devices);
Note: See TracChangeset for help on using the changeset viewer.