fix(media): restore peer-assisted 16-viewer admission (#170)

Keep the default at eight while restoring the documented explicit 1-16 admission range and its cap2/cap3 functional gate.
This commit is contained in:
AAA authored and GitHub committed 2026-08-22 05:00:26 +08:00 Unverified
1 parent 8774b43c35
commit f8aac57a63
11 files changed
+61 -42

No files matched your search

+7 -6
View File
@@ -1,8 +1,8 @@
# Low-Server-Cost Media Routes
- Research date: 2026-08-21
- Scope: one broadcaster, at most eight trusted viewers, low latency, and host
media fanout at most two
- Scope: one broadcaster, explicit admission up to sixteen trusted viewers,
low latency, and bounded host media fanout
- Status: ADR-0005 accepts STUN-only direct/peer UDP, bounded SFU/UDP roots,
then optional authenticated TURN/UDP for one controller-selected exceptional
edge. Production enables the controller for all rooms and has a configured
@@ -16,9 +16,10 @@
The smallest current plan is:
1. Use direct host P2P for one or two viewers.
2. For later viewers, use the fixed two-chain browser relay in ADR-0004. It is
controlled by `PEER_ASSISTED_MEDIA`, is limited to at most
eight viewers, and decodes and re-encodes at every relay.
2. For later viewers, use the bounded browser relay DAG in ADR-0004. It is
controlled by `PEER_ASSISTED_MEDIA`, shares the one-through-sixteen room
admission limit, and decodes and re-encodes at every relay. The retained
representative resource/quality gate remains eight viewers.
3. Plan a separate native shared-encode sender regardless of the browser relay
result. It reduces duplicate host encoding while retaining at most two
standard WebRTC edges, so it does not remove their upload cost. The bounded
@@ -527,7 +528,7 @@ lost.
| Route | Where copies are emitted | Endpoint cost | Current disposition |
| --- | --- | --- | --- |
| Direct host P2P | Host emits one copy per viewer | Host upload and sender pipelines grow with viewers | Keep for one or two viewers |
| Bounded browser relay DAG | Host and each Web relay emit at most two copies | Ordinary browser, but every relay decodes and re-encodes and adds a hop | Current capacity-two source candidate, maximum-eight-viewer gate |
| Bounded browser relay DAG | Host and each Web relay emit at most the configured endpoint cap | Ordinary browser, but every relay decodes and re-encodes and adds a hop | Admission defaults to eight and permits 1-16; representative resource/quality gate remains eight viewers |
| Native shared-encode host | Host targets one encode for at most two standard WebRTC edges | libwebrtc public-API proxy risk spike, with Pion as fallback | Planned separate sender phase; still pays per-edge upload |
| Native volunteer encoded-RTP relay | Each volunteer forwards one encoded copy | Native install, RTP/RTCP forwarding, packaging, and opt-in relay policy | Conditional experiment only if relay re-encoding is the sole browser-spike failure |
| SFU virtual parent | SFU normally emits one or two root copies; roots keep peer descendants | Service pays measured root egress; host sends one publication | Accepted primary central fallback after direct/peer UDP; local SFU/UDP and active Host-ingress relay function pass, while public-room/performance evidence remains open |
+20 -7
View File
@@ -1,8 +1,9 @@
# Peer-Assisted Media Research
- Research date: 2026-08-21
- Scope: one game-screen broadcaster, at most eight trusted viewers, host media fanout at most two
- Status: historical evidence plus the current capacity-two source candidate;
- Scope: one game-screen broadcaster, explicit admission up to sixteen trusted
viewers, with the retained resource/quality gate at eight
- Status: historical evidence plus the current bounded source candidate;
accepted ADR-0005 owns automatic peer/SFU routing. Production later removed
the room-`1` rollout boundary; retained SFU media remains unverified.
@@ -260,6 +261,17 @@ configures only its local server and gate. A 2026-08-22 Chrome 151 two-second
smoke passed with three Viewers at Host2/relay1 and six at Host3/relay3, with all
Viewers decoding. This is not a production-default, SFU-capacity, or resource claim.
A 2026-08-22 Windows Chrome 151.0.7922.138 headless loopback then ran sixteen
Viewers for two seconds at 720p30 with cap2 and cap3. Both runs had all sixteen
Viewers decoding and no fatal/check failure. Cap2 peaked at Host2/relay2 with
depth four and a 1,167 ms maximum first-decode diagnostic; cap3 peaked at
Host3/relay3 with depth three and 977 ms. Final samples were only 320x180 at
9-10 fps. The 8-core/16-thread Ryzen 7 9700X runner had 47.1 GiB RAM and 13.7
GiB free after the runs, but no process CPU, GPU, NIC, or peak-memory totals were
captured. This proves the explicit admission, bounded topology, and decode paths
only; resource, visual quality, endurance, heterogeneous networks, and the
separate 20-viewer gate remain open.
Peer multicast research such as SplitStream demonstrates why load-balanced,
failure-tolerant overlays normally introduce multiple trees and content
striping. Those mechanisms are intentionally excluded: needing them is a reason
@@ -315,11 +327,12 @@ longer has that room boundary. There is no mobile/iPad, UA, or visibility branch
This historical gate assumed default-off configuration through
`PEER_ASSISTED_MEDIA=false`; current production enables the controller for all
rooms.
It cannot be enabled above eight viewers and uses the existing standard WebRTC
screen stream, current Chrome/Edge as the controlled relay cohort, Android
Chrome and iOS Safari as compatibility observations, at most two children per
viewer, and at most eight viewers. It may carry the
existing screen-audio track when the browser provides one. SVC/simulcast,
It uses the existing standard WebRTC screen stream, current Chrome/Edge as the
controlled relay cohort, Android Chrome and iOS Safari as compatibility
observations, and the configured downstream edge cap. The runner accepts the
shared room admission ceiling of sixteen while the representative
resource/quality gate remains at eight. It may carry the existing screen-audio
track when the browser provides one. SVC/simulcast,
custom encoded transport, FEC changes, multi-tree striping, transcoding,
background mobile relay, and the later ADR-0005 SFU controller are outside this
historical browser-relay gate.