ref(log): logs device list and selected devices

Logs the device list when is updated in the reducer and removes
"button enabled" logging which used to dump the device list, but
in a useless way(Object[Object]).

Makes an attempt to log currently selected device, but because of
multiple possible paths it's impossible to find one reliable spot to log
selected device. One has to rely on device list and the GUM call logged
to figure things out.
This commit is contained in:
paweldomas 2020-03-06 07:56:46 -06:00 committed by Paweł Domas
parent fd8fb58eaf
commit b9addaed71
3 changed files with 39 additions and 18 deletions

View File

@ -2274,7 +2274,7 @@ export default {
}) })
.then(stream => this.useAudioStream(stream)) .then(stream => this.useAudioStream(stream))
.then(() => { .then(() => {
logger.log('switched local audio device'); logger.log(`switched local audio device: ${this.localAudio?.getDeviceId()}`);
this._updateAudioDeviceId(); this._updateAudioDeviceId();
}) })
@ -2651,12 +2651,6 @@ export default {
// audio devices detected or if the local audio stream already exists. // audio devices detected or if the local audio stream already exists.
const available = audioDeviceCount > 0 || Boolean(this.localAudio); const available = audioDeviceCount > 0 || Boolean(this.localAudio);
logger.debug(
`Microphone button enabled: ${available}`,
`local audio: ${this.localAudio}`,
`audio devices: ${audioMediaDevices}`,
`device count: ${audioDeviceCount}`);
APP.store.dispatch(setAudioAvailable(available)); APP.store.dispatch(setAudioAvailable(available));
APP.API.notifyAudioAvailabilityChanged(available); APP.API.notifyAudioAvailabilityChanged(available);
}, },
@ -2677,12 +2671,6 @@ export default {
// config). // config).
const available = videoDeviceCount > 0 || Boolean(this.localVideo); const available = videoDeviceCount > 0 || Boolean(this.localVideo);
logger.debug(
`Camera button enabled: ${available}`,
`local video: ${this.localVideo}`,
`video devices: ${videoMediaDevices}`,
`device count: ${videoDeviceCount}`);
APP.store.dispatch(setVideoAvailable(available)); APP.store.dispatch(setVideoAvailable(available));
APP.API.notifyVideoAvailabilityChanged(available); APP.API.notifyVideoAvailabilityChanged(available);
}, },

View File

@ -4,6 +4,8 @@ import { parseURLParams } from '../config';
import JitsiMeetJS from '../lib-jitsi-meet'; import JitsiMeetJS from '../lib-jitsi-meet';
import { updateSettings } from '../settings'; import { updateSettings } from '../settings';
import logger from './logger';
declare var APP: Object; declare var APP: Object;
/** /**
@ -187,6 +189,9 @@ export function setAudioOutputDeviceId(
dispatch: Function, dispatch: Function,
userSelection: boolean = false, userSelection: boolean = false,
newLabel: ?string): Promise<*> { newLabel: ?string): Promise<*> {
logger.debug(`setAudioOutputDevice: ${String(newLabel)}[${newId}]`);
return JitsiMeetJS.mediaDevices.setAudioOutputDevice(newId) return JitsiMeetJS.mediaDevices.setAudioOutputDevice(newId)
.then(() => { .then(() => {
const newSettings = { const newSettings = {

View File

@ -9,6 +9,8 @@ import { groupDevicesByKind } from './functions';
import { ReducerRegistry } from '../redux'; import { ReducerRegistry } from '../redux';
import logger from './logger';
const DEFAULT_STATE = { const DEFAULT_STATE = {
availableDevices: { availableDevices: {
audioInput: [], audioInput: [],
@ -18,6 +20,24 @@ const DEFAULT_STATE = {
pendingRequests: [] pendingRequests: []
}; };
/**
* Logs the current device list.
*
* @param {Object} deviceList - Whatever is returned by {@link groupDevicesByKind}.
* @returns {string}
*/
function logDeviceList(deviceList) {
const devicesToStr = list => list.map(device => `\t\t${device.label}[${device.deviceId}]`).join('\n');
const audioInputs = devicesToStr(deviceList.audioInput);
const audioOutputs = devicesToStr(deviceList.audioOutput);
const videoInputs = devicesToStr(deviceList.videoInput);
logger.debug('Device list updated:\n'
+ `audioInput:\n${audioInputs}\n`
+ `audioOutput:\n${audioOutputs}\n`
+ `videoInput:\n${videoInputs}`);
}
/** /**
* Listen for actions which changes the state of known and used devices. * Listen for actions which changes the state of known and used devices.
* *
@ -35,6 +55,8 @@ ReducerRegistry.register(
case UPDATE_DEVICE_LIST: { case UPDATE_DEVICE_LIST: {
const deviceList = groupDevicesByKind(action.devices); const deviceList = groupDevicesByKind(action.devices);
logDeviceList(deviceList);
return { return {
...state, ...state,
availableDevices: deviceList availableDevices: deviceList
@ -56,11 +78,17 @@ ReducerRegistry.register(
pendingRequests: [ ] pendingRequests: [ ]
}; };
// TODO: Changing of current audio and video device id is currently // TODO: Changing of current audio and video device id is currently handled outside of react/redux.
// handled outside of react/redux. Fall through to default logic for case SET_AUDIO_INPUT_DEVICE: {
// now. logger.debug(`set audio input device: ${action.deviceId}`);
case SET_AUDIO_INPUT_DEVICE:
case SET_VIDEO_INPUT_DEVICE: return state;
}
case SET_VIDEO_INPUT_DEVICE: {
logger.debug(`set video input device: ${action.deviceId}`);
return state;
}
default: default:
return state; return state;
} }