forked from r-oung/jitsi-headless
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
103 lines (85 loc) · 2.69 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
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");
const express = require('express');
const app = express();
const http = require("http");
const port=8001;
app.listen(port,()=>{
console.log('live on port '+port);
});
app.get('/reload', async (req,res)=>{
console.log('reload page')
await page.reload();
res.send('jo, seite wurde neu geladen');
});
app.get('/shutdown', async (req,res)=>{
console.log('shutdown browser')
process.kill(process.pid, "SIGINT");
res.send('jo, browser wurde heruntergefahren');
});
browser = null;
page = null;
async function main() {
// 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",
"--remote-debugging-port=9222",
// 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",
"config.prejoinPageEnabled=false"
];
const url = 'http://localhost:8000/static/jitsi/main.html';
console.log(`Loading local jitsi client`);
// 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
browser = await puppeteer.launch({
headless: true,
args: chromeArgs,
executablePath: "/usr/bin/chromium-browser",
handleSIGINT: false,
handleSIGTERM: false
});
page = await browser.newPage();
async function shutdown() {
console.log("Exiting...");
//await page.close();
browser.close();
console.log("Done!");
process.exit();
}
// Manual handling on SIGINT to gracefully hangup and exit
process.on("SIGINT", shutdown);
// Manual handling on SIGINT to gracefully hangup and exit
process.on("SIGTERM", shutdown);
// Start Jitsi Meet
await page.goto(url);
console.log("Running...");
}
main(process.argv[2] || "test-0123456789");