Impossible to create 2 streams with 2 different camera using getUserMedia({deviceId: {ideal: id}})
Categories
(Core :: WebRTC: Audio/Video, defect, P3)
Tracking
()
People
(Reporter: frederic.luart, Unassigned)
Details
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.30 Safari/537.36
Steps to reproduce:
Firefox 77.0.1 on Mac OS 10.15.4
Try to create two video stream with getUserMedia and different deviceId
Here is a page to reproduce the issue :
https://jsfiddle.net/FredLuart/90v1Lnst/
Actual results:
Two video stream are created but with the first selected camera/deviceId
Expected results:
Two video stream with different camera
Comment 1•6 years ago
|
||
Bugbug thinks this bug should belong to this component, but please revert this change in case of error.
Comment 2•6 years ago
|
||
If you look at the console your code set both videoDeviceId* variables with the same device id. In my case:
videoDeviceId1 : lY5vbroQyGnZft0R0M3XFPo10quBYzbmzecJtKqWwb0=
videoDeviceId2 : lY5vbroQyGnZft0R0M3XFPo10quBYzbmzecJtKqWwb0=
I have just done the test again and it is working on my side :
Here is my console logs :
"videoDeviceId1 :", "zW3oZCnSf5297xR8gistPBytdRwKf6mAurHgWGihqic="
"videoDeviceId2 :", "FOzeywQ+h3dLDUJXf6/JykF/NOJUhTb36ylHIwx+l08="
"createStream with constraints :", {
audio: false,
video: {
deviceId: "zW3oZCnSf5297xR8gistPBytdRwKf6mAurHgWGihqic="
}
}
"createStream with constraints :", {
audio: false,
video: {
deviceId: "FOzeywQ+h3dLDUJXf6/JykF/NOJUhTb36ylHIwx+l08="
}
}
Result :
With Chrome : two different video stream with the two camera
On Firefox : two stream with same camera
Comment 4•6 years ago
|
||
Ok, thanks, I'll have a second look.
Comment 5•6 years ago
•
|
||
You need the exact in constrains to open the second device. Something like:
var constraints = {
audio: false,
video: {
deviceId : { exact: deviceId }
}
};
I don't know why it does not work without it. Jib, does the spec say anything specific about it?
OK, thanks Alex. It is working with 'exact'.
I tested it with 'ideal' that is not working : usage of 'exact' is already a good workaround for me
Comment 7•6 years ago
|
||
(In reply to Alex Chronopoulos [:achronop] from comment #5)
You need the
exactin constrains to open the second device. ... I don't know why it does not work without it. Jib, does the spec say anything specific about it?
The spec says on ideal constraints: "The decision of which track to choose from the finalSet is completely up to the User Agent and may be determined by asking the user." and "[It] MAY use the value of the computed "fitness distance" from the SelectSettings algorithm"
The choice in this case is between A) returning a camera you already have access to, or B) prompt. Ironically, Firefox chooses A for web compat with Chrome, due to a bad web-dev habit of using getUserMedia all over the place (probably large pieces of code with lots of different libraries) as a lazy-getter for the same source.
This may have made sense for other constraints, but it seems fairly clear it's the wrong answer for deviceId. We should consider fixing this. Thanks for filing this Fred!
Updated•6 years ago
|
Thanks for feedback. Do you know the first version that support 'exact' constraint ? is it version 55 ?
Updated•1 year ago
|
Description
•