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
pull/828/head
Carlos Santos 2023-10-26 11:10:49 +02:00
parent 809ba26b35
commit 875c8536cc
1 changed files with 9 additions and 0 deletions

View File

@ -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();