-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added support for http streaming via GET request
- Loading branch information
Showing
7 changed files
with
82 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import {Render} from "./Render.js" | ||
import {Writable} from "node:stream" | ||
|
||
/** Non-realtime rendering , for use in tcp streaming for example. | ||
* This renders as fast as the display driver allows, letting the driver/client handle the fps rates. | ||
* This means buffers are hopefully filled and displaying will be smooth and stutterless. | ||
*/ | ||
export class RenderStream extends Render { | ||
|
||
/* | ||
Renders and sends one frame. | ||
Caller should keep calling us as fast as possible, as long as the external writable is draining. | ||
*/ | ||
async render(fh: Writable, encodedFrame: number[]) { | ||
|
||
|
||
//render as fast as possible, filling writable buffers | ||
let frameTime = 0 | ||
|
||
const _this = this | ||
|
||
async function fillFh() { | ||
|
||
console.log("FILLING") | ||
do { | ||
//NOTE: await is needed, to allow microtasks to run! | ||
frameTime = frameTime + await _this.scheduler.__step(false) | ||
|
||
frameTime = ~~(frameTime / _this.display.frameRoundingMicros) * _this.display.frameRoundingMicros | ||
|
||
encodedFrame.length = 0 | ||
_this.display.render(_this.box) | ||
_this.display.frame(frameTime) | ||
} while (fh.write(new Uint8Array(encodedFrame))) | ||
console.log("FULL") | ||
} | ||
|
||
fh.on('drain', async () => { | ||
console.log("CONTINUE") | ||
await fillFh() | ||
}) | ||
|
||
fh.on('close', () => { | ||
console.log("CLOSED") | ||
this.animationManager.stop(false) | ||
}) | ||
|
||
await fillFh() | ||
|
||
} | ||
|
||
} |
22 changes: 7 additions & 15 deletions
22
ledder/server/drivers/DisplayQOISstream.ts → ledder/server/drivers/DisplayQOISbuffer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters