fix(iframe-api-devices): Misc small issues.
This commit is contained in:
@@ -14,7 +14,7 @@ import { i18next } from '../base/i18n';
|
||||
import { updateSettings } from '../base/settings';
|
||||
|
||||
import { SET_DEVICE_SELECTION_POPUP_DATA } from './actionTypes';
|
||||
import { getDeviceSelectionDialogProps, processRequest } from './functions';
|
||||
import { getDeviceSelectionDialogProps, processExternalDeviceRequest } from './functions';
|
||||
|
||||
const logger = require('jitsi-meet-logger').getLogger(__filename);
|
||||
|
||||
@@ -58,7 +58,7 @@ export function openDeviceSelectionPopup() {
|
||||
});
|
||||
|
||||
transport.on('request',
|
||||
processRequest.bind(undefined, dispatch, getState));
|
||||
processExternalDeviceRequest.bind(undefined, dispatch, getState));
|
||||
transport.on('event', event => {
|
||||
if (event.type === 'devices-dialog' && event.name === 'close') {
|
||||
popup.close();
|
||||
|
||||
@@ -28,7 +28,7 @@ export function getDeviceSelectionDialogProps(stateful: Object | Function) {
|
||||
const settings = state['features/base/settings'];
|
||||
|
||||
return {
|
||||
availableDevices: state['features/base/devices'].devices,
|
||||
availableDevices: state['features/base/devices'].availableDevices,
|
||||
disableAudioInputChange:
|
||||
!JitsiMeetJS.isMultipleAudioInputSupported(),
|
||||
disableDeviceChange:
|
||||
@@ -52,133 +52,132 @@ export function getDeviceSelectionDialogProps(stateful: Object | Function) {
|
||||
* @param {Object} request - The request to be processed.
|
||||
* @param {Function} responseCallback - The callback that will send the
|
||||
* response.
|
||||
* @returns {boolean}
|
||||
* @returns {boolean} - True if the request has been processed and false otherwise.
|
||||
*/
|
||||
export function processRequest( // eslint-disable-line max-params
|
||||
export function processExternalDeviceRequest( // eslint-disable-line max-params
|
||||
dispatch: Dispatch<any>,
|
||||
getState: Function,
|
||||
request: Object,
|
||||
responseCallback: Function) {
|
||||
if (request.type === 'devices') {
|
||||
const state = getState();
|
||||
const settings = state['features/base/settings'];
|
||||
const { conference } = state['features/base/conference'];
|
||||
let result = true;
|
||||
if (request.type !== 'devices') {
|
||||
return false;
|
||||
}
|
||||
const state = getState();
|
||||
const settings = state['features/base/settings'];
|
||||
const { conference } = state['features/base/conference'];
|
||||
let result = true;
|
||||
|
||||
switch (request.name) {
|
||||
case 'isDeviceListAvailable':
|
||||
responseCallback(JitsiMeetJS.mediaDevices.isDeviceListAvailable());
|
||||
break;
|
||||
case 'isDeviceChangeAvailable':
|
||||
responseCallback(
|
||||
JitsiMeetJS.mediaDevices.isDeviceChangeAvailable(
|
||||
request.deviceType));
|
||||
break;
|
||||
case 'isMultipleAudioInputSupported':
|
||||
responseCallback(JitsiMeetJS.isMultipleAudioInputSupported());
|
||||
break;
|
||||
case 'getCurrentDevices':
|
||||
dispatch(getAvailableDevices()).then(devices => {
|
||||
if (areDeviceLabelsInitialized(state)) {
|
||||
let audioInput, audioOutput, videoInput;
|
||||
const audioOutputDeviceId = getAudioOutputDeviceId();
|
||||
const { cameraDeviceId, micDeviceId } = settings;
|
||||
switch (request.name) {
|
||||
case 'isDeviceListAvailable':
|
||||
responseCallback(JitsiMeetJS.mediaDevices.isDeviceListAvailable());
|
||||
break;
|
||||
case 'isDeviceChangeAvailable':
|
||||
responseCallback(
|
||||
JitsiMeetJS.mediaDevices.isDeviceChangeAvailable(
|
||||
request.deviceType));
|
||||
break;
|
||||
case 'isMultipleAudioInputSupported':
|
||||
responseCallback(JitsiMeetJS.isMultipleAudioInputSupported());
|
||||
break;
|
||||
case 'getCurrentDevices':
|
||||
dispatch(getAvailableDevices()).then(devices => {
|
||||
if (areDeviceLabelsInitialized(state)) {
|
||||
let audioInput, audioOutput, videoInput;
|
||||
const audioOutputDeviceId = getAudioOutputDeviceId();
|
||||
const { cameraDeviceId, micDeviceId } = settings;
|
||||
|
||||
devices.forEach(device => {
|
||||
const { deviceId } = device;
|
||||
devices.forEach(device => {
|
||||
const { deviceId } = device;
|
||||
|
||||
switch (deviceId) {
|
||||
case micDeviceId:
|
||||
audioInput = device;
|
||||
break;
|
||||
case audioOutputDeviceId:
|
||||
audioOutput = device;
|
||||
break;
|
||||
case cameraDeviceId:
|
||||
videoInput = device;
|
||||
break;
|
||||
}
|
||||
});
|
||||
switch (deviceId) {
|
||||
case micDeviceId:
|
||||
audioInput = device;
|
||||
break;
|
||||
case audioOutputDeviceId:
|
||||
audioOutput = device;
|
||||
break;
|
||||
case cameraDeviceId:
|
||||
videoInput = device;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
responseCallback({
|
||||
audioInput,
|
||||
audioOutput,
|
||||
videoInput
|
||||
});
|
||||
} else {
|
||||
// The labels are not available if the A/V permissions are
|
||||
// not yet granted.
|
||||
dispatch(addPendingDeviceRequest({
|
||||
type: 'devices',
|
||||
name: 'getCurrentDevices',
|
||||
responseCallback
|
||||
}));
|
||||
}
|
||||
});
|
||||
|
||||
break;
|
||||
case 'getAvailableDevices':
|
||||
dispatch(getAvailableDevices()).then(devices => {
|
||||
if (areDeviceLabelsInitialized(state)) {
|
||||
responseCallback(groupDevicesByKind(devices));
|
||||
} else {
|
||||
// The labels are not available if the A/V permissions are
|
||||
// not yet granted.
|
||||
dispatch(addPendingDeviceRequest({
|
||||
type: 'devices',
|
||||
name: 'getAvailableDevices',
|
||||
responseCallback
|
||||
}));
|
||||
}
|
||||
});
|
||||
|
||||
break;
|
||||
case 'setDevice': {
|
||||
const { device } = request;
|
||||
|
||||
if (!conference) {
|
||||
responseCallback({
|
||||
audioInput,
|
||||
audioOutput,
|
||||
videoInput
|
||||
});
|
||||
} else {
|
||||
// The labels are not available if the A/V permissions are
|
||||
// not yet granted.
|
||||
dispatch(addPendingDeviceRequest({
|
||||
type: 'devices',
|
||||
name: 'setDevice',
|
||||
device,
|
||||
name: 'getCurrentDevices',
|
||||
responseCallback
|
||||
}));
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
const { label, id } = device;
|
||||
const deviceId = label ? getDeviceIdByLabel(state, device.label) : id;
|
||||
|
||||
if (deviceId) {
|
||||
switch (device.kind) {
|
||||
case 'audioinput': {
|
||||
dispatch(setAudioInputDevice(deviceId));
|
||||
break;
|
||||
}
|
||||
case 'audiooutput':
|
||||
setAudioOutputDeviceId(deviceId, dispatch);
|
||||
break;
|
||||
case 'videoinput':
|
||||
dispatch(setVideoInputDevice(deviceId));
|
||||
break;
|
||||
default:
|
||||
result = false;
|
||||
}
|
||||
break;
|
||||
case 'getAvailableDevices':
|
||||
dispatch(getAvailableDevices()).then(devices => {
|
||||
if (areDeviceLabelsInitialized(state)) {
|
||||
responseCallback(groupDevicesByKind(devices));
|
||||
} else {
|
||||
// The labels are not available if the A/V permissions are
|
||||
// not yet granted.
|
||||
dispatch(addPendingDeviceRequest({
|
||||
type: 'devices',
|
||||
name: 'getAvailableDevices',
|
||||
responseCallback
|
||||
}));
|
||||
}
|
||||
});
|
||||
|
||||
break;
|
||||
case 'setDevice': {
|
||||
const { device } = request;
|
||||
|
||||
if (!conference) {
|
||||
dispatch(addPendingDeviceRequest({
|
||||
type: 'devices',
|
||||
name: 'setDevice',
|
||||
device,
|
||||
responseCallback
|
||||
}));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const { label, id } = device;
|
||||
const deviceId = label ? getDeviceIdByLabel(state, device.label) : id;
|
||||
|
||||
if (deviceId) {
|
||||
switch (device.kind) {
|
||||
case 'audioinput': {
|
||||
dispatch(setAudioInputDevice(deviceId));
|
||||
break;
|
||||
}
|
||||
case 'audiooutput':
|
||||
setAudioOutputDeviceId(deviceId, dispatch);
|
||||
break;
|
||||
case 'videoinput':
|
||||
dispatch(setVideoInputDevice(deviceId));
|
||||
break;
|
||||
default:
|
||||
result = false;
|
||||
}
|
||||
|
||||
responseCallback(result);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
||||
return false;
|
||||
} else {
|
||||
result = false;
|
||||
}
|
||||
|
||||
return true;
|
||||
responseCallback(result);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,17 +18,17 @@ MiddlewareRegistry.register(store => next => action => {
|
||||
if (action.type === UPDATE_DEVICE_LIST) {
|
||||
const state = store.getState();
|
||||
const { popupDialogData } = state['features/device-selection'];
|
||||
const { devices } = state['features/base/devices'];
|
||||
const { availableDevices } = state['features/base/devices'];
|
||||
|
||||
if (popupDialogData) {
|
||||
popupDialogData.transport.sendEvent({
|
||||
name: 'deviceListChanged',
|
||||
devices
|
||||
devices: availableDevices
|
||||
});
|
||||
}
|
||||
|
||||
if (typeof APP !== 'undefined') {
|
||||
APP.API.notifyDeviceListChanged(devices);
|
||||
APP.API.notifyDeviceListChanged(availableDevices);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user