From 875c8536cc4d835f640a9bf48a6b97492dd2a25b Mon Sep 17 00:00:00 2001 From: Carlos Santos <4a.santos@gmail.com> Date: Thu, 26 Oct 2023 11:10:49 +0200 Subject: [PATCH] openvidu-browser: Fixed bug with screensharing When a screen publisher was initialized with audio but the user disable the publish audio after it, in the default browser popup, the subscriber was not able to receive the video and audio. There was an inconsistent with transceivers in webrtpeer --- openvidu-browser/src/OpenVidu/Publisher.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/openvidu-browser/src/OpenVidu/Publisher.ts b/openvidu-browser/src/OpenVidu/Publisher.ts index d643593d..4b674904 100644 --- a/openvidu-browser/src/OpenVidu/Publisher.ts +++ b/openvidu-browser/src/OpenVidu/Publisher.ts @@ -470,6 +470,15 @@ export class Publisher extends StreamManager { }; if (this.stream.isSendScreen()) { + + if(this.stream.isSendAudio() && mediaStream.getAudioTracks().length === 0){ + // If sending audio is enabled and there are no audio tracks in the mediaStream, disable audio for screen sharing. + this.stream.audioActive = false; + this.stream.hasAudio = false; + this.stream.outboundStreamOpts.publisherProperties.publishAudio = false; + this.stream.outboundStreamOpts.publisherProperties.audioSource = false; + } + // Set interval to listen for screen resize events this.screenShareResizeInterval = setInterval(() => { const settings: MediaTrackSettings = mediaStream.getVideoTracks()[0].getSettings();