-
Notifications
You must be signed in to change notification settings - Fork 0
/
pull_client.js
35 lines (30 loc) · 937 Bytes
/
pull_client.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
const wsl = require('ws');
const macadam = require('macadam');
const request = require('request-promise-native')
// let ws = new wsl('http://localhost:8080')
let playback
// console.dir(macadam.getDeviceInfo()[0].outputDisplayModes);
let timer = (w) => new Promise((resolve) => {
setTimeout(resolve, w);
})
async function init () {
playback = await macadam.playback({
deviceIndex: 0, // Index relative to the 'macadam.getDeviceInfo()' array
displayMode: macadam.bmdModeHD1080i50,
pixelFormat: macadam.bmdFormat8BitBGRA
});
// ws.on('message', m => {
// console.log(m.length);
// playback.displayFrame(m);
// });
let start = process.hrtime();
let counter = 0;
while (true) {
let frame = await request('http://localhost:3000/', { encoding: null });
playback.displayFrame(frame);
let end = process.hrtime(start);
let wait = (40000000 * counter - end[1]) / 1000000 | 0;
await timer(wait);
}
};
init();