2017-03-30 16:58:31 +00:00
|
|
|
import { openDialog } from '../base/dialog';
|
2017-04-06 16:45:36 +00:00
|
|
|
|
2017-03-30 16:58:31 +00:00
|
|
|
import {
|
|
|
|
RESET_DESKTOP_SOURCES,
|
|
|
|
UPDATE_DESKTOP_SOURCES
|
|
|
|
} from './actionTypes';
|
|
|
|
import { DesktopPicker } from './components';
|
|
|
|
|
2017-04-06 16:45:36 +00:00
|
|
|
const logger = require('jitsi-meet-logger').getLogger(__filename);
|
2017-03-30 16:58:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Begins a request to get available DesktopCapturerSources.
|
|
|
|
*
|
|
|
|
* @param {Array} types - An array with DesktopCapturerSource type strings.
|
2017-04-06 16:45:36 +00:00
|
|
|
* @param {Object} options - Additional configuration for getting a list of
|
|
|
|
* sources.
|
|
|
|
* @param {Object} options.thumbnailSize - The desired height and width of the
|
|
|
|
* return native image object used for the preview image of the source.
|
2017-03-30 16:58:31 +00:00
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
export function obtainDesktopSources(types, options = {}) {
|
|
|
|
const capturerOptions = {
|
|
|
|
types
|
|
|
|
};
|
|
|
|
|
|
|
|
if (options.thumbnailSize) {
|
|
|
|
capturerOptions.thumbnailSize = options.thumbnailSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
return dispatch => {
|
2017-04-06 16:45:36 +00:00
|
|
|
const { JitsiMeetElectron } = window;
|
|
|
|
|
|
|
|
if (JitsiMeetElectron && JitsiMeetElectron.obtainDesktopStreams) {
|
|
|
|
JitsiMeetElectron.obtainDesktopStreams(
|
2017-03-30 16:58:31 +00:00
|
|
|
sources => dispatch(updateDesktopSources(sources)),
|
2017-04-06 16:45:36 +00:00
|
|
|
error =>
|
|
|
|
logger.error(
|
|
|
|
`Error while obtaining desktop sources: ${error}`),
|
2017-03-30 16:58:31 +00:00
|
|
|
capturerOptions
|
|
|
|
);
|
|
|
|
} else {
|
2017-04-06 16:45:36 +00:00
|
|
|
logger.error(
|
|
|
|
'Called JitsiMeetElectron.obtainDesktopStreams'
|
|
|
|
+ ' but it is not defined');
|
2017-03-30 16:58:31 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-04-06 16:45:36 +00:00
|
|
|
/**
|
|
|
|
* Signals to remove all stored DesktopCapturerSources.
|
|
|
|
*
|
|
|
|
* @returns {{
|
|
|
|
* type: RESET_DESKTOP_SOURCES
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export function resetDesktopSources() {
|
|
|
|
return {
|
|
|
|
type: RESET_DESKTOP_SOURCES
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-03-30 16:58:31 +00:00
|
|
|
/**
|
|
|
|
* Signals to open a dialog with the DesktopPicker component.
|
|
|
|
*
|
2017-07-09 21:34:08 +00:00
|
|
|
* @param {Object} options - Desktop sharing settings.
|
2017-03-30 16:58:31 +00:00
|
|
|
* @param {Function} onSourceChoose - The callback to invoke when
|
|
|
|
* a DesktopCapturerSource has been chosen.
|
|
|
|
* @returns {Object}
|
|
|
|
*/
|
2017-07-09 21:34:08 +00:00
|
|
|
export function showDesktopPicker(options, onSourceChoose) {
|
2017-03-30 16:58:31 +00:00
|
|
|
return openDialog(DesktopPicker, {
|
2017-07-09 21:34:08 +00:00
|
|
|
options,
|
2017-03-30 16:58:31 +00:00
|
|
|
onSourceChoose
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Signals new DesktopCapturerSources have been received.
|
|
|
|
*
|
|
|
|
* @param {Object} sources - Arrays with DesktopCapturerSources.
|
|
|
|
* @returns {{
|
|
|
|
* type: UPDATE_DESKTOP_SOURCES,
|
|
|
|
* sources: Array
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export function updateDesktopSources(sources) {
|
|
|
|
return {
|
|
|
|
type: UPDATE_DESKTOP_SOURCES,
|
|
|
|
sources
|
|
|
|
};
|
|
|
|
}
|