From b7c420292b140ec88a4cc1c961e84e43872989e1 Mon Sep 17 00:00:00 2001 From: Axel Eriksson Date: Mon, 20 Jan 2025 14:27:03 +0100 Subject: [PATCH] Use setDisplayMediaRequestHandler instead --- src/app/chrome-flags.ts | 5 +++-- src/app/display-media-request-handler.ts | 15 +++++++++++++++ src/app/main.ts | 2 ++ src/renderer/desktop-capturer.ts | 2 +- 4 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 src/app/display-media-request-handler.ts diff --git a/src/app/chrome-flags.ts b/src/app/chrome-flags.ts index 2a676e067..d4610915d 100644 --- a/src/app/chrome-flags.ts +++ b/src/app/chrome-flags.ts @@ -115,14 +115,15 @@ export const setChromeFlags = () => { export const setSessionProperties = () => { logger.info(`chrome-flags: Settings session properties`); const { customFlags } = config.getConfigFields(['customFlags']) as IConfig; + const { defaultSession } = session; if ( - session.defaultSession && + defaultSession && customFlags && customFlags.authServerWhitelist && customFlags.authServerWhitelist !== '' ) { - session.defaultSession.allowNTLMCredentialsForDomains( + defaultSession.allowNTLMCredentialsForDomains( customFlags.authServerWhitelist, ); } diff --git a/src/app/display-media-request-handler.ts b/src/app/display-media-request-handler.ts new file mode 100644 index 000000000..c4839d8e1 --- /dev/null +++ b/src/app/display-media-request-handler.ts @@ -0,0 +1,15 @@ +import { session } from 'electron'; + +export const setDisplayMediaRequestHandler = () => { + const { defaultSession } = session; + + defaultSession.setDisplayMediaRequestHandler( + async (_request, _callback) => { + console.log('We are here!'); + // const sources = await desktopCapturer.getSources({ types: ['screen', 'window'] }) + // callback({ video: sources[0] }) + // // Create picker --> + }, + { useSystemPicker: true }, + ); +}; diff --git a/src/app/main.ts b/src/app/main.ts index 8726b5241..f45198fc1 100644 --- a/src/app/main.ts +++ b/src/app/main.ts @@ -16,6 +16,7 @@ import { ICustomBrowserWindow, windowHandler } from './window-handler'; import { autoLaunchInstance } from './auto-launch-controller'; import { autoUpdate } from './auto-update-handler'; import { presenceStatusStore } from './stores'; +import { setDisplayMediaRequestHandler } from './display-media-request-handler'; // Set automatic period substitution to false because of a bug in draft js on the client app // See https://perzoinc.atlassian.net/browse/SDA-2215 for more details @@ -108,6 +109,7 @@ const startApplication = async () => { // Picks global config values and updates them in the user config await config.updateUserConfigOnStart(); setSessionProperties(); + setDisplayMediaRequestHandler(); await autoUpdate.init(); await windowHandler.createApplication(); logger.info(`main: created application`); diff --git a/src/renderer/desktop-capturer.ts b/src/renderer/desktop-capturer.ts index 41e3deacb..eec3b7eb0 100644 --- a/src/renderer/desktop-capturer.ts +++ b/src/renderer/desktop-capturer.ts @@ -59,7 +59,7 @@ export const getSource = async ( let captureWindow; let captureScreen; let id; - const sourcesOpts: string[] = []; + const sourcesOpts: ('window' | 'screen')[] = []; const { requestId, ...updatedOptions } = options; if (!isValid(options)) { callback({