@apocaliss92/nodelink-js 0.2.5 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -42,10 +42,10 @@ The library includes a **complete web-based management interface** for easy came
42
42
  - 📡 **NVR / Hub Support** - Add NVRs as first-class entities, discover channels, and manage child cameras. All cameras on an NVR share a single connection (like Scrypted). Connect/disconnect at the NVR level; add or remove cameras at any time via channel discovery
43
43
  - 🔋 **Battery Camera Support** - Cameras are auto-detected as battery-powered when they emit sleep/wake events. Per-camera battery mode setting: **Stream Only** (default — camera sleeps when no stream clients) or **Always On** (stays awake while connected). Live awake/sleeping badge on each camera card. Controls and stream discovery are paused while the camera sleeps to avoid unnecessary wake-ups
44
44
  - 💡 **Camera Controls** - Toggle floodlight, siren, floodlight-on-motion, siren-on-motion, PTZ auto-tracking, and PIR sensor directly from the camera card. PTZ directional controls and preset navigation via a dedicated modal
45
- - 📹 **Live Streaming** - Preview streams via MJPEG, WebRTC, or HLS. Stream options are cached so battery cameras show available streams even while sleeping
45
+ - 📹 **Live Streaming via go2rtc** - WebRTC, MSE/MP4, HLS, RTSP, and snapshot output powered by an embedded go2rtc restreamer. Stream options are cached so battery cameras show available streams even while sleeping
46
46
  - 🔔 **Real-time Events** - Per-camera event viewer with live SSE updates (motion, doorbell, people, vehicle, animal, face, package, day/night, sleep/wake). Events are broadcast via SSE, NDJSON stream, and MQTT
47
- - 📊 **Real-time Logs** - Monitor camera events and system logs
48
- - ⚙️ **Settings** - Configure RTSP proxy, ports, auto-start options, MQTT broker, and Home Assistant discovery
47
+ - 📊 **Real-time Logs** - Monitor camera events, system logs, and go2rtc process output
48
+ - ⚙️ **Settings** - Configure go2rtc ports, auto-start options, MQTT broker, and Home Assistant discovery
49
49
  - 📱 **PWA Support** - Install as a Progressive Web App on mobile devices
50
50
  - 🌐 **Responsive Design** - Works on desktop, tablet, and mobile
51
51
 
@@ -129,12 +129,12 @@ Recommended example:
129
129
  services:
130
130
  nodelink-manager:
131
131
  ports:
132
- - "3000:3000" # Web UI and API
133
- - "8554:8554" # RTSP proxy
134
- - "50000-50100:50000-50100/udp" # WebRTC / ICE UDP
135
- # Then configure Settings WebRTC (ICE):
136
- # - ICE UDP port range: 50000-50100
137
- # - Additional host addresses: 192.168.1.123
132
+ - "3000:3000" # Web UI and API
133
+ - "11984:11984" # go2rtc API + dashboard
134
+ - "18554:18554" # go2rtc RTSP output
135
+ - "18555:18555/udp" # go2rtc WebRTC ICE
136
+ # Then configure Settings go2rtc:
137
+ # - ICE servers if needed for NAT traversal
138
138
  ```
139
139
 
140
140
  Notes:
@@ -144,11 +144,16 @@ Notes:
144
144
 
145
145
  **Environment Variables:**
146
146
 
147
- | Variable | Default | Description |
148
- | ----------- | ------- | ------------------------------------ |
149
- | `PORT` | `3000` | HTTP server port |
150
- | `RTSP_PORT` | `8554` | RTSP proxy port |
147
+ | Variable | Default | Description |
148
+ | --- | --- | --- |
149
+ | `PORT` | `3000` | HTTP server port |
151
150
  | `DATA_PATH` | `/data` | Directory for settings.json and logs |
151
+ | `GO2RTC_PATH` | (auto) | Path to go2rtc binary (falls back to bundled `go2rtc-static`) |
152
+ | `GO2RTC_API_PORT` | `11984` | go2rtc REST API + web dashboard port |
153
+ | `GO2RTC_RTSP_PORT` | `18554` | go2rtc RTSP output port |
154
+ | `GO2RTC_WEBRTC_PORT` | `18555` | go2rtc WebRTC ICE port |
155
+
156
+ Environment variables override `settings.json` values. Ports are also configurable in Settings → go2rtc.
152
157
 
153
158
  **WebRTC / ICE (Docker bridge mode):**
154
159
 
@@ -162,88 +167,46 @@ Notes:
162
167
  | `AUTH_ENABLED` | (unset) | Enable auth when set to `1/true` (or disable with `0/false`). If unset, auth auto-enables when `ADMIN_PASSWORD` is set. |
163
168
  | `ADMIN_PASSWORD` | (unset) | Sets the `admin` password. This credential works for both the web login form and HTTP Basic auth. |
164
169
 
165
- ### Streaming Authentication (RTSP / MJPEG / HLS / WebRTC)
166
-
167
- When authentication is enabled (see `AUTH_ENABLED` / `ADMIN_PASSWORD`), **all streaming endpoints are protected**.
170
+ ### Streaming via go2rtc
168
171
 
169
- #### Step-by-step
172
+ All streaming is handled by an embedded **go2rtc** process (default API port `11984`, RTSP port `18554`). go2rtc provides:
170
173
 
171
- 1. **Login to the Manager UI** (or use the API login) to obtain an auth token.
172
- 2. (Recommended) **Generate a long-lived personal token** from **Settings → Personal token**.
173
- 3. Use the correct auth mechanism depending on the streaming protocol:
174
-
175
- - RTSP: **Digest** with username/password
176
- - MJPEG/HLS: token in query string `?token=...`
177
- - WebRTC signaling + status endpoints: `Authorization: Bearer ...`
178
- - WebSocket logs: `?token=...` in the WS URL
174
+ | Format | URL | Notes |
175
+ |--------|-----|-------|
176
+ | **WebRTC** | `POST http://HOST:11984/api/webrtc?src={name}` | WHEP signaling (SDP offer/answer) |
177
+ | **MSE/MP4** | `http://HOST:11984/api/stream.mp4?src={name}` | Fragmented MP4 for browsers |
178
+ | **HLS** | `http://HOST:11984/api/stream.m3u8?src={name}` | Adaptive streaming |
179
+ | **RTSP** | `rtsp://HOST:18554/{name}` | For VLC, ffmpeg, NVR software |
180
+ | **Snapshot** | `http://HOST:11984/api/frame.jpeg?src={name}` | Single JPEG (requires ffmpeg) |
181
+ | **Dashboard** | `http://HOST:11984/` | go2rtc web UI |
179
182
 
180
- There are two auth mechanisms depending on the protocol:
183
+ Stream names follow the pattern `{sanitized_camera_name}_{profile}` (e.g. `studio_main`, `garage_sub`).
181
184
 
182
- 1. **RTSP (RTSP proxy): Digest auth with username/password**
185
+ go2rtc has CORS enabled (`origin: "*"`) so browser-based players can connect directly.
183
186
 
184
- - URL format: `rtsp://<host>:<RTSP_PORT>/<camera>/<main|sub|ext>`
185
- - Credentials: the same **Users** list used by the dashboard.
186
- - Digest realm: `RTSP Proxy`
187
- - You can toggle whether auth is required via the Manager UI setting **“Require auth for RTSP connections”**.
187
+ ### Authentication
188
188
 
189
- Examples:
190
-
191
- ```bash
192
- # ffmpeg (Digest)
193
- ffmpeg -rtsp_transport tcp -i "rtsp://USERNAME:PASSWORD@HOST:8554/camera/main" -f null -
189
+ When authentication is enabled (see `AUTH_ENABLED` / `ADMIN_PASSWORD`), the Manager API endpoints are protected. go2rtc streaming endpoints are currently unauthenticated (accessible on the local network).
194
190
 
195
- # VLC (it will prompt for credentials, or use URL user:pass)
196
- vlc "rtsp://USERNAME:PASSWORD@HOST:8554/camera/main"
197
- ```
198
-
199
- 2. **HTTP-based streaming (MJPEG / HLS): token in query string**
200
-
201
- Browsers cannot reliably attach custom headers (like `Authorization`) to media tags (`<img>`, `<video>`), so MJPEG/HLS streams must be accessed with the auth token in the URL query string:
202
-
203
- - MJPEG: `/api/mpeg/<camera>/<profile>?token=...`
204
- - HLS playlist: `/api/hls/<camera>/<profile>/playlist.m3u8?token=...` (and segment requests will inherit the query param)
191
+ - Manager API: `Authorization: Bearer <token>` header or session cookie
192
+ - WebSocket logs: `?token=...` in the WS URL
205
193
 
206
194
  Examples:
207
195
 
208
- ```text
209
- MJPEG:
210
- http://HOST:3000/api/mpeg/camera/main?token=YOUR_TOKEN
211
-
212
- HLS:
213
- http://HOST:3000/api/hls/camera/main/playlist.m3u8?token=YOUR_TOKEN
214
- ```
215
-
216
- Security note: query tokens may end up in logs/history. Treat them like passwords.
217
-
218
- 3. **WebRTC control endpoints: Bearer token in Authorization header**
219
-
220
- WebRTC signaling uses JSON endpoints (create session, send ICE candidates, send answer) and supports standard Bearer auth:
221
-
222
196
  ```bash
223
- # 1) Login to obtain a token
224
- curl -sS -X POST http://HOST:3000/api/auth/login \
225
- -H 'content-type: application/json' \
226
- -d '{"username":"admin","password":"YOUR_PASSWORD"}'
227
-
228
- # 2) Use the returned token for WebRTC signaling
229
- curl -sS http://HOST:3000/api/webrtc/status \
230
- -H "Authorization: Bearer YOUR_TOKEN"
231
- ```
197
+ # RTSP via go2rtc (no auth)
198
+ ffmpeg -rtsp_transport tcp -i “rtsp://HOST:18554/studio_main” -f null -
199
+ vlc “rtsp://HOST:18554/studio_main”
232
200
 
233
- You can also generate a personal token via API (requires an existing valid token):
201
+ # WebRTC WHEP signaling
202
+ curl -X POST “http://HOST:11984/api/webrtc?src=studio_main” \
203
+ -H “Content-Type: application/sdp” \
204
+ --data-binary @offer.sdp
234
205
 
235
- ```bash
236
- curl -sS -X POST http://HOST:3000/api/auth/personal-token \
237
- -H "Authorization: Bearer YOUR_TOKEN" \
238
- -H 'content-type: application/json' \
239
- -d '{}'
240
- ```
241
-
242
- 4. **WebSocket logs: token in query string**
206
+ # Snapshot
207
+ curl -o snap.jpg http://HOST:11984/api/frame.jpeg?src=studio_main”
243
208
 
244
- The browser WebSocket handshake cannot reliably attach custom headers, so use:
245
-
246
- ```text
209
+ # WebSocket logs (auth)
247
210
  ws://HOST:3000/ws/logs?token=YOUR_TOKEN
248
211
  ```
249
212
 
@@ -262,10 +225,13 @@ The Manager UI exposes a REST API for integrations, scripts, and third-party app
262
225
  | Category | Endpoints |
263
226
  |----------|-----------|
264
227
  | **Auth** | `GET /api/auth/config`, `POST /api/auth/login`, `POST /api/auth/personal-token` |
265
- | **Streaming** | `GET /api/mpeg/:camera/:profile`, `GET /api/hls/:camera/:profile/playlist.m3u8`, `POST /api/webrtc/session` |
228
+ | **go2rtc Streaming** | Served directly by go2rtc (default port `11984`): WebRTC, MSE/MP4, HLS, RTSP, Snapshot |
229
+ | **go2rtc Management** | tRPC: `go2rtc.start`, `go2rtc.stop`, `go2rtc.status`, `go2rtc.listStreams` |
266
230
  | **Events** | `GET /api/events/sse` (SSE), `GET /api/events/stream` (NDJSON), `GET /api/events/status` |
267
231
  | **System** | `GET /api/health`, `GET /api/metrics`, `GET /api/updates` |
268
232
 
233
+ **Streaming** — All video output (WebRTC, MSE, HLS, RTSP, snapshots) is handled by an embedded go2rtc restreamer. The Manager creates internal RTSP servers per stream and registers them with go2rtc, which provides multi-format output with audio support.
234
+
269
235
  **Events** — Real-time camera events (motion, doorbell, people, vehicle, etc.) via Server-Sent Events or NDJSON stream. When MQTT is configured, events are also published to the broker.
270
236
 
271
237
  📖 **[Full Manager API documentation →](./documentation/manager-api.md)**