added constraints and fixed device not detected
This commit is contained in:
parent
a7249ec5a6
commit
865531868d
4 changed files with 28 additions and 22 deletions
|
@ -102,8 +102,8 @@ packages:
|
||||||
ajv-keywords: 3.5.2(ajv@6.12.6)
|
ajv-keywords: 3.5.2(ajv@6.12.6)
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@electron/asar@3.2.5:
|
/@electron/asar@3.2.6:
|
||||||
resolution: {integrity: sha512-Ypahc2ElTj9YOrFvUHuoXv5Z/V1nPA5enlhmQapc578m/HZBHKTbqhoL5JZQjje2+/6Ti5AHh7Gj1/haeJa63Q==}
|
resolution: {integrity: sha512-g3Qj43/4Fi8EOB7hwVF6TCwPfwWXTYqD6R16cuCWKD3khKIQJT0WOloF55+LzaP92rYovlE6XLlaESitrxSKmg==}
|
||||||
engines: {node: '>=10.12.0'}
|
engines: {node: '>=10.12.0'}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
dependencies:
|
dependencies:
|
||||||
|
@ -159,7 +159,7 @@ packages:
|
||||||
resolution: {integrity: sha512-lE/U3UNw1YHuowNbTmKNs9UlS3En3cPgwM5MI+agIgr/B1hSze9NdOP0qn7boZaI9Lph8IDv3/24g9IxnJP7aQ==}
|
resolution: {integrity: sha512-lE/U3UNw1YHuowNbTmKNs9UlS3En3cPgwM5MI+agIgr/B1hSze9NdOP0qn7boZaI9Lph8IDv3/24g9IxnJP7aQ==}
|
||||||
engines: {node: '>=8.6'}
|
engines: {node: '>=8.6'}
|
||||||
dependencies:
|
dependencies:
|
||||||
'@electron/asar': 3.2.5
|
'@electron/asar': 3.2.6
|
||||||
'@malept/cross-spawn-promise': 1.1.1
|
'@malept/cross-spawn-promise': 1.1.1
|
||||||
debug: 4.3.4
|
debug: 4.3.4
|
||||||
dir-compare: 3.3.0
|
dir-compare: 3.3.0
|
||||||
|
@ -619,8 +619,8 @@ packages:
|
||||||
resolution: {integrity: sha512-OxepLK9EuNEIPxWNME+C6WwbRAOOI2o2BaQEGzz5Lu2e4Z5eDnEo+/aVEDMIXywoJitJ7xWd641wrGLZdtwRyw==}
|
resolution: {integrity: sha512-OxepLK9EuNEIPxWNME+C6WwbRAOOI2o2BaQEGzz5Lu2e4Z5eDnEo+/aVEDMIXywoJitJ7xWd641wrGLZdtwRyw==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@types/verror@1.10.6:
|
/@types/verror@1.10.7:
|
||||||
resolution: {integrity: sha512-NNm+gdePAX1VGvPcGZCDKQZKYSiAWigKhKaz5KF94hG6f2s8de9Ow5+7AbXoeKxL8gavZfk4UquSAygOF2duEQ==}
|
resolution: {integrity: sha512-4c5F4T0qMSoXq1KHx7WV1FMuD2h0xdaFoJ7HSVWUfQ8w5YbqCwLOA8K7/yy1I+Txuzvm417dnPUaLmqazX1F7g==}
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dev: true
|
dev: true
|
||||||
optional: true
|
optional: true
|
||||||
|
@ -1530,7 +1530,7 @@ packages:
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/plist': 3.0.3
|
'@types/plist': 3.0.3
|
||||||
'@types/verror': 1.10.6
|
'@types/verror': 1.10.7
|
||||||
ajv: 6.12.6
|
ajv: 6.12.6
|
||||||
crc: 3.8.0
|
crc: 3.8.0
|
||||||
iconv-corefoundation: 1.1.7
|
iconv-corefoundation: 1.1.7
|
||||||
|
|
3
src/main/createVirtmic.ts
Normal file
3
src/main/createVirtmic.ts
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
export function createVirtmic () {
|
||||||
|
|
||||||
|
};
|
|
@ -45,6 +45,7 @@ export function registerScreenShareHandler() {
|
||||||
|
|
||||||
if (isWayland) {
|
if (isWayland) {
|
||||||
const video = data[0];
|
const video = data[0];
|
||||||
|
getAudioFromVirtmic();
|
||||||
callback(video ? { video } : {});
|
callback(video ? { video } : {});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
|
import { createVirtmic } from "./createVirtmic";
|
||||||
export function getAudioFromVirtmic() {
|
export function getAudioFromVirtmic() {
|
||||||
const getAudioDevice = async (deviceName) => {
|
const getAudioDevice = async (deviceName: string|undefined) => {
|
||||||
await navigator.mediaDevices.getUserMedia({
|
|
||||||
audio: true
|
|
||||||
});
|
|
||||||
|
|
||||||
await new Promise(r => setTimeout(r, 1000));
|
await new Promise(r => setTimeout(r, 1000));
|
||||||
let devices = await navigator.mediaDevices.enumerateDevices();
|
let devices = await navigator.mediaDevices.enumerateDevices();
|
||||||
let audioDevice = devices.find(({
|
let audioDevice = devices.find(({
|
||||||
|
@ -14,7 +11,7 @@ export function getAudioFromVirtmic() {
|
||||||
};
|
};
|
||||||
|
|
||||||
const getDisplayMedia = async () => {
|
const getDisplayMedia = async () => {
|
||||||
var id;
|
var id: string|undefined;
|
||||||
try {
|
try {
|
||||||
let myDiscordAudioSink = await getAudioDevice('virtmic');
|
let myDiscordAudioSink = await getAudioDevice('virtmic');
|
||||||
id = myDiscordAudioSink?.deviceId;
|
id = myDiscordAudioSink?.deviceId;
|
||||||
|
@ -23,16 +20,21 @@ export function getAudioFromVirtmic() {
|
||||||
id = 'default';
|
id = 'default';
|
||||||
}
|
}
|
||||||
|
|
||||||
let captureSystemAudioStream = await navigator.mediaDevices.getUserMedia({
|
const constraints = {
|
||||||
audio: {
|
deviceId: {
|
||||||
/*deviceId {
|
|
||||||
exact: id
|
exact: id
|
||||||
},
|
},
|
||||||
autoGainControl: false,
|
autoGainControl: false,
|
||||||
echoCancellation: false,
|
echoCancellation: false,
|
||||||
noiseSuppression: false
|
noiseSuppression: false,
|
||||||
channelCount: 2*/
|
channelCount: 2
|
||||||
}
|
};
|
||||||
|
|
||||||
|
await navigator.mediaDevices.getUserMedia({
|
||||||
|
audio: true
|
||||||
|
}).then((MediaStream) => {
|
||||||
|
const audioTrack = MediaStream.getAudioTracks()[0];
|
||||||
|
let captureSystemAudioStream = audioTrack.applyConstraints(constraints);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
};
|
};
|
Reference in a new issue