diff --git a/packages/client/src/Call.ts b/packages/client/src/Call.ts index a170b4662b..6ed94ddfea 100644 --- a/packages/client/src/Call.ts +++ b/packages/client/src/Call.ts @@ -278,36 +278,40 @@ export class Call { this.camera = new CameraManager(this); this.microphone = new MicrophoneManager(this); - this.state.localParticipant$.subscribe(async (p) => { - // Mute via device manager - // If integrator doesn't use device manager, we mute using stopPublish - if ( - !p?.publishedTracks.includes(TrackType.VIDEO) && - this.publisher?.isPublishing(TrackType.VIDEO) - ) { - this.logger( - 'info', - `Local participant's video track is muted remotely`, - ); - await this.camera.disable(); - if (this.publisher.isPublishing(TrackType.VIDEO)) { - this.stopPublish(TrackType.VIDEO); - } - } - if ( - !p?.publishedTracks.includes(TrackType.AUDIO) && - this.publisher?.isPublishing(TrackType.AUDIO) - ) { - this.logger( - 'info', - `Local participant's audio track is muted remotely`, - ); - await this.microphone.disable(); - if (this.publisher.isPublishing(TrackType.AUDIO)) { - this.stopPublish(TrackType.AUDIO); - } - } - }); + // FIXME OL: disable soft-mutes as they are not working properly + // this.state.localParticipant$.subscribe(async (p) => { + // if (!this.publisher) return; + // // Mute via device manager + // // If integrator doesn't use device manager, we mute using stopPublish + // if ( + // this.publisher.hasEverPublished(TrackType.VIDEO) && + // this.publisher.isPublishing(TrackType.VIDEO) && + // !p?.publishedTracks.includes(TrackType.VIDEO) + // ) { + // this.logger( + // 'info', + // `Local participant's video track is muted remotely`, + // ); + // await this.camera.disable(); + // if (this.publisher.isPublishing(TrackType.VIDEO)) { + // await this.stopPublish(TrackType.VIDEO); + // } + // } + // if ( + // this.publisher.hasEverPublished(TrackType.AUDIO) && + // this.publisher.isPublishing(TrackType.AUDIO) && + // !p?.publishedTracks.includes(TrackType.AUDIO) + // ) { + // this.logger( + // 'info', + // `Local participant's audio track is muted remotely`, + // ); + // await this.microphone.disable(); + // if (this.publisher.isPublishing(TrackType.AUDIO)) { + // await this.stopPublish(TrackType.AUDIO); + // } + // } + // }); this.speaker = new SpeakerManager(); } diff --git a/packages/client/src/rtc/Publisher.ts b/packages/client/src/rtc/Publisher.ts index 3d10585852..970142cba6 100644 --- a/packages/client/src/rtc/Publisher.ts +++ b/packages/client/src/rtc/Publisher.ts @@ -86,6 +86,15 @@ export class Publisher { [TrackType.UNSPECIFIED]: undefined, }; + /** + * A map keeping track of track types that were published to the SFU. + * This map shouldn't be cleared when unpublishing a track, as it is used + * to determine whether a track was published before. + * + * @private + */ + private readonly trackTypePublishHistory = new Map(); + private readonly isDtxEnabled: boolean; private readonly isRedEnabled: boolean; private readonly preferredVideoCodec?: string; @@ -269,6 +278,7 @@ export class Publisher { logger('debug', `Added ${TrackType[trackType]} transceiver`); this.transceiverInitOrder.push(trackType); this.transceiverRegistry[trackType] = transceiver; + this.trackTypePublishHistory.set(trackType, true); if ('setCodecPreferences' in transceiver && codecPreferences) { logger( @@ -352,6 +362,17 @@ export class Publisher { return false; }; + /** + * Returns true if the given track type was ever published to the SFU. + * Contrary to `isPublishing`, this method returns true if a certain + * track type was published before, even if it is currently unpublished. + * + * @param trackType the track type to check. + */ + hasEverPublished = (trackType: TrackType): boolean => { + return this.trackTypePublishHistory.get(trackType) ?? false; + }; + /** * Returns true if the given track type is currently live * diff --git a/sample-apps/react/react-video-demo/src/App.tsx b/sample-apps/react/react-video-demo/src/App.tsx index e4d4505982..af3b229475 100644 --- a/sample-apps/react/react-video-demo/src/App.tsx +++ b/sample-apps/react/react-video-demo/src/App.tsx @@ -82,7 +82,7 @@ const Init = () => { token, tokenProvider, options: { - logLevel: log_level || 'warn', + logLevel: log_level || 'info', }, }); setClient(_client);