Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Resolved] enumerateDevices index order is reversed #392

Closed
partnerparticle opened this issue Sep 29, 2019 · 5 comments
Closed

[Resolved] enumerateDevices index order is reversed #392

partnerparticle opened this issue Sep 29, 2019 · 5 comments
Assignees
Labels
Milestone

Comments

@partnerparticle
Copy link

In 5.0.1 the result of video devices from calling enumerateDevices was 0 for back camera and 1 for front camera.
In 5.0.3 (I skipped/did not test with 5.0.2) these indexes got reversed.
Is this on purpose, or an unwanted side effect?

From the logs it seems that first the indexes are correct (iosrtcPlugin#enumerateDevices()), then in the log of osrtc:enumerateDevices getMediaDeviceInfos() they are reversed.

  • Cordova version:
  • Plugin version:
    5.0.3
  • iOS version:
    12.4.1
  • Xcode version:
    10.3(10G8)

Logs attached

iosrtc_enumerateDevices_5.0.3.txt

@hthetiot hthetiot added this to the 5.0.4 milestone Sep 30, 2019
@hthetiot hthetiot self-assigned this Sep 30, 2019
@hthetiot hthetiot added the bug label Sep 30, 2019
@partnerparticle
Copy link
Author

log from 5.0.1, you can see the difference

iosrtc_enumerateDevices_5.0.1.txt

@hthetiot
Copy link
Contributor

hthetiot commented Sep 30, 2019

The change that cause the "issue" is the following: 558fcf3#diff-5a0cc8b323d62f1b113d553a63024544

But technically nowhere in WebRTC Spec it claim that front camera should be first in navigator.mediaDevices.enumerateDevices array and com.apple.avfoundation.avcapturedevice.built-in_video:0 always been back and com.apple.avfoundation.avcapturedevice.built-in_video:1 front, the order should not be an issue, instead you should order your Array if you display it to handle custom order from label (Front Cameravs Back Camera) as any platform can return a different order or number of devices if actually want to have specific order, note also that MediaDeviceInfo.facing is deprecated.

Now, because it look like you are not the only one with that problem, I have made a fix in order to restore the original order of 5.0.1 by putting AVCaptureDevice.Position.front at the begening of the videoinput list programmatically e6ff78b will be released on 5.0.4.

Note: We should add MediaDeviceInfo.getCapabilities support in the future and navigator.mediaDevices.getSupportedConstraints support instead to properly handle facingMode (https://www.w3.org/TR/mediacapture-streams/#dom-inputdeviceinfo-getcapabilities, https://www.w3.org/TR/mediacapture-streams/#media-track-supported-constraints)

@hthetiot
Copy link
Contributor

hthetiot commented Oct 3, 2019

Note: Will leave that issue open until 5.0.4 release to avoid duplicate reports and let the community know about the issue.

@hthetiot hthetiot changed the title enumerateDevices index order is reversed [Resolved] enumerateDevices index order is reversed Oct 3, 2019
@hthetiot hthetiot closed this as completed Oct 4, 2019
@partnerparticle
Copy link
Author

partnerparticle commented Oct 4, 2019

You are right, there is no such spec. I was using indexes, because on Android the labels are empty (Samsung Galaxy S9) when I call enumerateDevices, so I could not filter by any info, hence I relied on indexes being the same (using reverseArray on android to get the desired camera always on index 0).
If one can count on label being provided by this plugin, then as you suggested, a more future proof approach would be to use the label (on ios) rather than the index.

@rejebsab
Copy link

rejebsab commented Apr 9, 2020

Hi All,

Have you already added the MediaStreamTrack.getCapabilities() feature? If not yet, have you any release date please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants