This commit is contained in:
@@ -36,6 +36,12 @@ const DEFAULT_SETTINGS = {
|
||||
|
||||
let mainWindow = null;
|
||||
|
||||
// Screen-share source picked by the renderer right before LiveKit's
|
||||
// setScreenShareEnabled(true) call triggers getDisplayMedia. The
|
||||
// setDisplayMediaRequestHandler reads + clears this on each fire,
|
||||
// then resolves the callback with the matching DesktopCapturerSource.
|
||||
let pendingScreenSourceSelection = null;
|
||||
|
||||
// ───────────────────────────────────────────────────────────────
|
||||
// Voice recording — per-participant audio capture
|
||||
// ───────────────────────────────────────────────────────────────
|
||||
@@ -187,6 +193,34 @@ function createWindow() {
|
||||
});
|
||||
}
|
||||
|
||||
// Electron 20+ refuses navigator.mediaDevices.getDisplayMedia()
|
||||
// unless a handler is registered here. LiveKit's
|
||||
// setScreenShareEnabled(true) hits getDisplayMedia internally,
|
||||
// so without this the renderer sees "NotSupportedError: Not
|
||||
// supported". The renderer pre-stashes its picked source via the
|
||||
// `screen-share:set-pending-source` IPC, then triggers the LiveKit
|
||||
// call — we read + clear the pending selection here.
|
||||
mainWindow.webContents.session.setDisplayMediaRequestHandler(async (_request, callback) => {
|
||||
const pending = pendingScreenSourceSelection;
|
||||
pendingScreenSourceSelection = null;
|
||||
if (!pending) {
|
||||
callback({});
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const { desktopCapturer } = require('electron');
|
||||
const sources = await desktopCapturer.getSources({ types: ['window', 'screen'] });
|
||||
const source = sources.find(s => s.id === pending.sourceId);
|
||||
if (!source) { callback({}); return; }
|
||||
callback({
|
||||
video: source,
|
||||
audio: pending.includeAudio ? 'loopback' : undefined,
|
||||
});
|
||||
} catch {
|
||||
callback({});
|
||||
}
|
||||
}, { useSystemPicker: false });
|
||||
|
||||
if (settings.isMaximized) {
|
||||
mainWindow.maximize();
|
||||
}
|
||||
@@ -634,6 +668,13 @@ app.whenReady().then(async () => {
|
||||
}));
|
||||
});
|
||||
|
||||
ipcMain.handle('screen-share:set-pending-source', (_event, payload) => {
|
||||
pendingScreenSourceSelection = payload && typeof payload.sourceId === 'string'
|
||||
? { sourceId: payload.sourceId, includeAudio: !!payload.includeAudio }
|
||||
: null;
|
||||
return true;
|
||||
});
|
||||
|
||||
// Crypto Handlers
|
||||
const crypto = require('crypto');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user