- Protocol module: framed binary encoding for control requests/responses (ENUM_DEVICES, ENUM_CONTROLS, GET/SET_CONTROL, STREAM_OPEN/CLOSE) - video-node: scans /dev/media* and /dev/video*, serves V4L2 device topology and controls over TCP; uses UDP discovery for peer announce - query_cli: auto-discovers a node, queries devices and controls - protocol_cli: low-level protocol frame decoder for debugging - dev/web: Express 5 ESM web inspector — live SSE discovery picker, REST bridge to video-node, controls UI with sliders/selects/checkboxes - Makefile: sequential module builds before cli/node to fix make -j races - common.mk: add DEPFLAGS (-MMD -MP) for automatic header dependencies - All module Makefiles: split compile/link, generate .d dependency files - discovery: replace 100ms poll loop with pthread_cond_timedwait; respond to all announcements (not just new peers) for instant re-discovery - ENUM_DEVICES response: carry device_caps (V4L2_CAP_*) per video node so clients can distinguish capture nodes from metadata nodes Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
74 lines
2.1 KiB
C
74 lines
2.1 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
#include "config.h"
|
|
#include "discovery.h"
|
|
#include "transport.h"
|
|
#include "error.h"
|
|
|
|
/*
|
|
* Example schema covering node identity, discovery, and transport.
|
|
* Each module would normally provide its own schema table; they are
|
|
* combined here for the CLI demo.
|
|
*/
|
|
|
|
static const struct Config_Flag_Def function_flag_defs[] = {
|
|
{ "source", DISCOVERY_FLAG_SOURCE },
|
|
{ "relay", DISCOVERY_FLAG_RELAY },
|
|
{ "sink", DISCOVERY_FLAG_SINK },
|
|
{ "controller", DISCOVERY_FLAG_CONTROLLER },
|
|
{ NULL, 0 }
|
|
};
|
|
|
|
static const struct Config_Def schema[] = {
|
|
/* section key type default */
|
|
{ "node", "name", CONFIG_STRING, "unnamed:0", NULL },
|
|
{ "node", "site_id", CONFIG_UINT16, "0", NULL },
|
|
{ "node", "tcp_port", CONFIG_UINT16, "8000", NULL },
|
|
{ "node", "function", CONFIG_FLAGS, "source", function_flag_defs },
|
|
|
|
{ "discovery", "interval_ms", CONFIG_UINT32, "5000", NULL },
|
|
{ "discovery", "timeout_intervals", CONFIG_UINT32, "3", NULL },
|
|
{ "discovery", "connect_mask", CONFIG_FLAGS, "", function_flag_defs },
|
|
|
|
{ "transport", "max_connections", CONFIG_UINT32, "16", NULL },
|
|
{ "transport", "max_payload", CONFIG_UINT32, "16777216", NULL },
|
|
|
|
{ NULL }
|
|
};
|
|
|
|
static void usage(void) {
|
|
fprintf(stderr,
|
|
"usage: config_cli <file>\n"
|
|
" config_cli --defaults\n"
|
|
"\n"
|
|
" <file> load config file and print effective values\n"
|
|
" --defaults print schema defaults without a file\n");
|
|
}
|
|
|
|
int main(int argc, char **argv) {
|
|
if (argc < 2) {
|
|
usage();
|
|
return 1;
|
|
}
|
|
|
|
struct Config *cfg;
|
|
struct App_Error err;
|
|
|
|
if (argv[1][0] == '-') {
|
|
err = config_defaults(&cfg, schema);
|
|
} else {
|
|
err = config_load(&cfg, argv[1], schema);
|
|
}
|
|
|
|
if (!APP_IS_OK(err)) {
|
|
app_error_print(&err);
|
|
return 1;
|
|
}
|
|
|
|
config_dump(cfg);
|
|
|
|
config_free(cfg);
|
|
return 0;
|
|
}
|