openvidu-components: Fixed replaced track after mute camera

openvidu-browser needs a mediaStreamTrack param if a custom was assigned before mute video track releasing resources.
pull/750/head
csantosm 2022-08-18 13:51:37 +02:00
parent 7296057184
commit 27e686271e
1 changed files with 9 additions and 1 deletions

View File

@ -287,7 +287,15 @@ export class OpenViduService {
*/ */
private async publishVideoAux(publisher: Publisher, publish: boolean): Promise<void> { private async publishVideoAux(publisher: Publisher, publish: boolean): Promise<void> {
if (!!publisher) { if (!!publisher) {
await publisher.publishVideo(publish, true); let resource: boolean | MediaStreamTrack = true;
if(publish){
// Forcing restoration with a custom media stream (the older one instead the default)
const currentDeviceId = this.deviceService.getCameraSelected()?.device;
const mediaStream = await this.createMediaStream({videoSource: currentDeviceId, audioSource: false});
resource = mediaStream.getVideoTracks()[0];
}
await publisher.publishVideo(publish, resource);
this.participantService.updateLocalParticipant(); this.participantService.updateLocalParticipant();
} }
} }