Skip to content

Add /stream endpoint for real-time display via MJPEG streaming#555

Draft
Copilot wants to merge 4 commits intodevfrom
copilot/add-websocket-streaming
Draft

Add /stream endpoint for real-time display via MJPEG streaming#555
Copilot wants to merge 4 commits intodevfrom
copilot/add-websocket-streaming

Conversation

Copy link

Copilot AI commented Feb 11, 2026

HTTP Control Server currently requires polling /screen at ~30 FPS for real-time display, creating excessive TCP handshake overhead (30+ connections/sec).

Implementation

Added /stream endpoint using multipart/x-mixed-replace (MJPEG):

  • src/http_control_server.h: Added hcs_stream_callback type and hcs_set_stream_callback()
  • src/http_control_server.cpp: Implemented streaming endpoint with chunked content provider
  • src/main.c: Added se_hcs_stream_callback() for frame generation with JPEG encoding
  • docs/HTTP_CONTROL_SERVER.md: Documented new endpoint

Key features:

  • Configurable FPS (1-60, default 30) via query parameter
  • JPEG encoding at 85% quality for bandwidth efficiency
  • Exception handling for malformed FPS input (defaults to 30)
  • Thread-safe callback execution with mutex protection

Usage

GET http://localhost:8080/stream?fps=30

Works directly in HTML without JavaScript:

<img src="http://localhost:8080/stream">

Technical Notes

Chose multipart/x-mixed-replace over WebSockets:

  • Standard HTTP streaming protocol for video/images
  • Native browser support in <img> tags
  • Already supported by httplib's chunked content providers
  • One-way streaming sufficient for this use case

Single persistent connection eliminates per-frame TCP overhead while maintaining precise frame timing via std::this_thread::sleep_for().

Original prompt

This section details on the original issue you should resolve

<issue_title>Feature Request: Realtime display stream via websockets</issue_title>
<issue_description>Hi,

does anybody think it is possible to stream the data for drawing via a websocket connection in the headless mode? Currently I'm doing 30 /step /screen calls per second to retrieve the screen in real time. This is not a good solution because of all the handshakes. It would be pretty nice to get a continuous stream of frames to draw. Sadly I don't know if this is even possible with the architecture of the emulator. Maybe someone can help me out here.

Have a good one!</issue_description>

<agent_instructions>They are asking to real time stream the screen image from the emulator over the http_control_server, similar to the /screen command, except it would show the live display. </agent_instructions>

Comments on the Issue (you are @copilot in this section)

@skylersaleh It should be possible with the architecture of the emulator, however I don't know how to do the web/http server side. If someone knows how this works on the web dev side, I can help them hook the rest into the emulator.

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits February 11, 2026 03:56
Co-authored-by: skylersaleh <7118296+skylersaleh@users.noreply.github.com>
Co-authored-by: skylersaleh <7118296+skylersaleh@users.noreply.github.com>
Co-authored-by: skylersaleh <7118296+skylersaleh@users.noreply.github.com>
Copilot AI changed the title [WIP] Add realtime display stream via websockets Add /stream endpoint for real-time display via MJPEG streaming Feb 11, 2026
Copilot AI requested a review from skylersaleh February 11, 2026 04:10
@github-actions
Copy link

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.

Feature Request: Realtime display stream via websockets

2 participants