Merge pull request #998 from vector-im/bwindels/fix-mic-unmute

fix mic unmute
This commit is contained in:
Bruno Windels 2023-01-20 16:36:17 +00:00 committed by GitHub
commit f4582f19f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -28,22 +28,22 @@ export class LocalMedia {
) {} ) {}
withUserMedia(stream: Stream) { withUserMedia(stream: Stream) {
return new LocalMedia(stream, this.screenShare, this.dataChannelOptions); return new LocalMedia(stream, this.screenShare?.clone(), this.dataChannelOptions);
} }
withScreenShare(stream: Stream) { withScreenShare(stream: Stream) {
return new LocalMedia(this.userMedia, stream, this.dataChannelOptions); return new LocalMedia(this.userMedia?.clone(), stream, this.dataChannelOptions);
} }
withDataChannel(options: RTCDataChannelInit): LocalMedia { withDataChannel(options: RTCDataChannelInit): LocalMedia {
return new LocalMedia(this.userMedia, this.screenShare, options); return new LocalMedia(this.userMedia?.clone(), this.screenShare?.clone(), options);
} }
/** /**
* Create an instance of LocalMedia without audio track (for user preview) * Create an instance of LocalMedia without audio track (for user preview)
*/ */
asPreview(): LocalMedia { asPreview(): LocalMedia {
const media = new LocalMedia(this.userMedia, this.screenShare, this.dataChannelOptions); const media = this.clone();
const userMedia = media.userMedia; const userMedia = media.userMedia;
if (userMedia && userMedia.getVideoTracks().length > 0) { if (userMedia && userMedia.getVideoTracks().length > 0) {
const audioTrack = getStreamAudioTrack(userMedia); const audioTrack = getStreamAudioTrack(userMedia);