Commit graph

35 commits

Author SHA1 Message Date
2d29dc9c4a fix(config): preserve WebRTC section in Config.Clone()
Some checks failed
tests / build (push) Failing after 3s
Config.Clone() copied every top-level Data section except WebRTC.
Because api.go receives a clone (not the original), cfg.WebRTC.Enable
was always the zero value at runtime, the subsystem was skipped, and
the WHEP route was never mounted — regardless of CORE_WEBRTC_ENABLE.

Caught on the first live M2 TrueNAS deploy: env said enable=true,
container listened fine, but /api/v3/whep/:id returned Echo's default
JSON 404 (from router) instead of the handler's plain-text
'webrtc: stream not found' (which it would return for an unknown id).

- Add data.WebRTC = d.WebRTC in the struct-copy block.
- Deep-copy NAT1To1IPs alongside the other []string sections.
- Regression test TestConfigCopyWebRTC covers both.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-17 15:26:11 -04:00
9d38e9ccdb feat(webrtc): add app/webrtc subsystem + lifecycle hooks
Introduces the subsystem layer that sits alongside api.API and wires
the M1 core/webrtc primitives into the per-process restream lifecycle.

app/webrtc/subsystem.go:
  - Subsystem struct holding the global WebRTC config, core PeerFactory,
    per-process stream map, and logger
  - New(config.DataWebRTC, logger) constructor
  - Enabled(), Hooks(), Close(), lookup() methods

app/webrtc/lifecycle.go:
  - onProcessStart: allocates an adjacent UDP port pair, binds two
    Pion Sources (video on V, audio on V+1), registers them under the
    process id, and returns the two RTP output legs to append to the
    FFmpeg command.
  - onProcessStop: tears down the pair.
  - allocAdjacentPair: retries up to 10 times to find a free (V, V+1)
    pair since the kernel's ephemeral picker can hand us an odd port.
  - splitRTPLegs: converts BuildArgs' flat []string into two ConfigIO
    entries by splitting on the second -map token.

core/webrtc/peer.go + forward.go:
  - Adds PeerFactory.CreatePeerFromSources for the M2 two-source
    forwarding mode (video and audio on separate UDP ports, no
    payload-type sniffing). Leaves CreatePeer intact for the M1 PoC.
  - Adds forwardRTPSplit companion goroutine.

config/data.go:
  - Promote anonymous WebRTC struct to named type DataWebRTC so
    app/webrtc can accept it by value.
2026-04-17 10:02:00 -04:00
80db028281 feat(config): add webrtc global config block
Adds webrtc.enable, webrtc.public_ip, webrtc.nat_1_to_1_ips, and
webrtc.udp_mux_port to the Core Data struct and registers each via
the existing vars system. Default is disabled; no behavior change
without explicit opt-in.
2026-04-17 09:51:02 -04:00
Ingo Oppermann
0f4c88be39
Fix default search paths for config file 2023-09-07 16:23:15 +02:00
Ingo Oppermann
a1682b7aa4
Fix parsing S3 storage definition from environment variable 2023-04-13 12:19:20 +02:00
Ingo Oppermann
baf1c3391a
Deprecate ENV names that do not correspond to JSON name 2023-04-03 21:21:02 +02:00
Ingo Oppermann
1c04961fc1
Fix tests 2023-02-21 12:57:33 +01:00
Ingo Oppermann
2a3288ffd0
Use abstract filesystem for stores 2023-02-01 16:09:20 +01:00
Ingo Oppermann
e3d25b1bdd
Add check for duplicate filesystem names 2023-01-31 15:53:48 +01:00
Ingo Oppermann
f519acfd71
Add S3 storage support 2023-01-31 14:45:58 +01:00
Ingo Oppermann
ad3538d224
Add tests 2023-01-24 13:40:36 +01:00
Ingo Oppermann
59b7978470
Add tests 2023-01-24 11:22:31 +01:00
Ingo Oppermann
e374f83377
Fix config timestamps
created_at represents the time when the configuration has been persisted to disk.
loaded_at represents the time when the configuration has actually been used.

If created_at is larger than loaded_at, then the Core needs a reload in order
to apply the latest configuration.

if created_at is lower than laoded_at, then the Core applied the latest
configuration.

The value of updated_at is irrelevant and shouldn't be used.
2023-01-19 16:13:53 +01:00
Ingo Oppermann
ea79b87236
Add format annotation for integer types for swagger documentation 2023-01-11 21:05:40 +01:00
Ingo Oppermann
1bbb7a9c1f
Use config locations for import and ffmigrage 2023-01-03 11:45:10 +01:00
Ingo Oppermann
17c9f6ef13
Test different standard location for config file
If no path is given in the environment variable CORE_CONFIGFILE, different
standard locations will be probed:
- os.UserConfigDir() + /datarhei-core/config.js
- os.UserHomeDir() + /.config/datarhei-core/config.js
- ./config/config.js
If the config.js doesn't exist in any of these locations, it will be
assumed at ./config/config.js
2023-01-03 07:55:55 +01:00
Ingo Oppermann
378a3cd9cf
Allow to set a soft memory limit for the binary itself
The setting debug.memory_limit_mbytes should not be used in conjuction
with debug.force_gc because the memory limit influences the garbage
collector.
2023-01-02 11:58:54 +01:00
Ingo Oppermann
992b04d180
Allow alternative syntax for auth0 tenants as environment variable 2023-01-02 11:39:58 +01:00
Ingo Oppermann
391681447e
Fix MustDir config type to create directory 2023-01-02 10:54:29 +01:00
Ingo Oppermann
9ad19fbdd6
Fix reading partial config
If the config on the disk doesn't have all fields, then the missing
fields are now populated with their defaults.
2022-11-08 14:44:47 +01:00
Ingo Oppermann
4d4e70571e
Fix proper version handling for uploading a new config 2022-10-10 16:19:45 +02:00
Ingo Oppermann
33bd7bd384
Set default email address 2022-09-30 12:25:01 +02:00
Ingo Oppermann
fe2e9d375c
Use LE porduction CA, allow to configure an email address 2022-09-30 12:12:36 +02:00
Ingo Oppermann
5cb0592854
Exclude .m3u8 and .mpd files from disk cache by default 2022-08-26 11:35:56 +03:00
Ingo Oppermann
6802830c62
Don't use deprecated functions from io/ioutil 2022-08-18 10:27:33 +03:00
Ingo Oppermann
273ca0abbc
Add cache block list for extensions not to cache 2022-08-02 19:10:28 +02:00
Ingo Oppermann
5dd378902b
Add test for v1 import 2022-07-22 08:33:38 +02:00
Ingo Oppermann
c3d8c40162
Fix default config version number 2022-07-20 12:41:13 +02:00
Ingo Oppermann
00c382262e
Add config migration from version 1 to version 2 2022-07-20 12:27:55 +02:00
Ingo Oppermann
971b8337fe
Add new placeholders and parameters for placeholder 2022-07-06 19:51:47 +02:00
Ingo Oppermann
fa3f8b9b57
Allow RTMP server if RTMPS server is enabled 2022-07-05 20:30:40 +02:00
Ingo Oppermann
4420d04a3b
Add config option for RTMPS listen address 2022-07-05 18:52:54 +02:00
Ingo Oppermann
2058554524
Allow to configure SRT logging 2022-07-01 18:39:39 +02:00
Jan Stabenow
eb1cc37456
Add GoSRT & improvements (repo-merge)
Commits (Ingo Oppermann):
- Add experimental SRT connection stats and logs
- Hide /config/reload endpoint in reade-only mode
- Add SRT server
- Create v16 in go.mod
- Fix data races, tests, lint, and update dependencies
- Add trailing slash for routed directories (datarhei/restreamer#340)
- Allow relative URLs in content in static routes

Co-Authored-By: Ingo Oppermann <57445+ioppermann@users.noreply.github.com>
2022-06-23 22:13:58 +02:00
Jan Stabenow
9c0b535199
Add v16.7.2 2022-05-13 19:26:45 +02:00