This repository has been archived by the owner on May 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
81 lines (67 loc) · 2.37 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
Streams the first webcam in the system to the specified Jitsi Meet room.
Audio is currently not sent.
TODO
- Detect if we are kicked from the room
- Support authenticated deployments
*/
const puppeteer = require("puppeteer");
async function main(room, baseUrl = "https://meet.jit.si") {
// Chromium browser options
// https://peter.sh/experiments/chromium-command-line-switches/
const chromeArgs = [
// Automatically give permission to use media devices
"--use-fake-ui-for-media-stream",
// Silence all output, just in case
"--alsa-output-device=plug:null",
// Point chromium to xvfb display
"--display=:1",
"--no-sandbox",
"--disable-extensions",
];
// // Jitsi Meet options
// // https://github.com/jitsi/lib-jitsi-meet/blob/master/doc/API.md
// const meetArgs = [
// // Disable receiving of video
// "config.channelLastN=0",
// // Mute our audio
// "config.startWithAudioMuted=true",
// // Don't use simulcast to save resources on the sender (our) side
// "config.disableSimulcast=true",
// // No need to process audio levels
// "config.disableAudioLevels=true",
// // Disable P2P mode due to a bug in Jitsi Meet
// "config.p2p.enabled=false",
// ];
// const url = `${baseUrl}/${room}#${meetArgs.join("&")}`;
const url = `${baseUrl}/${room}`;
console.log(`Loading ${url}`);
// Puppeteer launch options
// https://github.com/puppeteer/puppeteer/blob/v3.0.1/docs/api.md#puppeteerlaunchoptions
// https://github.com/puppeteer/puppeteer/issues/550#issuecomment-551991273
const browser = await puppeteer.launch({
defaultViewport: { height: 1080, width: 1920 },
headless: false,
args: chromeArgs,
executablePath: "/usr/bin/chromium-browser",
handleSIGINT: false,
});
const page = await browser.newPage();
// Manual handling on SIGINT to gracefully hangup and exit
process.on("SIGINT", async () => {
console.log("Exiting...");
await page.evaluate("APP.conference.hangup();");
await page.close();
browser.close();
console.log("Done!");
process.exit();
});
// Start Jitsi Meet
await page.goto(url);
// Mute audio
await page.evaluate(`APP.conference.muteAudio(true);`);
// Set some friendly display name
await page.evaluate(`APP.conference.changeLocalDisplayName('Webcam');`);
console.log("Running...");
}
main(process.argv[2] || "test-0123456789");