Skip to content

feat: NUI protocol support for video uploads#38

Merged
itschip merged 2 commits into
mainfrom
copilot/add-nui-protocol-video-uploads
May 8, 2026
Merged

feat: NUI protocol support for video uploads#38
itschip merged 2 commits into
mainfrom
copilot/add-nui-protocol-video-uploads

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 8, 2026

Video streaming only worked via HTTP protocol. When protocol 'nui' was set in fxmanifest, video chunks still bypassed NUI callbacks and went direct to the Koa HTTP server. This adds the NUI transport path for video, mirroring how images already work.

Data flow (NUI mode)

NUI encodes each video chunk as base64 → POSTs to NUI callback → client forwards via TriggerLatentServerEvent (using stream_bps) → server decodes and appends to temp file → finalize assembles and uploads.

Changes

  • game/nui/src/capture-stream.ts — Split writable stream creation into createHttpWritableStream() and createNuiWritableStream(). NUI path base64-encodes binary chunks in batches and POSTs to callback URLs. Used discriminated union type for request to enforce correct parameter combinations per protocol.

  • game/client/bootstrap.ts — Added protocol === 'nui' branch in captureStream handler, passing callbackUrl/finalizeCallbackUrl instead of serverEndpoint. Registered capture_stream_chunk and capture_stream_finalize NUI callback types.

  • game/client/protocols/nui.ts — Added stream_bps config. Two new NUI callback handlers forward chunk data via TriggerLatentServerEvent and finalization via emitNet (no large payload).

  • game/server/koa-router.ts — Extracted finalizeStream() as shared export to avoid duplicating the read→upload→cleanup logic.

  • game/server/bootstrap.ts — Added screencapture:stream-chunk-nui (base64→buffer→appendFile) and screencapture:stream-finalize-nui event handlers, reusing finalizeStream().

  • fxmanifest.lua — Updated comment to remove "nui is not yet supported for videos".

Copilot AI and others added 2 commits May 8, 2026 10:50
- Add protocol check in client captureStream handler
- Register capture_stream_chunk and capture_stream_finalize NUI callbacks
- Add stream_bps config reading and NUI callback handlers for video chunks/finalize
- Add NUI writable stream in capture-stream.ts (base64 transport)
- Extract shared finalizeStream() from koa-router.ts
- Add server event handlers for stream-chunk-nui and stream-finalize-nui
- Update fxmanifest.lua comment to reflect video NUI support

Agent-Logs-Url: https://github.com/itschip/screencapture/sessions/97074cbd-72d9-42d8-b60c-7e38a0a97090

Co-authored-by: itschip <59088889+itschip@users.noreply.github.com>
Copilot AI requested a review from itschip May 8, 2026 10:57
Copilot finished work on behalf of itschip May 8, 2026 10:57
Copilot finished work on behalf of itschip May 8, 2026 11:12
@itschip itschip marked this pull request as ready for review May 8, 2026 12:22
@itschip itschip merged commit 5779d44 into main May 8, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants