add virtmic patch (#127)
This commit is contained in:
parent
7447fe3b70
commit
bac269411a
2 changed files with 42 additions and 0 deletions
|
@ -8,3 +8,4 @@
|
|||
import "./spellCheck";
|
||||
import "./platformClass";
|
||||
import "./windowsTitleBar";
|
||||
import "./screenShareAudio";
|
41
src/renderer/patches/screenShareAudio.ts
Normal file
41
src/renderer/patches/screenShareAudio.ts
Normal file
|
@ -0,0 +1,41 @@
|
|||
import { isLinux } from "../utils";
|
||||
if (isLinux) {
|
||||
const original = navigator.mediaDevices.getDisplayMedia;
|
||||
async function getVirtmic() {
|
||||
const getAudioDevice = async (deviceName: string|undefined) => {;
|
||||
let devices = await navigator.mediaDevices.enumerateDevices();
|
||||
let audioDevice = devices.find(({
|
||||
label
|
||||
}) => label === deviceName);
|
||||
return audioDevice;
|
||||
}
|
||||
|
||||
var id: string|undefined;
|
||||
try {
|
||||
let vesktopAudioSink = await getAudioDevice('vesktop-virtmic');
|
||||
id = vesktopAudioSink?.deviceId;
|
||||
}
|
||||
catch (error) {
|
||||
id = 'error';
|
||||
}
|
||||
return id;
|
||||
};
|
||||
navigator.mediaDevices.getDisplayMedia = async function() {
|
||||
const id = await getVirtmic();
|
||||
const stream = await original.apply(this);
|
||||
if (id !== 'error'){
|
||||
const audio = await navigator.mediaDevices.getUserMedia({
|
||||
audio: {
|
||||
deviceId: {
|
||||
exact: id
|
||||
},
|
||||
autoGainControl: false,
|
||||
echoCancellation: false,
|
||||
noiseSuppression: false
|
||||
}
|
||||
});
|
||||
audio.getAudioTracks().forEach(t => stream.addTrack(t));
|
||||
};
|
||||
return stream;
|
||||
};
|
||||
};
|
Reference in a new issue