From 6ed59332d1965f70da4364813fd2fd2c7e9cb8a8 Mon Sep 17 00:00:00 2001 From: Noah <37805707+Curve@users.noreply.github.com> Date: Tue, 9 Apr 2024 04:22:20 +0200 Subject: [PATCH 01/21] Bump venmic to `3.3.3` (#483) --- package.json | 2 +- pnpm-lock.yaml | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 1130fb2..ea29c6f 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "arrpc": "github:OpenAsar/arrpc#98879cae0565e6fce34e4cb6f544bf42c6a7e7c8" }, "optionalDependencies": { - "@vencord/venmic": "^3.3.2" + "@vencord/venmic": "^3.3.3" }, "devDependencies": { "@fal-works/esbuild-plugin-global-externals": "^2.1.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4c33237..7e4d219 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,8 +11,8 @@ dependencies: optionalDependencies: '@vencord/venmic': - specifier: ^3.3.2 - version: 3.3.2 + specifier: ^3.3.3 + version: 3.3.3 devDependencies: '@fal-works/esbuild-plugin-global-externals': @@ -1000,14 +1000,14 @@ packages: type-fest: 3.13.1 dev: true - /@vencord/venmic@3.3.2: - resolution: {integrity: sha512-fwGr5v+Xe4EisKxxhTDlUDamBGlBzSK3+yYZH/7d9ui1j8Q78wCbE1iP8MnDjBvV2kIKn/xV/84wjt9iQvDkFw==} + /@vencord/venmic@3.3.3: + resolution: {integrity: sha512-qC3fPAUtw8j5L6uV3m9BGEnKpuOAlrYeZzFgILF3bFnDNFE9ANJsYttoHt80laBU7C1Xo56tHG2vVpLBsH+sgw==} engines: {node: '>=14.15'} os: [linux] requiresBuild: true dependencies: cmake-js: 7.3.0 - node-addon-api: 7.1.0 + node-addon-api: 8.0.0 pkg-prebuilds: 0.2.1 transitivePeerDependencies: - supports-color @@ -3581,9 +3581,9 @@ packages: dev: true optional: true - /node-addon-api@7.1.0: - resolution: {integrity: sha512-mNcltoe1R8o7STTegSOHdnJNN7s5EUvhoS7ShnTHDyOSd+8H+UdWODq6qSv67PjC8Zc5JRT8+oLAMCr0SIXw7g==} - engines: {node: ^16 || ^18 || >= 20} + /node-addon-api@8.0.0: + resolution: {integrity: sha512-ipO7rsHEBqa9STO5C5T10fj732ml+5kLN1cAG8/jdHd56ldQeGj3Q7+scUS+VHK/qy1zLEwC4wMK5+yM0btPvw==} + engines: {node: ^18 || ^20 || >= 21} requiresBuild: true dev: false optional: true From 8c6941b8e92a9cd76ebc81c6331928bbf3dbd416 Mon Sep 17 00:00:00 2001 From: Diego Parra <101421807+0bCdian@users.noreply.github.com> Date: Tue, 9 Apr 2024 04:23:34 +0200 Subject: [PATCH 02/21] Tray: Add left click hide/show feature (#404) Co-authored-by: V --- src/main/mainWindow.ts | 6 +++++- src/renderer/components/settings/Settings.tsx | 6 ++++++ src/shared/settings.d.ts | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/mainWindow.ts b/src/main/mainWindow.ts index 1479b8a..7e0afde 100644 --- a/src/main/mainWindow.ts +++ b/src/main/mainWindow.ts @@ -73,6 +73,10 @@ const [addSettingsListener, removeSettingsListeners] = makeSettingsListenerHelpe const [addVencordSettingsListener, removeVencordSettingsListeners] = makeSettingsListenerHelpers(VencordSettings); function initTray(win: BrowserWindow) { + const onTrayClick = () => { + if (Settings.store.clickTrayToShowHide && win.isVisible()) win.hide(); + else win.show(); + }; const trayMenu = Menu.buildFromTemplate([ { label: "Open", @@ -120,7 +124,7 @@ function initTray(win: BrowserWindow) { tray = new Tray(ICON_PATH); tray.setToolTip("Vesktop"); tray.setContextMenu(trayMenu); - tray.on("click", () => win.show()); + tray.on("click", onTrayClick); } async function clearData(win: BrowserWindow) { diff --git a/src/renderer/components/settings/Settings.tsx b/src/renderer/components/settings/Settings.tsx index cc6b3c2..d6de13c 100644 --- a/src/renderer/components/settings/Settings.tsx +++ b/src/renderer/components/settings/Settings.tsx @@ -83,6 +83,12 @@ const SettingsOptions: Record> invisible: () => isMac, disabled: () => Settings.store.tray === false }, + { + key: "clickTrayToShowHide", + title: "Hide/Show on tray click", + description: "Left clicking tray icon will toggle the vesktop window visibility.", + defaultValue: false + }, { key: "disableMinSize", title: "Disable minimum window size", diff --git a/src/shared/settings.d.ts b/src/shared/settings.d.ts index d796e4b..7f6e74a 100644 --- a/src/shared/settings.d.ts +++ b/src/shared/settings.d.ts @@ -20,7 +20,7 @@ export interface Settings { arRPC?: boolean; appBadge?: boolean; disableMinSize?: boolean; - + clickTrayToShowHide?: boolean; /** @deprecated use customTitleBar */ discordWindowsTitleBar?: boolean; customTitleBar?: boolean; From df05d12fb26a97c63323a7b9fdfb103ec580433c Mon Sep 17 00:00:00 2001 From: Noah <37805707+Curve@users.noreply.github.com> Date: Sun, 14 Apr 2024 02:24:19 +0200 Subject: [PATCH 03/21] Venmic v3.4 (#499) --- package.json | 2 +- pnpm-lock.yaml | 20 +- src/main/venmic.ts | 5 +- src/preload/VesktopNative.ts | 3 +- src/renderer/components/ScreenSharePicker.tsx | 215 +++++++++++------- src/renderer/components/screenSharePicker.css | 6 + 6 files changed, 149 insertions(+), 102 deletions(-) diff --git a/package.json b/package.json index ea29c6f..917dd41 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "arrpc": "github:OpenAsar/arrpc#98879cae0565e6fce34e4cb6f544bf42c6a7e7c8" }, "optionalDependencies": { - "@vencord/venmic": "^3.3.3" + "@vencord/venmic": "^3.4.1" }, "devDependencies": { "@fal-works/esbuild-plugin-global-externals": "^2.1.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7e4d219..7099617 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,8 +11,8 @@ dependencies: optionalDependencies: '@vencord/venmic': - specifier: ^3.3.3 - version: 3.3.3 + specifier: ^3.4.1 + version: 3.4.1 devDependencies: '@fal-works/esbuild-plugin-global-externals': @@ -1000,8 +1000,8 @@ packages: type-fest: 3.13.1 dev: true - /@vencord/venmic@3.3.3: - resolution: {integrity: sha512-qC3fPAUtw8j5L6uV3m9BGEnKpuOAlrYeZzFgILF3bFnDNFE9ANJsYttoHt80laBU7C1Xo56tHG2vVpLBsH+sgw==} + /@vencord/venmic@3.4.1: + resolution: {integrity: sha512-PkMXx53nxiYBLWxiMRaBjBm8aTTJTcueKsMZ0v35TtIQ93yfuSzfCilDFLs3kYz1uQHArTaI9IGQykgmSfe/2w==} engines: {node: '>=14.15'} os: [linux] requiresBuild: true @@ -1333,11 +1333,11 @@ packages: possible-typed-array-names: 1.0.0 dev: true - /axios@1.6.7(debug@4.3.4): - resolution: {integrity: sha512-/hDJGff6/c7u0hDkvkGxR/oy6CbCs8ziCsC7SqmhjfozqiJGc8Z11wrv9z9lYfY4K8l+H9TpjcMDX0xOZmx+RA==} + /axios@1.6.8(debug@4.3.4): + resolution: {integrity: sha512-v/ZHtJDU39mDpyBoFVkETcd/uNdxrWRrg3bKpOKzXFA6Bvqopts6ALSMU3y6ijYxbw2B+wPrIv46egTzJXCLGQ==} requiresBuild: true dependencies: - follow-redirects: 1.15.5(debug@4.3.4) + follow-redirects: 1.15.6(debug@4.3.4) form-data: 4.0.0 proxy-from-env: 1.1.0 transitivePeerDependencies: @@ -1576,7 +1576,7 @@ packages: hasBin: true requiresBuild: true dependencies: - axios: 1.6.7(debug@4.3.4) + axios: 1.6.8(debug@4.3.4) debug: 4.3.4 fs-extra: 11.2.0 lodash.isplainobject: 4.0.6 @@ -2540,8 +2540,8 @@ packages: resolution: {integrity: sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==} dev: true - /follow-redirects@1.15.5(debug@4.3.4): - resolution: {integrity: sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==} + /follow-redirects@1.15.6(debug@4.3.4): + resolution: {integrity: sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==} engines: {node: '>=4.0'} requiresBuild: true peerDependencies: diff --git a/src/main/venmic.ts b/src/main/venmic.ts index c6f9d44..b86e7f6 100644 --- a/src/main/venmic.ts +++ b/src/main/venmic.ts @@ -72,11 +72,12 @@ ipcMain.handle(IpcEvents.VIRT_MIC_START, (_, targets: string[], workaround?: boo return obtainVenmic()?.link(data); }); -ipcMain.handle(IpcEvents.VIRT_MIC_START_SYSTEM, (_, workaround?: boolean) => { +ipcMain.handle(IpcEvents.VIRT_MIC_START_SYSTEM, (_, workaround?: boolean, onlyDefaultSpeakers?: boolean) => { const pid = getRendererAudioServicePid(); const data: LinkData = { - exclude: [{ key: "application.process.id", value: pid }] + exclude: [{ key: "application.process.id", value: pid }], + only_default_speakers: onlyDefaultSpeakers }; if (workaround) { diff --git a/src/preload/VesktopNative.ts b/src/preload/VesktopNative.ts index 625b8c1..4fc068a 100644 --- a/src/preload/VesktopNative.ts +++ b/src/preload/VesktopNative.ts @@ -64,7 +64,8 @@ export const VesktopNative = { list: () => invoke<{ ok: false; isGlibcxxToOld: boolean } | { ok: true; targets: string[] }>(IpcEvents.VIRT_MIC_LIST), start: (targets: string[], workaround?: boolean) => invoke(IpcEvents.VIRT_MIC_START, targets, workaround), - startSystem: (workaround?: boolean) => invoke(IpcEvents.VIRT_MIC_START_SYSTEM, workaround), + startSystem: (workaround?: boolean, onlyDefaultSpeakers?: boolean) => + invoke(IpcEvents.VIRT_MIC_START_SYSTEM, workaround, onlyDefaultSpeakers), stop: () => invoke(IpcEvents.VIRT_MIC_STOP) }, arrpc: { diff --git a/src/renderer/components/ScreenSharePicker.tsx b/src/renderer/components/ScreenSharePicker.tsx index 9842afe..eddfd7a 100644 --- a/src/renderer/components/ScreenSharePicker.tsx +++ b/src/renderer/components/ScreenSharePicker.tsx @@ -6,7 +6,7 @@ import "./screenSharePicker.css"; -import { closeModal, Margins, Modals, openModal, useAwaiter } from "@vencord/types/utils"; +import { closeModal, Margins, Modals, ModalSize, openModal, useAwaiter } from "@vencord/types/utils"; import { findStoreLazy, onceReady } from "@vencord/types/webpack"; import { Button, @@ -37,6 +37,7 @@ interface StreamSettings { audio: boolean; audioSource?: string; workaround?: boolean; + onlyDefaultSpeakers?: boolean; } export interface StreamPick extends StreamSettings { @@ -167,54 +168,61 @@ function StreamSettings({ ); return ( -
- What you're streaming - - - {source.name} - +
+
+ What you're streaming + + + {source.name} + - Stream Settings + Stream Settings - -
-
- Resolution -
- {StreamResolutions.map(res => ( - - ))} -
-
+ +
+
+ Resolution +
+ {StreamResolutions.map(res => ( + + ))} +
+
-
- Frame Rate -
- {StreamFps.map(fps => ( - - ))} -
-
-
+
+ Frame Rate +
+ {StreamFps.map(fps => ( + + ))} +
+
+
+
+
+
{isWindows && ( setSettings(s => ({ ...s, audioSource: source }))} - setWorkaround={workaround => setSettings(s => ({ ...s, workaround: workaround }))} + setWorkaround={value => setSettings(s => ({ ...s, workaround: value }))} + setOnlyDefaultSpeakers={value => setSettings(s => ({ ...s, onlyDefaultSpeakers: value }))} /> )} - +
); } @@ -242,13 +252,17 @@ function StreamSettings({ function AudioSourcePickerLinux({ audioSource, workaround, + onlyDefaultSpeakers, setAudioSource, - setWorkaround + setWorkaround, + setOnlyDefaultSpeakers }: { audioSource?: string; workaround?: boolean; + onlyDefaultSpeakers?: boolean; setAudioSource(s: string): void; setWorkaround(b: boolean): void; + setOnlyDefaultSpeakers(b: boolean): void; }) { const [sources, _, loading] = useAwaiter(() => VesktopNative.virtmic.list(), { fallbackValue: { ok: true, targets: [] } @@ -256,49 +270,74 @@ function AudioSourcePickerLinux({ const allSources = sources.ok ? ["None", "Entire System", ...sources.targets] : null; return ( -
- Audio - {loading && Loading Audio sources...} - {!sources.ok && - (sources.isGlibcxxToOld ? ( - - Failed to retrieve Audio Sources because your C++ library is too old to run venmic. If you would - like to stream with Audio, see{" "} - - this guide - - + <> + Audio Settings + + {loading ? ( + Loading Audio Sources... ) : ( - - Failed to retrieve Audio Sources. If you would like to stream with Audio, make sure you're using - Pipewire, not Pulseaudio - - ))} + Audio Source + )} - {allSources && ( - ({ label: s, value: s, default: s === "None" }))} + isSelected={s => s === audioSource} + select={setAudioSource} + serialize={String} + /> + )} - - Work around an issue that causes the microphone to be shared instead of the correct audio. Only - enable if you're experiencing this issue. - - } - > - Microphone Workaround - -
+ + + + Work around an issue that causes the microphone to be shared instead of the correct audio. + Only enable if you're experiencing this issue. + + } + > + Microphone Workaround + + + + When sharing entire desktop audio, only share apps that play to the default speakers and + ignore apps that play to other speakers or devices. + + } + > + Only Default Speakers + + + ); } @@ -323,7 +362,7 @@ function ModalComponent({ }); return ( - + ScreenShare diff --git a/src/renderer/components/screenSharePicker.css b/src/renderer/components/screenSharePicker.css index 356a1ca..c9e8110 100644 --- a/src/renderer/components/screenSharePicker.css +++ b/src/renderer/components/screenSharePicker.css @@ -11,6 +11,12 @@ gap: 1em; } +.vcd-screen-picker-settings-grid { + gap: 1em; + display: grid; + grid-template-columns: 1fr 1fr; +} + .vcd-screen-picker-grid { display: grid; grid-template-columns: 1fr 1fr; From 8eaa5206b98ce7029b6879cc2ce361c2ae5f6239 Mon Sep 17 00:00:00 2001 From: kaitlynkitty <87152313+kaitlynkittyy@users.noreply.github.com> Date: Wed, 17 Apr 2024 19:40:03 -0400 Subject: [PATCH 04/21] overhaul & improve Linux screenshare (#489) Fixes fps/resolution not properly being applied Enables hardware encoding via vaapi Redesigns stream picker modal Co-authored-by: kaitlynkittyy Co-authored-by: Oleh Polisan Co-authored-by: Vendicated --- src/main/index.ts | 8 +- src/renderer/components/ScreenSharePicker.tsx | 141 +++++++++++++++--- src/renderer/components/screenSharePicker.css | 16 ++ src/renderer/patches/index.ts | 2 +- ...creenShareAudio.ts => screenShareFixes.ts} | 27 ++++ 5 files changed, 167 insertions(+), 27 deletions(-) rename src/renderer/patches/{screenShareAudio.ts => screenShareFixes.ts} (54%) diff --git a/src/main/index.ts b/src/main/index.ts index 9d6a52c..325d417 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -27,14 +27,18 @@ process.env.VENCORD_USER_DATA_DIR = DATA_DIR; function init() { const { disableSmoothScroll, hardwareAcceleration } = Settings.store; - if (hardwareAcceleration === false) app.disableHardwareAcceleration(); + if (hardwareAcceleration === false) { + app.disableHardwareAcceleration(); + } else { + app.commandLine.appendSwitch("enable-features", "VaapiVideoDecodeLinuxGL,VaapiVideoEncoder,VaapiVideoDecoder"); + } + if (disableSmoothScroll) { app.commandLine.appendSwitch("disable-smooth-scrolling"); } // work around chrome 66 disabling autoplay by default app.commandLine.appendSwitch("autoplay-policy", "no-user-gesture-required"); - // WinRetrieveSuggestionsOnlyOnDemand: Work around electron 13 bug w/ async spellchecking on Windows. // HardwareMediaKeyHandling,MediaSessionService: Prevent Discord from registering as a media service. // diff --git a/src/renderer/components/ScreenSharePicker.tsx b/src/renderer/components/ScreenSharePicker.tsx index eddfd7a..cc0964c 100644 --- a/src/renderer/components/ScreenSharePicker.tsx +++ b/src/renderer/components/ScreenSharePicker.tsx @@ -6,7 +6,7 @@ import "./screenSharePicker.css"; -import { closeModal, Margins, Modals, ModalSize, openModal, useAwaiter } from "@vencord/types/utils"; +import { closeModal, Logger, Margins, Modals, ModalSize, openModal, useAwaiter } from "@vencord/types/utils"; import { findStoreLazy, onceReady } from "@vencord/types/webpack"; import { Button, @@ -36,6 +36,7 @@ interface StreamSettings { fps: StreamFps; audio: boolean; audioSource?: string; + contentHint?: string; workaround?: boolean; onlyDefaultSpeakers?: boolean; } @@ -50,7 +51,9 @@ interface Source { url: string; } -let currentSettings: StreamSettings | null = null; +export let currentSettings: StreamSettings | null = null; + +const logger = new Logger("VesktopScreenShare"); addPatch({ patches: [ @@ -60,6 +63,20 @@ addPatch({ match: /this.localWant=/, replace: "$self.patchStreamQuality(this);$&" } + }, + { + find: "x-google-max-bitrate", + replacement: [ + { + // eslint-disable-next-line no-useless-escape + match: /"x-google-max-bitrate=".concat\(\i\)/, + replace: '"x-google-max-bitrate=".concat("80_000")' + }, + { + match: /;level-asymmetry-allowed=1/, + replace: ";b=AS:800000;level-asymmetry-allowed=1" + } + ] } ], patchStreamQuality(opts: any) { @@ -74,6 +91,14 @@ addPatch({ bitrateMax: 8000000, bitrateTarget: 600000 }); + if (opts?.encode) { + Object.assign(opts.encode, { + framerate, + width, + height, + pixelCount: height * width + }); + } Object.assign(opts.capture, { framerate, width, @@ -219,6 +244,47 @@ function StreamSettings({
+
+
+ Content Type +
+
+ + +
+
+

+ Choosing "Prefer Clarity" will result in a significantly lower framerate in + exchange for a much sharper and clearer image. +

+
+
+
+
@@ -358,6 +424,7 @@ function ModalComponent({ const [settings, setSettings] = useState({ resolution: "1080", fps: "60", + contentHint: "motion", audio: true }); @@ -367,7 +434,6 @@ function ModalComponent({ ScreenShare - {!selected ? ( @@ -380,35 +446,62 @@ function ModalComponent({ /> )} -