Calling: Prevent video flicker when switching audio devices
This commit is contained in:
parent
fd06ac9d57
commit
c2aa8eb82b
1 changed files with 14 additions and 6 deletions
|
@ -265,7 +265,8 @@ export class CallingClass {
|
||||||
this.lastMediaDeviceSettings,
|
this.lastMediaDeviceSettings,
|
||||||
newSettings
|
newSettings
|
||||||
);
|
);
|
||||||
await this.selectPreferredMediaDevices(newSettings);
|
|
||||||
|
await this.selectPreferredDevices(newSettings);
|
||||||
this.lastMediaDeviceSettings = newSettings;
|
this.lastMediaDeviceSettings = newSettings;
|
||||||
this.uxActions?.refreshIODevices(newSettings);
|
this.uxActions?.refreshIODevices(newSettings);
|
||||||
}
|
}
|
||||||
|
@ -407,9 +408,19 @@ export class CallingClass {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async selectPreferredMediaDevices(
|
private async selectPreferredDevices(
|
||||||
settings: MediaDeviceSettings
|
settings: MediaDeviceSettings
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
if (
|
||||||
|
(!this.lastMediaDeviceSettings && settings.selectedCamera) ||
|
||||||
|
(this.lastMediaDeviceSettings &&
|
||||||
|
settings.selectedCamera &&
|
||||||
|
this.lastMediaDeviceSettings.selectedCamera !== settings.selectedCamera)
|
||||||
|
) {
|
||||||
|
window.log.info('MediaDevice: selecting camera', settings.selectedCamera);
|
||||||
|
await this.videoCapturer.setPreferredDevice(settings.selectedCamera);
|
||||||
|
}
|
||||||
|
|
||||||
// Assume that the MediaDeviceSettings have been obtained very recently and the index is still valid (no devices have been plugged in in between).
|
// Assume that the MediaDeviceSettings have been obtained very recently and the index is still valid (no devices have been plugged in in between).
|
||||||
if (settings.selectedMicrophone) {
|
if (settings.selectedMicrophone) {
|
||||||
window.log.info(
|
window.log.info(
|
||||||
|
@ -418,6 +429,7 @@ export class CallingClass {
|
||||||
);
|
);
|
||||||
RingRTC.setAudioInput(settings.selectedMicrophone.index);
|
RingRTC.setAudioInput(settings.selectedMicrophone.index);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings.selectedSpeaker) {
|
if (settings.selectedSpeaker) {
|
||||||
window.log.info(
|
window.log.info(
|
||||||
'MediaDevice: selecting speaker',
|
'MediaDevice: selecting speaker',
|
||||||
|
@ -425,10 +437,6 @@ export class CallingClass {
|
||||||
);
|
);
|
||||||
RingRTC.setAudioOutput(settings.selectedSpeaker.index);
|
RingRTC.setAudioOutput(settings.selectedSpeaker.index);
|
||||||
}
|
}
|
||||||
if (settings.selectedCamera) {
|
|
||||||
window.log.info('MediaDevice: selecting camera', settings.selectedCamera);
|
|
||||||
await this.videoCapturer.setPreferredDevice(settings.selectedCamera);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async requestCameraPermissions(): Promise<boolean> {
|
private async requestCameraPermissions(): Promise<boolean> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue