提交 045550b0 authored 作者: Joao Mesquita's avatar Joao Mesquita

FS-8043: [verto_communicator] Adjust to improved verto API and refactor how we select cameras

上级 3850e467
...@@ -110,6 +110,7 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', 'stora ...@@ -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 ...@@ -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(!data.bestHeight) { if(resolution.width == width && resolution.height == height) {
if (videoResolution[data.vidQual]) { supported = true;
maxHeight = videoResolution[data.vidQual].height;
} }
});
if(!supported) {
delete videoQuality[id];
++removed;
} }
});
return { videoQuality.length = videoQuality.length - removed;
minWidth: videoResolution[data.vidQual].width, data.videoQuality = videoQuality;
minHeight: videoResolution[data.vidQual].height, data.vidQual = (videoQuality.length > 0) ? videoQuality[videoQuality.length - 1].id : null;
maxWidth: maxWidth,
maxHeight: maxHeight,
minFrameRate: 15,
vertoBestFrameRate: 30
return videoQuality;
}; };
}
var callState = { var callState = {
muteMic: false, muteMic: false,
...@@ -199,13 +200,8 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', 'stora ...@@ -199,13 +200,8 @@ 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.videoDevices = [{
id: 'none',
label: 'No camera'
}];
data.shareDevices = [{ data.shareDevices = [{
id: 'screen', id: 'screen',
label: 'Screen' label: 'Screen'
...@@ -228,7 +224,7 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', 'stora ...@@ -228,7 +224,7 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', 'stora
// Selecting the first source. // Selecting the first source.
if (i == 0) { if (i == 0) {
data.selectedVideo = device.id; storage.data.selectedVideo = device.id;
} }
if (!device.label) { if (!device.label) {
...@@ -249,7 +245,7 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', 'stora ...@@ -249,7 +245,7 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', 'stora
var device = jQuery.verto.audioInDevices[i]; var device = jQuery.verto.audioInDevices[i];
// Selecting the first source. // Selecting the first source.
if (i == 0) { if (i == 0) {
data.selectedAudio = device.id; storage.data.selectedAudio = device.id;
} }
if (!device.label) { if (!device.label) {
...@@ -264,53 +260,62 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', 'stora ...@@ -264,53 +260,62 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', 'stora
label: device.label || device.id label: device.label || device.id
}); });
} }
console.debug('Devices were refreshed.'); console.debug('Devices were refreshed, checking that we have cameras.');
};
jQuery.verto.refreshDevices(refreshDevicesCallback); // 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',
label: 'No camera'
});
} else {
data.canVideo = true;
}
},
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];
} else { var h = resolutions['bestResSupported'][1];
console.debug('There is no instance of verto.');
}
},
updateResolutions: function(supportedResolutions) { if (h === 1080) {
console.debug('Attempting to sync supported and available resolutions'); w = 1280;
h = 720;
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) { updateResolutions(resolutions['validRes']);
delete videoQuality[id]; data.instance.videoParams({
++removed; 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;
}
}
videoQuality.length = videoQuality.length - removed; });
this.videoQuality = videoQuality;
this.data.vidQual = (videoQuality.length > 0) ? videoQuality[videoQuality.length - 1].id : null;
return videoQuality; } else {
console.debug('There is no instance of verto.');
}
}, },
/** /**
...@@ -502,24 +507,11 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', 'stora ...@@ -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 ...@@ -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 ...@@ -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);
}, },
/** /**
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论