Merge pull request #453 in FS/freeswitch from ~JMESQUITA/freeswitch:bugfix/FS-8043-doesn-t-appear-to-use-the-selected to master
* commit '045550b00f13455fbbd1675d9387e9fa229e08aa': FS-8043: [verto_communicator] Adjust to improved verto API and refactor how we select cameras
This commit is contained in:
commit
2a5d664c85
|
@ -110,6 +110,7 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', 'stora
|
||||||
videoDevices: [],
|
videoDevices: [],
|
||||||
audioDevices: [],
|
audioDevices: [],
|
||||||
shareDevices: [],
|
shareDevices: [],
|
||||||
|
videoQuality: [],
|
||||||
extension: $cookieStore.get('verto_demo_ext'),
|
extension: $cookieStore.get('verto_demo_ext'),
|
||||||
name: $cookieStore.get('verto_demo_name'),
|
name: $cookieStore.get('verto_demo_name'),
|
||||||
email: $cookieStore.get('verto_demo_email'),
|
email: $cookieStore.get('verto_demo_email'),
|
||||||
|
@ -155,34 +156,34 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', 'stora
|
||||||
$rootScope.$emit('call.incoming', number);
|
$rootScope.$emit('call.incoming', number);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getVideoParams() {
|
function updateResolutions(supportedResolutions) {
|
||||||
var maxWidth, maxHeight;
|
console.debug('Attempting to sync supported and available resolutions');
|
||||||
|
|
||||||
maxWidth = data.bestWidth;
|
var removed = 0;
|
||||||
maxHeight = data.bestHeight;
|
|
||||||
|
|
||||||
if(!data.bestWidth) {
|
angular.forEach(videoQuality, function(resolution, id) {
|
||||||
if (videoResolution[data.vidQual]) {
|
var supported = false;
|
||||||
maxWidth = videoResolution[data.vidQual].width;
|
angular.forEach(supportedResolutions, function(res) {
|
||||||
|
var width = res[0];
|
||||||
|
var height = res[1];
|
||||||
|
|
||||||
|
if(resolution.width == width && resolution.height == height) {
|
||||||
|
supported = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if(!supported) {
|
||||||
|
delete videoQuality[id];
|
||||||
|
++removed;
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
if(!data.bestHeight) {
|
videoQuality.length = videoQuality.length - removed;
|
||||||
if (videoResolution[data.vidQual]) {
|
data.videoQuality = videoQuality;
|
||||||
maxHeight = videoResolution[data.vidQual].height;
|
data.vidQual = (videoQuality.length > 0) ? videoQuality[videoQuality.length - 1].id : null;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return videoQuality;
|
||||||
minWidth: videoResolution[data.vidQual].width,
|
};
|
||||||
minHeight: videoResolution[data.vidQual].height,
|
|
||||||
maxWidth: maxWidth,
|
|
||||||
maxHeight: maxHeight,
|
|
||||||
minFrameRate: 15,
|
|
||||||
vertoBestFrameRate: 30
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
var callState = {
|
var callState = {
|
||||||
muteMic: false,
|
muteMic: false,
|
||||||
|
@ -199,120 +200,124 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', 'stora
|
||||||
videoResolution: videoResolution,
|
videoResolution: videoResolution,
|
||||||
bandwidth: bandwidth,
|
bandwidth: bandwidth,
|
||||||
|
|
||||||
refreshDevices: function(callback) {
|
refreshDevicesCallback : function refreshDevicesCallback() {
|
||||||
console.debug('Attempting to refresh the devices.');
|
data.videoDevices = [];
|
||||||
function refreshDevicesCallback() {
|
data.shareDevices = [{
|
||||||
data.videoDevices = [{
|
id: 'screen',
|
||||||
|
label: 'Screen'
|
||||||
|
}];
|
||||||
|
data.audioDevices = [];
|
||||||
|
|
||||||
|
for (var i in jQuery.verto.videoDevices) {
|
||||||
|
var device = jQuery.verto.videoDevices[i];
|
||||||
|
if (!device.label) {
|
||||||
|
data.videoDevices.push({
|
||||||
|
id: 'Camera ' + i,
|
||||||
|
label: 'Camera ' + i
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
data.videoDevices.push({
|
||||||
|
id: device.id,
|
||||||
|
label: device.label || device.id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Selecting the first source.
|
||||||
|
if (i == 0) {
|
||||||
|
storage.data.selectedVideo = device.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!device.label) {
|
||||||
|
data.shareDevices.push({
|
||||||
|
id: 'Share Device ' + i,
|
||||||
|
label: 'Share Device ' + i
|
||||||
|
});
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
data.shareDevices.push({
|
||||||
|
id: device.id,
|
||||||
|
label: device.label || device.id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i in jQuery.verto.audioInDevices) {
|
||||||
|
var device = jQuery.verto.audioInDevices[i];
|
||||||
|
// Selecting the first source.
|
||||||
|
if (i == 0) {
|
||||||
|
storage.data.selectedAudio = device.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!device.label) {
|
||||||
|
data.audioDevices.push({
|
||||||
|
id: 'Microphone ' + i,
|
||||||
|
label: 'Microphone ' + i
|
||||||
|
});
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
data.audioDevices.push({
|
||||||
|
id: device.id,
|
||||||
|
label: device.label || device.id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
console.debug('Devices were refreshed, checking that we have cameras.');
|
||||||
|
|
||||||
|
// This means that we cannot use video!
|
||||||
|
if (data.videoDevices.length === 0) {
|
||||||
|
console.log('No camera, disabling video.');
|
||||||
|
data.canVideo = false;
|
||||||
|
data.videoDevices.push({
|
||||||
id: 'none',
|
id: 'none',
|
||||||
label: 'No camera'
|
label: 'No camera'
|
||||||
}];
|
});
|
||||||
data.shareDevices = [{
|
} else {
|
||||||
id: 'screen',
|
data.canVideo = true;
|
||||||
label: 'Screen'
|
}
|
||||||
}];
|
},
|
||||||
data.audioDevices = [];
|
|
||||||
|
|
||||||
for (var i in jQuery.verto.videoDevices) {
|
|
||||||
var device = jQuery.verto.videoDevices[i];
|
|
||||||
if (!device.label) {
|
|
||||||
data.videoDevices.push({
|
|
||||||
id: 'Camera ' + i,
|
|
||||||
label: 'Camera ' + i
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
data.videoDevices.push({
|
|
||||||
id: device.id,
|
|
||||||
label: device.label || device.id
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Selecting the first source.
|
|
||||||
if (i == 0) {
|
|
||||||
data.selectedVideo = device.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!device.label) {
|
|
||||||
data.shareDevices.push({
|
|
||||||
id: 'Share Device ' + i,
|
|
||||||
label: 'Share Device ' + i
|
|
||||||
});
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
data.shareDevices.push({
|
|
||||||
id: device.id,
|
|
||||||
label: device.label || device.id
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var i in jQuery.verto.audioInDevices) {
|
|
||||||
var device = jQuery.verto.audioInDevices[i];
|
|
||||||
// Selecting the first source.
|
|
||||||
if (i == 0) {
|
|
||||||
data.selectedAudio = device.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!device.label) {
|
|
||||||
data.audioDevices.push({
|
|
||||||
id: 'Microphone ' + i,
|
|
||||||
label: 'Microphone ' + i
|
|
||||||
});
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
data.audioDevices.push({
|
|
||||||
id: device.id,
|
|
||||||
label: device.label || device.id
|
|
||||||
});
|
|
||||||
}
|
|
||||||
console.debug('Devices were refreshed.');
|
|
||||||
};
|
|
||||||
|
|
||||||
jQuery.verto.refreshDevices(refreshDevicesCallback);
|
|
||||||
|
|
||||||
|
refreshDevices: function(callback) {
|
||||||
|
console.debug('Attempting to refresh the devices.');
|
||||||
|
jQuery.verto.refreshDevices(this.refreshDevicesCallback);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the video resolutions based on settings.
|
* Updates the video resolutions based on settings.
|
||||||
*/
|
*/
|
||||||
refreshVideoResolution: function() {
|
refreshVideoResolution: function(resolutions) {
|
||||||
console.debug('Attempting to refresh video resolutions.');
|
console.debug('Attempting to refresh video resolutions.');
|
||||||
|
|
||||||
if (data.instance) {
|
if (data.instance) {
|
||||||
data.instance.videoParams(getVideoParams());
|
var w = resolutions['bestResSupported'][0];
|
||||||
|
var h = resolutions['bestResSupported'][1];
|
||||||
|
|
||||||
|
if (h === 1080) {
|
||||||
|
w = 1280;
|
||||||
|
h = 720;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateResolutions(resolutions['validRes']);
|
||||||
|
data.instance.videoParams({
|
||||||
|
minWidth: w,
|
||||||
|
minHeight: h,
|
||||||
|
maxWidth: w,
|
||||||
|
maxHeight: h,
|
||||||
|
minFrameRate: 15,
|
||||||
|
vertoBestFrameRate: 30
|
||||||
|
});
|
||||||
|
videoQuality.forEach(function(qual){
|
||||||
|
if (w === qual.width && h === qual.height) {
|
||||||
|
if (storage.data.vidQual !== qual.id) {
|
||||||
|
storage.data.vidQual = qual.id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
console.debug('There is no instance of verto.');
|
console.debug('There is no instance of verto.');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
updateResolutions: function(supportedResolutions) {
|
|
||||||
console.debug('Attempting to sync supported and available resolutions');
|
|
||||||
|
|
||||||
var removed = 0;
|
|
||||||
|
|
||||||
angular.forEach(videoQuality, function(resolution, id) {
|
|
||||||
var supported = false;
|
|
||||||
angular.forEach(supportedResolutions, function(res) {
|
|
||||||
var width = res[0];
|
|
||||||
var height = res[1];
|
|
||||||
|
|
||||||
if(resolution.width == width && resolution.height == height) {
|
|
||||||
supported = true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if(!supported) {
|
|
||||||
delete videoQuality[id];
|
|
||||||
++removed;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
videoQuality.length = videoQuality.length - removed;
|
|
||||||
this.videoQuality = videoQuality;
|
|
||||||
this.data.vidQual = (videoQuality.length > 0) ? videoQuality[videoQuality.length - 1].id : null;
|
|
||||||
|
|
||||||
return videoQuality;
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connects to the verto server. Automatically calls `onWSLogin`
|
* Connects to the verto server. Automatically calls `onWSLogin`
|
||||||
* callback set in the verto object.
|
* callback set in the verto object.
|
||||||
|
@ -502,24 +507,11 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', 'stora
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var init = function(resolutions) {
|
var that = this;
|
||||||
// This means that we cannot use video!
|
function ourBootstrap() {
|
||||||
if (resolutions.validRes.length === 0) {
|
|
||||||
console.log('No valid resolutions, disabling video.');
|
|
||||||
data.canVideo = false;
|
|
||||||
} else {
|
|
||||||
data.canVideo = true;
|
|
||||||
}
|
|
||||||
data.bestWidth = resolutions['bestResSupported'][0];
|
|
||||||
data.bestHeight = resolutions['bestResSupported'][1];
|
|
||||||
|
|
||||||
if (data.canVideo) {
|
|
||||||
that.updateResolutions(resolutions['validRes']);
|
|
||||||
that.refreshVideoResolution();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Checking if we have a failed connection attempt before
|
// Checking if we have a failed connection attempt before
|
||||||
// connecting again.
|
// connecting again.
|
||||||
|
that.refreshDevicesCallback();
|
||||||
if (data.instance && !data.instance.rpcClient.socketReady()) {
|
if (data.instance && !data.instance.rpcClient.socketReady()) {
|
||||||
clearTimeout(data.instance.rpcClient.to);
|
clearTimeout(data.instance.rpcClient.to);
|
||||||
data.instance.logout();
|
data.instance.logout();
|
||||||
|
@ -530,7 +522,6 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', 'stora
|
||||||
socketUrl: data.wsURL,
|
socketUrl: data.wsURL,
|
||||||
tag: "webcam",
|
tag: "webcam",
|
||||||
ringFile: "sounds/bell_ring2.wav",
|
ringFile: "sounds/bell_ring2.wav",
|
||||||
videoParams: getVideoParams(),
|
|
||||||
// TODO: Add options for this.
|
// TODO: Add options for this.
|
||||||
audioParams: {
|
audioParams: {
|
||||||
googEchoCancellation: storage.data.googEchoCancellation || false,
|
googEchoCancellation: storage.data.googEchoCancellation || false,
|
||||||
|
@ -540,10 +531,15 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', 'stora
|
||||||
iceServers: data.useSTUN
|
iceServers: data.useSTUN
|
||||||
}, callbacks);
|
}, callbacks);
|
||||||
|
|
||||||
that.refreshDevices();
|
data.instance.deviceParams({
|
||||||
};
|
useCamera: storage.data.selectedVideo,
|
||||||
|
useMic: storage.data.selectedAudio,
|
||||||
|
resCheck: that.refreshVideoResolution
|
||||||
|
});
|
||||||
|
|
||||||
jQuery.verto.init({}, init);
|
}
|
||||||
|
|
||||||
|
$.verto.init({}, ourBootstrap);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue