mirror of https://github.com/OpenVidu/openvidu.git
openvidu-browser: standarize "screen" videoSource for Electron
parent
936d8274f8
commit
5760f4e7ef
|
@ -562,12 +562,30 @@ export class OpenVidu {
|
|||
if (!!publisherProperties.videoSource && typeof publisherProperties.videoSource === 'string') {
|
||||
|
||||
if (publisherProperties.videoSource === 'screen' ||
|
||||
(platform.name!.indexOf('Firefox') !== -1 && publisherProperties.videoSource === 'window')) {
|
||||
(platform.name!.indexOf('Firefox') !== -1 && publisherProperties.videoSource === 'window') ||
|
||||
(platform.name === 'Electron' && publisherProperties.videoSource.startsWith('screen:'))) {
|
||||
|
||||
if (!this.checkScreenSharingCapabilities()) {
|
||||
|
||||
const error = new OpenViduError(OpenViduErrorName.SCREEN_SHARING_NOT_SUPPORTED, 'You can only screen share in desktop Chrome, Firefox or Opera. Detected browser: ' + platform.name);
|
||||
console.error(error);
|
||||
reject(error);
|
||||
|
||||
} else {
|
||||
|
||||
if (platform.name === 'Electron') {
|
||||
|
||||
const prefix = "screen:";
|
||||
const videoSourceString: string = publisherProperties.videoSource;
|
||||
const electronScreenId = videoSourceString.substr(videoSourceString.lastIndexOf(prefix) + prefix.length);
|
||||
(<any>mediaConstraints['video']) = {
|
||||
mandatory: {
|
||||
chromeMediaSource: 'desktop',
|
||||
chromeMediaSourceId: electronScreenId
|
||||
}
|
||||
};
|
||||
resolve(mediaConstraints);
|
||||
|
||||
} else {
|
||||
|
||||
if (!!this.advancedConfiguration.screenShareChromeExtension && !(platform.name!.indexOf('Firefox') !== -1) && !navigator.mediaDevices['getDisplayMedia']) {
|
||||
|
@ -600,6 +618,7 @@ export class OpenVidu {
|
|||
resolve(mediaConstraints);
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
|
||||
if (navigator.mediaDevices['getDisplayMedia']) {
|
||||
|
@ -637,6 +656,7 @@ export class OpenVidu {
|
|||
publisherProperties.videoSource = 'screen';
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// tslint:disable-next-line:no-string-literal
|
||||
mediaConstraints.video['deviceId'] = { exact: publisherProperties.videoSource };
|
||||
|
|
|
@ -618,7 +618,7 @@ export class Publisher extends StreamManager {
|
|||
startTime = Date.now();
|
||||
this.setPermissionDialogTimer(timeForDialogEvent);
|
||||
|
||||
if (this.stream.isSendScreen() && navigator.mediaDevices['getDisplayMedia']) {
|
||||
if (this.stream.isSendScreen() && navigator.mediaDevices['getDisplayMedia'] && platform.name !== 'Electron') {
|
||||
|
||||
navigator.mediaDevices['getDisplayMedia']({ video: true })
|
||||
.then(mediaStream => {
|
||||
|
@ -627,6 +627,7 @@ export class Publisher extends StreamManager {
|
|||
.catch(error => {
|
||||
getMediaError(error);
|
||||
});
|
||||
|
||||
} else {
|
||||
|
||||
let userMediaFunc = () => {
|
||||
|
|
|
@ -513,8 +513,12 @@ export class Stream implements EventDispatcher {
|
|||
* @hidden
|
||||
*/
|
||||
isSendScreen(): boolean {
|
||||
return (!!this.outboundStreamOpts &&
|
||||
this.outboundStreamOpts.publisherProperties.videoSource === 'screen');
|
||||
let screen = this.outboundStreamOpts.publisherProperties.videoSource === 'screen';
|
||||
if (platform.name === 'Electron') {
|
||||
screen = typeof this.outboundStreamOpts.publisherProperties.videoSource === 'string' &&
|
||||
this.outboundStreamOpts.publisherProperties.videoSource.startsWith('screen:');
|
||||
}
|
||||
return !!this.outboundStreamOpts && screen;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue