-
Notifications
You must be signed in to change notification settings - Fork 41
Add Restream menu to System Settings #144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,14 @@ extern lv_indev_t * indev_drv; | |
| extern int audio_get_enabled(void); | ||
| extern void audio_set_enabled(int enabled); | ||
|
|
||
| /* 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); | ||
|
|
||
| static colstack_t * g_cs; | ||
|
|
||
| /* True while the command-error dialog is up, so async teardowns (e.g. the text | ||
|
|
@@ -103,6 +111,24 @@ char * colmenu_get(const char * type, const char * page, const char * param, cha | |
| return strdup(audio_get_enabled() ? "1" : "0"); | ||
| } | ||
|
|
||
| /* Restream is configured from pixelpilot.yaml and lives entirely inside the | ||
| * app — gsmenu.sh has no say in it. Serve its rows from the C API, here on | ||
| * read and in do_set() on write, so no shell round-trip happens at all. */ | ||
| if(strcmp(param, "restream_enabled") == 0) { | ||
| return strdup(restream_get_enabled() ? "1" : "0"); | ||
| } | ||
| if(strcmp(param, "restream_target") == 0) { | ||
| /* scan_clients already returns the dropdown's option list: "Auto" followed | ||
| * by one discovered/pinned IP per line. Empty manual ip == auto-discover. */ | ||
| if(opts) { | ||
| char clients[1024] = {0}; | ||
| restream_scan_clients(clients, sizeof(clients)); | ||
| *opts = strdup(clients); | ||
| } | ||
|
Comment on lines
+124
to
+127
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1. Truncated dropdown options 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
|
||
| const char * ip = restream_get_manual_ip(); | ||
| return strdup(ip && ip[0] ? ip : "Auto"); | ||
| } | ||
|
|
||
| char errf[] = "/tmp/gsmenu_gerr_XXXXXX"; | ||
| int efd = mkstemp(errf); | ||
| if(efd >= 0) close(efd); | ||
|
|
@@ -373,6 +399,18 @@ static void do_set_done(void * ctx, int rc) | |
| static void do_set(void * ctx, const char * value) | ||
| { | ||
| bind_ctx_t * b = ctx; | ||
|
|
||
| /* Restream applies to the running app only (see colmenu_get) — apply it | ||
| * straight away and skip the gsmenu.sh set entirely. */ | ||
| if(b->param && strncmp(b->param, "restream_", 9) == 0) { | ||
| if(strcmp(b->param, "restream_enabled") == 0) | ||
| restream_set_enabled(value && strcmp(value, "on") == 0); | ||
| else if(strcmp(b->param, "restream_target") == 0) | ||
| restream_set_manual_ip(value ? value : ""); /* "Auto" → auto-discover */ | ||
| if(b->on_change) b->on_change(value ? value : ""); | ||
| return; | ||
| } | ||
|
|
||
| char cmd[320]; | ||
| snprintf(cmd, sizeof(cmd), "gsmenu.sh set %s %s %s \"%s\"", | ||
| b->type, b->page, b->param, value ? value : ""); | ||
|
|
||
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
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2. Duplicated restream api decls
🐞 Bug⚙ MaintainabilityAgent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools