2017-03-29 17:43:30 +00:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
|
|
|
import {
|
|
|
|
setAudioInputDevice,
|
|
|
|
setAudioOutputDevice,
|
|
|
|
setVideoInputDevice
|
|
|
|
} from '../../base/devices';
|
2017-06-04 03:12:04 +00:00
|
|
|
import { hideDialog } from '../../base/dialog';
|
2017-03-29 17:43:30 +00:00
|
|
|
|
2017-06-04 03:12:04 +00:00
|
|
|
import DeviceSelectionDialogBase from './DeviceSelectionDialogBase';
|
2017-03-29 17:43:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* React component for previewing and selecting new audio and video sources.
|
|
|
|
*
|
|
|
|
* @extends Component
|
|
|
|
*/
|
|
|
|
class DeviceSelectionDialog extends Component {
|
|
|
|
/**
|
|
|
|
* DeviceSelectionDialog component's property types.
|
|
|
|
*
|
|
|
|
* @static
|
|
|
|
*/
|
|
|
|
static propTypes = {
|
2017-06-15 00:40:51 +00:00
|
|
|
/**
|
2017-03-29 17:43:30 +00:00
|
|
|
* All known audio and video devices split by type. This prop comes from
|
|
|
|
* the app state.
|
|
|
|
*/
|
2017-04-26 02:15:19 +00:00
|
|
|
_availableDevices: React.PropTypes.object,
|
2017-03-29 17:43:30 +00:00
|
|
|
|
|
|
|
/**
|
2017-04-26 02:15:19 +00:00
|
|
|
* Device id for the current audio input device. This device will be set
|
|
|
|
* as the default audio input device to preview.
|
2017-03-29 17:43:30 +00:00
|
|
|
*/
|
2017-04-26 02:15:19 +00:00
|
|
|
currentAudioInputId: React.PropTypes.string,
|
2017-03-29 17:43:30 +00:00
|
|
|
|
|
|
|
/**
|
2017-04-26 02:15:19 +00:00
|
|
|
* Device id for the current audio output device. This device will be
|
|
|
|
* set as the default audio output device to preview.
|
2017-03-29 17:43:30 +00:00
|
|
|
*/
|
2017-04-26 02:15:19 +00:00
|
|
|
currentAudioOutputId: React.PropTypes.string,
|
2017-03-29 17:43:30 +00:00
|
|
|
|
|
|
|
/**
|
2017-04-26 02:15:19 +00:00
|
|
|
* Device id for the current video input device. This device will be set
|
|
|
|
* as the default video input device to preview.
|
2017-03-29 17:43:30 +00:00
|
|
|
*/
|
2017-04-26 02:15:19 +00:00
|
|
|
currentVideoInputId: React.PropTypes.string,
|
2017-03-29 17:43:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether or not the audio selector can be interacted with. If true,
|
|
|
|
* the audio input selector will be rendered as disabled. This is
|
|
|
|
* specifically used to prevent audio device changing in Firefox, which
|
|
|
|
* currently does not work due to a browser-side regression.
|
|
|
|
*/
|
|
|
|
disableAudioInputChange: React.PropTypes.bool,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* True if device changing is configured to be disallowed. Selectors
|
|
|
|
* will display as disabled.
|
|
|
|
*/
|
|
|
|
disableDeviceChange: React.PropTypes.bool,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Invoked to notify the store of app state changes.
|
|
|
|
*/
|
|
|
|
dispatch: React.PropTypes.func,
|
|
|
|
|
|
|
|
/**
|
2017-06-13 00:12:29 +00:00
|
|
|
* Function that checks whether or not a new audio input source can be
|
|
|
|
* selected.
|
2017-03-29 17:43:30 +00:00
|
|
|
*/
|
2017-06-13 00:12:29 +00:00
|
|
|
hasAudioPermission: React.PropTypes.func,
|
2017-03-29 17:43:30 +00:00
|
|
|
|
|
|
|
/**
|
2017-06-13 00:12:29 +00:00
|
|
|
* Function that checks whether or not a new video input sources can be
|
|
|
|
* selected.
|
2017-03-29 17:43:30 +00:00
|
|
|
*/
|
2017-06-13 00:12:29 +00:00
|
|
|
hasVideoPermission: React.PropTypes.func,
|
2017-03-29 17:43:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* If true, the audio meter will not display. Necessary for browsers or
|
|
|
|
* configurations that do not support local stats to prevent a
|
|
|
|
* non-responsive mic preview from displaying.
|
|
|
|
*/
|
|
|
|
hideAudioInputPreview: React.PropTypes.bool,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether or not the audio output source selector should display. If
|
|
|
|
* true, the audio output selector and test audio link will not be
|
|
|
|
* rendered. This is specifically used for hiding audio output on
|
|
|
|
* temasys browsers which do not support such change.
|
|
|
|
*/
|
2017-06-04 03:12:04 +00:00
|
|
|
hideAudioOutputSelect: React.PropTypes.bool
|
2017-06-02 02:01:50 +00:00
|
|
|
};
|
2017-03-29 17:43:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
render() {
|
2017-06-04 03:12:04 +00:00
|
|
|
const {
|
|
|
|
currentAudioInputId,
|
|
|
|
currentAudioOutputId,
|
|
|
|
currentVideoInputId,
|
|
|
|
disableAudioInputChange,
|
|
|
|
disableDeviceChange,
|
|
|
|
dispatch,
|
|
|
|
hasAudioPermission,
|
|
|
|
hasVideoPermission,
|
|
|
|
hideAudioInputPreview,
|
|
|
|
hideAudioOutputSelect
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
const props = {
|
|
|
|
availableDevices: this.props._availableDevices,
|
|
|
|
closeModal: () => dispatch(hideDialog()),
|
|
|
|
currentAudioInputId,
|
|
|
|
currentAudioOutputId,
|
|
|
|
currentVideoInputId,
|
|
|
|
disableAudioInputChange,
|
|
|
|
disableDeviceChange,
|
|
|
|
hasAudioPermission,
|
|
|
|
hasVideoPermission,
|
|
|
|
hideAudioInputPreview,
|
|
|
|
hideAudioOutputSelect,
|
|
|
|
setAudioInputDevice: id => {
|
|
|
|
dispatch(setAudioInputDevice(id));
|
|
|
|
|
|
|
|
return Promise.resolve();
|
2017-03-29 17:43:30 +00:00
|
|
|
},
|
2017-06-04 03:12:04 +00:00
|
|
|
setAudioOutputDevice: id => {
|
|
|
|
dispatch(setAudioOutputDevice(id));
|
2017-03-29 17:43:30 +00:00
|
|
|
|
2017-06-04 03:12:04 +00:00
|
|
|
return Promise.resolve();
|
|
|
|
},
|
|
|
|
setVideoInputDevice: id => {
|
|
|
|
dispatch(setVideoInputDevice(id));
|
2017-04-26 02:15:19 +00:00
|
|
|
|
2017-06-04 03:12:04 +00:00
|
|
|
return Promise.resolve();
|
|
|
|
}
|
|
|
|
};
|
2017-04-26 02:15:19 +00:00
|
|
|
|
2017-06-04 03:12:04 +00:00
|
|
|
return <DeviceSelectionDialogBase { ...props } />;
|
2017-04-26 02:15:19 +00:00
|
|
|
}
|
2017-03-29 17:43:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps (parts of) the Redux state to the associated DeviceSelectionDialog's
|
|
|
|
* props.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state.
|
|
|
|
* @private
|
|
|
|
* @returns {{
|
2017-04-26 02:15:19 +00:00
|
|
|
* _availableDevices: Object
|
2017-03-29 17:43:30 +00:00
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
function _mapStateToProps(state) {
|
|
|
|
return {
|
2017-04-26 02:15:19 +00:00
|
|
|
_availableDevices: state['features/base/devices']
|
2017-03-29 17:43:30 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-06-04 03:12:04 +00:00
|
|
|
export default connect(_mapStateToProps)(DeviceSelectionDialog);
|