Skip to content

Commit

Permalink
Merge branch 'dev' into fix/WEB-2954-screenshare-toast
Browse files Browse the repository at this point in the history
  • Loading branch information
KaustubhKumar05 authored Jul 29, 2024
2 parents a63900a + b51524a commit db3bd11
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -295,23 +295,7 @@ export class AudioSinkManager {
if ('ondevicechange' in navigator.mediaDevices) {
return;
}
let bluetoothDevice: InputDeviceInfo | null = null;
let speakerPhone: InputDeviceInfo | null = null;
let wired: InputDeviceInfo | null = null;
let earpiece: InputDeviceInfo | null = null;

for (const device of this.deviceManager.audioInput) {
const label = device.label.toLowerCase();
if (label.includes('speakerphone')) {
speakerPhone = device;
} else if (label.includes('wired')) {
wired = device;
} else if (label.includes('bluetooth')) {
bluetoothDevice = device;
} else if (label.includes('earpiece')) {
earpiece = device;
}
}
const { bluetoothDevice, earpiece, speakerPhone, wired } = this.deviceManager.categorizeAudioInputDevices();
const localAudioTrack = this.store.getLocalPeer()?.audioTrack;
if (localAudioTrack && earpiece) {
const externalDeviceID = bluetoothDevice?.deviceId || wired?.deviceId || speakerPhone?.deviceId;
Expand Down
30 changes: 29 additions & 1 deletion packages/hms-video-store/src/device-manager/DeviceManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ErrorFactory } from '../error/ErrorFactory';
import { HMSException } from '../error/HMSException';
import { EventBus } from '../events/EventBus';
import { DeviceMap, HMSDeviceChangeEvent, SelectedDevices } from '../interfaces';
import { isIOS } from '../internal';
import { HMSAudioTrackSettingsBuilder, HMSVideoTrackSettingsBuilder } from '../media/settings';
import { HMSLocalAudioTrack, HMSLocalTrack, HMSLocalVideoTrack } from '../media/tracks';
import { Store } from '../sdk/store';
Expand Down Expand Up @@ -205,7 +206,11 @@ export class DeviceManager implements HMSDeviceManager {
}
const audioDeviceId = this.store.getConfig()?.settings?.audioInputDeviceId;
if (!audioDeviceId && localPeer?.audioTrack) {
await localPeer.audioTrack.setSettings({ deviceId: this.audioInput[0]?.deviceId }, true);
const getInitialDeviceId = () => {
const nonIPhoneDevice = this.audioInput.find(device => !device.label.toLowerCase().includes('iphone'));
return isIOS() && nonIPhoneDevice ? nonIPhoneDevice?.deviceId : this.getNewAudioInputDevice()?.deviceId;
};
await localPeer.audioTrack.setSettings({ deviceId: getInitialDeviceId() }, true);
}
};

Expand Down Expand Up @@ -416,6 +421,29 @@ export class DeviceManager implements HMSDeviceManager {
}
};

// specifically used for mweb
categorizeAudioInputDevices() {
let bluetoothDevice: InputDeviceInfo | null = null;
let speakerPhone: InputDeviceInfo | null = null;
let wired: InputDeviceInfo | null = null;
let earpiece: InputDeviceInfo | null = null;

for (const device of this.audioInput) {
const label = device.label.toLowerCase();
if (label.includes('speakerphone')) {
speakerPhone = device;
} else if (label.includes('wired')) {
wired = device;
} else if (/airpods|buds|wireless|bluetooth/gi.test(label)) {
bluetoothDevice = device;
} else if (label.includes('earpiece')) {
earpiece = device;
}
}

return { bluetoothDevice, speakerPhone, wired, earpiece };
}

// eslint-disable-next-line complexity
private getAudioOutputDeviceMatchingInput(inputDevice?: MediaDeviceInfo) {
const blacklist = this.store.getConfig()?.settings?.speakerAutoSelectionBlacklist || [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import { useSidepaneResetOnLayoutUpdate } from '../AppData/useSidepaneResetOnLay
// @ts-ignore
import { useSetAppDataByKey, useUISettings } from '../AppData/useUISettings';
import { APP_DATA, SIDE_PANE_OPTIONS, UI_SETTINGS } from '../../common/constants';
import { defaultMedia } from './constants';

const iconDims = { height: '40px', width: '40px' };

Expand All @@ -52,9 +51,7 @@ export const VBPicker = ({ backgroundMedia = [] }: { backgroundMedia: VirtualBac
const [loadingEffects, setLoadingEffects] = useSetAppDataByKey(APP_DATA.loadingEffects);
const isPluginAdded = useHMSStore(selectIsLocalVideoPluginPresent(VBHandler?.getName() || ''));
const background = useHMSStore(selectAppData(APP_DATA.background));
const mediaList = backgroundMedia.length
? backgroundMedia.map((media: VirtualBackgroundMedia) => media.url || '')
: defaultMedia;
const mediaList = backgroundMedia.map((media: VirtualBackgroundMedia) => media.url || '');

const inPreview = roomState === HMSRoomState.Preview;
// Hidden in preview as the effect will be visible in the preview tile
Expand Down

This file was deleted.

0 comments on commit db3bd11

Please sign in to comment.