From 63e273129bef98ea0602fd63c3b03b050a296b29 Mon Sep 17 00:00:00 2001 From: Matthias Seemann <296476+semmel@users.noreply.github.com> Date: Wed, 21 Jun 2023 21:36:37 +0200 Subject: [PATCH] Fix Stream.isSendScreen() for custom videoSource The custom MediaStreamTrack provided as videoSource parameter in the Publisher factory functions is now examined by the Stream.isSendScreen() method if it is a screen sharing video track. --- openvidu-browser/src/OpenVidu/Stream.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/openvidu-browser/src/OpenVidu/Stream.ts b/openvidu-browser/src/OpenVidu/Stream.ts index 9ec14929..9b315da8 100644 --- a/openvidu-browser/src/OpenVidu/Stream.ts +++ b/openvidu-browser/src/OpenVidu/Stream.ts @@ -790,12 +790,20 @@ export class Stream { * @hidden */ isSendScreen(): boolean { - let screen = this.outboundStreamOpts.publisherProperties.videoSource === 'screen'; - if (platform.isElectron()) { + let screen; + if (typeof MediaStreamTrack !== 'undefined' && + this.outboundStreamOpts.publisherProperties.videoSource instanceof MediaStreamTrack) { + var trackSettings = this.outboundStreamOpts.publisherProperties.videoSource.getSettings(); + screen = ["monitor", "window", "browser"].includes(trackSettings.displaySurface); + } + else if (platform.isElectron()) { screen = typeof this.outboundStreamOpts.publisherProperties.videoSource === 'string' && this.outboundStreamOpts.publisherProperties.videoSource.startsWith('screen:'); } + else { + screen = this.outboundStreamOpts.publisherProperties.videoSource === 'screen'; + } return !!this.outboundStreamOpts && screen; }