FS-8222 [verto_communicator] updated getScreenId.js in order to detect plugin issues and attached an 'ended' event to screenshare stream in order to detect 'stop sharing' click
This commit is contained in:
parent
9edede6c08
commit
43cb965f7e
|
@ -1,10 +1,10 @@
|
||||||
// Last time updated at Sep 07, 2014, 08:32:23
|
// Last time updated at Oct 24, 2015, 08:32:23
|
||||||
|
|
||||||
// Latest file can be found here: https://cdn.webrtc-experiment.com/getScreenId.js
|
// Latest file can be found here: https://cdn.webrtc-experiment.com/getScreenId.js
|
||||||
|
|
||||||
// Muaz Khan - www.MuazKhan.com
|
// Muaz Khan - www.MuazKhan.com
|
||||||
// MIT License - www.WebRTC-Experiment.com/licence
|
// MIT License - www.WebRTC-Experiment.com/licence
|
||||||
// Documentation - https://github.com/muaz-khan/WebRTC-Experiment/tree/master/getScreenId.js
|
// Documentation - https://github.com/muaz-khan/getScreenId.
|
||||||
|
|
||||||
// ______________
|
// ______________
|
||||||
// getScreenId.js
|
// getScreenId.js
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
getScreenId(function (error, sourceId, screen_constraints) {
|
getScreenId(function (error, sourceId, screen_constraints) {
|
||||||
// error == null || 'permission-denied' || 'not-installed' || 'installed-disabled' || 'not-chrome'
|
// error == null || 'permission-denied' || 'not-installed' || 'installed-disabled' || 'not-chrome'
|
||||||
// sourceId == null || 'string' || 'firefox'
|
// sourceId == null || 'string' || 'firefox'
|
||||||
|
|
||||||
if(sourceId == 'firefox') {
|
if(sourceId == 'firefox') {
|
||||||
navigator.mozGetUserMedia(screen_constraints, onSuccess, onFailure);
|
navigator.mozGetUserMedia(screen_constraints, onSuccess, onFailure);
|
||||||
}
|
}
|
||||||
|
@ -79,6 +79,11 @@ getScreenId(function (error, sourceId, screen_constraints) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function postMessage() {
|
function postMessage() {
|
||||||
|
if (!iframe) {
|
||||||
|
loadIFrame(postMessage);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!iframe.isLoaded) {
|
if (!iframe.isLoaded) {
|
||||||
setTimeout(postMessage, 100);
|
setTimeout(postMessage, 100);
|
||||||
return;
|
return;
|
||||||
|
@ -89,11 +94,137 @@ getScreenId(function (error, sourceId, screen_constraints) {
|
||||||
}, '*');
|
}, '*');
|
||||||
}
|
}
|
||||||
|
|
||||||
var iframe = document.createElement('iframe');
|
function loadIFrame(loadCallback) {
|
||||||
iframe.onload = function() {
|
if (iframe) {
|
||||||
iframe.isLoaded = true;
|
loadCallback();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
iframe = document.createElement('iframe');
|
||||||
|
iframe.onload = function() {
|
||||||
|
iframe.isLoaded = true;
|
||||||
|
|
||||||
|
loadCallback();
|
||||||
|
};
|
||||||
|
iframe.src = 'https://www.webrtc-experiment.com/getSourceId/'; // https://wwww.yourdomain.com/getScreenId.html
|
||||||
|
iframe.style.display = 'none';
|
||||||
|
(document.body || document.documentElement).appendChild(iframe);
|
||||||
|
}
|
||||||
|
|
||||||
|
var iframe;
|
||||||
|
|
||||||
|
// this function is used in v3.0
|
||||||
|
window.getScreenConstraints = function(callback) {
|
||||||
|
loadIFrame(function() {
|
||||||
|
getScreenId(function(error, sourceId, screen_constraints) {
|
||||||
|
callback(error, screen_constraints.video);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
if(document.domain.indexOf('webrtc-experiment.com') === -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
window.getScreenId = function(callback) {
|
||||||
|
// for Firefox:
|
||||||
|
// sourceId == 'firefox'
|
||||||
|
// screen_constraints = {...}
|
||||||
|
if (!!navigator.mozGetUserMedia) {
|
||||||
|
callback(null, 'firefox', {
|
||||||
|
video: {
|
||||||
|
mozMediaSource: 'window',
|
||||||
|
mediaSource: 'window'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
postMessage();
|
||||||
|
|
||||||
|
window.addEventListener('message', onIFrameCallback);
|
||||||
|
|
||||||
|
function onIFrameCallback(event) {
|
||||||
|
if (!event.data) return;
|
||||||
|
|
||||||
|
if (event.data.chromeMediaSourceId) {
|
||||||
|
if (event.data.chromeMediaSourceId === 'PermissionDeniedError') {
|
||||||
|
callback('permission-denied');
|
||||||
|
} else callback(null, event.data.chromeMediaSourceId, getScreenConstraints(null, event.data.chromeMediaSourceId));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.data.chromeExtensionStatus) {
|
||||||
|
callback(event.data.chromeExtensionStatus, null, getScreenConstraints(event.data.chromeExtensionStatus));
|
||||||
|
}
|
||||||
|
|
||||||
|
// this event listener is no more needed
|
||||||
|
window.removeEventListener('message', onIFrameCallback);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function getScreenConstraints(error, sourceId) {
|
||||||
|
var screen_constraints = {
|
||||||
|
audio: false,
|
||||||
|
video: {
|
||||||
|
mandatory: {
|
||||||
|
chromeMediaSource: error ? 'screen' : 'desktop',
|
||||||
|
maxWidth: window.screen.width > 1920 ? window.screen.width : 1920,
|
||||||
|
maxHeight: window.screen.height > 1080 ? window.screen.height : 1080
|
||||||
|
},
|
||||||
|
optional: []
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (sourceId) {
|
||||||
|
screen_constraints.video.mandatory.chromeMediaSourceId = sourceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
return screen_constraints;
|
||||||
|
}
|
||||||
|
|
||||||
|
function postMessage() {
|
||||||
|
if (!iframe) {
|
||||||
|
loadIFrame(postMessage);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!iframe.isLoaded) {
|
||||||
|
setTimeout(postMessage, 100);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
iframe.contentWindow.postMessage({
|
||||||
|
captureSourceId: true
|
||||||
|
}, '*');
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadIFrame(loadCallback) {
|
||||||
|
if (iframe) {
|
||||||
|
loadCallback();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
iframe = document.createElement('iframe');
|
||||||
|
iframe.onload = function() {
|
||||||
|
iframe.isLoaded = true;
|
||||||
|
|
||||||
|
loadCallback();
|
||||||
|
};
|
||||||
|
iframe.src = 'https://www.webrtc-experiment.com/getSourceId/'; // https://wwww.yourdomain.com/getScreenId.html
|
||||||
|
iframe.style.display = 'none';
|
||||||
|
(document.body || document.documentElement).appendChild(iframe);
|
||||||
|
}
|
||||||
|
|
||||||
|
var iframe;
|
||||||
|
|
||||||
|
// this function is used in v3.0
|
||||||
|
window.getScreenConstraints = function(callback) {
|
||||||
|
loadIFrame(function() {
|
||||||
|
getScreenId(function(error, sourceId, screen_constraints) {
|
||||||
|
callback(error, screen_constraints.video);
|
||||||
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
iframe.src = 'https://www.webrtc-experiment.com/getSourceId/';
|
|
||||||
iframe.style.display = 'none';
|
|
||||||
(document.body || document.documentElement).appendChild(iframe);
|
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
if (storage.data.videoCall) {
|
if (storage.data.videoCall) {
|
||||||
$scope.callTemplate = 'partials/video_call.html';
|
$scope.callTemplate = 'partials/video_call.html';
|
||||||
}
|
}
|
||||||
|
|
||||||
$rootScope.$on('call.conference', function(event, data) {
|
$rootScope.$on('call.conference', function(event, data) {
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
if($scope.chatStatus) {
|
if($scope.chatStatus) {
|
||||||
|
@ -75,9 +75,31 @@
|
||||||
verto.data.conf.setVideoLayout(layout);
|
verto.data.conf.setVideoLayout(layout);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
$scope.screenshare = function() {
|
||||||
|
if(verto.data.shareCall) {
|
||||||
|
verto.screenshareHangup();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
verto.screenshare(storage.data.called_number);
|
||||||
|
};
|
||||||
|
|
||||||
$scope.muteMic = verto.muteMic;
|
$scope.muteMic = verto.muteMic;
|
||||||
$scope.muteVideo = verto.muteVideo;
|
$scope.muteVideo = verto.muteVideo;
|
||||||
|
|
||||||
|
$scope.$on('ScreenShareExtensionStatus', function(error) {
|
||||||
|
switch(error) {
|
||||||
|
case 'permission-denied':
|
||||||
|
toastr.info('Please allow the plugin in order to use Screen Share', 'Error'); break;
|
||||||
|
case 'not-installed':
|
||||||
|
toastr.warning('Please install the plugin in order to use Screen Share', 'Warning'); break;
|
||||||
|
case 'installed-disabled':
|
||||||
|
toastr.info('Please enable the plugin in order to use Screen Share', 'Error'); break;
|
||||||
|
// case 'not-chrome'
|
||||||
|
// toastr.info('Please allow the plugin in order to use Screen Share', 'Error');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
console.log('broadcast time-start incall');
|
console.log('broadcast time-start incall');
|
||||||
$scope.$broadcast('timer-start');
|
$scope.$broadcast('timer-start');
|
||||||
|
|
|
@ -24,13 +24,13 @@
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
$rootScope.dialpadNumber = '';
|
$rootScope.dialpadNumber = '';
|
||||||
|
|
||||||
// If verto is not connected, redirects to login page.
|
// If verto is not connected, redirects to login page.
|
||||||
if (!verto.data.connected) {
|
if (!verto.data.connected) {
|
||||||
console.debug('MainController: WebSocket not connected. Redirecting to login.');
|
console.debug('MainController: WebSocket not connected. Redirecting to login.');
|
||||||
$location.path('/');
|
$location.path('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
$rootScope.$on('config.http.success', function(ev) {
|
$rootScope.$on('config.http.success', function(ev) {
|
||||||
$scope.login(false);
|
$scope.login(false);
|
||||||
});
|
});
|
||||||
|
@ -58,7 +58,7 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
verto.data.connecting = true;
|
verto.data.connecting = true;
|
||||||
verto.connect(connectCallback);
|
verto.connect(connectCallback);
|
||||||
};
|
};
|
||||||
|
@ -135,7 +135,7 @@
|
||||||
templateUrl: templateUrl,
|
templateUrl: templateUrl,
|
||||||
controller: controller,
|
controller: controller,
|
||||||
};
|
};
|
||||||
|
|
||||||
angular.extend(options, _options);
|
angular.extend(options, _options);
|
||||||
|
|
||||||
var modalInstance = $modal.open(options);
|
var modalInstance = $modal.open(options);
|
||||||
|
@ -154,7 +154,7 @@
|
||||||
jQuery.material.init();
|
jQuery.material.init();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
return modalInstance;
|
return modalInstance;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -454,14 +454,6 @@
|
||||||
$scope.incomingCall = false;
|
$scope.incomingCall = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.screenshare = function() {
|
|
||||||
if (verto.data.shareCall) {
|
|
||||||
verto.screenshareHangup();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
verto.screenshare(storage.data.called_number);
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.play = function() {
|
$scope.play = function() {
|
||||||
var file = $scope.promptInput('Please, enter filename', '', 'File',
|
var file = $scope.promptInput('Please, enter filename', '', 'File',
|
||||||
function(file) {
|
function(file) {
|
||||||
|
|
|
@ -169,7 +169,7 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', 'stora
|
||||||
var height = res[1];
|
var height = res[1];
|
||||||
|
|
||||||
if(resolution.width == width && resolution.height == height) {
|
if(resolution.width == width && resolution.height == height) {
|
||||||
videoQuality.push(resolution);
|
videoQuality.push(resolution);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -200,9 +200,9 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', 'stora
|
||||||
|
|
||||||
refreshDevicesCallback : function refreshDevicesCallback(callback) {
|
refreshDevicesCallback : function refreshDevicesCallback(callback) {
|
||||||
data.videoDevices = [{
|
data.videoDevices = [{
|
||||||
id: 'none',
|
id: 'none',
|
||||||
label: 'No Camera'
|
label: 'No Camera'
|
||||||
}];
|
}];
|
||||||
data.shareDevices = [{
|
data.shareDevices = [{
|
||||||
id: 'screen',
|
id: 'screen',
|
||||||
label: 'Screen'
|
label: 'Screen'
|
||||||
|
@ -556,10 +556,10 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', 'stora
|
||||||
// Checking if we have a failed connection attempt before
|
// Checking if we have a failed connection attempt before
|
||||||
// connecting again.
|
// connecting again.
|
||||||
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();
|
||||||
data.instance.login();
|
data.instance.login();
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
data.instance = new jQuery.verto({
|
data.instance = new jQuery.verto({
|
||||||
login: data.login + '@' + data.hostname,
|
login: data.login + '@' + data.hostname,
|
||||||
|
@ -583,22 +583,22 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', 'stora
|
||||||
jQuery.verto.unloadJobs.push(function() {
|
jQuery.verto.unloadJobs.push(function() {
|
||||||
that.reloaded = true;
|
that.reloaded = true;
|
||||||
});
|
});
|
||||||
data.instance.deviceParams({
|
data.instance.deviceParams({
|
||||||
useCamera: storage.data.selectedVideo,
|
useCamera: storage.data.selectedVideo,
|
||||||
useMic: storage.data.selectedAudio,
|
useMic: storage.data.selectedAudio,
|
||||||
onResCheck: that.refreshVideoResolution
|
onResCheck: that.refreshVideoResolution
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.mediaPerm) {
|
if (data.mediaPerm) {
|
||||||
ourBootstrap();
|
ourBootstrap();
|
||||||
} else {
|
} else {
|
||||||
$.FSRTC.checkPerms(ourBootstrap, true, true);
|
$.FSRTC.checkPerms(ourBootstrap, true, true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
mediaPerm: function(callback) {
|
mediaPerm: function(callback) {
|
||||||
$.FSRTC.checkPerms(callback, true, true);
|
$.FSRTC.checkPerms(callback, true, true);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -681,6 +681,12 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', 'stora
|
||||||
var that = this;
|
var that = this;
|
||||||
|
|
||||||
getScreenId(function(error, sourceId, screen_constraints) {
|
getScreenId(function(error, sourceId, screen_constraints) {
|
||||||
|
|
||||||
|
if(error) {
|
||||||
|
$rootScope.$emit('ScreenShareExtensionStatus', error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var call = data.instance.newCall({
|
var call = data.instance.newCall({
|
||||||
destination_number: destination + '-screen',
|
destination_number: destination + '-screen',
|
||||||
caller_id_name: data.name + ' (Screen)',
|
caller_id_name: data.name + ' (Screen)',
|
||||||
|
@ -698,6 +704,24 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', 'stora
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
call.rtc.options.callbacks.onStream = function(rtc, stream) {
|
||||||
|
if(stream) {
|
||||||
|
var StreamTrack = stream.getVideoTracks()[0];
|
||||||
|
StreamTrack.addEventListener('ended', stopSharing);
|
||||||
|
// (stream.getVideoTracks()[0]).onended = stopSharing;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("stream started");
|
||||||
|
|
||||||
|
function stopSharing() {
|
||||||
|
if(that.data.shareCall) {
|
||||||
|
that.screenshareHangup();
|
||||||
|
console.log("screenshare ended");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
data.shareCall = call;
|
data.shareCall = call;
|
||||||
|
|
||||||
console.log('shareCall', data);
|
console.log('shareCall', data);
|
||||||
|
|
Loading…
Reference in New Issue