Skip to content
This repository has been archived by the owner on Aug 8, 2024. It is now read-only.

Commit

Permalink
fix: get settings
Browse files Browse the repository at this point in the history
  • Loading branch information
eswarclynn committed Dec 13, 2023
1 parent 09ebd36 commit a5c04cd
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions packages/hms-video-web/src/sdk/RoleChangeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,15 @@ export default class RoleChangeManager {
await this.removeVideoTracks(removeVideo || videoHasSimulcastDifference);
await this.removeScreenTracks(removeScreen || screenHasSimulcastDifference);

const initialSettings = Object.assign(
{ ...this.store.getConfig()?.settings },
{
isAudioMuted: true,
isVideoMuted: true,
audioInputDeviceId: 'default',
videoDeviceId: 'default',
audioOutputDeviceId: 'default',
},
);
const settings = this.getSettings();

if (videoHasSimulcastDifference) {
initialSettings.isVideoMuted = !prevVideoEnabled;
settings.isVideoMuted = !prevVideoEnabled;
}

// call publish with new settings, local track manager will diff policies
await this.publish(initialSettings);
await this.syncDevices(initialSettings, newRole);
await this.publish(settings);
await this.syncDevices(settings, newRole);
};

private async syncDevices(initialSettings: InitialSettings, newRole: HMSRole) {
Expand Down Expand Up @@ -151,4 +142,16 @@ export default class RoleChangeManager {
return newLayer?.maxBitrate !== layer.maxBitrate || newLayer?.maxFramerate !== layer.maxFramerate;
});
}

private getSettings(): InitialSettings {
const initialSettings = this.store.getConfig()?.settings;

return {
isAudioMuted: initialSettings?.isAudioMuted ?? true,
isVideoMuted: initialSettings?.isVideoMuted ?? true,
audioInputDeviceId: initialSettings?.audioInputDeviceId || 'default',
audioOutputDeviceId: initialSettings?.audioOutputDeviceId || 'default',
videoDeviceId: initialSettings?.videoDeviceId || 'default',
};
}
}

0 comments on commit a5c04cd

Please sign in to comment.