mirror of
https://github.com/nestriness/nestri.git
synced 2025-12-12 08:45:38 +02:00
✨ feat: Add streaming support (#125)
This adds: - [x] Keyboard and mouse handling on the frontend - [x] Video and audio streaming from the backend to the frontend - [x] Input server that works with Websockets Update - 17/11 - [ ] Master docker container to run this - [ ] Steam runtime - [ ] Entrypoint.sh --------- Co-authored-by: Kristian Ollikainen <14197772+DatCaptainHorse@users.noreply.github.com> Co-authored-by: Kristian Ollikainen <DatCaptainHorse@users.noreply.github.com>
This commit is contained in:
45
packages/moq/transfork/frame.ts
Normal file
45
packages/moq/transfork/frame.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import type { Reader, Writer } from "./stream"
|
||||
|
||||
export class FrameReader {
|
||||
#stream: Reader
|
||||
|
||||
constructor(stream: Reader) {
|
||||
this.#stream = stream
|
||||
}
|
||||
|
||||
// Returns the next frame
|
||||
async read(): Promise<Uint8Array | undefined> {
|
||||
if (await this.#stream.done()) return
|
||||
|
||||
const size = await this.#stream.u53()
|
||||
const payload = await this.#stream.read(size)
|
||||
|
||||
return payload
|
||||
}
|
||||
|
||||
async stop(code: number) {
|
||||
await this.#stream.stop(code)
|
||||
}
|
||||
}
|
||||
|
||||
export class FrameWriter {
|
||||
#stream: Writer
|
||||
|
||||
constructor(stream: Writer) {
|
||||
this.#stream = stream
|
||||
}
|
||||
|
||||
// Writes the next frame
|
||||
async write(payload: Uint8Array) {
|
||||
await this.#stream.u53(payload.byteLength)
|
||||
await this.#stream.write(payload)
|
||||
}
|
||||
|
||||
async close() {
|
||||
await this.#stream.close()
|
||||
}
|
||||
|
||||
async reset(code: number) {
|
||||
await this.#stream.reset(code)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user