|
1 | 1 | --- |
2 | 2 | name: build-run |
3 | | -description: > |
4 | | - Build, run, and configure rtp2httpd locally. Use this skill whenever the user wants to compile |
5 | | - the project, start the daemon, pass command-line arguments, edit configuration, or troubleshoot |
6 | | - build/runtime issues. Also activate when the user mentions cmake, build directory, rtp2httpd.conf, |
7 | | - web-ui build, pnpm run, vite build, embedded_web_data.h, or asks how to test the service locally. |
| 3 | +description: Build, configure, and run rtp2httpd locally, including embedded Web UI builds and build/runtime troubleshooting. Excludes cross-compilation and deployment. |
8 | 4 | --- |
9 | 5 |
|
10 | | -# Building and Running rtp2httpd |
| 6 | +# Local Build and Run |
11 | 7 |
|
12 | | -rtp2httpd is a C daemon (CMake build system) that converts RTP multicast / RTSP / HTTP streams |
13 | | -to HTTP unicast. This skill covers local development builds — not OpenWrt cross-compilation. |
| 8 | +Run commands from the repository root. Use the toolchain conventions in [AGENTS.md](../../../AGENTS.md). |
14 | 9 |
|
15 | | -## Build |
| 10 | +Cursor Cloud's startup setup installs locked pnpm dependencies and runs `uv sync --group dev`. Reuse that environment; repeat setup only when dependencies are missing or changed. |
16 | 11 |
|
17 | | -Always prefer production builds unless the user explicitly asks for debug. |
| 12 | +## Build the needed components |
| 13 | + |
| 14 | +For embedded UI changes, rebuild the frontend before the C binary. C-only changes can use the committed header without Node.js. Follow `package.json` for build scripts and `CMakeLists.txt` for current options. |
18 | 15 |
|
19 | 16 | ```bash |
20 | | -# 1. If web-ui/src/ has changed, rebuild the frontend first (generates src/embedded_web_data.h) |
21 | | -pnpm run web-ui:build # production (preferred) |
22 | | -pnpm run web-ui:build:debug # debug: unminified, with source maps |
| 17 | +# When Web UI sources or build inputs changed: |
| 18 | +pnpm run web-ui:build |
23 | 19 |
|
24 | | -# 2. Configure & compile the C binary |
25 | 20 | cmake -B build -DCMAKE_BUILD_TYPE=Release -DENABLE_AGGRESSIVE_OPT=ON |
26 | 21 | cmake --build build -j$(getconf _NPROCESSORS_ONLN) |
27 | 22 | ``` |
28 | 23 |
|
29 | | -The binary lands at `build/rtp2httpd`. Skip step 1 when only C code changed — the generated |
30 | | -`embedded_web_data.h` is committed so Node.js is not required for C-only builds. |
| 24 | +Release is the default for normal builds. Use Debug/RelWithDebInfo or `pnpm run web-ui:build:debug` when diagnosis needs symbols or source maps. `ENABLE_AGGRESSIVE_OPT` enables LTO and fast-math and defaults to OFF in CMake; disable it when investigating optimization-sensitive behavior. |
31 | 25 |
|
32 | | -### CMake options |
| 26 | +The binary is `build/rtp2httpd`. The generated header follows the commit boundary in AGENTS.md. |
33 | 27 |
|
34 | | -| Option | Default | Purpose | |
35 | | -|---------------------------|---------|--------------------------------------| |
36 | | -| `CMAKE_BUILD_TYPE` | Release | Debug / Release / RelWithDebInfo | |
37 | | -| `ENABLE_AGGRESSIVE_OPT` | OFF | LTO, fast-math, loop unrolling | |
| 28 | +## Run and configure |
38 | 29 |
|
39 | | -## Run |
| 30 | +Use an unused port, bind a local preview to loopback, and avoid loading a deployed configuration accidentally: |
40 | 31 |
|
41 | 32 | ```bash |
42 | | -# Minimal: no config file, verbose, listen on port 8080 |
43 | | -./build/rtp2httpd -C -v -v -v -v -l 8080 |
44 | | - |
45 | | -# With a config file |
46 | | -./build/rtp2httpd -c rtp2httpd.conf |
47 | | - |
48 | | -# Override specific settings via CLI |
49 | | -./build/rtp2httpd -c rtp2httpd.conf -l 5140 -m 20 -v -v |
| 33 | +./build/rtp2httpd -C -v -v -v -v -l 127.0.0.1:8080 |
50 | 34 | ``` |
51 | 35 |
|
52 | | -### Commonly used CLI flags |
53 | | - |
54 | | -| Flag | Short | Purpose | |
55 | | -|--------------------|-------|--------------------------------------------| |
56 | | -| `--noconfig` | `-C` | Skip default config file | |
57 | | -| `--config <file>` | `-c` | Use specific config file | |
58 | | -| `--listen [addr:]port` | `-l` | Bind address/port (default ANY:5140) | |
59 | | -| `--verbose` | `-v` | Increase verbosity (stack up to 4 times) | |
60 | | -| `--maxclients <n>` | `-m` | Max simultaneous clients (default 5) | |
61 | | -| `--help` | `-h` | Show all available options | |
62 | | - |
63 | | -Run `./build/rtp2httpd --help` for the complete flag list. |
64 | | - |
65 | | -## Configuration |
66 | | - |
67 | | -The config file is INI-style with three sections: `[global]`, `[bind]`, `[services]`. |
68 | | - |
69 | | -- **Reference config**: `rtp2httpd.conf` in the project root — all options are documented with comments |
70 | | -- **Full docs**: `docs/reference/configuration.md` |
71 | | - |
72 | | -When both CLI flags and config file settings are present, CLI flags take precedence. |
73 | | - |
74 | | -### Quick config example |
75 | | - |
76 | | -```ini |
77 | | -[global] |
78 | | -verbosity = 3 |
79 | | - |
80 | | -[bind] |
81 | | -* 5140 |
| 36 | +`-C` skips the default config; `-c <file>` selects a config; `-l [addr:]port` sets the listener. For a config-based reproduction, inspect that file's listeners and upstreams first. Use `./build/rtp2httpd --help` for current flags. |
82 | 37 |
|
83 | | -[services] |
84 | | -#EXTM3U |
85 | | -#EXTINF:-1,Channel One |
86 | | -rtp://239.253.64.120:5140 |
87 | | -#EXTINF:-1,RTSP Channel |
88 | | -rtsp://10.0.0.50:554/live |
89 | | -#EXTINF:-1,HTTP Channel |
90 | | -http://upstream.example.com/stream |
91 | | -``` |
92 | | - |
93 | | -## URL formats |
94 | | - |
95 | | -Constructing correct URLs is critical when testing rtp2httpd. The path prefix determines the |
96 | | -protocol handler — getting it wrong gives a 404 or unexpected behavior. |
97 | | - |
98 | | -| Type | URL pattern | Example | |
99 | | -|---------------|------------------------------------------------------|---------------------------------------------------------------| |
100 | | -| RTP multicast | `/rtp/<mcast_ip>:<port>[?fcc=...&fec=...]` | `/rtp/239.253.64.120:5140` | |
101 | | -| RTSP proxy | `/rtsp/<rtsp_host>:<port>/<path>[?playseek=...]` | `/rtsp/iptv.example.com:554/channel1` | |
102 | | -| HTTP proxy | `/http/<upstream_host>[:<port>]/<path>[?params]` | `/http/upstream.example.com:8080/live/stream.m3u8` | |
103 | | -| Playlist | `/playlist.m3u` | `/playlist.m3u` | |
104 | | - |
105 | | -For the full URL reference with all query parameters (fcc, fec, playseek, tvdr, r2h-ifname, |
106 | | -r2h-token, r2h-seek-name, r2h-seek-offset, etc.), read `docs/guide/url-formats.md`. |
107 | | - |
108 | | -## Verify it works |
109 | | - |
110 | | -```bash |
111 | | -# Status page |
112 | | -curl http://127.0.0.1:5140/status |
113 | | - |
114 | | -# M3U playlist (if services configured) |
115 | | -curl http://127.0.0.1:5140/playlist.m3u |
116 | | - |
117 | | -# Stream a channel (replace with actual multicast addr) |
118 | | -curl http://127.0.0.1:5140/rtp/239.253.64.120:5140 --max-time 3 -o /dev/null -w "%{http_code}" |
119 | | -``` |
| 38 | +- For INI settings and `[global]`, `[bind]`, `[services]` examples, read [rtp2httpd.conf](../../../rtp2httpd.conf) and the relevant section of [Configuration Reference](../../../docs/reference/configuration.md). CLI settings take precedence. |
| 39 | +- For stream paths and query parameters, read [URL Formats](../../../docs/guide/url-formats.md). The `/rtp/`, `/rtsp/`, and `/http/` prefixes choose different protocol handlers. |
| 40 | +- For player scenarios using mock upstreams, use [devlab](../../../tools/devlab/README.md). |
| 41 | +- For automated daemon behavior checks, use [e2e](../e2e/SKILL.md). |
120 | 42 |
|
121 | | -## Troubleshooting |
| 43 | +## Verify the requested behavior |
122 | 44 |
|
123 | | -- **Port in use**: change `-l` port or kill the old process |
| 45 | +`curl --fail http://127.0.0.1:8080/status` checks basic readiness. Playback, seek, or rendering work also needs the affected stream/player scenario; a status response alone does not verify it. Reuse the chosen listener port in checks, and stop the task's daemon when finished. If a port is occupied, choose another port rather than terminating an unrelated process. |
0 commit comments