Add Restream menu to System Settings - #144
Conversation
PR Summary by QodoAdd System → Restream settings page backed by in-app restream API
AI Description
Diagram
High-Level Assessment
Files changed (3)
|
Code Review by Qodo
1. Truncated dropdown options
|
| char clients[1024] = {0}; | ||
| restream_scan_clients(clients, sizeof(clients)); | ||
| *opts = strdup(clients); | ||
| } |
There was a problem hiding this comment.
1. Truncated dropdown options 🐞 Bug ≡ Correctness
colmenu_get() copies the restream client option list through a fixed 1024-byte buffer, so a long discovered/pinned list can be truncated mid-line and produce incomplete dropdown entries. Selecting a truncated entry can set an invalid manual target string and prevent restream from reaching the intended client.
Agent Prompt
## Issue description
`colmenu_get()` builds the Restream Target dropdown options by calling `restream_scan_clients()` into a fixed 1024-byte stack buffer and then `strdup()`s it. If the generated options string exceeds 1024 bytes, it will be truncated without preserving line boundaries, which can result in a partial/invalid last option.
## Issue Context
The device implementation (`restream_scan_clients`) generates a newline-delimited list and copies it into the provided buffer with bounded copy semantics; truncation can occur when many ARP entries exist or when pinned/manual IPs add additional lines.
## Fix Focus Areas
- src/gsmenu/colmenu.c[111-121]
- src/gstrtpreceiver.cpp[1572-1605]
## Suggested fix approach
- Increase the buffer substantially (e.g., 4096/8192) **and** defensively trim any trailing partial line by cutting back to the last `\n` when the buffer fills.
- Preferably, change the API to return the required size (or return an allocated string) so callers never guess buffer sizes.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| /* Restream C API (gstrtpreceiver.cpp on device, stubs in simulator.c) — declared | ||
| * here rather than including gstrtpreceiver.h, which drags in gst/gst.h. */ | ||
| extern bool restream_get_enabled(void); | ||
| extern void restream_set_enabled(bool enabled); | ||
| extern void restream_scan_clients(char * buf, size_t buf_len); | ||
| extern const char * restream_get_manual_ip(void); | ||
| extern void restream_set_manual_ip(const char * ip); |
There was a problem hiding this comment.
2. Duplicated restream api decls 🐞 Bug ⚙ Maintainability
colmenu.c manually re-declares the restream_* API instead of including the canonical declarations, so future signature/linkage changes can silently desync and become hard to detect. This introduces unnecessary interface drift risk across device implementation and simulator stubs.
Agent Prompt
## Issue description
`src/gsmenu/colmenu.c` adds manual `extern` declarations for the Restream API to avoid including `gstrtpreceiver.h` (which pulls in GStreamer headers). This duplicates the interface already declared in `gstrtpreceiver.h`, creating a long-term risk of signature drift.
## Issue Context
The PR comment explains the motivation (avoiding heavy GStreamer includes), but duplication is still avoidable by splitting the lightweight C API into a dedicated header.
## Fix Focus Areas
- src/gsmenu/colmenu.c[17-23]
- src/gstrtpreceiver.h[113-124]
## Suggested fix approach
- Create a small header (e.g., `src/restream_api.h`) containing only the `extern \"C\"` C API declarations (restream_* and any related functions) and minimal includes (`<stdbool.h>`, `<stddef.h>`).
- Include this new header from both `gstrtpreceiver.h` and `colmenu.c` (and keep simulator stubs aligned), removing the duplicated declarations from `colmenu.c`.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
Restore the restream enable/disable option and target IP configuration that was available before colmenu integration. Shows detected clients (on device; stubs on simulator) and allows manual IP configuration. - Add System → Restream sub-page with dynamic client detection - Add restream_enabled get/set handlers to gsmenu.sh - Add restream_manual_ip get/set handlers to gsmenu.sh - Device builds use restream_scan_clients; simulator uses stubs Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
e2042a8 to
7cd89fa
Compare
Restore the restream enable/disable option and target IP configuration that was available before colmenu integration. Shows detected clients (on device; stubs on simulator) and allows manual IP configuration.