123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- import JitsiMeetJS from '../lib-jitsi-meet';
- import { updateSettings } from '../settings';
-
- import {
- SET_AUDIO_INPUT_DEVICE,
- SET_VIDEO_INPUT_DEVICE,
- UPDATE_DEVICE_LIST
- } from './actionTypes';
- import { getDevicesFromURL } from './functions';
-
- /**
- * Queries for connected A/V input and output devices and updates the redux
- * state of known devices.
- *
- * @returns {Function}
- */
- 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([]);
- }
- });
- }
-
- /**
- * Signals to update the currently used audio input device.
- *
- * @param {string} deviceId - The id of the new audio input device.
- * @returns {{
- * type: SET_AUDIO_INPUT_DEVICE,
- * deviceId: string
- * }}
- */
- export function setAudioInputDevice(deviceId) {
- return {
- type: SET_AUDIO_INPUT_DEVICE,
- 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
- };
- }
-
- /**
- * Configures the initial A/V devices before the conference has started.
- *
- * @returns {Function}
- */
- export function configureInitialDevices() {
- return (dispatch, getState) => new Promise(resolve => {
- const devices = getDevicesFromURL(getState());
-
- if (devices) {
- dispatch(updateSettings({
- ...devices
- }));
- resolve();
- }
- });
- }
|