diff --git a/app/lib/RoomClient.js b/app/lib/RoomClient.js index 6700f5a..5957919 100644 --- a/app/lib/RoomClient.js +++ b/app/lib/RoomClient.js @@ -134,7 +134,7 @@ export default class RoomClient device : null }; - this._screenSharing = ScreenShare.create(); + this._screenSharing = ScreenShare.create(device); this._screenSharingProducer = null; diff --git a/app/lib/ScreenShare.js b/app/lib/ScreenShare.js index 59111b1..542d2a3 100644 --- a/app/lib/ScreenShare.js +++ b/app/lib/ScreenShare.js @@ -1,5 +1,3 @@ -import { getBrowserType } from './utils'; - class ChromeScreenShare { constructor() @@ -109,6 +107,57 @@ class ChromeScreenShare } } +class Chrome72ScreenShare +{ + constructor() + { + this._stream = null; + } + + start(options = {}) + { + const constraints = this._toConstraints(options); + + return navigator.mediaDevices.getDisplayMedia(constraints) + .then((stream) => + { + this._stream = stream; + + return Promise.resolve(stream); + }); + } + + stop() + { + if (this._stream instanceof MediaStream === false) + { + return; + } + + this._stream.getTracks().forEach((track) => track.stop()); + this._stream = null; + } + + isScreenShareAvailable() + { + return true; + } + + needExtension() + { + return false; + } + + _toConstraints() + { + const constraints = { + video : true + }; + + return constraints; + } +} + class FirefoxScreenShare { constructor() @@ -255,9 +304,9 @@ class DefaultScreenShare export default class ScreenShare { - static create() + static create(device) { - switch (getBrowserType()) + switch (device.flag) { case 'firefox': { @@ -265,9 +314,12 @@ export default class ScreenShare } case 'chrome': { - return new ChromeScreenShare(); + if (device.version < 72.0) + return new ChromeScreenShare(); + else + return new Chrome72ScreenShare(); } - case 'edge': + case 'msedge': { return new EdgeScreenShare(); } diff --git a/app/lib/utils.js b/app/lib/utils.js index 88709f4..0a862df 100644 --- a/app/lib/utils.js +++ b/app/lib/utils.js @@ -19,31 +19,6 @@ export function isMobile() return !mediaQueryDetectorElem.offsetParent; } -export function getBrowserType() -{ - const ua = navigator.userAgent.toLowerCase(); - - // Firefox - if (ua.indexOf('firefox') !== -1) - { - return 'firefox'; - } - - // Chrome - if (ua.indexOf('chrome') !== -1 && ua.indexOf('edge') === -1) - { - return 'chrome'; - } - - // MSEdge - if (ua.indexOf('edge') !== -1) - { - return 'edge'; - } - - return 'N/A'; -} - /** * Create a function which will call the callback function * after the given amount of milliseconds has passed since