Skip to content
Snippets Groups Projects
Commit 9e6208b2 authored by virtuacoplenny's avatar virtuacoplenny Committed by Saúl Ibarra Corretgé
Browse files

feat(screensharing): expose a method for obtaining a list of available desktop sources

#4
parent e527b13e
No related branches found
No related tags found
No related merge requests found
const electron = require("electron"); const electron = require("electron");
/** /**
* Adds screen sharing support. Prompts the user to choose screen, window or * Get sources available for screensharing. The callback is invoked
* tab to share (not implemented yet). And passes the chosen source to caller * with an array of DesktopCapturerSources.
* of the method. *
* @param {Function} callback the success callback * @param {Function} callback - The success callback.
* @param {Function} errorCallback the callback for errors * @param {Function} errorCallback - The callback for errors.
* @param {Object} options - Configuration for getting sources.
* @param {Array} options.types - Specify the desktop source types to get,
* with valid sources being "window" and "screen".
* @param {Object} options.thumbnailSize - Specify how big the preview
* images for the sources should be. The valid keys are height and width,
* e.g. { height: number, width: number}. By default electron will return
* images with height and width of 150px.
*/ */
function obtainDesktopStream (callback, errorCallback) { function obtainDesktopStreams(callback, errorCallback, options = {}) {
//FIXME: add more types electron.desktopCapturer.getSources(options,
electron.desktopCapturer.getSources({types: ['screen']},
(error, sources) => { (error, sources) => {
if (error) { if (error) {
errorCallback(error); errorCallback(error);
return; return;
} }
//FIXME: Implement window picker instead of choosing always the
// first sourceId callback(sources);
callback(sources[0].id);
}); });
} }
module.exports = function setupScreenSharingForWindow(pWindow) { module.exports = function setupScreenSharingForWindow(pWindow) {
pWindow.JitsiMeetElectron = {obtainDesktopStream}; pWindow.JitsiMeetElectron = {
obtainDesktopStreams
};
}; };
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment