-
Notifications
You must be signed in to change notification settings - Fork 0
/
webcam.js
executable file
·31 lines (27 loc) · 1.04 KB
/
webcam.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
"use strict";
(function (exports) {
exports.init = function init(api) {
const child_process = require('child_process');
let childPID;
api.registerDataStream('webcam-stream', {
start: function () {
console.log('starting webcam-stream');
const proc = child_process.spawn('/home/pi/mjpg-streamer-experimental/stream.sh', [], {});
proc.stdout.on('data', function (data) {
const num = parseInt(data.toString());
if (!isNaN(num)) {
childPID = num;
console.log('wcPID: ' + childPID);
api.registerProcess(childPID);
}
});
},
stop: function () {
if (childPID) {
console.log('stopping webcam-stream');
api.killStartedProc(childPID);
}
}
});
}
})(exports);