Skip to content

Commit

Permalink
fix: echo in firefox versions >= 116
Browse files Browse the repository at this point in the history
  • Loading branch information
adityaa30 authored Jan 15, 2024
1 parent 4141fa5 commit e61f613
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
16 changes: 14 additions & 2 deletions packages/hms-video-store/src/media/tracks/HMSAudioTrack.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { HMSTrack, HMSTrackSource } from './HMSTrack';
import { HMSTrackType } from './HMSTrackType';
import HMSLogger from '../../utils/logger';
import { isFirefox } from '../../utils/support';
import { HMSMediaStream, HMSRemoteStream } from '../streams';

export class HMSAudioTrack extends HMSTrack {
Expand Down Expand Up @@ -69,8 +70,19 @@ export class HMSAudioTrack extends HMSTrack {
try {
// @ts-ignore
if (typeof this.audioElement.setSinkId === 'function') {
// @ts-ignore
await this.audioElement?.setSinkId(device.deviceId);
if (isFirefox) {
// using setSinkId in firefox disables echo cancellation (introduced in Firefox 116)
// todo: GoogleMeet doesn't set sinkId for all 3 audio elements, how do they redirect audio then?
//
// refer: https://100ms.atlassian.net/browse/LIVE-1992
// refer: https://bugzilla.mozilla.org/show_bug.cgi?id=1849108
// refer: https://bugzilla.mozilla.org/show_bug.cgi?id=1848283
// refer: https://github.com/aws/amazon-chime-sdk-js/issues/2742
} else {
// @ts-ignore
await this.audioElement?.setSinkId(device.deviceId);
}

this.outputDevice = device;
}
} catch (error) {
Expand Down
2 changes: 2 additions & 0 deletions packages/hms-video-store/src/utils/support.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ export const isMobile = () => parsedUserAgent.getDevice().type === 'mobile';
export const isPageHidden = () => typeof document !== 'undefined' && document.hidden;

export const isIOS = () => parsedUserAgent.getOS().name?.toLowerCase() === 'ios';

export const isFirefox = parsedUserAgent.getBrowser()?.name?.toLowerCase() === 'firefox';

0 comments on commit e61f613

Please sign in to comment.