Skip to content

Commit

Permalink
feat(external_api) facilitate gDM Electron
Browse files Browse the repository at this point in the history
In order to use gDM in Electron the flow is somewhat reversed. It starts
from the Electron main process, so we need an API in the external_api
that can trigger the builtin picker. The picker is still necessary.
  • Loading branch information
saghul committed Feb 11, 2025
1 parent 994d95b commit c569890
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
1 change: 1 addition & 0 deletions conference.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ let room;
* lib-jitsi-meet to detect and invoke
*/
window.JitsiMeetScreenObtainer = {
gDMSupported: true,
openDesktopPicker(options, onSourceChoose) {
APP.store.dispatch(showDesktopPicker(options, onSourceChoose));
}
Expand Down
18 changes: 18 additions & 0 deletions modules/API/API.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ import {
toggleChat
} from '../../react/features/chat/actions';
import { openChat } from '../../react/features/chat/actions.web';
import { showDesktopPicker } from '../../react/features/desktop-picker/actions';
import {
processExternalDeviceRequest
} from '../../react/features/device-selection/functions';
Expand Down Expand Up @@ -1048,6 +1049,23 @@ function initCommands() {
}
case '_new_electron_screensharing_supported': {
callback(true);

break;
}
case 'open-desktop-picker': {
const { desktopSharingSources } = APP.store.getState()['features/base/config'];
const options = {
desktopSharingSources: desktopSharingSources ?? [ 'screen', 'window' ]
};
const onSourceChoose = (streamId, _, screenShareAudio) => {
callback({
streamId,
screenShareAudio
});
};

dispatch(showDesktopPicker(options, onSourceChoose));

break;
}
default:
Expand Down
13 changes: 12 additions & 1 deletion modules/API/external/external_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -1243,7 +1243,7 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
* @returns {Promise}
*
* TODO: should be removed after we make sure that all Electron clients use only versions
* after with the legacy SS suport was removed from the electron SDK. If we remove it now the SS for Electron
* after with the legacy SS support was removed from the electron SDK. If we remove it now the SS for Electron
* clients with older versions wont work.
*/
_isNewElectronScreensharingSupported() {
Expand Down Expand Up @@ -1455,4 +1455,15 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
setVirtualBackground(enabled, backgroundImage) {
this.executeCommand('setVirtualBackground', enabled, backgroundImage);
}

/**
* Opens the desktop picker. This is invoked by the Electron SDK when gDM is used.
*
* @returns {Promise}
*/
_openDesktopPicker() {
return this._transport.sendRequest({
name: 'open-desktop-picker'
});
}
}

0 comments on commit c569890

Please sign in to comment.