1
0
mirror of https://github.com/ossrs/srs.git synced 2026-10-24 09:59:20 +03:00
Files
Winlin 3fc1810a46 WebRTC: Add RFC 4588 RTX config, tests, tools fix. v8.0.41 (#4746)
First step toward RFC 4588 RTX retransmission with SSRC multiplexing
(#4671). This PR adds the config, the server-side groundwork, the tests
and the test tools. RTX negotiation, the uplink unwrap and the downlink
RTX send path come in a follow-up PR.

## Config

New per-vhost `nack_prefer_rtx` directive, off by default. It can be
overridden with `SRS_VHOST_RTC_NACK_PREFER_RTX`.

```
vhost __defaultVhost__ {
    rtc {
        nack_prefer_rtx on;
    }
}
```

`rtc.rtx.conf` and `rtc.plain.conf` are sample configs for the two
modes. `regression-test.conf` turns RTX on.

## Server changes

- **NACK simulator fix:** simulated drops (and `drop_for_pt`) now happen
before SRTP unprotect. Before, a dropped packet had already been
unprotected, so its retransmission was rejected as a replay.
- SDP writes `a=ssrc-group` lines. `SrsRtxPayloadDes` uses the offered
clock rate and reads `apt` from the fmtp.
- A play NACK that names an RTX SSRC is ignored.
- RTX counters show up as cumulative totals in the `rtx=(s,r,u,p)` stats
group.
- Detailed NACK logs are compiled in only for `--simulator=on` or
debug-drop builds.

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-21 20:38:54 -04:00
..

pion-whep

A WHEP player on pion/webrtc with FFmpeg-style options, for the SRS E2E scripts. It plays one stream, prints what it receives, and logs every NACK it sends and every retransmission it gets back, plain or RTX, so a script can verify retransmission from the tool's log alone.

Build:

cd tools/pion-whep && make

make test runs the unit tests and make clean removes objs/.

Play a stream for ten seconds, with the offer, the answer, the ICE and DTLS states, a packet count every second and the NACK lines:

./objs/pion-whep -hide_banner -loglevel debug -f whep -i 'http://localhost:1985/rtc/v1/whep/?app=live&stream=livestream' -t 10 -f null -

Without -t it plays until interrupted. The whep input format is inferred from an http or https URL, so -f whep is optional. The output is always -f null -.

The offer carries rtx for every video codec, as a browser's does, and SRS chooses the retransmission format by its nack_prefer_rtx. FFmpeg has no option for this, so the environment variable PION_WHEP_RTX selects it: on, or unset, offers rtx; off omits it, so the session can only use plain retransmission whatever SRS prefers, and the same running SRS can be verified in both formats:

PION_WHEP_RTX=off ./objs/pion-whep -hide_banner -loglevel debug -i 'http://localhost:1985/rtc/v1/whep/?app=live&stream=livestream' -t 10 -f null -

The log lines a script greps, printed at verbose and above:

NACK sent ssrc=<media>, seqs=[<seq>,...]
Recovered plain seq=<seq>, ssrc=<media>, pt=<pt>
Recovered RTX seq=<rtx seq>, ssrc=<rtx>, pt=<rtx pt>, osn=<seq>

At debug it also prints Session URL: <url>, the WHEP delete URL, whose session= query is the SRS username that the NACK API of a --simulator=on build takes to drop packets on this session.