diff options
author | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2020-09-24 09:11:13 +0300 |
---|---|---|
committer | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2020-09-24 15:16:53 +0300 |
commit | 9a902a7256dea9dba44c18aa41c2170bee8ba48e (patch) | |
tree | 759d106d9f4c47499a53cc1434c56ea950b637c0 /src | |
parent | 0926044bca3b2ffb1d4c254b4e398a33ea9592d1 (diff) |
Ensure that devices were enumerated when starting the local media
When starting the local media for the first time the media devices could
have not been enumerated yet, so even if the remembered devices are
available they were not used in the first "getUserMedia" request.
However, as the devices are enumerated after getting the user media (as
that is the only time when it is guaranteed that the full device
information can be got) this caused the remembered devices to be then
found and further "getUserMedia" requests to be made for them.
To avoid an initial "getUserMedia" request with default ids followed by
other requests with the remembered ones now the media devices are tried
to be enumerated before starting a call.
This does not guarantee that the extra "getUserMedia" requests will be
avoided, as if persistent media permissions are not granted the browser
may not provide the full device IDs, but at least avoids them in some
cases.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/utils/webrtc/simplewebrtc/localmedia.js | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/utils/webrtc/simplewebrtc/localmedia.js b/src/utils/webrtc/simplewebrtc/localmedia.js index fc9fea051..35c1563a9 100644 --- a/src/utils/webrtc/simplewebrtc/localmedia.js +++ b/src/utils/webrtc/simplewebrtc/localmedia.js @@ -138,6 +138,12 @@ LocalMedia.prototype.start = function(mediaConstraints, cb, context) { this.emit('localStreamRequested', constraints, context) + if (!context) { + // Try to get the devices list before getting user media. + webrtcIndex.mediaDevicesManager.enableDeviceEvents() + webrtcIndex.mediaDevicesManager.disableDeviceEvents() + } + webrtcIndex.mediaDevicesManager.getUserMedia(constraints).then(function(stream) { // Although the promise should be resolved only if all the constraints // are met Edge resolves it if both audio and video are requested but |