Skip to content

Commit

Permalink
fix(rtc) use exact deviceId constraints
Browse files Browse the repository at this point in the history
webrtc-adapter transforms "deviceId": "foo" to "deviceId": { ideal:
"foo"}.

This makes the camera non-selectable if the resolution constraints are
not met.

Setting the constraint to exact will sidestep that adapter behavior, and
express stronger intent.
  • Loading branch information
saghul committed Apr 5, 2024
1 parent b035680 commit b59b8cb
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions modules/RTC/RTCUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ function getConstraints(um = [], options = {}) {
}
}
if (options.cameraDeviceId) {
constraints.video.deviceId = options.cameraDeviceId;
constraints.video.deviceId = { exact: options.cameraDeviceId };
} else {
const facingMode = options.facingMode || CameraFacingMode.USER;

Expand All @@ -139,11 +139,14 @@ function getConstraints(um = [], options = {}) {

constraints.audio = {
autoGainControl: !disableAGC && !disableAP,
deviceId: options.micDeviceId,
echoCancellation: !disableAEC && !disableAP,
noiseSuppression: !disableNS && !disableAP
};

if (options.micDeviceId) {
constraints.audio.deviceId = { exact: options.micDeviceId };
}

if (stereo) {
Object.assign(constraints.audio, { channelCount: 2 });
}
Expand Down

0 comments on commit b59b8cb

Please sign in to comment.