feat(iframe-api): Device handling.
This commit is contained in:
@@ -11,6 +11,9 @@ import { invite } from '../../react/features/invite';
|
||||
import { getJitsiMeetTransport } from '../transport';
|
||||
|
||||
import { API_ID } from './constants';
|
||||
import {
|
||||
processRequest
|
||||
} from '../../react/features/device-selection/functions';
|
||||
|
||||
const logger = require('jitsi-meet-logger').getLogger(__filename);
|
||||
|
||||
@@ -117,6 +120,12 @@ function initCommands() {
|
||||
return false;
|
||||
});
|
||||
transport.on('request', (request, callback) => {
|
||||
const { dispatch, getState } = APP.store;
|
||||
|
||||
if (processRequest(dispatch, getState, request, callback)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const { name } = request;
|
||||
|
||||
switch (name) {
|
||||
|
||||
Vendored
+90
@@ -7,6 +7,16 @@ import {
|
||||
} from '../../transport';
|
||||
|
||||
import electronPopupsConfig from './electronPopupsConfig.json';
|
||||
import {
|
||||
getAvailableDevices,
|
||||
getCurrentDevices,
|
||||
isDeviceChangeAvailable,
|
||||
isDeviceListAvailable,
|
||||
isMultipleAudioInputSupported,
|
||||
setAudioInputDevice,
|
||||
setAudioOutputDevice,
|
||||
setVideoInputDevice
|
||||
} from './functions';
|
||||
|
||||
const logger = require('jitsi-meet-logger').getLogger(__filename);
|
||||
|
||||
@@ -593,6 +603,24 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Promise that resolves with result an list of available devices.
|
||||
*
|
||||
* @returns {Promise}
|
||||
*/
|
||||
getAvailableDevices() {
|
||||
return getAvailableDevices(this._transport);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Promise that resolves with current selected devices.
|
||||
*
|
||||
* @returns {Promise}
|
||||
*/
|
||||
getCurrentDevices() {
|
||||
return getCurrentDevices(this._transport);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the audio is available.
|
||||
*
|
||||
@@ -605,6 +633,38 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Promise that resolves with true if the device change is available
|
||||
* and with false if not.
|
||||
*
|
||||
* @param {string} [deviceType] - Values - 'output', 'input' or undefined.
|
||||
* Default - 'input'.
|
||||
* @returns {Promise}
|
||||
*/
|
||||
isDeviceChangeAvailable(deviceType) {
|
||||
return isDeviceChangeAvailable(this._transport, deviceType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Promise that resolves with true if the device list is available
|
||||
* and with false if not.
|
||||
*
|
||||
* @returns {Promise}
|
||||
*/
|
||||
isDeviceListAvailable() {
|
||||
return isDeviceListAvailable(this._transport);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Promise that resolves with true if the device list is available
|
||||
* and with false if not.
|
||||
*
|
||||
* @returns {Promise}
|
||||
*/
|
||||
isMultipleAudioInputSupported() {
|
||||
return isMultipleAudioInputSupported(this._transport);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invite people to the call.
|
||||
*
|
||||
@@ -771,6 +831,36 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the audio input device to the one with the id that is passed.
|
||||
*
|
||||
* @param {string} deviceId - The id of the new device.
|
||||
* @returns {Promise}
|
||||
*/
|
||||
setAudioInputDevice(deviceId) {
|
||||
return setAudioInputDevice(this._transport, deviceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the audio output device to the one with the id that is passed.
|
||||
*
|
||||
* @param {string} deviceId - The id of the new device.
|
||||
* @returns {Promise}
|
||||
*/
|
||||
setAudioOutputDevice(deviceId) {
|
||||
return setAudioOutputDevice(this._transport, deviceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the video input device to the one with the id that is passed.
|
||||
*
|
||||
* @param {string} deviceId - The id of the new device.
|
||||
* @returns {Promise}
|
||||
*/
|
||||
setVideoInputDevice(deviceId) {
|
||||
return setVideoInputDevice(this._transport, deviceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the configuration for electron for the windows that are open
|
||||
* from Jitsi Meet.
|
||||
|
||||
Vendored
+162
@@ -0,0 +1,162 @@
|
||||
// @flow
|
||||
|
||||
import Logger from 'jitsi-meet-logger';
|
||||
|
||||
const logger = Logger.getLogger(__filename);
|
||||
|
||||
/**
|
||||
* Returns Promise that resolves with result an list of available devices.
|
||||
*
|
||||
* @param {Transport} transport - The @code{Transport} instance responsible for
|
||||
* the external communication.
|
||||
* @returns {Promise}
|
||||
*/
|
||||
export function getAvailableDevices(transport: Object) {
|
||||
return transport.sendRequest({
|
||||
type: 'devices',
|
||||
name: 'getAvailableDevices'
|
||||
}).catch(e => {
|
||||
logger.error(e);
|
||||
|
||||
return {};
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Promise that resolves with current selected devices.
|
||||
*
|
||||
* @param {Transport} transport - The @code{Transport} instance responsible for
|
||||
* the external communication.
|
||||
* @returns {Promise}
|
||||
*/
|
||||
export function getCurrentDevices(transport: Object) {
|
||||
return transport.sendRequest({
|
||||
type: 'devices',
|
||||
name: 'getCurrentDevices'
|
||||
}).catch(e => {
|
||||
logger.error(e);
|
||||
|
||||
return {};
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Promise that resolves with true if the device change is available
|
||||
* and with false if not.
|
||||
*
|
||||
* @param {Transport} transport - The @code{Transport} instance responsible for
|
||||
* the external communication.
|
||||
* @param {string} [deviceType] - Values - 'output', 'input' or undefined.
|
||||
* Default - 'input'.
|
||||
* @returns {Promise}
|
||||
*/
|
||||
export function isDeviceChangeAvailable(transport: Object, deviceType: string) {
|
||||
return transport.sendRequest({
|
||||
deviceType,
|
||||
type: 'devices',
|
||||
name: 'isDeviceChangeAvailable'
|
||||
}).catch(e => {
|
||||
logger.error(e);
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Promise that resolves with true if the device list is available
|
||||
* and with false if not.
|
||||
*
|
||||
* @param {Transport} transport - The @code{Transport} instance responsible for
|
||||
* the external communication.
|
||||
* @returns {Promise}
|
||||
*/
|
||||
export function isDeviceListAvailable(transport: Object) {
|
||||
return transport.sendRequest({
|
||||
type: 'devices',
|
||||
name: 'isDeviceListAvailable'
|
||||
}).catch(e => {
|
||||
logger.error(e);
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Promise that resolves with true if the device list is available
|
||||
* and with false if not.
|
||||
*
|
||||
* @param {Transport} transport - The @code{Transport} instance responsible for
|
||||
* the external communication.
|
||||
* @returns {Promise}
|
||||
*/
|
||||
export function isMultipleAudioInputSupported(transport: Object) {
|
||||
return transport.sendRequest({
|
||||
type: 'devices',
|
||||
name: 'isMultipleAudioInputSupported'
|
||||
}).catch(e => {
|
||||
logger.error(e);
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the audio input device to the one with the id that is passed.
|
||||
*
|
||||
* @param {Transport} transport - The @code{Transport} instance responsible for
|
||||
* the external communication.
|
||||
* @param {string} id - The id of the new device.
|
||||
* @returns {Promise}
|
||||
*/
|
||||
export function setAudioInputDevice(transport: Object, id: string) {
|
||||
return _setDevice(transport, {
|
||||
id,
|
||||
kind: 'audioinput'
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the audio output device to the one with the id that is passed.
|
||||
*
|
||||
* @param {Transport} transport - The @code{Transport} instance responsible for
|
||||
* the external communication.
|
||||
* @param {string} id - The id of the new device.
|
||||
* @returns {Promise}
|
||||
*/
|
||||
export function setAudioOutputDevice(transport: Object, id: string) {
|
||||
return _setDevice(transport, {
|
||||
id,
|
||||
kind: 'audiooutput'
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the currently used device to the one that is passed.
|
||||
*
|
||||
* @param {Transport} transport - The @code{Transport} instance responsible for
|
||||
* the external communication.
|
||||
* @param {Object} device - The new device to be used.
|
||||
* @returns {Promise}
|
||||
*/
|
||||
function _setDevice(transport: Object, device) {
|
||||
return transport.sendRequest({
|
||||
type: 'devices',
|
||||
name: 'setDevice',
|
||||
device
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the video input device to the one with the id that is passed.
|
||||
*
|
||||
* @param {Transport} transport - The @code{Transport} instance responsible for
|
||||
* the external communication.
|
||||
* @param {string} id - The id of the new device.
|
||||
* @returns {Promise}
|
||||
*/
|
||||
export function setVideoInputDevice(transport: Object, id: string) {
|
||||
return _setDevice(transport, {
|
||||
id,
|
||||
kind: 'videoinput'
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user