2018-03-08 05:20:37 +08:00
|
|
|
const isFirefox = typeof window.InstallTrigger !== 'undefined';
|
|
|
|
const isOpera = !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
|
|
|
|
const isChrome = !!window.chrome && !isOpera;
|
|
|
|
const isSafari = navigator.userAgent.indexOf('Safari') >= 0 && !isChrome;
|
|
|
|
const kurentoHandler = null;
|
2018-01-16 04:15:58 +08:00
|
|
|
|
|
|
|
Kurento = function (
|
2018-03-08 05:20:37 +08:00
|
|
|
tag,
|
|
|
|
voiceBridge,
|
2018-06-29 02:50:56 +08:00
|
|
|
userId,
|
2018-03-08 05:20:37 +08:00
|
|
|
internalMeetingId,
|
2018-07-10 05:29:27 +08:00
|
|
|
onFail,
|
|
|
|
onSuccess,
|
|
|
|
options = {},
|
2018-03-08 05:20:37 +08:00
|
|
|
) {
|
2018-01-16 04:15:58 +08:00
|
|
|
this.ws = null;
|
2018-03-10 02:35:37 +08:00
|
|
|
this.video = null;
|
|
|
|
this.screen = null;
|
|
|
|
this.webRtcPeer = null;
|
2018-01-16 04:15:58 +08:00
|
|
|
this.mediaCallback = null;
|
|
|
|
|
2018-07-10 05:29:27 +08:00
|
|
|
this.renderTag = tag;
|
|
|
|
this.voiceBridge = voiceBridge;
|
|
|
|
this.userId = userId;
|
2018-01-16 04:15:58 +08:00
|
|
|
this.internalMeetingId = internalMeetingId;
|
|
|
|
|
2018-07-10 05:29:27 +08:00
|
|
|
// Optional parameters are: userName, caleeName, chromeExtension, wsUrl, iceServers,
|
|
|
|
// chromeScreenshareSources, firefoxScreenshareSource
|
|
|
|
|
|
|
|
Object.assign(this, options);
|
|
|
|
|
2018-08-23 23:49:16 +08:00
|
|
|
this.SEND_ROLE = 'send';
|
|
|
|
this.RECV_ROLE = 'recv';
|
|
|
|
this.SFU_APP = 'screenshare';
|
|
|
|
this.ON_ICE_CANDIDATE_MSG = 'iceCandidate';
|
2018-07-21 03:34:50 +08:00
|
|
|
this.PING_INTERVAL = 15000;
|
|
|
|
|
2018-07-26 04:04:20 +08:00
|
|
|
window.Logger = this.logger || console;
|
2018-07-21 03:34:50 +08:00
|
|
|
|
2018-07-10 05:29:27 +08:00
|
|
|
if (this.wsUrl == null) {
|
|
|
|
this.defaultPath = 'bbb-webrtc-sfu';
|
|
|
|
this.hostName = window.location.hostname;
|
|
|
|
this.wsUrl = `wss://${this.hostName}/${this.defaultPath}`;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.chromeScreenshareSources == null) {
|
2018-08-23 23:49:16 +08:00
|
|
|
this.chromeScreenshareSources = ['screen', 'window'];
|
2018-07-10 05:29:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (this.firefoxScreenshareSource == null) {
|
2018-08-23 23:49:16 +08:00
|
|
|
this.firefoxScreenshareSource = 'window';
|
2018-07-10 05:29:27 +08:00
|
|
|
}
|
2018-06-29 02:50:56 +08:00
|
|
|
|
2018-05-10 07:38:20 +08:00
|
|
|
// Limiting max resolution to WQXGA
|
2018-03-10 02:35:37 +08:00
|
|
|
// In FireFox we force full screen share and in the case
|
|
|
|
// of multiple screens the total area shared becomes too large
|
2018-05-10 07:38:20 +08:00
|
|
|
this.vid_max_width = 2560;
|
|
|
|
this.vid_max_height = 1600;
|
2018-05-10 00:39:59 +08:00
|
|
|
this.width = window.screen.width;
|
|
|
|
this.height = window.screen.height;
|
2018-01-16 04:15:58 +08:00
|
|
|
|
|
|
|
|
2018-06-29 02:50:56 +08:00
|
|
|
this.userId = userId;
|
2018-01-16 04:15:58 +08:00
|
|
|
|
2018-05-08 01:44:18 +08:00
|
|
|
this.pingInterval = null;
|
2018-01-16 04:15:58 +08:00
|
|
|
|
|
|
|
|
|
|
|
if (onFail != null) {
|
|
|
|
this.onFail = Kurento.normalizeCallback(onFail);
|
|
|
|
} else {
|
2018-03-08 05:20:37 +08:00
|
|
|
const _this = this;
|
2018-01-16 04:15:58 +08:00
|
|
|
this.onFail = function () {
|
|
|
|
_this.logError('Default error handler');
|
|
|
|
};
|
|
|
|
}
|
2018-04-28 05:37:41 +08:00
|
|
|
|
|
|
|
if (onSuccess != null) {
|
|
|
|
this.onSuccess = Kurento.normalizeCallback(onSuccess);
|
|
|
|
} else {
|
2018-08-23 23:49:16 +08:00
|
|
|
const _this = this;
|
2018-04-28 05:37:41 +08:00
|
|
|
this.onSuccess = function () {
|
|
|
|
_this.logSuccess('Default success handler');
|
|
|
|
};
|
|
|
|
}
|
2018-01-16 04:15:58 +08:00
|
|
|
};
|
|
|
|
|
2018-03-08 05:20:37 +08:00
|
|
|
this.KurentoManager = function () {
|
2018-01-16 04:15:58 +08:00
|
|
|
this.kurentoVideo = null;
|
|
|
|
this.kurentoScreenshare = null;
|
2018-04-28 05:37:41 +08:00
|
|
|
this.kurentoAudio = null;
|
2018-01-16 04:15:58 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
KurentoManager.prototype.exitScreenShare = function () {
|
2018-03-08 05:20:37 +08:00
|
|
|
if (typeof this.kurentoScreenshare !== 'undefined' && this.kurentoScreenshare) {
|
2018-07-19 05:04:20 +08:00
|
|
|
if (this.kurentoScreenshare.logger !== null) {
|
2018-07-27 02:26:56 +08:00
|
|
|
this.kurentoScreenshare.logger.info(' [exitScreenShare] Exiting screensharing');
|
2018-07-19 05:04:20 +08:00
|
|
|
}
|
|
|
|
|
2018-03-08 05:20:37 +08:00
|
|
|
if (this.kurentoScreenshare.ws !== null) {
|
|
|
|
this.kurentoScreenshare.ws.onclose = function () {};
|
2018-01-16 04:15:58 +08:00
|
|
|
this.kurentoScreenshare.ws.close();
|
|
|
|
}
|
|
|
|
|
2018-05-08 01:44:18 +08:00
|
|
|
if (this.kurentoScreenshare.pingInterval) {
|
|
|
|
clearInterval(this.kurentoScreenshare.pingInterval);
|
|
|
|
}
|
2018-01-16 04:15:58 +08:00
|
|
|
|
2018-05-08 01:44:18 +08:00
|
|
|
this.kurentoScreenshare.dispose();
|
2018-01-16 04:15:58 +08:00
|
|
|
this.kurentoScreenshare = null;
|
|
|
|
}
|
|
|
|
|
2018-03-08 05:20:37 +08:00
|
|
|
if (typeof this.kurentoVideo !== 'undefined' && this.kurentoVideo) {
|
2018-01-16 04:15:58 +08:00
|
|
|
this.exitVideo();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
KurentoManager.prototype.exitVideo = function () {
|
2018-03-08 05:20:37 +08:00
|
|
|
if (typeof this.kurentoVideo !== 'undefined' && this.kurentoVideo) {
|
2018-07-19 05:04:20 +08:00
|
|
|
|
2018-08-29 00:40:51 +08:00
|
|
|
if(this.kurentoVideo.webRtcPeer) {
|
|
|
|
this.kurentoVideo.webRtcPeer.peerConnection.oniceconnectionstatechange = null;
|
|
|
|
}
|
|
|
|
|
2018-07-19 05:04:20 +08:00
|
|
|
if (this.kurentoVideo.logger !== null) {
|
2018-07-27 02:26:56 +08:00
|
|
|
this.kurentoVideo.logger.info(' [exitScreenShare] Exiting screensharing viewing');
|
2018-07-19 05:04:20 +08:00
|
|
|
}
|
|
|
|
|
2018-03-08 05:20:37 +08:00
|
|
|
if (this.kurentoVideo.ws !== null) {
|
|
|
|
this.kurentoVideo.ws.onclose = function () {};
|
2018-01-16 04:15:58 +08:00
|
|
|
this.kurentoVideo.ws.close();
|
|
|
|
}
|
|
|
|
|
2018-05-08 01:44:18 +08:00
|
|
|
if (this.kurentoVideo.pingInterval) {
|
|
|
|
clearInterval(this.kurentoVideo.pingInterval);
|
|
|
|
}
|
2018-01-16 04:15:58 +08:00
|
|
|
|
2018-05-08 01:44:18 +08:00
|
|
|
this.kurentoVideo.dispose();
|
2018-01-16 04:15:58 +08:00
|
|
|
this.kurentoVideo = null;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-04-28 05:37:41 +08:00
|
|
|
KurentoManager.prototype.exitAudio = function () {
|
|
|
|
if (typeof this.kurentoAudio !== 'undefined' && this.kurentoAudio) {
|
2018-07-19 05:04:20 +08:00
|
|
|
if (this.kurentoAudio.logger !== null) {
|
2018-07-27 02:26:56 +08:00
|
|
|
this.kurentoAudio.logger.info(' [exitAudio] Exiting listen only audio');
|
2018-07-19 05:04:20 +08:00
|
|
|
}
|
|
|
|
|
2018-04-28 05:37:41 +08:00
|
|
|
if (this.kurentoAudio.ws !== null) {
|
|
|
|
this.kurentoAudio.ws.onclose = function () {};
|
|
|
|
this.kurentoAudio.ws.close();
|
|
|
|
}
|
|
|
|
|
2018-07-12 00:32:52 +08:00
|
|
|
if (this.kurentoAudio.pingInterval) {
|
|
|
|
clearInterval(this.kurentoAudio.pingInterval);
|
|
|
|
}
|
2018-04-28 05:37:41 +08:00
|
|
|
|
2018-07-12 00:32:52 +08:00
|
|
|
this.kurentoAudio.dispose();
|
2018-04-28 05:37:41 +08:00
|
|
|
this.kurentoAudio = null;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-01-16 04:15:58 +08:00
|
|
|
KurentoManager.prototype.shareScreen = function (tag) {
|
|
|
|
this.exitScreenShare();
|
2018-03-08 05:20:37 +08:00
|
|
|
const obj = Object.create(Kurento.prototype);
|
2018-01-16 04:15:58 +08:00
|
|
|
Kurento.apply(obj, arguments);
|
|
|
|
this.kurentoScreenshare = obj;
|
2018-04-26 00:56:16 +08:00
|
|
|
this.kurentoScreenshare.setScreensharing(tag);
|
2018-01-16 04:15:58 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
KurentoManager.prototype.joinWatchVideo = function (tag) {
|
|
|
|
this.exitVideo();
|
2018-03-08 05:20:37 +08:00
|
|
|
const obj = Object.create(Kurento.prototype);
|
2018-01-16 04:15:58 +08:00
|
|
|
Kurento.apply(obj, arguments);
|
|
|
|
this.kurentoVideo = obj;
|
|
|
|
this.kurentoVideo.setWatchVideo(tag);
|
|
|
|
};
|
|
|
|
|
2018-07-10 05:29:27 +08:00
|
|
|
KurentoManager.prototype.getFirefoxScreenshareSource = function () {
|
|
|
|
return this.kurentoScreenshare.firefoxScreenshareSource;
|
2018-08-23 23:49:16 +08:00
|
|
|
};
|
2018-07-10 05:29:27 +08:00
|
|
|
|
|
|
|
KurentoManager.prototype.getChromeScreenshareSources = function () {
|
|
|
|
return this.kurentoScreenshare.chromeScreenshareSources;
|
2018-08-23 23:49:16 +08:00
|
|
|
};
|
2018-07-10 05:29:27 +08:00
|
|
|
|
|
|
|
KurentoManager.prototype.getChromeExtensionKey = function () {
|
|
|
|
return this.kurentoScreenshare.chromeExtension;
|
2018-08-23 23:49:16 +08:00
|
|
|
};
|
2018-07-10 05:29:27 +08:00
|
|
|
|
2018-01-16 04:15:58 +08:00
|
|
|
|
2018-04-26 00:56:16 +08:00
|
|
|
Kurento.prototype.setScreensharing = function (tag) {
|
|
|
|
this.mediaCallback = this.startScreensharing.bind(this);
|
2018-01-16 04:15:58 +08:00
|
|
|
this.create(tag);
|
|
|
|
};
|
|
|
|
|
|
|
|
Kurento.prototype.create = function (tag) {
|
|
|
|
this.setRenderTag(tag);
|
|
|
|
this.init();
|
|
|
|
};
|
|
|
|
|
2018-05-09 22:21:03 +08:00
|
|
|
Kurento.prototype.downscaleResolution = function (oldWidth, oldHeight) {
|
|
|
|
const factorWidth = this.vid_max_width / oldWidth;
|
|
|
|
const factorHeight = this.vid_max_height / oldHeight;
|
2018-08-23 23:49:16 +08:00
|
|
|
let width,
|
|
|
|
height;
|
2018-05-09 22:21:03 +08:00
|
|
|
|
|
|
|
if (factorWidth < factorHeight) {
|
|
|
|
width = Math.trunc(oldWidth * factorWidth);
|
|
|
|
height = Math.trunc(oldHeight * factorWidth);
|
2018-08-23 23:49:16 +08:00
|
|
|
} else {
|
2018-05-09 22:21:03 +08:00
|
|
|
width = Math.trunc(oldWidth * factorHeight);
|
|
|
|
height = Math.trunc(oldHeight * factorHeight);
|
|
|
|
}
|
|
|
|
|
|
|
|
return { width, height };
|
|
|
|
};
|
|
|
|
|
2018-01-16 04:15:58 +08:00
|
|
|
Kurento.prototype.init = function () {
|
2018-03-08 05:20:37 +08:00
|
|
|
const self = this;
|
|
|
|
if ('WebSocket' in window) {
|
2018-07-27 02:26:56 +08:00
|
|
|
this.logger.info('this browser supports websockets');
|
2018-07-10 05:29:27 +08:00
|
|
|
this.ws = new WebSocket(this.wsUrl);
|
2018-01-16 04:15:58 +08:00
|
|
|
|
|
|
|
this.ws.onmessage = this.onWSMessage.bind(this);
|
|
|
|
this.ws.onclose = (close) => {
|
|
|
|
kurentoManager.exitScreenShare();
|
2018-03-08 05:20:37 +08:00
|
|
|
self.onFail('Websocket connection closed');
|
2018-01-16 04:15:58 +08:00
|
|
|
};
|
|
|
|
this.ws.onerror = (error) => {
|
|
|
|
kurentoManager.exitScreenShare();
|
2018-03-08 05:20:37 +08:00
|
|
|
self.onFail('Websocket connection error');
|
2018-01-16 04:15:58 +08:00
|
|
|
};
|
|
|
|
this.ws.onopen = function () {
|
2018-07-21 03:34:50 +08:00
|
|
|
self.pingInterval = setInterval(self.ping.bind(self), self.PING_INTERVAL);
|
2018-01-16 04:15:58 +08:00
|
|
|
self.mediaCallback();
|
2018-03-08 05:20:37 +08:00
|
|
|
};
|
2018-07-27 02:26:56 +08:00
|
|
|
} else { this.logger.info('this browser does not support websockets'); }
|
2018-01-16 04:15:58 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
Kurento.prototype.onWSMessage = function (message) {
|
2018-03-08 05:20:37 +08:00
|
|
|
const parsedMessage = JSON.parse(message.data);
|
2018-01-16 04:15:58 +08:00
|
|
|
switch (parsedMessage.id) {
|
2018-04-26 00:56:16 +08:00
|
|
|
case 'startResponse':
|
|
|
|
this.startResponse(parsedMessage);
|
2018-01-16 04:15:58 +08:00
|
|
|
break;
|
|
|
|
case 'stopSharing':
|
|
|
|
kurentoManager.exitScreenShare();
|
|
|
|
break;
|
|
|
|
case 'iceCandidate':
|
|
|
|
this.webRtcPeer.addIceCandidate(parsedMessage.candidate);
|
|
|
|
break;
|
2018-04-28 05:37:41 +08:00
|
|
|
case 'webRTCAudioSuccess':
|
|
|
|
this.onSuccess(parsedMessage.success);
|
|
|
|
break;
|
|
|
|
case 'webRTCAudioError':
|
2018-08-30 10:41:02 +08:00
|
|
|
this.onFail(parsedMessage);
|
2018-04-28 05:37:41 +08:00
|
|
|
break;
|
2018-05-08 01:44:18 +08:00
|
|
|
case 'pong':
|
|
|
|
break;
|
2018-01-16 04:15:58 +08:00
|
|
|
default:
|
2018-07-19 05:04:20 +08:00
|
|
|
this.logger.error('Unrecognized message', parsedMessage);
|
2018-01-16 04:15:58 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
Kurento.prototype.setRenderTag = function (tag) {
|
|
|
|
this.renderTag = tag;
|
|
|
|
};
|
|
|
|
|
2018-04-26 00:56:16 +08:00
|
|
|
Kurento.prototype.startResponse = function (message) {
|
2018-03-08 05:20:37 +08:00
|
|
|
if (message.response !== 'accepted') {
|
|
|
|
const errorMsg = message.message ? message.message : 'Unknow error';
|
2018-08-23 23:49:16 +08:00
|
|
|
this.logger.warn('Call not accepted for the following reason:', { error: errorMsg });
|
2018-04-28 05:37:41 +08:00
|
|
|
switch (message.type) {
|
|
|
|
case 'screenshare':
|
2018-07-21 03:34:50 +08:00
|
|
|
if (message.role === this.SEND_ROLE) {
|
2018-04-28 05:37:41 +08:00
|
|
|
kurentoManager.exitScreenShare();
|
2018-08-23 23:49:16 +08:00
|
|
|
} else if (message.role === this.RECV_ROLE) {
|
2018-04-28 05:37:41 +08:00
|
|
|
kurentoManager.exitVideo();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'audio':
|
|
|
|
kurentoManager.exitAudio();
|
|
|
|
break;
|
|
|
|
}
|
2018-01-16 04:15:58 +08:00
|
|
|
} else {
|
2018-08-23 23:49:16 +08:00
|
|
|
this.logger.debug(`Procedure for ${message.type} was accepted with SDP =>`, { sdpAnswer: message.sdpAnswer });
|
2018-01-16 04:15:58 +08:00
|
|
|
this.webRtcPeer.processAnswer(message.sdpAnswer);
|
|
|
|
}
|
2018-03-08 05:20:37 +08:00
|
|
|
};
|
2018-01-16 04:15:58 +08:00
|
|
|
|
|
|
|
Kurento.prototype.onOfferPresenter = function (error, offerSdp) {
|
2018-03-08 05:20:37 +08:00
|
|
|
const self = this;
|
2018-05-09 22:21:03 +08:00
|
|
|
|
2018-03-08 05:20:37 +08:00
|
|
|
if (error) {
|
2018-07-27 02:26:56 +08:00
|
|
|
this.logger.info(`Kurento.prototype.onOfferPresenter Error ${error}`);
|
2018-01-16 04:15:58 +08:00
|
|
|
this.onFail(error);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-03-08 05:20:37 +08:00
|
|
|
const message = {
|
2018-04-26 00:56:16 +08:00
|
|
|
id: 'start',
|
2018-07-21 03:34:50 +08:00
|
|
|
type: this.SFU_APP,
|
|
|
|
role: this.SEND_ROLE,
|
2018-01-16 04:15:58 +08:00
|
|
|
internalMeetingId: self.internalMeetingId,
|
|
|
|
voiceBridge: self.voiceBridge,
|
2018-06-29 02:50:56 +08:00
|
|
|
callerName: self.userId,
|
2018-03-08 05:20:37 +08:00
|
|
|
sdpOffer: offerSdp,
|
2018-05-10 00:39:59 +08:00
|
|
|
vh: this.height,
|
|
|
|
vw: this.width,
|
2018-01-16 04:15:58 +08:00
|
|
|
};
|
2018-04-26 00:56:16 +08:00
|
|
|
|
2018-08-23 23:49:16 +08:00
|
|
|
this.logger.info('onOfferPresenter sending to screenshare server => ', { sdpOffer: message });
|
2018-01-16 04:15:58 +08:00
|
|
|
this.sendMessage(message);
|
2018-03-08 05:20:37 +08:00
|
|
|
};
|
2018-01-16 04:15:58 +08:00
|
|
|
|
2018-07-10 05:29:27 +08:00
|
|
|
|
2018-04-26 00:56:16 +08:00
|
|
|
Kurento.prototype.startScreensharing = function () {
|
2018-03-08 05:20:37 +08:00
|
|
|
if (window.chrome) {
|
2018-07-10 05:29:27 +08:00
|
|
|
if (this.chromeExtension == null) {
|
2018-04-26 00:56:16 +08:00
|
|
|
this.logError({
|
2018-03-08 05:20:37 +08:00
|
|
|
status: 'failed',
|
2018-01-16 04:15:58 +08:00
|
|
|
message: 'Missing Chrome Extension key',
|
|
|
|
});
|
2018-04-26 00:56:16 +08:00
|
|
|
this.onFail();
|
2018-01-16 04:15:58 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-08 05:20:37 +08:00
|
|
|
const options = {
|
2018-01-16 04:15:58 +08:00
|
|
|
localVideo: document.getElementById(this.renderTag),
|
2018-04-26 00:56:16 +08:00
|
|
|
onicecandidate: (candidate) => {
|
2018-07-21 03:34:50 +08:00
|
|
|
this.onIceCandidate(candidate, this.SEND_ROLE);
|
2018-04-26 00:56:16 +08:00
|
|
|
},
|
2018-03-08 05:20:37 +08:00
|
|
|
sendSource: 'desktop',
|
2018-01-16 04:15:58 +08:00
|
|
|
};
|
|
|
|
|
2018-08-23 23:49:16 +08:00
|
|
|
this.logger.info(' Peer options =>', options);
|
2018-01-16 04:15:58 +08:00
|
|
|
|
2018-05-10 07:38:20 +08:00
|
|
|
let resolution;
|
2018-07-19 05:04:20 +08:00
|
|
|
this.logger.debug(`Screenshare screen dimensions are ${this.width} x ${this.height}`);
|
2018-05-10 07:38:20 +08:00
|
|
|
if (this.width > this.vid_max_width || this.height > this.vid_max_height) {
|
|
|
|
resolution = this.downscaleResolution(this.width, this.height);
|
|
|
|
this.width = resolution.width;
|
|
|
|
this.height = resolution.height;
|
2018-08-23 23:49:16 +08:00
|
|
|
this.logger.debug('Screenshare track dimensions have been resized to', this.width, 'x', this.height);
|
2018-05-10 07:38:20 +08:00
|
|
|
}
|
|
|
|
|
2018-07-10 05:29:27 +08:00
|
|
|
this.addIceServers(this.iceServers, options);
|
|
|
|
|
2018-04-26 00:56:16 +08:00
|
|
|
this.webRtcPeer = kurentoUtils.WebRtcPeer.WebRtcPeerSendonly(options, (error) => {
|
2018-03-08 05:20:37 +08:00
|
|
|
if (error) {
|
2018-08-23 23:49:16 +08:00
|
|
|
this.logger.error('WebRtcPeerSendonly constructor error:', { error });
|
2018-04-26 00:56:16 +08:00
|
|
|
this.onFail(error);
|
2018-01-16 04:15:58 +08:00
|
|
|
return kurentoManager.exitScreenShare();
|
|
|
|
}
|
|
|
|
|
2018-04-26 00:56:16 +08:00
|
|
|
this.webRtcPeer.generateOffer(this.onOfferPresenter.bind(this));
|
2018-08-23 23:49:16 +08:00
|
|
|
this.logger.info('Generated peer offer w/ options:', { options });
|
2018-03-08 05:10:28 +08:00
|
|
|
|
2018-04-26 00:56:16 +08:00
|
|
|
const localStream = this.webRtcPeer.peerConnection.getLocalStreams()[0];
|
2018-08-28 23:40:26 +08:00
|
|
|
const _this = this;
|
2018-03-08 05:10:28 +08:00
|
|
|
localStream.getVideoTracks()[0].onended = function () {
|
2018-08-28 23:40:26 +08:00
|
|
|
_this.webRtcPeer.peerConnection.oniceconnectionstatechange = null;
|
2018-03-08 05:10:28 +08:00
|
|
|
return kurentoManager.exitScreenShare();
|
|
|
|
};
|
|
|
|
|
|
|
|
localStream.getVideoTracks()[0].oninactive = function () {
|
|
|
|
return kurentoManager.exitScreenShare();
|
|
|
|
};
|
2018-01-16 04:15:58 +08:00
|
|
|
});
|
2018-08-23 02:10:08 +08:00
|
|
|
this.webRtcPeer.peerConnection.oniceconnectionstatechange = () => {
|
2018-08-23 23:49:16 +08:00
|
|
|
if (this.webRtcPeer) {
|
2018-08-23 02:10:08 +08:00
|
|
|
const connectionState = this.webRtcPeer.peerConnection.iceConnectionState;
|
2018-08-28 23:40:26 +08:00
|
|
|
if (connectionState === 'failed' || connectionState === 'closed') {
|
|
|
|
this.webRtcPeer.peerConnection.oniceconnectionstatechange = null;
|
2018-08-23 02:51:25 +08:00
|
|
|
this.onFail('ICE connection failed');
|
2018-08-23 02:10:08 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2018-03-08 05:20:37 +08:00
|
|
|
};
|
2018-01-16 04:15:58 +08:00
|
|
|
|
2018-04-26 00:56:16 +08:00
|
|
|
Kurento.prototype.onIceCandidate = function (candidate, role) {
|
2018-03-08 05:20:37 +08:00
|
|
|
const self = this;
|
2018-08-23 23:49:16 +08:00
|
|
|
this.logger.info('Local candidate:', { candidate });
|
2018-01-16 04:15:58 +08:00
|
|
|
|
2018-03-08 05:20:37 +08:00
|
|
|
const message = {
|
2018-07-21 03:34:50 +08:00
|
|
|
id: this.ON_ICE_CANDIDATE_MSG,
|
2018-08-23 23:49:16 +08:00
|
|
|
role,
|
2018-07-21 03:34:50 +08:00
|
|
|
type: this.SFU_APP,
|
2018-01-16 04:15:58 +08:00
|
|
|
voiceBridge: self.voiceBridge,
|
2018-03-08 05:20:37 +08:00
|
|
|
candidate,
|
2018-06-29 02:50:56 +08:00
|
|
|
callerName: self.userId,
|
2018-03-08 05:20:37 +08:00
|
|
|
};
|
2018-04-26 00:56:16 +08:00
|
|
|
|
2018-01-16 04:15:58 +08:00
|
|
|
this.sendMessage(message);
|
2018-03-08 05:20:37 +08:00
|
|
|
};
|
2018-01-16 04:15:58 +08:00
|
|
|
|
|
|
|
Kurento.prototype.setWatchVideo = function (tag) {
|
|
|
|
this.useVideo = true;
|
|
|
|
this.useCamera = 'none';
|
|
|
|
this.useMic = 'none';
|
|
|
|
this.mediaCallback = this.viewer;
|
|
|
|
this.create(tag);
|
|
|
|
};
|
|
|
|
|
|
|
|
Kurento.prototype.viewer = function () {
|
2018-03-08 05:20:37 +08:00
|
|
|
const self = this;
|
2018-01-16 04:15:58 +08:00
|
|
|
if (!this.webRtcPeer) {
|
2018-03-08 05:20:37 +08:00
|
|
|
const options = {
|
2018-04-13 02:25:51 +08:00
|
|
|
mediaConstraints: {
|
2018-08-23 23:49:16 +08:00
|
|
|
audio: false,
|
2018-04-13 02:25:51 +08:00
|
|
|
},
|
2018-01-16 04:15:58 +08:00
|
|
|
remoteVideo: document.getElementById(this.renderTag),
|
2018-04-26 00:56:16 +08:00
|
|
|
onicecandidate: (candidate) => {
|
2018-07-21 03:34:50 +08:00
|
|
|
this.onIceCandidate(candidate, this.RECV_ROLE);
|
2018-08-23 23:49:16 +08:00
|
|
|
},
|
|
|
|
};
|
2018-01-16 04:15:58 +08:00
|
|
|
|
2018-07-10 05:29:27 +08:00
|
|
|
this.addIceServers(this.iceServers, options);
|
|
|
|
|
2018-03-08 05:20:37 +08:00
|
|
|
self.webRtcPeer = kurentoUtils.WebRtcPeer.WebRtcPeerRecvonly(options, function (error) {
|
|
|
|
if (error) {
|
2018-01-16 04:15:58 +08:00
|
|
|
return self.onFail(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.generateOffer(self.onOfferViewer.bind(self));
|
|
|
|
});
|
2018-08-23 02:10:08 +08:00
|
|
|
self.webRtcPeer.peerConnection.oniceconnectionstatechange = () => {
|
2018-08-23 23:49:16 +08:00
|
|
|
if (this.webRtcPeer) {
|
2018-08-23 02:10:08 +08:00
|
|
|
const connectionState = this.webRtcPeer.peerConnection.iceConnectionState;
|
2018-08-29 00:40:51 +08:00
|
|
|
if (connectionState === 'failed' || connectionState === 'closed') {
|
|
|
|
this.webRtcPeer.peerConnection.oniceconnectionstatechange = null;
|
2018-08-23 02:51:25 +08:00
|
|
|
this.onFail('ICE connection failed');
|
2018-08-23 02:10:08 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2018-01-16 04:15:58 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
Kurento.prototype.onOfferViewer = function (error, offerSdp) {
|
2018-03-08 05:20:37 +08:00
|
|
|
const self = this;
|
|
|
|
if (error) {
|
2018-07-27 02:26:56 +08:00
|
|
|
this.logger.info(`Kurento.prototype.onOfferViewer Error ${error}`);
|
2018-01-16 04:15:58 +08:00
|
|
|
return this.onFail();
|
|
|
|
}
|
2018-03-08 05:20:37 +08:00
|
|
|
const message = {
|
2018-04-26 00:56:16 +08:00
|
|
|
id: 'start',
|
2018-07-21 03:34:50 +08:00
|
|
|
type: this.SFU_APP,
|
|
|
|
role: this.RECV_ROLE,
|
2018-01-16 04:15:58 +08:00
|
|
|
internalMeetingId: self.internalMeetingId,
|
|
|
|
voiceBridge: self.voiceBridge,
|
2018-06-29 02:50:56 +08:00
|
|
|
callerName: self.userId,
|
2018-03-08 05:20:37 +08:00
|
|
|
sdpOffer: offerSdp,
|
2018-01-16 04:15:58 +08:00
|
|
|
};
|
|
|
|
|
2018-08-23 23:49:16 +08:00
|
|
|
this.logger.info('onOfferViewer sending to screenshare server: ', { sdpOffer: message.sdpOffer });
|
2018-01-16 04:15:58 +08:00
|
|
|
this.sendMessage(message);
|
|
|
|
};
|
|
|
|
|
2018-04-28 05:37:41 +08:00
|
|
|
KurentoManager.prototype.joinAudio = function (tag) {
|
|
|
|
this.exitAudio();
|
2018-08-23 23:49:16 +08:00
|
|
|
const obj = Object.create(Kurento.prototype);
|
2018-04-28 05:37:41 +08:00
|
|
|
Kurento.apply(obj, arguments);
|
2018-08-23 23:49:16 +08:00
|
|
|
this.kurentoAudio = obj;
|
2018-04-28 05:37:41 +08:00
|
|
|
this.kurentoAudio.setAudio(tag);
|
|
|
|
};
|
|
|
|
|
|
|
|
Kurento.prototype.setAudio = function (tag) {
|
|
|
|
this.mediaCallback = this.listenOnly.bind(this);
|
|
|
|
this.create(tag);
|
|
|
|
};
|
|
|
|
|
|
|
|
Kurento.prototype.listenOnly = function () {
|
|
|
|
var self = this;
|
2018-08-30 03:12:34 +08:00
|
|
|
const remoteVideo = document.getElementById(this.renderTag);
|
|
|
|
remoteVideo.muted = true;
|
2018-04-28 05:37:41 +08:00
|
|
|
if (!this.webRtcPeer) {
|
|
|
|
var options = {
|
2018-08-28 23:24:06 +08:00
|
|
|
audioStream: this.inputStream,
|
2018-08-30 03:12:34 +08:00
|
|
|
remoteVideo,
|
2018-04-28 05:37:41 +08:00
|
|
|
onicecandidate : this.onListenOnlyIceCandidate.bind(this),
|
|
|
|
mediaConstraints: {
|
2018-08-23 23:49:16 +08:00
|
|
|
audio: true,
|
|
|
|
video: false,
|
|
|
|
},
|
|
|
|
};
|
2018-04-28 05:37:41 +08:00
|
|
|
|
2018-07-10 05:29:27 +08:00
|
|
|
this.addIceServers(this.iceServers, options);
|
|
|
|
|
2018-08-23 23:49:16 +08:00
|
|
|
self.webRtcPeer = kurentoUtils.WebRtcPeer.WebRtcPeerRecvonly(options, function (error) {
|
|
|
|
if (error) {
|
2018-04-28 05:37:41 +08:00
|
|
|
return self.onFail(PEER_ERROR);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.generateOffer(self.onOfferListenOnly.bind(self));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
Kurento.prototype.onListenOnlyIceCandidate = function (candidate) {
|
2018-08-23 23:49:16 +08:00
|
|
|
const self = this;
|
|
|
|
this.logger.debug('[onListenOnlyIceCandidate]', { candidate });
|
2018-04-28 05:37:41 +08:00
|
|
|
|
2018-08-23 23:49:16 +08:00
|
|
|
const message = {
|
|
|
|
id: this.ON_ICE_CANDIDATE_MSG,
|
2018-04-28 05:37:41 +08:00
|
|
|
type: 'audio',
|
2018-06-29 02:50:56 +08:00
|
|
|
role: 'viewer',
|
2018-04-28 05:37:41 +08:00
|
|
|
voiceBridge: self.voiceBridge,
|
2018-08-23 23:49:16 +08:00
|
|
|
candidate,
|
|
|
|
};
|
2018-04-28 05:37:41 +08:00
|
|
|
this.sendMessage(message);
|
|
|
|
};
|
|
|
|
|
|
|
|
Kurento.prototype.onOfferListenOnly = function (error, offerSdp) {
|
2018-08-23 23:49:16 +08:00
|
|
|
const self = this;
|
|
|
|
if (error) {
|
|
|
|
this.logger.error('[onOfferListenOnly]', error);
|
2018-04-28 05:37:41 +08:00
|
|
|
return this.onFail(SDP_ERROR);
|
|
|
|
}
|
|
|
|
|
2018-08-23 23:49:16 +08:00
|
|
|
const message = {
|
|
|
|
id: 'start',
|
2018-04-28 05:37:41 +08:00
|
|
|
type: 'audio',
|
|
|
|
role: 'viewer',
|
|
|
|
voiceBridge: self.voiceBridge,
|
2018-06-29 02:50:56 +08:00
|
|
|
caleeName: self.caleeName,
|
2018-08-23 23:49:16 +08:00
|
|
|
sdpOffer: offerSdp,
|
2018-04-28 05:37:41 +08:00
|
|
|
userId: self.userId,
|
|
|
|
userName: self.userName,
|
2018-08-23 23:49:16 +08:00
|
|
|
internalMeetingId: self.internalMeetingId,
|
2018-04-28 05:37:41 +08:00
|
|
|
};
|
|
|
|
|
2018-08-23 23:49:16 +08:00
|
|
|
this.logger.debug('[onOfferListenOnly]', { message });
|
2018-04-28 05:37:41 +08:00
|
|
|
this.sendMessage(message);
|
|
|
|
};
|
|
|
|
|
2018-04-26 00:56:16 +08:00
|
|
|
Kurento.prototype.pauseTrack = function (message) {
|
|
|
|
const localStream = this.webRtcPeer.peerConnection.getLocalStreams()[0];
|
|
|
|
const track = localStream.getVideoTracks()[0];
|
|
|
|
|
|
|
|
if (track) {
|
|
|
|
track.enabled = false;
|
|
|
|
}
|
2018-08-23 23:49:16 +08:00
|
|
|
};
|
2018-04-26 00:56:16 +08:00
|
|
|
|
|
|
|
Kurento.prototype.resumeTrack = function (message) {
|
|
|
|
const localStream = this.webRtcPeer.peerConnection.getLocalStreams()[0];
|
|
|
|
const track = localStream.getVideoTracks()[0];
|
|
|
|
|
|
|
|
if (track) {
|
|
|
|
track.enabled = true;
|
|
|
|
}
|
2018-08-23 23:49:16 +08:00
|
|
|
};
|
2018-04-26 00:56:16 +08:00
|
|
|
|
2018-07-10 05:29:27 +08:00
|
|
|
Kurento.prototype.addIceServers = function (iceServers, options) {
|
2018-08-23 23:49:16 +08:00
|
|
|
this.logger.debug('Adding iceServers', iceServers);
|
2018-07-10 05:29:27 +08:00
|
|
|
if (iceServers && iceServers.length > 0) {
|
|
|
|
options.configuration = {};
|
|
|
|
options.configuration.iceServers = iceServers;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-03-08 05:20:37 +08:00
|
|
|
Kurento.prototype.stop = function () {
|
|
|
|
// if (this.webRtcPeer) {
|
2018-01-16 04:15:58 +08:00
|
|
|
// var message = {
|
|
|
|
// id : 'stop',
|
|
|
|
// type : 'screenshare',
|
|
|
|
// voiceBridge: kurentoHandler.voiceBridge
|
|
|
|
// }
|
|
|
|
// kurentoHandler.sendMessage(message);
|
|
|
|
// kurentoHandler.disposeScreenShare();
|
2018-03-08 05:20:37 +08:00
|
|
|
// }
|
|
|
|
};
|
2018-01-16 04:15:58 +08:00
|
|
|
|
2018-03-08 05:20:37 +08:00
|
|
|
Kurento.prototype.dispose = function () {
|
2018-01-16 04:15:58 +08:00
|
|
|
if (this.webRtcPeer) {
|
|
|
|
this.webRtcPeer.dispose();
|
|
|
|
this.webRtcPeer = null;
|
|
|
|
}
|
2018-03-08 05:20:37 +08:00
|
|
|
};
|
2018-01-16 04:15:58 +08:00
|
|
|
|
2018-05-08 01:44:18 +08:00
|
|
|
Kurento.prototype.ping = function () {
|
|
|
|
const message = {
|
2018-08-23 23:49:16 +08:00
|
|
|
id: 'ping',
|
2018-05-08 01:44:18 +08:00
|
|
|
};
|
|
|
|
this.sendMessage(message);
|
2018-08-23 23:49:16 +08:00
|
|
|
};
|
2018-05-08 01:44:18 +08:00
|
|
|
|
2018-03-08 05:20:37 +08:00
|
|
|
Kurento.prototype.sendMessage = function (message) {
|
|
|
|
const jsonMessage = JSON.stringify(message);
|
2018-08-23 23:49:16 +08:00
|
|
|
this.logger.info('Sending message:', { message });
|
2018-01-16 04:15:58 +08:00
|
|
|
this.ws.send(jsonMessage);
|
2018-03-08 05:20:37 +08:00
|
|
|
};
|
2018-01-16 04:15:58 +08:00
|
|
|
|
|
|
|
Kurento.prototype.logger = function (obj) {
|
2018-07-27 02:26:56 +08:00
|
|
|
this.logger.info(obj);
|
2018-01-16 04:15:58 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
Kurento.prototype.logError = function (obj) {
|
2018-07-19 05:04:20 +08:00
|
|
|
this.logger.error(obj);
|
2018-01-16 04:15:58 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Kurento.normalizeCallback = function (callback) {
|
2018-03-08 05:20:37 +08:00
|
|
|
if (typeof callback === 'function') {
|
2018-01-16 04:15:58 +08:00
|
|
|
return callback;
|
|
|
|
}
|
2018-07-27 02:26:56 +08:00
|
|
|
this.logger.info(document.getElementById('BigBlueButton')[callback]);
|
2018-03-08 05:20:37 +08:00
|
|
|
return function (args) {
|
|
|
|
document.getElementById('BigBlueButton')[callback](args);
|
|
|
|
};
|
2018-01-16 04:15:58 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Global methods */
|
|
|
|
|
|
|
|
// this function explains how to use above methods/objects
|
2018-03-08 05:20:37 +08:00
|
|
|
window.getScreenConstraints = function (sendSource, callback) {
|
2018-04-13 02:25:51 +08:00
|
|
|
const screenConstraints = { video: {}, audio: false };
|
2018-01-16 04:15:58 +08:00
|
|
|
|
2018-02-09 06:53:18 +08:00
|
|
|
// Limiting FPS to a range of 5-10 (5 ideal)
|
2018-03-08 05:20:37 +08:00
|
|
|
screenConstraints.video.frameRate = { ideal: 5, max: 10 };
|
2018-02-09 06:53:18 +08:00
|
|
|
|
2018-05-10 07:38:20 +08:00
|
|
|
screenConstraints.video.height = { max: kurentoManager.kurentoScreenshare.vid_max_height };
|
|
|
|
screenConstraints.video.width = { max: kurentoManager.kurentoScreenshare.vid_max_width };
|
2018-02-09 06:53:18 +08:00
|
|
|
|
2018-07-10 05:29:27 +08:00
|
|
|
const getChromeScreenConstraints = function (extensionKey) {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
chrome.runtime.sendMessage(
|
|
|
|
extensionKey,
|
|
|
|
{
|
|
|
|
getStream: true,
|
|
|
|
sources: kurentoManager.getChromeScreenshareSources(),
|
|
|
|
},
|
|
|
|
(response) => {
|
|
|
|
resolve(response);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2018-03-08 05:20:37 +08:00
|
|
|
if (isChrome) {
|
2018-07-10 05:29:27 +08:00
|
|
|
const extensionKey = kurentoManager.getChromeExtensionKey();
|
|
|
|
getChromeScreenConstraints(extensionKey).then((constraints) => {
|
2018-02-09 06:53:18 +08:00
|
|
|
if (!constraints) {
|
2018-03-08 05:20:37 +08:00
|
|
|
document.dispatchEvent(new Event('installChromeExtension'));
|
2018-02-09 06:53:18 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-03-08 05:20:37 +08:00
|
|
|
const sourceId = constraints.streamId;
|
2018-01-16 04:15:58 +08:00
|
|
|
|
2018-02-09 06:53:18 +08:00
|
|
|
kurentoManager.kurentoScreenshare.extensionInstalled = true;
|
|
|
|
|
2018-01-16 04:15:58 +08:00
|
|
|
// this statement sets gets 'sourceId" and sets "chromeMediaSourceId"
|
2018-03-08 05:20:37 +08:00
|
|
|
screenConstraints.video.chromeMediaSource = { exact: [sendSource] };
|
2018-01-16 04:15:58 +08:00
|
|
|
screenConstraints.video.chromeMediaSourceId = sourceId;
|
2018-04-17 23:23:25 +08:00
|
|
|
screenConstraints.optional = [
|
|
|
|
{ googCpuOveruseDetection: true },
|
|
|
|
{ googCpuOveruseEncodeUsage: true },
|
|
|
|
{ googCpuUnderuseThreshold: 55 },
|
2018-08-23 23:49:16 +08:00
|
|
|
{ googCpuOveruseThreshold: 100 },
|
2018-04-17 23:23:25 +08:00
|
|
|
{ googPayloadPadding: true },
|
2018-04-27 22:37:18 +08:00
|
|
|
{ googScreencastMinBitrate: 600 },
|
2018-04-17 23:23:25 +08:00
|
|
|
{ googHighStartBitrate: true },
|
|
|
|
{ googHighBitrate: true },
|
2018-08-23 23:49:16 +08:00
|
|
|
{ googVeryHighBitrate: true },
|
2018-04-17 23:23:25 +08:00
|
|
|
];
|
2018-02-09 06:53:18 +08:00
|
|
|
|
2018-03-10 02:35:37 +08:00
|
|
|
console.log('getScreenConstraints for Chrome returns => ', screenConstraints);
|
2018-07-10 05:29:27 +08:00
|
|
|
return callback(null, screenConstraints);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isFirefox) {
|
|
|
|
const firefoxScreenshareSource = kurentoManager.getFirefoxScreenshareSource();
|
|
|
|
screenConstraints.video.mediaSource = firefoxScreenshareSource;
|
2018-01-16 04:15:58 +08:00
|
|
|
|
2018-03-10 02:35:37 +08:00
|
|
|
console.log('getScreenConstraints for Firefox returns => ', screenConstraints);
|
2018-07-10 05:29:27 +08:00
|
|
|
return callback(null, screenConstraints);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isSafari) {
|
2018-05-24 00:04:03 +08:00
|
|
|
// At this time (version 11.1), Safari doesn't support screenshare.
|
2018-05-23 01:17:35 +08:00
|
|
|
document.dispatchEvent(new Event('safariScreenshareNotSupported'));
|
2018-01-16 04:15:58 +08:00
|
|
|
}
|
2018-03-08 05:20:37 +08:00
|
|
|
};
|
2018-01-16 04:15:58 +08:00
|
|
|
|
|
|
|
window.kurentoInitialize = function () {
|
2018-03-08 05:20:37 +08:00
|
|
|
if (window.kurentoManager == null || window.KurentoManager === undefined) {
|
2018-01-16 04:15:58 +08:00
|
|
|
window.kurentoManager = new KurentoManager();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-03-08 05:20:37 +08:00
|
|
|
window.kurentoShareScreen = function () {
|
2018-01-16 04:15:58 +08:00
|
|
|
window.kurentoInitialize();
|
|
|
|
window.kurentoManager.shareScreen.apply(window.kurentoManager, arguments);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
window.kurentoExitScreenShare = function () {
|
|
|
|
window.kurentoInitialize();
|
|
|
|
window.kurentoManager.exitScreenShare();
|
|
|
|
};
|
|
|
|
|
|
|
|
window.kurentoWatchVideo = function () {
|
|
|
|
window.kurentoInitialize();
|
|
|
|
window.kurentoManager.joinWatchVideo.apply(window.kurentoManager, arguments);
|
|
|
|
};
|
|
|
|
|
|
|
|
window.kurentoExitVideo = function () {
|
|
|
|
window.kurentoInitialize();
|
|
|
|
window.kurentoManager.exitVideo();
|
2018-03-08 05:20:37 +08:00
|
|
|
};
|
|
|
|
|
2018-04-28 05:37:41 +08:00
|
|
|
window.kurentoJoinAudio = function () {
|
|
|
|
window.kurentoInitialize();
|
|
|
|
window.kurentoManager.joinAudio.apply(window.kurentoManager, arguments);
|
|
|
|
};
|
|
|
|
|
|
|
|
window.kurentoExitAudio = function () {
|
|
|
|
window.kurentoInitialize();
|
|
|
|
window.kurentoManager.exitAudio();
|
|
|
|
};
|
|
|
|
|
2018-05-08 01:44:18 +08:00
|
|
|
// a function to check whether the browser (Chrome only) is in an isIncognito
|
|
|
|
// session. Requires 1 mandatory callback that only gets called if the browser
|
|
|
|
// session is incognito. The callback for not being incognito is optional.
|
|
|
|
// Attempts to retrieve the chrome filesystem API.
|
|
|
|
/* window.checkIfIncognito = function(isIncognito, isNotIncognito = function () {}) {
|
|
|
|
isIncognito = Kurento.normalizeCallback(isIncognito);
|
|
|
|
isNotIncognito = Kurento.normalizeCallback(isNotIncognito);
|
|
|
|
|
|
|
|
var fs = window.RequestFileSystem || window.webkitRequestFileSystem;
|
|
|
|
if (!fs) {
|
|
|
|
isNotIncognito();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
fs(window.TEMPORARY, 100, function(){isNotIncognito()}, function(){isIncognito()});
|
|
|
|
};
|
|
|
|
|
|
|
|
window.checkChromeExtInstalled = function (callback, chromeExtensionId) {
|
|
|
|
callback = Kurento.normalizeCallback(callback);
|
|
|
|
|
|
|
|
if (typeof chrome === "undefined" || !chrome || !chrome.runtime) {
|
|
|
|
// No API, so no extension for sure
|
|
|
|
callback(false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
chrome.runtime.sendMessage(
|
|
|
|
chromeExtensionId,
|
|
|
|
{ getVersion: true },
|
|
|
|
function (response) {
|
|
|
|
if (!response || !response.version) {
|
|
|
|
// Communication failure - assume that no endpoint exists
|
|
|
|
callback(false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
callback(true);
|
|
|
|
}
|
|
|
|
);
|
2018-08-23 23:49:16 +08:00
|
|
|
} */
|