mirror of
https://github.com/serratus/quaggaJS.git
synced 2026-08-12 21:21:42 +08:00
Closes #167; Removed dependency on webrtc-adapter; Removed workaround for facing-mode that is not needed any more when using the latest version of webrtc-adapter;
This commit is contained in:
@@ -69,42 +69,15 @@ function deprecatedConstraints(videoConstraints) {
|
||||
return normalized;
|
||||
}
|
||||
|
||||
function pickDevice(constraints) {
|
||||
const desiredFacing = constraints.video.facingMode,
|
||||
facingMatch = facingMatching[desiredFacing];
|
||||
|
||||
if (!facingMatch) {
|
||||
return Promise.resolve(constraints);
|
||||
}
|
||||
return enumerateDevices()
|
||||
.then(devices => {
|
||||
const selectedDeviceId = devices
|
||||
.filter(device => device.kind === 'videoinput' && facingMatch.test(device.label))
|
||||
.map(facingDevice => facingDevice.deviceId)[0];
|
||||
if (selectedDeviceId) {
|
||||
constraints = {
|
||||
...constraints,
|
||||
video: {
|
||||
...omit(constraints.video, ["facingMode"]),
|
||||
deviceId: selectedDeviceId,
|
||||
}
|
||||
};
|
||||
}
|
||||
return Promise.resolve(constraints);
|
||||
});
|
||||
}
|
||||
|
||||
export function pickConstraints(videoConstraints) {
|
||||
const normalizedConstraints = {
|
||||
audio: false,
|
||||
video: deprecatedConstraints(videoConstraints)
|
||||
};
|
||||
|
||||
if (!normalizedConstraints.video.deviceId) {
|
||||
if (typeof normalizedConstraints.video.facingMode === 'string'
|
||||
&& normalizedConstraints.video.facingMode.length > 0) {
|
||||
return pickDevice(normalizedConstraints);
|
||||
}
|
||||
if (normalizedConstraints.video.deviceId
|
||||
&& normalizedConstraints.video.facingMode) {
|
||||
delete normalizedConstraints.video.facingMode;
|
||||
}
|
||||
return Promise.resolve(normalizedConstraints);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import TypeDefs from './common/typedefs'; // eslint-disable-line no-unused-vars
|
||||
import WebrtcAdapter from 'webrtc-adapter'; // eslint-disable-line no-unused-vars
|
||||
import ImageWrapper from './common/image_wrapper';
|
||||
import BarcodeLocator from './locator/barcode_locator';
|
||||
import BarcodeDecoder from './decoder/barcode_decoder';
|
||||
|
||||
Reference in New Issue
Block a user