Venmic v3.4 (#499)

This commit is contained in:
Noah 2024-04-14 02:24:19 +02:00 committed by GitHub
parent 8c6941b8e9
commit df05d12fb2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 149 additions and 102 deletions

View file

@ -27,7 +27,7 @@
"arrpc": "github:OpenAsar/arrpc#98879cae0565e6fce34e4cb6f544bf42c6a7e7c8" "arrpc": "github:OpenAsar/arrpc#98879cae0565e6fce34e4cb6f544bf42c6a7e7c8"
}, },
"optionalDependencies": { "optionalDependencies": {
"@vencord/venmic": "^3.3.3" "@vencord/venmic": "^3.4.1"
}, },
"devDependencies": { "devDependencies": {
"@fal-works/esbuild-plugin-global-externals": "^2.1.2", "@fal-works/esbuild-plugin-global-externals": "^2.1.2",

View file

@ -11,8 +11,8 @@ dependencies:
optionalDependencies: optionalDependencies:
'@vencord/venmic': '@vencord/venmic':
specifier: ^3.3.3 specifier: ^3.4.1
version: 3.3.3 version: 3.4.1
devDependencies: devDependencies:
'@fal-works/esbuild-plugin-global-externals': '@fal-works/esbuild-plugin-global-externals':
@ -1000,8 +1000,8 @@ packages:
type-fest: 3.13.1 type-fest: 3.13.1
dev: true dev: true
/@vencord/venmic@3.3.3: /@vencord/venmic@3.4.1:
resolution: {integrity: sha512-qC3fPAUtw8j5L6uV3m9BGEnKpuOAlrYeZzFgILF3bFnDNFE9ANJsYttoHt80laBU7C1Xo56tHG2vVpLBsH+sgw==} resolution: {integrity: sha512-PkMXx53nxiYBLWxiMRaBjBm8aTTJTcueKsMZ0v35TtIQ93yfuSzfCilDFLs3kYz1uQHArTaI9IGQykgmSfe/2w==}
engines: {node: '>=14.15'} engines: {node: '>=14.15'}
os: [linux] os: [linux]
requiresBuild: true requiresBuild: true
@ -1333,11 +1333,11 @@ packages:
possible-typed-array-names: 1.0.0 possible-typed-array-names: 1.0.0
dev: true dev: true
/axios@1.6.7(debug@4.3.4): /axios@1.6.8(debug@4.3.4):
resolution: {integrity: sha512-/hDJGff6/c7u0hDkvkGxR/oy6CbCs8ziCsC7SqmhjfozqiJGc8Z11wrv9z9lYfY4K8l+H9TpjcMDX0xOZmx+RA==} resolution: {integrity: sha512-v/ZHtJDU39mDpyBoFVkETcd/uNdxrWRrg3bKpOKzXFA6Bvqopts6ALSMU3y6ijYxbw2B+wPrIv46egTzJXCLGQ==}
requiresBuild: true requiresBuild: true
dependencies: dependencies:
follow-redirects: 1.15.5(debug@4.3.4) follow-redirects: 1.15.6(debug@4.3.4)
form-data: 4.0.0 form-data: 4.0.0
proxy-from-env: 1.1.0 proxy-from-env: 1.1.0
transitivePeerDependencies: transitivePeerDependencies:
@ -1576,7 +1576,7 @@ packages:
hasBin: true hasBin: true
requiresBuild: true requiresBuild: true
dependencies: dependencies:
axios: 1.6.7(debug@4.3.4) axios: 1.6.8(debug@4.3.4)
debug: 4.3.4 debug: 4.3.4
fs-extra: 11.2.0 fs-extra: 11.2.0
lodash.isplainobject: 4.0.6 lodash.isplainobject: 4.0.6
@ -2540,8 +2540,8 @@ packages:
resolution: {integrity: sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==} resolution: {integrity: sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==}
dev: true dev: true
/follow-redirects@1.15.5(debug@4.3.4): /follow-redirects@1.15.6(debug@4.3.4):
resolution: {integrity: sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==} resolution: {integrity: sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==}
engines: {node: '>=4.0'} engines: {node: '>=4.0'}
requiresBuild: true requiresBuild: true
peerDependencies: peerDependencies:

View file

@ -72,11 +72,12 @@ ipcMain.handle(IpcEvents.VIRT_MIC_START, (_, targets: string[], workaround?: boo
return obtainVenmic()?.link(data); 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 pid = getRendererAudioServicePid();
const data: LinkData = { const data: LinkData = {
exclude: [{ key: "application.process.id", value: pid }] exclude: [{ key: "application.process.id", value: pid }],
only_default_speakers: onlyDefaultSpeakers
}; };
if (workaround) { if (workaround) {

View file

@ -64,7 +64,8 @@ export const VesktopNative = {
list: () => list: () =>
invoke<{ ok: false; isGlibcxxToOld: boolean } | { ok: true; targets: string[] }>(IpcEvents.VIRT_MIC_LIST), invoke<{ ok: false; isGlibcxxToOld: boolean } | { ok: true; targets: string[] }>(IpcEvents.VIRT_MIC_LIST),
start: (targets: string[], workaround?: boolean) => invoke<void>(IpcEvents.VIRT_MIC_START, targets, workaround), start: (targets: string[], workaround?: boolean) => invoke<void>(IpcEvents.VIRT_MIC_START, targets, workaround),
startSystem: (workaround?: boolean) => invoke<void>(IpcEvents.VIRT_MIC_START_SYSTEM, workaround), startSystem: (workaround?: boolean, onlyDefaultSpeakers?: boolean) =>
invoke<void>(IpcEvents.VIRT_MIC_START_SYSTEM, workaround, onlyDefaultSpeakers),
stop: () => invoke<void>(IpcEvents.VIRT_MIC_STOP) stop: () => invoke<void>(IpcEvents.VIRT_MIC_STOP)
}, },
arrpc: { arrpc: {

View file

@ -6,7 +6,7 @@
import "./screenSharePicker.css"; 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 { findStoreLazy, onceReady } from "@vencord/types/webpack";
import { import {
Button, Button,
@ -37,6 +37,7 @@ interface StreamSettings {
audio: boolean; audio: boolean;
audioSource?: string; audioSource?: string;
workaround?: boolean; workaround?: boolean;
onlyDefaultSpeakers?: boolean;
} }
export interface StreamPick extends StreamSettings { export interface StreamPick extends StreamSettings {
@ -167,54 +168,61 @@ function StreamSettings({
); );
return ( return (
<div> <div className="vcd-screen-picker-settings-grid">
<Forms.FormTitle>What you're streaming</Forms.FormTitle> <div>
<Card className="vcd-screen-picker-card vcd-screen-picker-preview"> <Forms.FormTitle>What you're streaming</Forms.FormTitle>
<img src={thumb} alt="" /> <Card className="vcd-screen-picker-card vcd-screen-picker-preview">
<Text variant="text-sm/normal">{source.name}</Text> <img src={thumb} alt="" />
</Card> <Text variant="text-sm/normal">{source.name}</Text>
</Card>
<Forms.FormTitle>Stream Settings</Forms.FormTitle> <Forms.FormTitle>Stream Settings</Forms.FormTitle>
<Card className="vcd-screen-picker-card"> <Card className="vcd-screen-picker-card">
<div className="vcd-screen-picker-quality"> <div className="vcd-screen-picker-quality">
<section> <section>
<Forms.FormTitle>Resolution</Forms.FormTitle> <Forms.FormTitle>Resolution</Forms.FormTitle>
<div className="vcd-screen-picker-radios"> <div className="vcd-screen-picker-radios">
{StreamResolutions.map(res => ( {StreamResolutions.map(res => (
<label className="vcd-screen-picker-radio" data-checked={settings.resolution === res}> <label
<Text variant="text-sm/bold">{res}</Text> className="vcd-screen-picker-radio"
<input data-checked={settings.resolution === res}
type="radio" >
name="resolution" <Text variant="text-sm/bold">{res}</Text>
value={res} <input
checked={settings.resolution === res} type="radio"
onChange={() => setSettings(s => ({ ...s, resolution: res }))} name="resolution"
/> value={res}
</label> checked={settings.resolution === res}
))} onChange={() => setSettings(s => ({ ...s, resolution: res }))}
</div> />
</section> </label>
))}
</div>
</section>
<section> <section>
<Forms.FormTitle>Frame Rate</Forms.FormTitle> <Forms.FormTitle>Frame Rate</Forms.FormTitle>
<div className="vcd-screen-picker-radios"> <div className="vcd-screen-picker-radios">
{StreamFps.map(fps => ( {StreamFps.map(fps => (
<label className="vcd-screen-picker-radio" data-checked={settings.fps === fps}> <label className="vcd-screen-picker-radio" data-checked={settings.fps === fps}>
<Text variant="text-sm/bold">{fps}</Text> <Text variant="text-sm/bold">{fps}</Text>
<input <input
type="radio" type="radio"
name="fps" name="fps"
value={fps} value={fps}
checked={settings.fps === fps} checked={settings.fps === fps}
onChange={() => setSettings(s => ({ ...s, fps }))} onChange={() => setSettings(s => ({ ...s, fps }))}
/> />
</label> </label>
))} ))}
</div> </div>
</section> </section>
</div> </div>
</Card>
</div>
<div>
{isWindows && ( {isWindows && (
<Switch <Switch
value={settings.audio} value={settings.audio}
@ -230,11 +238,13 @@ function StreamSettings({
<AudioSourcePickerLinux <AudioSourcePickerLinux
audioSource={settings.audioSource} audioSource={settings.audioSource}
workaround={settings.workaround} workaround={settings.workaround}
onlyDefaultSpeakers={settings.onlyDefaultSpeakers}
setAudioSource={source => setSettings(s => ({ ...s, audioSource: source }))} setAudioSource={source => 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 }))}
/> />
)} )}
</Card> </div>
</div> </div>
); );
} }
@ -242,13 +252,17 @@ function StreamSettings({
function AudioSourcePickerLinux({ function AudioSourcePickerLinux({
audioSource, audioSource,
workaround, workaround,
onlyDefaultSpeakers,
setAudioSource, setAudioSource,
setWorkaround setWorkaround,
setOnlyDefaultSpeakers
}: { }: {
audioSource?: string; audioSource?: string;
workaround?: boolean; workaround?: boolean;
onlyDefaultSpeakers?: boolean;
setAudioSource(s: string): void; setAudioSource(s: string): void;
setWorkaround(b: boolean): void; setWorkaround(b: boolean): void;
setOnlyDefaultSpeakers(b: boolean): void;
}) { }) {
const [sources, _, loading] = useAwaiter(() => VesktopNative.virtmic.list(), { const [sources, _, loading] = useAwaiter(() => VesktopNative.virtmic.list(), {
fallbackValue: { ok: true, targets: [] } fallbackValue: { ok: true, targets: [] }
@ -256,49 +270,74 @@ function AudioSourcePickerLinux({
const allSources = sources.ok ? ["None", "Entire System", ...sources.targets] : null; const allSources = sources.ok ? ["None", "Entire System", ...sources.targets] : null;
return ( return (
<section> <>
<Forms.FormTitle>Audio</Forms.FormTitle> <Forms.FormTitle>Audio Settings</Forms.FormTitle>
{loading && <Forms.FormTitle>Loading Audio sources...</Forms.FormTitle>} <Card className="vcd-screen-picker-card">
{!sources.ok && {loading ? (
(sources.isGlibcxxToOld ? ( <Forms.FormTitle>Loading Audio Sources...</Forms.FormTitle>
<Forms.FormText>
Failed to retrieve Audio Sources because your C++ library is too old to run venmic. If you would
like to stream with Audio, see{" "}
<a href="https://gist.github.com/Vendicated/b655044ffbb16b2716095a448c6d827a" target="_blank">
this guide
</a>
</Forms.FormText>
) : ( ) : (
<Forms.FormText> <Forms.FormTitle>Audio Source</Forms.FormTitle>
Failed to retrieve Audio Sources. If you would like to stream with Audio, make sure you're using )}
Pipewire, not Pulseaudio
</Forms.FormText>
))}
{allSources && ( {!sources.ok &&
<Select (sources.isGlibcxxToOld ? (
options={allSources.map(s => ({ label: s, value: s, default: s === "None" }))} <Forms.FormText>
isSelected={s => s === audioSource} Failed to retrieve Audio Sources because your C++ library is too old to run venmic. If you
select={setAudioSource} would like to stream with Audio, see{" "}
serialize={String} <a
/> href="https://gist.github.com/Vendicated/b655044ffbb16b2716095a448c6d827a"
)} target="_blank"
>
this guide
</a>
</Forms.FormText>
) : (
<Forms.FormText>
Failed to retrieve Audio Sources. If you would like to stream with Audio, make sure you're
using Pipewire, not Pulseaudio
</Forms.FormText>
))}
<Forms.FormDivider className={Margins.top16 + " " + Margins.bottom16} /> {allSources && (
<Select
options={allSources.map(s => ({ label: s, value: s, default: s === "None" }))}
isSelected={s => s === audioSource}
select={setAudioSource}
serialize={String}
/>
)}
<Switch <Forms.FormDivider className={Margins.top16 + " " + Margins.bottom16} />
onChange={setWorkaround}
value={workaround ?? false} <Switch
note={ onChange={setWorkaround}
<> value={workaround ?? false}
Work around an issue that causes the microphone to be shared instead of the correct audio. Only note={
enable if you're experiencing this issue. <>
</> 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 }
</Switch> >
</section> Microphone Workaround
</Switch>
<Switch
hideBorder
onChange={setOnlyDefaultSpeakers}
disabled={audioSource !== "Entire System"}
value={onlyDefaultSpeakers ?? true}
note={
<>
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
</Switch>
</Card>
</>
); );
} }
@ -323,7 +362,7 @@ function ModalComponent({
}); });
return ( return (
<Modals.ModalRoot {...modalProps}> <Modals.ModalRoot {...modalProps} size={ModalSize.MEDIUM}>
<Modals.ModalHeader className="vcd-screen-picker-header"> <Modals.ModalHeader className="vcd-screen-picker-header">
<Forms.FormTitle tag="h2">ScreenShare</Forms.FormTitle> <Forms.FormTitle tag="h2">ScreenShare</Forms.FormTitle>
<Modals.ModalCloseButton onClick={close} /> <Modals.ModalCloseButton onClick={close} />

View file

@ -11,6 +11,12 @@
gap: 1em; gap: 1em;
} }
.vcd-screen-picker-settings-grid {
gap: 1em;
display: grid;
grid-template-columns: 1fr 1fr;
}
.vcd-screen-picker-grid { .vcd-screen-picker-grid {
display: grid; display: grid;
grid-template-columns: 1fr 1fr; grid-template-columns: 1fr 1fr;