electron/lib/renderer/api/desktop-capturer.ts

23 lines
887 B
TypeScript
Raw Normal View History

2020-03-20 20:28:31 +00:00
import { ipcRendererInternal } from '@electron/internal/renderer/ipc-renderer-internal';
import { deserialize } from '@electron/internal/common/type-utils';
2020-03-20 20:28:31 +00:00
const { hasSwitch } = process.electronBinding('command_line');
2020-03-20 20:28:31 +00:00
const enableStacks = hasSwitch('enable-api-filtering-logging');
function getCurrentStack () {
2020-03-20 20:28:31 +00:00
const target = {};
if (enableStacks) {
2020-03-20 20:28:31 +00:00
Error.captureStackTrace(target, getCurrentStack);
}
2020-03-20 20:28:31 +00:00
return (target as any).stack;
}
export async function getSources (options: Electron.SourcesOptions) {
return deserialize(await ipcRendererInternal.invoke('ELECTRON_BROWSER_DESKTOP_CAPTURER_GET_SOURCES', options, getCurrentStack()));
}
export function getMediaSourceIdForWebContents (webContentsId: number) {
return ipcRendererInternal.invoke<string>('ELECTRON_BROWSER_DESKTOP_CAPTURER_GET_MEDIA_SOURCE_ID_FOR_WEB_CONTENTS', webContentsId, getCurrentStack());
}