mirror of https://github.com/OpenVidu/openvidu.git
openvidu-browser: fix wrong screen audio track management
parent
ff8605ef85
commit
50a07ed203
|
@ -568,6 +568,7 @@ export class OpenVidu {
|
||||||
// getDisplayMedia supported
|
// getDisplayMedia supported
|
||||||
try {
|
try {
|
||||||
const mediaStream = await navigator.mediaDevices['getDisplayMedia']({ video: true, audio: options.audioSource === 'screen' });
|
const mediaStream = await navigator.mediaDevices['getDisplayMedia']({ video: true, audio: options.audioSource === 'screen' });
|
||||||
|
this.removeScreenAudioTrackIfNotAvailable(mediaStream);
|
||||||
this.addAlreadyProvidedTracks(myConstraints, mediaStream);
|
this.addAlreadyProvidedTracks(myConstraints, mediaStream);
|
||||||
if (mustAskForAudioTrackLater) {
|
if (mustAskForAudioTrackLater) {
|
||||||
return await askForAudioStreamOnly(mediaStream, <MediaStreamConstraints>myConstraints.constraints);
|
return await askForAudioStreamOnly(mediaStream, <MediaStreamConstraints>myConstraints.constraints);
|
||||||
|
@ -1161,6 +1162,21 @@ export class OpenVidu {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @hidden
|
||||||
|
*/
|
||||||
|
removeScreenAudioTrackIfNotAvailable(mediaStream: MediaStream) {
|
||||||
|
const [screenVideoTrack] = mediaStream.getVideoTracks();
|
||||||
|
const displaySurface = (screenVideoTrack.getSettings() as any).displaySurface;
|
||||||
|
if (displaySurface !== 'browser') {
|
||||||
|
// tab screen share. This is the only way in CHromium right now that is possible to share the audio of a screen
|
||||||
|
mediaStream.getAudioTracks().forEach((screenAudioTrack) => {
|
||||||
|
mediaStream.removeTrack(screenAudioTrack);
|
||||||
|
screenAudioTrack.stop();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @hidden
|
* @hidden
|
||||||
*/
|
*/
|
||||||
|
@ -1298,4 +1314,5 @@ export class OpenVidu {
|
||||||
private isScreenShare(videoSource: string) {
|
private isScreenShare(videoSource: string) {
|
||||||
return videoSource === 'screen' || videoSource === 'window' || (platform.isElectron() && videoSource.startsWith('screen:'));
|
return videoSource === 'screen' || videoSource === 'window' || (platform.isElectron() && videoSource.startsWith('screen:'));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -645,6 +645,7 @@ export class Publisher extends StreamManager {
|
||||||
try {
|
try {
|
||||||
if (this.stream.isSendScreen() && navigator.mediaDevices['getDisplayMedia'] && !platform.isElectron()) {
|
if (this.stream.isSendScreen() && navigator.mediaDevices['getDisplayMedia'] && !platform.isElectron()) {
|
||||||
const mediaStream = await navigator.mediaDevices['getDisplayMedia']({ video: true, audio: this.properties.audioSource === 'screen' });
|
const mediaStream = await navigator.mediaDevices['getDisplayMedia']({ video: true, audio: this.properties.audioSource === 'screen' });
|
||||||
|
this.openvidu.removeScreenAudioTrackIfNotAvailable(mediaStream);
|
||||||
this.openvidu.addAlreadyProvidedTracks(myConstraints, mediaStream);
|
this.openvidu.addAlreadyProvidedTracks(myConstraints, mediaStream);
|
||||||
await getMediaSuccess(mediaStream, definedAudioConstraint);
|
await getMediaSuccess(mediaStream, definedAudioConstraint);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue