'BROWSER_NOT_SUPPORTED' and 'SCREEN_SHARING_NOT_SUPPORTED' errors

pull/39/head
pabloFuente 2018-03-15 12:43:30 +01:00
parent e043eca95d
commit 644b22fe37
6 changed files with 1267 additions and 162 deletions

File diff suppressed because it is too large Load Diff

View File

@ -25,6 +25,7 @@ import { LocalRecorder } from '../OpenViduInternal/LocalRecorder';
import * as adapter from 'webrtc-adapter'; import * as adapter from 'webrtc-adapter';
import * as screenSharing from '../ScreenSharing/Screen-Capturing.js'; import * as screenSharing from '../ScreenSharing/Screen-Capturing.js';
import * as screenSharingAuto from '../ScreenSharing/Screen-Capturing-Auto.js'; import * as screenSharingAuto from '../ScreenSharing/Screen-Capturing-Auto.js';
import * as DetectRTC from '../KurentoUtils/DetectRTC';
if (window) { if (window) {
window["adapter"] = adapter; window["adapter"] = adapter;
@ -43,15 +44,11 @@ export class OpenVidu {
initSession(sessionId: string): Session; initSession(sessionId: string): Session;
initSession(param1, param2?): any { initSession(param1, param2?): any {
if (this.checkSystemRequirements()) {
if (typeof param2 == "string") { if (typeof param2 == "string") {
return new Session(this.openVidu.initSession(param2), this); return new Session(this.openVidu.initSession(param2), this);
} else { } else {
return new Session(this.openVidu.initSession(param1), this); return new Session(this.openVidu.initSession(param1), this);
} }
} else {
alert("Browser not supported");
}
} }
initPublisher(parentId: string): Publisher; initPublisher(parentId: string): Publisher;
@ -59,7 +56,7 @@ export class OpenVidu {
initPublisher(parentId: string, cameraOptions: any, callback: any): Publisher; initPublisher(parentId: string, cameraOptions: any, callback: any): Publisher;
initPublisher(parentId: string, cameraOptions?: any, callback?: Function): any { initPublisher(parentId: string, cameraOptions?: any, callback?: Function): any {
if (this.checkSystemRequirements()) {
let publisher: Publisher; let publisher: Publisher;
if (cameraOptions != null) { if (cameraOptions != null) {
@ -87,8 +84,10 @@ export class OpenVidu {
} else { } else {
// Screen share is being requested
publisher = new Publisher(this.openVidu.initPublisherScreen(parentId, true, callback), parentId, true); publisher = new Publisher(this.openVidu.initPublisherScreen(parentId, true, callback), parentId, true);
if (adapter.browserDetails.browser === 'firefox' && adapter.browserDetails.version >= 52) { if (DetectRTC.browser.name === 'Firefox' && DetectRTC.browser.version >= 52) {
screenSharingAuto.getScreenId((error, sourceId, screenConstraints) => { screenSharingAuto.getScreenId((error, sourceId, screenConstraints) => {
cameraOptions = { cameraOptions = {
sendAudio: cameraOptions.audio, sendAudio: cameraOptions.audio,
@ -108,7 +107,7 @@ export class OpenVidu {
publisher.stream.ee.emitEvent('can-request-screen'); publisher.stream.ee.emitEvent('can-request-screen');
}); });
return publisher; return publisher;
} else if (adapter.browserDetails.browser === 'chrome') { } else if (DetectRTC.browser.name === 'Chrome') {
// Screen is being requested // Screen is being requested
/*screenSharing.isChromeExtensionAvailable((availability) => { /*screenSharing.isChromeExtensionAvailable((availability) => {
@ -170,7 +169,8 @@ export class OpenVidu {
console.info("'Publisher' initialized"); console.info("'Publisher' initialized");
return publisher; return publisher;
} else { } else {
console.error('Screen sharing not supported on ' + adapter.browserDetails.browser); console.error('Screen sharing not supported on ' + DetectRTC.browser.name);
if (!!callback) callback(new OpenViduError(OpenViduErrorName.SCREEN_SHARING_NOT_SUPPORTED, 'Screen sharing not supported on ' + DetectRTC.browser.name + ' ' + DetectRTC.browser.version));
} }
} }
} else { } else {
@ -190,9 +190,6 @@ export class OpenVidu {
return publisher; return publisher;
} }
} else {
alert("Browser not supported");
}
} }
reinitPublisher(publisher: Publisher): any { reinitPublisher(publisher: Publisher): any {
@ -202,7 +199,7 @@ export class OpenVidu {
return publisher; return publisher;
} else { } else {
publisher = new Publisher(this.openVidu.initPublisherScreen(publisher.stream.getParentId(), false), publisher.stream.getParentId(), true); publisher = new Publisher(this.openVidu.initPublisherScreen(publisher.stream.getParentId(), false), publisher.stream.getParentId(), true);
if (adapter.browserDetails.browser === 'firefox' && adapter.browserDetails.version >= 52) { if (DetectRTC.browser.name === 'Firefox' && DetectRTC.browser.version >= 52) {
screenSharingAuto.getScreenId((error, sourceId, screenConstraints) => { screenSharingAuto.getScreenId((error, sourceId, screenConstraints) => {
publisher.stream.outboundOptions.mediaConstraints.video = screenConstraints.video; publisher.stream.outboundOptions.mediaConstraints.video = screenConstraints.video;
@ -212,7 +209,7 @@ export class OpenVidu {
publisher.stream.ee.emitEvent('can-request-screen'); publisher.stream.ee.emitEvent('can-request-screen');
}); });
return publisher; return publisher;
} else if (adapter.browserDetails.browser === 'chrome') { } else if (DetectRTC.browser.name === 'Chrome') {
screenSharingAuto.getScreenId((error, sourceId, screenConstraints) => { screenSharingAuto.getScreenId((error, sourceId, screenConstraints) => {
if (error === 'not-installed') { if (error === 'not-installed') {
let error = new OpenViduError(OpenViduErrorName.SCREEN_EXTENSION_NOT_INSTALLED, 'https://chrome.google.com/webstore/detail/screen-capturing/ajhifddimkapgcifgcodmmfdlknahffk'); let error = new OpenViduError(OpenViduErrorName.SCREEN_EXTENSION_NOT_INSTALLED, 'https://chrome.google.com/webstore/detail/screen-capturing/ajhifddimkapgcifgcodmmfdlknahffk');
@ -234,23 +231,21 @@ export class OpenVidu {
console.info("'Publisher' initialized"); console.info("'Publisher' initialized");
return publisher; return publisher;
} else { } else {
console.error('Screen sharing not supported on ' + adapter.browserDetails.browser); console.error('Screen sharing not supported on ' + DetectRTC.browser.name);
} }
} }
} }
checkSystemRequirements(): number { checkSystemRequirements(): number {
let browser = adapter.browserDetails.browser;
let version = adapter.browserDetails.version;
//Bug fix: 'navigator.userAgent' in Firefox for Ubuntu 14.04 does not return "Firefox/[version]" in the string, so version returned is null let defaultWebRTCSupport: boolean = DetectRTC.isWebRTCSupported;
if ((browser == 'firefox') && (version == null)) { let browser = DetectRTC.browser.name;
return 1; let version = DetectRTC.browser.version;
}
if (((browser == 'chrome') && (version >= 28)) || ((browser == 'edge') && (version >= 12)) || ((browser == 'firefox') && (version >= 22))) { if ((browser !== 'Chrome') && (browser !== 'Firefox') && (browser !== 'Opera')) {
return 1;
} else {
return 0; return 0;
} else {
return defaultWebRTCSupport ? 1 : 0;
} }
} }

View File

@ -1,12 +1,14 @@
import { SessionInternal, SessionOptions, SignalOptions } from '../OpenViduInternal/SessionInternal'; import { SessionInternal, SessionOptions, SignalOptions } from '../OpenViduInternal/SessionInternal';
import { Stream } from '../OpenViduInternal/Stream'; import { Stream } from '../OpenViduInternal/Stream';
import { Connection } from "../OpenViduInternal/Connection"; import { Connection } from '../OpenViduInternal/Connection';
import { OpenViduError, OpenViduErrorName } from '../OpenViduInternal/OpenViduError';
import { OpenVidu } from './OpenVidu'; import { OpenVidu } from './OpenVidu';
import { Publisher } from './Publisher'; import { Publisher } from './Publisher';
import { Subscriber } from './Subscriber'; import { Subscriber } from './Subscriber';
import EventEmitter = require('wolfy87-eventemitter'); import EventEmitter = require('wolfy87-eventemitter');
import * as DetectRTC from '../KurentoUtils/DetectRTC';
export class Session { export class Session {
@ -48,6 +50,7 @@ export class Session {
connect(param1, param2, param3?) { connect(param1, param2, param3?) {
// Early configuration to deactivate automatic subscription to streams // Early configuration to deactivate automatic subscription to streams
if (param3) { if (param3) {
if (this.openVidu.checkSystemRequirements()) {
this.session.configure({ this.session.configure({
sessionId: this.session.getSessionId(), sessionId: this.session.getSessionId(),
participantId: param1, participantId: param1,
@ -56,6 +59,10 @@ export class Session {
}); });
this.session.connect(param1, param3); this.session.connect(param1, param3);
} else { } else {
param3(new OpenViduError(OpenViduErrorName.BROWSER_NOT_SUPPORTED, 'Browser ' + DetectRTC.browser.name + ' ' + DetectRTC.browser.version + ' is not supported in OpenVidu'));
}
} else {
if (this.openVidu.checkSystemRequirements()) {
this.session.configure({ this.session.configure({
sessionId: this.session.getSessionId(), sessionId: this.session.getSessionId(),
participantId: param1, participantId: param1,
@ -63,6 +70,9 @@ export class Session {
subscribeToStreams: false subscribeToStreams: false
}); });
this.session.connect(param1, param2); this.session.connect(param1, param2);
} else {
param2(new OpenViduError(OpenViduErrorName.BROWSER_NOT_SUPPORTED, 'Browser ' + DetectRTC.browser.name + ' ' + DetectRTC.browser.version + ' is not supported in OpenVidu'));
}
} }
} }

View File

@ -1,9 +1,11 @@
export const enum OpenViduErrorName { export const enum OpenViduErrorName {
BROWSER_NOT_SUPPORTED = 'BROWSER_NOT_SUPPORTED',
CAMERA_ACCESS_DENIED = 'CAMERA_ACCESS_DENIED', CAMERA_ACCESS_DENIED = 'CAMERA_ACCESS_DENIED',
MICROPHONE_ACCESS_DENIED = 'MICROPHONE_ACCESS_DENIED', MICROPHONE_ACCESS_DENIED = 'MICROPHONE_ACCESS_DENIED',
SCREEN_CAPTURE_DENIED = 'SCREEN_CAPTURE_DENIED', SCREEN_CAPTURE_DENIED = 'SCREEN_CAPTURE_DENIED',
NO_VIDEO_DEVICE = 'NO_VIDEO_DEVICE', NO_VIDEO_DEVICE = 'NO_VIDEO_DEVICE',
NO_INPUT_DEVICE = 'NO_INPUT_DEVICE', NO_INPUT_DEVICE = 'NO_INPUT_DEVICE',
SCREEN_SHARING_NOT_SUPPORTED = 'SCREEN_SHARING_NOT_SUPPORTED',
SCREEN_EXTENSION_NOT_INSTALLED = 'SCREEN_EXTENSION_NOT_INSTALLED', SCREEN_EXTENSION_NOT_INSTALLED = 'SCREEN_EXTENSION_NOT_INSTALLED',
GENERIC_ERROR = 'GENERIC_ERROR' GENERIC_ERROR = 'GENERIC_ERROR'
} }

View File

@ -278,7 +278,7 @@ export class Stream {
if (this.local && !this.displayMyRemote()) { if (this.local && !this.displayMyRemote()) {
this.video.muted = true; this.video.muted = true;
this.video.onplaying = () => { this.video.oncanplay = () => {
console.info("Local 'Stream' with id [" + this.streamId + "] video is now playing"); console.info("Local 'Stream' with id [" + this.streamId + "] video is now playing");
this.ee.emitEvent('video-is-playing', [{ this.ee.emitEvent('video-is-playing', [{
element: this.video element: this.video
@ -609,7 +609,7 @@ export class Stream {
if (!!this.video) { if (!!this.video) {
// let thumbnailId = this.video.thumb; // let thumbnailId = this.video.thumb;
this.video.onplaying = () => { this.video.oncanplay = () => {
if (this.local && this.displayMyRemote()) { if (this.local && this.displayMyRemote()) {
console.info("Your own remote 'Stream' with id [" + this.streamId + "] video is now playing"); console.info("Your own remote 'Stream' with id [" + this.streamId + "] video is now playing");
this.ee.emitEvent('remote-video-is-playing', [{ this.ee.emitEvent('remote-video-is-playing', [{

View File

@ -1,5 +1,6 @@
import { Stream } from './Stream'; import { Stream } from './Stream';
import * as adapter from 'webrtc-adapter'; import * as adapter from 'webrtc-adapter';
import * as DetectRTC from '../KurentoUtils/DetectRTC';
export class WebRtcStats { export class WebRtcStats {
@ -93,7 +94,7 @@ export class WebRtcStats {
let f = (stats) => { let f = (stats) => {
if (adapter.browserDetails.browser === 'firefox') { if (DetectRTC.browser.name === 'Firefox') {
stats.forEach((stat) => { stats.forEach((stat) => {
let json = {}; let json = {};
@ -190,7 +191,7 @@ export class WebRtcStats {
sendPost(JSON.stringify(json)); sendPost(JSON.stringify(json));
} }
}); });
} else if (adapter.browserDetails.browser === 'chrome') { } else if (DetectRTC.browser.name === 'Chrome') {
for (let key of Object.keys(stats)) { for (let key of Object.keys(stats)) {
let stat = stats[key]; let stat = stats[key];
if (stat.type === 'ssrc') { if (stat.type === 'ssrc') {
@ -286,7 +287,7 @@ export class WebRtcStats {
} }
private standardizeReport(response) { private standardizeReport(response) {
if (adapter.browserDetails.browser === 'firefox') { if (DetectRTC.browser.name === 'Firefox') {
return response; return response;
} }
@ -307,13 +308,13 @@ export class WebRtcStats {
} }
private getStatsAgnostic(pc, selector, successCb, failureCb) { private getStatsAgnostic(pc, selector, successCb, failureCb) {
if (adapter.browserDetails.browser === 'firefox') { if (DetectRTC.browser.name === 'Firefox') {
// getStats takes args in different order in Chrome and Firefox // getStats takes args in different order in Chrome and Firefox
return pc.getStats(selector, (response) => { return pc.getStats(selector, (response) => {
var report = this.standardizeReport(response); var report = this.standardizeReport(response);
successCb(report); successCb(report);
}, failureCb); }, failureCb);
} else if (adapter.browserDetails.browser === 'chrome') { } else if (DetectRTC.browser.name === 'Chrome') {
// In Chrome, the first two arguments are reversed // In Chrome, the first two arguments are reversed
return pc.getStats((response) => { return pc.getStats((response) => {
var report = this.standardizeReport(response); var report = this.standardizeReport(response);