mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-11 15:07:07 +00:00
Merge pull request #1646 in FS/freeswitch from ~MARCELL-G/freeswitch:bugfix/FS-11370-device-id-fallback-by-its-label to master
* commit '5075e54425466b3abb3de3a2943fbc7a03dcefbc': FS-11370 [verto_communicator] verto may rely on device labels to assure correct mic/cam selection
This commit is contained in:
commit
788a1bfa70
html5/verto/js/src
@ -455,9 +455,11 @@
|
||||
audio: false,
|
||||
video: { deviceId: params.useCamera },
|
||||
},
|
||||
localVideo: self.options.localVideo,
|
||||
localVideo: self.options.localVideo,
|
||||
useCameraLabel: self.options.useCameraLabel,
|
||||
useMicLabel: self.options.useMicLabel,
|
||||
onsuccess: function(e) {self.options.localVideoStream = e; console.log("local video ready");},
|
||||
onerror: function(e) {console.error("local video error!");}
|
||||
onerror: function(e) {console.error("local video error!", e);}
|
||||
});
|
||||
}
|
||||
|
||||
@ -477,6 +479,8 @@
|
||||
video: mediaParams.video
|
||||
},
|
||||
video: mediaParams.useVideo,
|
||||
useCameraLabel: self.options.useCameraLabel,
|
||||
useMicLabel: self.options.useMicLabel,
|
||||
onsuccess: onSuccess,
|
||||
onerror: onError
|
||||
});
|
||||
@ -504,7 +508,7 @@
|
||||
|
||||
if (obj.options.useMic !== "any") {
|
||||
//audio.optional = [{sourceId: obj.options.useMic}];
|
||||
audio.deviceId = {exact: obj.options.useMic};
|
||||
audio.deviceId = assignMediaIdToConstraint(obj.options.useMic);
|
||||
}
|
||||
}
|
||||
|
||||
@ -514,9 +518,11 @@
|
||||
audio: false,
|
||||
video: { deviceId: obj.options.useCamera },
|
||||
},
|
||||
localVideo: obj.options.localVideo,
|
||||
localVideo: obj.options.localVideo,
|
||||
useCameraLabel: obj.options.useCameraLabel,
|
||||
useMicLabel: obj.options.useMicLabel,
|
||||
onsuccess: function(e) {obj.options.localVideoStream = e; console.log("local video ready");},
|
||||
onerror: function(e) {console.error("local video error!");}
|
||||
onerror: function(e) {console.error("local video error!", e); }
|
||||
});
|
||||
}
|
||||
|
||||
@ -571,9 +577,7 @@
|
||||
|
||||
if (obj.options.useCamera !== "any") {
|
||||
//video.optional.push({sourceId: obj.options.useCamera});
|
||||
video.deviceId = {
|
||||
exact: obj.options.useCamera,
|
||||
};
|
||||
video = assignMediaIdToConstraint(obj.options.useCamera, video);
|
||||
}
|
||||
|
||||
if (bestFrameRate) {
|
||||
@ -661,7 +665,6 @@
|
||||
onSuccess(self.options.useStream);
|
||||
}
|
||||
else if (mediaParams.audio || mediaParams.video) {
|
||||
|
||||
getUserMedia({
|
||||
constraints: {
|
||||
audio: mediaParams.audio,
|
||||
@ -669,7 +672,9 @@
|
||||
},
|
||||
video: mediaParams.useVideo,
|
||||
onsuccess: onSuccess,
|
||||
onerror: onError
|
||||
onerror: onError,
|
||||
useCameraLabel: self.options.useCameraLabel,
|
||||
useMicLabel: self.options.useMicLabel,
|
||||
});
|
||||
|
||||
} else {
|
||||
@ -977,32 +982,77 @@
|
||||
el.style.display = 'none';
|
||||
}
|
||||
|
||||
function getUserMedia(options) {
|
||||
var n = navigator,
|
||||
media;
|
||||
n.getMedia = n.getUserMedia;
|
||||
n.getMedia(options.constraints || {
|
||||
audio: true,
|
||||
video: video_constraints
|
||||
},
|
||||
streaming, options.onerror ||
|
||||
function(e) {
|
||||
console.error(e);
|
||||
});
|
||||
function assureConstraintByLabel(constraint, fallbackLabel) {
|
||||
if (fallbackLabel === undefined && constraint === undefined) {
|
||||
return Promise.resolve(constraint);
|
||||
}
|
||||
|
||||
function streaming(stream) {
|
||||
if (typeof(assureMediaInputId) !== 'function') {
|
||||
console.warn('Tried to use constraint fallbacks but did not found vendor function `assureMediaInputId` on window scope. Did you forget to import `vendor/media-device-id.js` before Verto?');
|
||||
return Promise.resolve(constraint);
|
||||
}
|
||||
|
||||
if (typeof(constraint) === 'object' && !constraint.deviceId) {
|
||||
return Promise.resolve(constraint);
|
||||
}
|
||||
|
||||
if (constraint.deviceId) {
|
||||
if (typeof(constraint.deviceId) === 'string') {
|
||||
return new Promise(function(resolve) {
|
||||
assureMediaInputId(fallbackLabel, constraint.deviceId).then(function(id) {
|
||||
resolve(Object.assign({}, constraint, { deviceId: id }));
|
||||
}).catch(function() {
|
||||
resolve(constraint);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (typeof(constraint.deviceId) === 'object' && typeof(constraint.deviceId.exact) === 'string') {
|
||||
return new Promise(function(resolve) {
|
||||
assureMediaInputId(fallbackLabel, constraint.deviceId.exact).then(function(id) {
|
||||
resolve(assignMediaIdToConstraint(id, constraint));
|
||||
}).catch(function() {
|
||||
resolve(constraint);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return Promise.resolve(constraint);
|
||||
}
|
||||
|
||||
function trustyGetUserMedia(options, constraints) {
|
||||
navigator.mediaDevices.getUserMedia(constraints).then(function(stream) {
|
||||
if (options.localVideo) {
|
||||
activateLocalVideo(options.localVideo, stream);
|
||||
activateLocalVideo(options.localVideo, stream);
|
||||
}
|
||||
|
||||
if (options.onsuccess) {
|
||||
options.onsuccess(stream);
|
||||
}
|
||||
}).catch(options.onerror || function(e) {
|
||||
console.error(e);
|
||||
});
|
||||
}
|
||||
|
||||
media = stream;
|
||||
}
|
||||
function assignMediaIdToConstraint(mediaId, rest) {
|
||||
return Object.assign({}, rest || {}, { deviceId: { exact: mediaId } });
|
||||
}
|
||||
|
||||
return media;
|
||||
function getUserMedia(options) {
|
||||
var constraints = options.constraints || {
|
||||
audio: true,
|
||||
video: video_constraints,
|
||||
};
|
||||
|
||||
Promise.all([
|
||||
assureConstraintByLabel(constraints.audio, options.useMicLabel),
|
||||
assureConstraintByLabel(constraints.video, options.useCameraLabel),
|
||||
]).then(function(assurances) {
|
||||
trustyGetUserMedia(options, { audio: assurances[0], video: assurances[1] });
|
||||
}).catch(function(error) {
|
||||
console.error('Unexpected error on media id assurance attempts:', error, 'Options:', options);
|
||||
});
|
||||
}
|
||||
|
||||
$.FSRTC.resSupported = function(w, h) {
|
||||
@ -1056,9 +1106,7 @@
|
||||
};
|
||||
|
||||
if (cam !== "any") {
|
||||
video.deviceId = {
|
||||
exact: cam,
|
||||
};
|
||||
video = assignMediaIdToConstraint(cam, video);
|
||||
}
|
||||
|
||||
getUserMedia({
|
||||
|
@ -462,6 +462,7 @@
|
||||
|
||||
if (args["useCamera"]) {
|
||||
verto.options.deviceParams["useCamera"] = args["useCamera"];
|
||||
verto.options.deviceParams["useCameraLabel"] = args["useCameraLabel"];
|
||||
}
|
||||
|
||||
var dialog = new $.verto.dialog($.verto.enum.direction.outbound, this, args);
|
||||
@ -1938,6 +1939,7 @@
|
||||
screenShare: false,
|
||||
useCamera: false,
|
||||
useMic: verto.options.deviceParams.useMic,
|
||||
useMicLabel: verto.options.deviceParams.useMicLabel,
|
||||
useSpeak: verto.options.deviceParams.useSpeak,
|
||||
tag: verto.options.tag,
|
||||
localTag: verto.options.localTag,
|
||||
@ -1949,6 +1951,7 @@
|
||||
|
||||
if (!dialog.params.screenShare) {
|
||||
dialog.params.useCamera = verto.options.deviceParams.useCamera;
|
||||
dialog.params.useCameraLabel = verto.options.deviceParams.useCameraLabel;
|
||||
}
|
||||
|
||||
dialog.verto = verto;
|
||||
@ -1960,7 +1963,9 @@
|
||||
dialog.attach = params.attach || false;
|
||||
dialog.screenShare = params.screenShare || false;
|
||||
dialog.useCamera = dialog.params.useCamera;
|
||||
dialog.useCameraLabel = dialog.params.useCameraLabel;
|
||||
dialog.useMic = dialog.params.useMic;
|
||||
dialog.useMicLabel = dialog.params.useMicLabel;
|
||||
dialog.useSpeak = dialog.params.useSpeak;
|
||||
|
||||
if (dialog.params.callID) {
|
||||
@ -2099,7 +2104,9 @@
|
||||
iceServers: verto.options.iceServers,
|
||||
screenShare: dialog.screenShare,
|
||||
useCamera: dialog.useCamera,
|
||||
useCameraLabel: dialog.useCameraLabel,
|
||||
useMic: dialog.useMic,
|
||||
useMicLabel: dialog.useMicLabel,
|
||||
useSpeak: dialog.useSpeak,
|
||||
turnServer: verto.options.turnServer,
|
||||
useStream: dialog.params.useStream
|
||||
@ -2551,11 +2558,13 @@
|
||||
dialog.params.callee_id_number = params.callee_id_number;
|
||||
|
||||
if (params.useCamera) {
|
||||
dialog.useCamera = params.useCamera;
|
||||
dialog.useCamera = params.useCamera;
|
||||
dialog.useCameraLabel = params.useCameraLabel;
|
||||
}
|
||||
|
||||
if (params.useMic) {
|
||||
dialog.useMic = params.useMic;
|
||||
dialog.useMic = params.useMic;
|
||||
dialog.useMic = params.useMicLabel;
|
||||
}
|
||||
|
||||
if (params.useSpeak) {
|
||||
|
1
html5/verto/js/src/vendor/media-device-id.min.js
vendored
Normal file
1
html5/verto/js/src/vendor/media-device-id.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user