startVideoStream function to live stream a client screen#43
Open
SuperCraft3M wants to merge 1 commit into
Open
startVideoStream function to live stream a client screen#43SuperCraft3M wants to merge 1 commit into
SuperCraft3M wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a new live relay capture mode that streams WebM data as MSE-appendable segments to a server-side callback (startVideoStream), enabling low-latency playback without writing recordings to disk.
Changes:
- Added
startVideoStreamexport and server-side relay plumbing to forward live WebM segments (init+ per-Clustermedia) to anonSegmentcallback. - Introduced
streamChunkSizecapture option to tune streaming latency vs overhead, wired through to the NUI encoder output chunking. - Updated documentation and refreshed dependency lockfiles.
Reviewed changes
Copilot reviewed 8 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents the new startVideoStream export and updates stopVideoCapture docs to include it. |
| pnpm-lock.yaml | Updates dependency resolutions for pnpm-managed workspace. |
| package-lock.json | Adds an npm lockfile (new file) in addition to pnpm lockfile. |
| game/server/webm-stream.ts | New WebM framing logic to split a continuous append-only WebM stream into init and media segments. |
| game/server/upload-store.ts | Stores relay-mode flags and in-memory framing state for active streams. |
| game/server/types.ts | Adds relay types (StreamSegment, StreamSegmentFn) and extends stream/capture option types. |
| game/server/stream.ts | Routes NUI stream chunks either to disk (existing) or to live relay framing (new). |
| game/server/koa-router.ts | Routes HTTP stream chunks either to disk (existing) or to live relay framing (new); relay finalization flushes without touching disk. |
| game/server/export.ts | Exposes startVideoStream and wires it to stream setup with relay mode enabled. |
| game/nui/src/capture-stream.ts | Accepts streamChunkSize and uses it as the encoder/stream target chunk size. |
| .gitignore | Adds ignores for game/.turbo, game/node_modules, and game/dist. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+18
to
+29
| function emit(stream: StreamUploadData, type: StreamSegment['type'], bytes: Buffer): void { | ||
| if (!stream.onSegment || bytes.length === 0) return; | ||
| const seq = stream.segSeq ?? 0; | ||
| stream.segSeq = seq + 1; | ||
| stream.onSegment({ | ||
| captureId: stream.captureId, | ||
| source: stream.source, | ||
| type, | ||
| seq, | ||
| data: bytes.toString('base64'), | ||
| }); | ||
| } |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new "live relay" streaming mode for video capture, allowing real-time streaming of WebM segments directly to a callback without writing to disk. This enables low-latency, gap-free playback via MediaSource Extensions (MSE) on the client side. The implementation adds a new
startVideoStreamexport, updates capture options to support chunk size tuning for latency, and introduces new logic for segmenting and relaying live WebM streams. Documentation and type definitions are updated accordingly.Live relay streaming support:
startVideoStreamserver-side export, which starts a continuous video capture and relays live MSE-appendable WebM segments (init + media) to a providedonSegmentcallback, supporting real-time streaming use cases. [1] [2] [3] [4] [5] [6] [7] [8]StreamSegment,StreamSegmentFn) and extendedStreamUploadDataandCaptureOptionsto support relay mode, segment callbacks, and chunk size configuration. [1] [2] [3] [4]WebM segment framing and relay logic:
webm-stream.tsimplementing logic to split the continuous WebM byte stream into MSE-appendable segments (initandmedia) and invoke theonSegmentcallback in real time.Capture options and configuration:
streamChunkSizeoption to capture requests (client and server), allowing tuning of WebM output chunk size to trade off latency versus overhead. Defaults to 800 KiB if not specified. [1] [2] [3] [4]Documentation:
README.mdwith detailed documentation and usage examples for the newstartVideoStreamexport, including explanation of segment structure, options, and integration with MediaSource Extensions. Also updatedstopVideoCapturedocs to reference the new streaming mode. [1] [2]Every comment on the files an this description is made by AI btw. All the code is done by myself.