2018-08-06 15:24:59 +00:00
|
|
|
import JitsiMeetJS from '../lib-jitsi-meet';
|
|
|
|
|
2017-03-29 17:43:30 +00:00
|
|
|
import {
|
|
|
|
SET_AUDIO_INPUT_DEVICE,
|
|
|
|
SET_VIDEO_INPUT_DEVICE,
|
|
|
|
UPDATE_DEVICE_LIST
|
|
|
|
} from './actionTypes';
|
|
|
|
|
|
|
|
/**
|
2018-08-06 15:24:59 +00:00
|
|
|
* Queries for connected A/V input and output devices and updates the redux
|
|
|
|
* state of known devices.
|
2017-03-29 17:43:30 +00:00
|
|
|
*
|
2018-08-06 15:24:59 +00:00
|
|
|
* @returns {Function}
|
2017-03-29 17:43:30 +00:00
|
|
|
*/
|
2018-08-06 15:24:59 +00:00
|
|
|
export function getAvailableDevices() {
|
|
|
|
return dispatch => new Promise(resolve => {
|
|
|
|
const { mediaDevices } = JitsiMeetJS;
|
|
|
|
|
|
|
|
if (mediaDevices.isDeviceListAvailable()
|
|
|
|
&& mediaDevices.isDeviceChangeAvailable()) {
|
|
|
|
mediaDevices.enumerateDevices(devices => {
|
|
|
|
dispatch(updateDeviceList(devices));
|
|
|
|
|
|
|
|
resolve(devices);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
resolve([]);
|
|
|
|
}
|
|
|
|
});
|
2017-03-29 17:43:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-08-06 15:24:59 +00:00
|
|
|
* Signals to update the currently used audio input device.
|
2017-03-29 17:43:30 +00:00
|
|
|
*
|
2018-08-06 15:24:59 +00:00
|
|
|
* @param {string} deviceId - The id of the new audio input device.
|
2017-03-29 17:43:30 +00:00
|
|
|
* @returns {{
|
2018-08-06 15:24:59 +00:00
|
|
|
* type: SET_AUDIO_INPUT_DEVICE,
|
2017-03-29 17:43:30 +00:00
|
|
|
* deviceId: string
|
|
|
|
* }}
|
|
|
|
*/
|
2018-08-06 15:24:59 +00:00
|
|
|
export function setAudioInputDevice(deviceId) {
|
2017-03-29 17:43:30 +00:00
|
|
|
return {
|
2018-08-06 15:24:59 +00:00
|
|
|
type: SET_AUDIO_INPUT_DEVICE,
|
2017-03-29 17:43:30 +00:00
|
|
|
deviceId
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Signals to update the currently used video input device.
|
|
|
|
*
|
|
|
|
* @param {string} deviceId - The id of the new video input device.
|
|
|
|
* @returns {{
|
|
|
|
* type: SET_VIDEO_INPUT_DEVICE,
|
|
|
|
* deviceId: string
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export function setVideoInputDevice(deviceId) {
|
|
|
|
return {
|
|
|
|
type: SET_VIDEO_INPUT_DEVICE,
|
|
|
|
deviceId
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Signals to update the list of known audio and video devices.
|
|
|
|
*
|
|
|
|
* @param {Array<MediaDeviceInfo>} devices - All known available audio input,
|
|
|
|
* audio output, and video input devices.
|
|
|
|
* @returns {{
|
|
|
|
* type: UPDATE_DEVICE_LIST,
|
|
|
|
* devices: Array<MediaDeviceInfo>
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export function updateDeviceList(devices) {
|
|
|
|
return {
|
|
|
|
type: UPDATE_DEVICE_LIST,
|
|
|
|
devices
|
|
|
|
};
|
|
|
|
}
|