Skip to content

Add Restream menu to System Settings - #144

Merged
henkwiedig merged 2 commits into
OpenIPC:masterfrom
henkwiedig:add/restream-menu
Aug 6, 2026
Merged

Add Restream menu to System Settings#144
henkwiedig merged 2 commits into
OpenIPC:masterfrom
henkwiedig:add/restream-menu

Conversation

@henkwiedig

Copy link
Copy Markdown
Collaborator

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

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Add System → Restream settings page backed by in-app restream API

✨ Enhancement 🕐 20-40 Minutes

Grey Divider

AI Description

• Add a new System → Restream sub-page with Enabled and Target controls.
• Serve restream state/options directly from the app (no gsmenu.sh round-trips).
• Make simulator builds exercise the UI with stateful restream stubs and fake clients.
Diagram

graph TD
  UI["System → Restream UI"] --> CM["colmenu get/set"] --> API["Restream C API"] --> DEV["Device: gstrtpreceiver"] --> LAN["LAN clients"]
  API --> SIM["Simulator stubs"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Implement restream_* via gsmenu.sh like other settings
  • ➕ Keeps all settings behind a single shell interface (consistent backend)
  • ➕ Avoids adding app-level special cases in colmenu.c
  • ➖ Requires plumbing runtime-only state through a shell round-trip
  • ➖ Harder to expose dynamic client discovery cleanly
  • ➖ Adds latency and more failure surface during menu interaction
2. Create a small restream_api.h wrapper (no GStreamer includes)
  • ➕ Avoids duplicating extern declarations in colmenu.c
  • ➕ Keeps the 'no gst/gst.h in menu code' constraint while improving maintainability
  • ➖ Adds a new header/API surface to maintain
  • ➖ Still effectively the same architecture (direct in-app access)

Recommendation: The PR’s approach (intercept restream_* in colmenu.c and call a lightweight C API) is the best fit for runtime-only restream state and dynamic client lists while avoiding gsmenu.sh latency. Consider the small-header wrapper option if more restream menu integration is expected, to avoid repeating externs and to centralize the minimal non-GStreamer API.

Files changed (3) +66 / -7

Enhancement (2) +51 / -1
colmenu.cIntercept restream_* menu params and route directly to restream C API +38/-0

Intercept restream_* menu params and route directly to restream C API

• Adds forward declarations for the restream C API and handles restream_enabled/restream_target in colmenu_get() to return current state and populate dropdown options via restream_scan_clients(). Updates do_set() to apply restream changes immediately (enable toggle and manual IP selection) without invoking gsmenu.sh.

src/gsmenu/colmenu.c

colmenu_pages.cAdd System → Restream sub-page with Enabled and Target controls +13/-1

Add System → Restream sub-page with Enabled and Target controls

• Introduces a new Restream submenu under System with a switch for enabling restream and a dropdown for selecting the target (Auto or discovered IPs). Updates the System page’s item count to include the new submenu entry.

src/gsmenu/colmenu_pages.c

Other (1) +15 / -6
simulator.cMake simulator restream stubs stateful and return a fake client list +15/-6

Make simulator restream stubs stateful and return a fake client list

• Replaces no-op restream stubs with stateful implementations so the new menu rows can be exercised in the simulator. Adds a small fake client list (including Auto) and stores the selected manual IP unless set to Auto/empty.

src/simulator.c

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Truncated dropdown options 🐞 Bug ≡ Correctness
Description
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.
Code

src/gsmenu/colmenu.c[R115-118]

+            char clients[1024] = {0};
+            restream_scan_clients(clients, sizeof(clients));
+            *opts = strdup(clients);
+        }
Evidence
The menu currently hard-limits the options string to 1024 bytes, while the device implementation
builds a variable-length newline-delimited list and then copies as much as fits into the caller’s
buffer, which can truncate in the middle of an IP/line.

src/gsmenu/colmenu.c[105-121]
src/gstrtpreceiver.cpp[1572-1605]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## 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



Informational

2. Duplicated restream API decls 🐞 Bug ⚙ Maintainability
Description
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.
Code

src/gsmenu/colmenu.c[R17-23]

+/* 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);
Evidence
The PR introduces a second, manually-maintained copy of the restream API declarations in colmenu.c
even though the same API already exists in gstrtpreceiver.h.

src/gsmenu/colmenu.c[17-23]
src/gstrtpreceiver.h[113-124]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## 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


Grey Divider

To customize comments, go to the Qodo configuration screen, or learn more in the docs.

Qodo Logo

Comment thread src/gsmenu/colmenu.c
Comment on lines +115 to +118
char clients[1024] = {0};
restream_scan_clients(clients, sizeof(clients));
*opts = strdup(clients);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

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

Comment thread src/gsmenu/colmenu.c
Comment on lines +17 to +23
/* 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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Informational

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>
@henkwiedig
henkwiedig merged commit 6c41aa9 into OpenIPC:master Aug 6, 2026
10 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.

1 participant