Skip to content

[pull] develop from ossrs:develop - #17

Open
pull[bot] wants to merge 4766 commits into
httpsgithu:developfrom
ossrs:develop
Open

pull[bot] wants to merge 4766 commits into
httpsgithu:developfrom
ossrs:develop

Conversation

@pull

@pull pull Bot commented Jan 15, 2022 •

Copy link
Copy Markdown

See Commits and Changes for more details.


Created by pull[bot]

Can you help keep this open source service alive? 💖 Please sponsor : )

@pull pull Bot added the ⤵️ pull label Jan 15, 2022
@winlinvip
winlinvip force-pushed the develop branch 5 times, most recently from 927df62 to 75cf9b3 Compare March 3, 2022 01:40
@winlinvip
winlinvip force-pushed the develop branch 2 times, most recently from ff7e709 to e14c3a9 Compare April 6, 2022 09:15
@winlinvip
winlinvip force-pushed the develop branch 2 times, most recently from d4cf3e0 to e8240d6 Compare April 24, 2022 01:24
@winlinvip
winlinvip force-pushed the develop branch 3 times, most recently from 7290933 to 3ed4aed Compare June 9, 2022 12:46
@winlinvip
winlinvip force-pushed the develop branch 4 times, most recently from 4395ee1 to 06e8680 Compare June 17, 2022 09:39
@winlinvip
winlinvip force-pushed the develop branch 2 times, most recently from f070db0 to 0badae4 Compare June 29, 2022 12:48
@winlinvip
winlinvip force-pushed the develop branch 2 times, most recently from 46def44 to 6c29595 Compare July 20, 2022 13:54
@winlinvip
winlinvip force-pushed the develop branch 8 times, most recently from 087317c to bac0470 Compare August 11, 2022 12:45
winlinvip and others added 30 commits October 6, 2026 09:46
Improve test isolation and cross-platform testing, and update the AI
skills. No SRS media server or proxy code changes; only tests, test
tools and skills change.

## Test ports

Every test layer gets its own port range below the Linux ephemeral range
(32768+), so tests run in parallel, alongside a human SRS or Docker
container, and a client socket never takes a port a test picked.

- Each test script takes one optional `SRS_TEST_PORT_BASE` and defaults
to its own 100-port slot: 11000-11700 for the eight proxy E2E scripts,
12100-12800 for the config-file, reload, GB28181 and RTC scripts. This
replaces `SRS_E2E_PORT_OFFSET` and the per-port `SRS_GB_*`,
`SRS_PLAIN_*` and `SRS_RTX_*` variables, so a Full tier sets no port
variables.
- The regression SRS runs on 13000+ through the `SRS_*_LISTEN` env, with
its pid and log in `/tmp/srs-regression`. `srs_test` adds
`-srs-rtmp-port`, `-srs-api-port` and `-srs-rtsp-port`, so it no longer
needs 1935, 1985 or 8554.
- Black-box tests allocate from 21000-25999 (`SRS_BLACKBOX_PORTS`), and
the custom-port RTSP case now allocates its port too. C++ utests use
26000-29999 (`SRS_UTEST_PORTS`).
- The Port Plan in `integration-tests.md` is the source of truth, with
every range, its owner, and the ports bound and still free.

## State Threads on every OS

- New `st-test.sh` detects the platforms and runs every ST test on each:
the local OS first, then Linux in Docker and Windows x64 in parallel,
with a summary per OS and the platforms not tested and why.
`st-test-runner.sh` runs one build.
- New `st-windows-test.sh`, opted in by `SRS_TEST_WINDOWS_HOST`, mirrors
the local checkout on a Windows host over SSH. It syncs a commit by
pushing to the branch's upstream, never `origin`.
- `full-tier-lock.sh` takes `--product`, so ST runs hold their own lock
and run in parallel with SRS tiers.

## Skills

- `srs-autopilot`: `tasks/tracker.md` lists every task file and its
state, and this skill's rows are owned by `SRS`. Each task gets its own
worktree and branch in every repository it changes. Tests are reported
by OS and CPU.
- `srs-develop`: `testable-code.md` covers the test platforms and
running tests in a subagent. New Step 5 verifies ST on Windows. Issue
titles start with the owning component: `SRS:`, `Proxy:`, `ST:` or
`Oryx:`.
- `internal-codemap-for-srs` and `internal-docs-for-srs`: the C++ test
map moves into `cpp-server.md`, `go-server.md` adds the Go proxy tests,
and the docs list the native Windows x64 coroutine doc and
`md_win64.asm`.

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
A multi-line bash -c blob needs the user's permission and stalls the
autopilot loop. Planning now fixes every command a task runs and writes
multi-step checks as scripts; the task prompt forbids shell blobs.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Clean the AI agent config so each agent loads only what it uses. No SRS
media server or proxy code changes; only AI config, skills, and a doc
copy change. Docs: ossrs/srs-docs2#1.

SRS keeps supporting four agents: OpenClaw, Claude Code, Codex, and
Kiro.

## Coding agents: skills only

Claude Code, Codex, and Kiro used to load the OpenClaw persona files
(SRSBot's IDENTITY, SOUL, MEMORY, TOOLS, USER) through an entry file in
each folder. Now each folder holds only a `skills -> ../skills` link:

- `.claude/skills`, with no `CLAUDE.md` and no persona links.
- `.agents/skills` for Codex and other Agent Skills tools;
`.agents/AGENTS.md` is removed, since no tool reads it.
- `.kiro/skills`; `.kiro/steering/` is removed, since Kiro auto-loads
every steering file, persona links included.
- `.codex/` is removed: its `config.toml` set `model_instructions_file`,
which replaces the Codex base prompt, and `.codex/skills` duplicated
`.agents/skills`.

There is no root `AGENTS.md`; the skills carry all the rules.

## OpenClaw: rewritten for SRSBot

`.openclaw/` serves the SRS community robot in Telegram and Discord, and
users' own OpenClaw.

- `AGENTS.md` replaces the stock personal-assistant template with an SRS
guide: session start, group-chat behavior, the `srs-support` skill,
platform formatting, safety (no private data, ask before external
actions, never push), memory, and a `## Tools` section merged from
`TOOLS.md`.
- `TOOLS.md` and `HEARTBEAT.md` are removed; current OpenClaw no longer
reads them.
- `SOUL.md` and `IDENTITY.md` drop the personal-assistant text and keep
SRSBot ⚡. `MEMORY.md` has current facts instead of the first-boot note.
`USER.md` gets the `air config` dictation row and a note for users of
their own OpenClaw.

## Skills and other cleanup

- `srs-support`: the workspace folder list names the real folders and
sibling links, and says how OpenClaw reaches `state-threads/` and
`website/` through `srs/`.
- `srs-develop`: commit prefixes add `Kiro:`; Claude uses the co-author
line its harness gives instead of a hard-coded model name.
- `srs-develop` Oryx local development guide: project-root paths and
subshells instead of `~/git/srs`.
- `internal-docs-for-srs`: the bundled `getting-started-ai.md` copy is
synced with the website doc.
- Root `.gitignore`: drops the OpenClaw-era patterns that matched
nothing; `/tasks` and `/objs` stay.

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Update the AI skills for the State Threads coroutine entry and the QEMU tests of [state-threads#42](ossrs/state-threads#42). No SRS media server or proxy code changes; only skills, and the version and changelog.

## State Threads code map and docs router

ST now starts every new coroutine in the `_st_md_thread_start` assembly entry on every platform but Cygwin64, and tests 10 Linux CPUs with QEMU. The skills that route to ST say so:

- `internal-codemap-for-srs` `references/state-threads.md`:
  - `md.h` has `MD_INIT_THREAD_ENTRY`, and each `md_*.S` has the entry. Cygwin64 has none and keeps the old start.
  - Lists `st_utest_entry.cpp`, and notes that `tools/backtrace` stops at the entry.
  - Tests another CPU with `auto/qemu.sh <cpu>` (QEMU user mode in Docker) or `auto/darwin.sh <cpu>` (macOS, x86_64 under Rosetta 2).
- `internal-docs-for-srs`: routes to the new `docs/coroutine_entry.md` for the entry on every CPU, keeps `docs/win64_coroutine.md` for Windows x64, and notes the README section on QEMU and Rosetta.

## Autopilot

- `srs-autopilot` decides open choices itself: it picks the best option, logs it as a decision, and goes on. It stops only for a dangerous operation or a severe, unexpected situation.
- Each workflow (plan, track, run, review) moves to its own file in `references/`, so a session loads only the one it uses.

## Docs content

- `srs-develop` `develop-code.md`: updating the English docs bundled in `skills/internal-docs-for-srs/` is done with the develop workflow. Translation, the website framework and releases stay with the private website skill.

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Implements the two useful ideas from #4763 (issue #4760) in our own
design, as concluded in [this
comment](#4763 (comment)):
a read-only forwarder status API, and a keyframe restart after a
forwarder reconnects or its queue overflows. Before any production
change, it adds test coverage for the forward feature as it is today.

## Keyframe restart

After a forwarder connects or reconnects, or after its queue overflows
and shrinks, it starts fresh from live at a keyframe instead of sending
the stale queue in a burst:

- It drops the queued media and sends the metadata and the audio/video
sequence headers once.
- Video waits for the next keyframe. Audio is never dropped, so
audio-only streams keep playing.
- Always on, no config. It works for both `forward.destination` and
`forward.backend`.

## Forwarder status API

A new read-only `GET /api/v1/forwards/` lists each forwarder of each
publishing stream:

- Fields: `id`, `stream`, `vhost`, `app`, `name`, `url` (the url the
forwarder publishes to), `state` (`connecting`, `forwarding` or
`retrying`) and `state_at` (Unix ms).
- `?stream=<stream id>` filters by stream; `start`/`count` page the
list, and `total` is the number of forwards after the filter, like the
streams and clients APIs.
- `GET /api/v1/forwards/{id}` returns one forward; an unknown id returns
code 2057 (`ERROR_RTMP_FORWARD_NOT_FOUND`).
- Any other method returns 405. There is no API to add or remove a
forward: with `forward.backend`, the backend decides the forwards on
each publish, and kicking the publisher (`DELETE
/api/v1/clients/{publish.cid}`) applies a change. The docs give the
steps, and black-box cases prove them.
- The id stays the same across retries and is new on each publish. The
forwarder now takes the publishing stream's request in its constructor.

## Tests

- Coverage first, for the forward code that exists today: utests for
`SrsForwarder` (intake, queue, connect, send, reconnect), the forward
parts of `SrsOriginHub`, `SrsHttpHooks::on_forward_backend()` and the
forward config getters, and black-box cases for `forward.destination`
and `forward.backend`. `SRS_VHOST_FORWARD_DESTINATION` is now supported
as an env, so black-box cases can configure a destination.
- Keyframe restart: utests and workflow utests, written failing first,
plus black-box cases that check the first packet after a reconnect is
live (and a keyframe for video), including audio-only and video-only
streams.
- Status: utests for the statistic and the API, black-box cases for both
forward paths and for changing forwards by kick, and a new feature
script `forward-status-test.sh`, which checks `retrying` while a
destination is down and `forwarding` with the same id after it comes
back.
- Verified on macOS arm64 with the Full tier (all C++ utests, proxy
utests, black-box, regression and every feature script); C++ utests also
on Linux arm64 and x64 in Docker.

## Skills and docs

- `srs-develop`: runner scripts for the utests and the Full tier, the
new feature script in the test tables, and its port slot (12900).
- `internal-codemap-for-srs`: forward and statistic lines, and
`forward_test.go`.
- `internal-docs-for-srs`: `forward.md` gets Keyframe Restart, Forward
Status, and Add or Remove a Forward; `http-api.md` gets a Forwards
section.

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Add a security-critical rule to srs-develop: never write secrets,
personal information, local paths, host names or aliases, account names,
or private repository names into the public SRS-family repositories.
Environment-specific values stay with the user: read them from
environment variables or user-configured tools, and document only the
variable name with a matching placeholder.

The Windows test script now documents SRS_TEST_WINDOWS_HOST with the
placeholder <srs-test-windows-host> instead of a real host alias.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Adds `srs-integ`, a black-box integration suite for the SRS media
server, and fixes the SRS bugs it found: over 120 of them, in every
protocol. The suite tests SRS from outside the process, only through
what a client, an operator or a callback server can see, so a rewritten
server could pass the same cases.

The suite now has about 1,450 cases (1,353 main and 99 timer), with no
known bugs left: every bug a case found is fixed in this PR. It also
removes some unused features, adds env support for a few more
directives, and changes a few hook and API fields.

## srs-integ suite

`cmd/integ` is a Go module of its own, `srs-integ`, separate from the
root `srsx` module. It imports nothing from the repository.

- **Run:** `make integ` makes the test media, then runs the cases in two
`go test` processes at once: the main cases and the `TestTimer_` cases.
`make integ-unit` runs the unit tests of the clients and analyzers, and
`bin/srs-integ` gives `probe`, `publish` and `prepare` from the command
line.
- **Server adapter:** each server is `objs/srs -e`, configured only by
env vars, on ports from `SRS_INTEG_PORTS` (14000-14999 in the Port
Plan). Most cases share a Common server, split into 4 shards. Cases that
need other settings run on variant servers, and groups share these where
they can.
- **Case classes:** Fast (≤100ms), Normal (≤500ms) and Timer (≤10s, only
in `TestTimer_` groups). A case that runs over its limit fails.
`KnownBug` marks a case that fails because of an SRS bug, and the case
fails once the bug is fixed, so the mark can't go stale.
- **Clients and analyzers written for the suite:** RTMP and RTMPS (both
handshakes, any chunk size, enhanced RTMP, malformed input), FLV, TS,
AAC/MP3, MP4, HLS (TS, fMP4, AES-128, SAMPLE-AES) and DASH. Each one
fills a shared stream report: codecs, picture size, sequence headers,
keyframes, timestamps and A/V sync.
- **Clients built on libraries:** WebRTC WHIP/WHEP on pion (UDP and TCP,
NACK/RTX/TWCC recorder, raw DTLS sessions), SRT on gosrt, RTSP on
gortsplib, and a GB28181 PS-over-RTP publisher with no SIP.
- **Test media:** generated from `doc/source.flv` by `make
integ-prepare` and never committed. The files cover H.264, HEVC, VP9,
AV1, AAC, Opus, MP3 and G.711, in FLV, MP4 and TS. A manifest keeps the
media from being made again when nothing changed.
- **Feature coverage:** the HTTP API, HTTPS API and exporter, reload,
heartbeat, RTMP, RTMPS, HTTP-FLV, HTTP-TS, HTTP AAC and MP3, HTTPS, HLS,
DASH, WebRTC, SRT, RTSP, GB28181, the MPEG-TS over UDP caster, every
HTTP hook, security rules, forward, edge, the origin cluster, DVR,
static files and VOD, signals, the command line and env settings.
- **Conversion matrix:** each source (RTMP/RTMPS, WHIP, SRT, GB28181) is
played by each player (RTMP, HTTP-FLV, HTTP-TS, MP3, AAC, HLS ts and
fMP4, DASH, WHEP, SRT, RTSP) with each codec it can carry. The README
has the matrix.
- **Scale:** `-integ.scale=N` runs each case N times. A run of about
1,000 cases passes in about 11s.

## SRS bug fixes

Every fix has a utest and, where a client can see it, an srs-integ case
that failed before the fix. The main ones by area:

- **HLS:** fMP4:
  - The default init file is now listed by its dir.
  - `hls_entry_prefix` now applies to fMP4 URIs.
  - MP3 streams now get an audio track in the init file.
  - Each publish now starts with a discontinuity.
  - `hls_keys` now encrypts the samples with cbcs.
  - A segment that fails to open is now dropped. Before, it crashed SRS.

Other HLS fixes: key URIs, AES padding, HLS starts again after
`hls_dispose`, the ratios, a TS republish, session names, and the
`hls_ctx` of another stream's session is now checked as a new session.
- **DASH:** the config, the MPD (window, update period, HEVC and MP3
codecs), init files of MP3 and of one-track streams, and dispose.
- **WebRTC:**
  - Keyframes with an SEI, and Sender Reports and their mapping.
  - Opus timing, G.711, and WHEP SSRCs.
  - A refused WHIP publisher now frees its stream.
  - The start and hooks, and WebRTC over TCP.
- **SRT:** only the configured latencies are set, as ffmpeg does. Also
fixed: HEVC headers and CTS, frame counts, and the listener.
- **RTSP:** a republish to a kept player, PLAY without SETUP, unknown
methods, closes, DESCRIBE/TEARDOWN, request bodies and `on_stop`.
- **GB28181:**
  - SSRC parsing.
  - HEVC to RTMP is no longer sent in legacy FLV tags.
  - A crash on a second media connection.
- Latency with no audio, sliced frames, CTS, session lifetime, and the
muxer and caster output.
- **RTMP and HTTP:**
- Timestamps that jump back without time correction no longer stop a
player.
  - The republish param and the publish timeout after a pause.
  - The no-origin close and the RTMPS port.
  - HTTP ranges, including MP4 suffix ranges and VOD 416.
  - Redirects, mounts, unmounts and URL `..`.
  - CORS, API auth paths, JSONP 400 and 403 answers.
  - Static files and the request echo.
- **Hooks:**
  - The heartbeat URL's query is now sent.
  - `on_play` clients and client types, and `on_dvr`.
  - A client that `on_connect` refused no longer gets `on_close`.
- **Other:** DVR (MP4 info frame, audio rate, audio cut), listen ports
above 65535, the env vhost check, the UDP caster, process stats, the
tcmalloc rate, the encoder loop, the edge failover, STUN, coroutine
joins, and the resource manager's fast-id cache (WebRTC and GB lookups
never used it).

## Behavior changes

- **Hooks:**
- `on_publish`, `on_unpublish`, `on_play` and `on_stop` have a new
`type` field after `client_id`, such as `rtmp-play` or `hls-play`, the
same value as `/api/v1/clients`.
  - Every protocol now sends `param` with its leading `?`.
- HTTP players send their own `http(s)://` tcUrl, and WHIP/WHEP clients
send `webrtc://<host>/<app>`.
- **API:** `/api/v1/features` adds `srt`, `rtsp`, `gb28181`, `rtc`,
`simulator` and `sanitizer`. The `/api/v1/` index lists only the URLs
SRS serves.
- **Env support:**
  - The vhost security rules.
  - The edge protocol.
  - The origin cluster and coworkers.
  - The DVR apply filter.
- **Timers in seconds:** `hls_dispose`, `dash_dispose`, `dvr_duration`,
`queue_length`, `stun_timeout` and the heartbeat `interval` now accept
fractions such as `0.5`. A fraction used to be cut to whole seconds, so
`0.5` read as 0.
- **Removed features:** a config or env var that names one of these, on
or off, now makes SRS refuse to start (and `-t` fail) with `<name> is
removed`:
  - HDS, including `--hds=on`.
  - The FLV POST caster and `asprocess`.
  - `query_latest_version` and `first_wait_for_qlv`.
  - The vhost `bandcheck`, `refer` and `atc_auto`.
- Edge `token_traverse`. Check clients with the edge's HTTP hooks
instead.

## Tests, CI and skills

- **CI:** a new `integration-test` job builds `trunk/Dockerfile.test`
(now with `--simulator=on`) and runs srs-integ.
  - It caches the test media.
- It runs the main cases and the timer cases as separate steps, each
retried on its own.
  - Limits are scaled by 4 with `-integ.limit-scale=4`.
- **Unit tests:** more stable. They use random seeds, the test servers
no longer share ports or leak fds, and a gtest listener fails a test
that leaves a handler on a global resource manager.
- **Skills:**
  - The `srs-develop` Gate and Full tiers run `make integ`.
  - `integration-tests.md` explains how to add cases.
- The new `internal-audit-for-srs` skill audits each commit blind before
review.

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
OBS Studio, the publisher most SRS users use, becomes a test client for
SRS, driven by an internal skill.

The internal-obs-control skill drives OBS over obs-websocket 5:

- scripts/obsws.py: a stdlib-only websocket client. probe, enable the
websocket, launch and quit, call and batch requests, events,
screenshots, run ids, and isolated instances with a private config, pid
and websocket port from OBS_CONTROL_WS_PORTS.
- scripts/obs_srs_test.py: setup, stream start, stop and restart, verify
through the SRS HTTP API (exit 6 on a failed check), and teardown by run
id. It keeps SRT stream ids and RTMP key parameters, and takes
--http-url for non-default playback ports.
- Fixes found in use: a restart waits for the output cleanup, the
display_uuid list is refused before it crashes OBS, the user's crash
sentinels are kept, and Windows quit targets the selected PIDs.
- Windows instances run portable through directory junctions, launched
by a scheduled task, since SSH has no desktop.
- references/: the protocol, config files, sources and encoders, SRS
targets from source builds, the CLI and lifecycle, and what the tests
showed about SRT, WHIP and the RTMP bridge.
- test_obsws.py and test_obs_srs_test.py, without a real OBS.

The srs-develop OBS tests publish H.264 from an isolated OBS to SRS and
check the API and HTTP-FLV, and HLS for RTMP:

- obs-rtmp-publish-test.sh (AAC), obs-srt-publish-test.sh (AAC) and
obs-whip-publish-test.sh (Opus), on obs-test-lib.sh, the Bash 3.2
harness with owned cleanup, one bounded OBS relaunch and a 60 s budget;
obs-test-lib-test.sh covers it with fakes.
- obs-lane-test.sh runs the three in parallel as lane G of the Full
tier, beside lanes A-F; lane H stays alone after them.
- obs-linux-test.sh runs them against SRS built and run in Docker, and
obs-windows-test.sh runs RTMP and WHIP from OBS on the Windows test host
to SRS in WSL, reconfiguring when configure changes.
- SRS_TEST_OBS=0 skips them; SKIP and KNOWN lines are reported as
unverified, never as passed. An isolated OBS that fails to launch after
a good probe is a FAIL, not a SKIP, so leaked instances cannot make lane
G pass unverified. srs-full-tier-test.sh tests the runner.
- windows-host-run.sh runs a local script on the Windows test host from
a mirrored checkout, never pushing to origin; st-windows-test.sh now
uses it. windows-host-run-test.sh covers both with a fake host.
- integration-tests.md gains the Feature-Specific rows, the 15000-15999
Port Plan rows, lane G and the Full tier times.

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Codex <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
…8.0.63 (#4785)

SRS gets performance tools that load and profile SRS in Docker for every
protocol: a lean load tool, an internal skill that runs an improvement
round, and a measurement method that holds up to a 10% verdict. The same
tools then measure the Go proxy. The first runs found one SRS fix and
three Go proxy fixes.

The load tool, a standalone Go module in cmd/perf (bin/srs-perf):

- Per-core worker processes shard the clients and report counters each
second. Lean clients for every protocol: RTMP publish and play,
HTTP-FLV, HTTP-TS, HLS, DASH, RTSP, SRT, WHIP and WHEP. No decode;
frames and lag come from timestamps.
- 17 scenarios: each protocol's fan-out, publishers (rtmp-pub,
whip-pub), many-streams, cross-protocol bridges (srt-rtmp, srt-whep,
whip-rtmp, whip-flv), and delay probes for the RTMP pause, forward and
edge.
- run ramps by doubling to a capacity, then holds at 50% and 90% of it.
compare checks that the setups match and reports capacity and CPU per
client at the 10% line.
- make perf-image builds an optimized SRS with symbols and frame
pointers, with perf, FlameGraph and FFmpeg. SRS runs on one pinned core
and is configured only by env files, one per scenario.

The measurement method:

- A flat CBR source, checked to ±3% per second, since SRS CPU follows
the bitrate.
- SRS CPU from its cgroup once a second. Holds have no profiler in the
measuring window; each count gets its own separate profile hold.
- perf-ab.sh builds two revisions and runs them side by side on separate
cpusets. compare gives the 95% CI of the paired per-second difference.
- perf-verify.sh checks every run: capacity, healthy steps, profiles and
symbols, noise, and what bound the run.

The internal-perf-for-srs skill:

- SKILL.md holds the rules, the shared tools and the round workflow. A
Target Router loads references/cpp-server.md for the C++ media server or
references/go-server.md for the Go proxy.
- Each reference covers its tools, topology, scenarios, measuring, how
to read its profiles (Linux perf, or Go pprof and trace), A/B, the
verified scenarios with their capacity and top bottleneck, and how to
start a round.
- srs-develop routes performance, benchmark, load test and profile tasks
to it. perf-skill-test.sh checks the text against the scenario registry.
- Reports are git-ignored, since their numbers hold only for the machine
that made them.
- The skills now name each server by its job: the C++ media server and
the Go proxy, with no "generation".

C++ media server, one core, Linux arm64 in Docker:

- Fix: an empty SrsSharedPtr holds no reference count, so each fan-out
copy of a message does one malloc instead of three. Covered by
srs_utest_ai05.cpp.
- Capacity: rtmp-rtmp, rtmp-flv, rtmp-hls, whip-rtmp and whip-flv
12,800; rtmp-dash and srt-rtmp 6,400; rtmp-ts and rtmp-rtsp 3,200;
whip-whep 2,000 (cap); rtmp-whep, srt-whep, srt-srt and rtmp-pub 1,280;
whip-pub 1,000 (cap); many-streams 640 streams.
- Top bottlenecks found, not fixed: the RTMP fan-out copy,
_st_epoll_dispatch with EAGAIN reads, 4 KB reads and writes for HLS and
DASH segments, one write per message for HTTP-TS and two per packet for
RTSP, the SRTP replay window in libsrtp, and libsrt for SRT.
- Delays: the paused RTMP player's 500 ms sleep, and the forward's and
edge publish's 500 ms receive timeout, each adding about 220 ms of lag.

The Go proxy, cmd/proxy, on one core in front of 1 to 4 SRS origins:

- perf-up.sh -target proxy, run -target proxy, which samples the proxy
and each origin, Go profiles in each profile hold (CPU, allocations,
mutex, block, trace, GC), and proxy A/B.
- Fix: HTTP-FLV, HTTP-TS and HLS relay the origin's error status,
headers and body, rather than a 500 with the origin's address.
- Fix: a WebRTC STUN binding routes by its ufrag, not a cached client
address. WHIP and WHEP failed from 160 clients on three origins.
- Capacity on three origins: rtmp-flv and rtmp-hls 12,800; rtmp-rtmp and
rtmp-ts 6,400; whip-whep 2,000 (cap); srt-srt and rtmp-pub 1,280;
whip-pub 1,000 (cap); many-streams 1,280 streams.

---------

Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Add the v8.0-d1 release line to the README releases and the SRS 8.0 changelog.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fixes #4762: with `srt_to_rtmp on`, 48 kHz AAC published over SRT got
wrong per-frame timestamps on the RTMP side, so the audio of RTMP
playback, HLS and forwards crackled. This replaces #4765, and keeps its
author's credit for what was learned from it.

## Cause

An SRT publisher such as FFmpeg packs several AAC frames into one PES,
which carries a single PTS. `SrsSrtFrameBuilder::on_ts_audio()` times
frame `i` at `pts + i * 1024 / sample_rate`, and took `sample_rate` from
the FLV sound rate, which has only 5.5, 11, 22 and 44.1 kHz:

- 48 kHz frames were stamped 23.22 ms apart instead of 21.33 ms, and the
timeline stepped at each PES.
- Every other rate FLV can't represent was wrong too: 96, 88.2, 64, 32,
24, 16, 12, 8 and 7.35 kHz.
- Players that place audio by timestamp, such as hls.js and YouTube
ingest, played gaps and overlaps. flv.js and ffplay hide it.

It regressed in the SRS 5.0 SRT rewrite. The AAC sequence header was
already right, and the UDP MPEG-TS ingest path already used the AAC
rate.

## Fix

Take the rate from the ADTS `sampling_frequency_index`, as the UDP
MPEG-TS path does, and keep 44.1 kHz for a reserved index, which has no
rate.

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Nandisha <61039123+AlexFreik@users.noreply.github.com>
SRS builds and runs natively on Windows x64 again, now with MSVC and
without Cygwin. This change adds `srs.exe` and `srs_utest.exe`, which
are tested on a Windows host and in CI, and the release attaches a
Windows zip. The Cygwin64 build was removed in v7.0.60 (#4447) because
it was too hard to maintain. This build sits on the native Windows
support that State Threads got in v8.0.56, and every Windows feature has
automated tests so it does not rot again.

## Build

- A Windows-only CMake build, `trunk/cmake/windows/CMakeLists.txt`,
reads the same module list as `./configure`
(`trunk/auto/module_files.txt`). The Unix `./configure` build is
unchanged.
- Dependencies: vcpkg pins OpenSSL 3, libsrtp, libsrt, Opus and
googletest in `trunk/vcpkg.json`. MSYS2 builds the bundled FFmpeg-fit
with MSVC, for AAC and Opus in WebRTC.
- The platform shims for sockets, file IO, time, processes, signals and
system stats live in `srs_core_platform.hpp/.cpp`. App code has no new
`#ifdef` spread.
- `skills/srs-develop/scripts/srs-windows-runner.sh` builds, tests and
packages. The Windows host, CI and the release all use it. Its `vs` step
makes a Visual Studio solution.
- The IDE CMake, `trunk/cmake/CMakeLists.txt`, now takes its sources
from the module list too.

## Features on Windows

- Live: RTMP, RTMPS, HTTP-FLV, HTTP-TS, HTTPS, HLS (TS and fMP4), DASH,
DVR, static files and VOD.
- HTTP API, exporter, hooks, security, edge and forward.
- WebRTC WHIP and WHEP with AAC and Opus conversion, SRT through libsrt
including SRT to RTMP, GB28181 and RTSP.
- Ingest, transcode and exec, which start `ffmpeg.exe` through
`CreateProcessW`. A job object kills the child when SRS exits.
- Control: Ctrl+C quits fast. Ctrl+Break or closing the console quits
gracefully. The RAW API runs `reload` and `reopen-log`. The pid file
uses `LockFileEx`. Daemon mode is refused, because `srs.exe` is a
console program.

## Tests and CI

- **Windows host:** `srs_utest` 3325 of 3325. `cmd/integ` main and timer
cases pass at `-integ.limit-scale 4`. The OBS RTMP, SRT and WHIP cases
now publish to native `srs.exe` instead of WSL.
- **Skipped on Windows:** six timer cases that need Unix signals. Each
names the case that covers it (`cmd/integ/internal/check/skips.go`).
- **CI:** a `windows-utest` job in `test.yml` on `windows-2025`. The
build names `cl` for CMake, because the current image's Visual Studio 18
puts its clang on PATH.
- **Release:** a `windows` job in `release.yml` attaches
`SRS-Windows-x86_64-<ver>.zip`. The zip needs no DLLs beyond Windows'
own.
- **Linux and macOS:** the Full tier is unchanged. A Linux RTMP A/B
against `develop` at 11,520 players measured +1.8% SRS CPU, below the
10% line.

## Fixes found on the way, for every OS

- A forked child that fails to redirect or exec, such as for ffmpeg, now
calls `_exit`. Before, with SRT started, it hung in libsrt's exit
handlers, and SRS treated ffmpeg as running.
- A child's `process ppid=...` banner now reaches its log: stdout is
flushed before `execv`.
- `mkdir_all` can create a missing dir right under the root, such as
`/data/hls`.
- An HEVC sequence header from WebRTC is the same for the same parameter
sets. The hvcC record had uninitialized fields, so RTMP could get two
headers.
- With OpenSSL 3, which a Unix `--use-sys-ssl` build may use too: RSA
DTLS certificates are 2048-bit. `dtls_version dtls1.0` works, but leaves
out the anonymous, null and MD5 suites that security level 1 refuses.
- The utest builds with RTSP or GB28181 off, the configure defaults.
- `openssl3-api-check.sh` works under GCC. Before, every compile failed
and it reported PASS.
- Several `cmd/integ` cases no longer flake: the DASH
`availabilityStartTime` bound, the RTC hook queue cases, the GB publish
waits, and RTC to RTMP keyframe requests.

## Limits

- ST on Windows uses WSAPoll only, with a ~15.6 ms timer. Non-blocking
TCP sends are all-or-nothing.
- No `/proc` stats, inotify reload, `SO_REUSEPORT`, daemon, Windows
service or installer.
- No ASan, gperftools, Valgrind or backtraces.
- UTF-8 file names need Windows 10 1903 or later.

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Add the v8.0-d2 release line to the README releases and the SRS 8.0 changelog.

---

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fixes #4778.

## Problem

Several places take `&vec[0]`, or call `back()`, on a `std::vector` that
can be empty. That is undefined behavior. Plain builds usually get away
with it, but GCC 15 turns on the libstdc++ bounds checks by default at
`-O0`, so `srs_utest` aborts at `KernelMp4Test.SampleDescBox`:

```
stl_vector.h:1263: ... operator[](size_type) ...: Assertion '__n < this->size()' failed.
```

## Changes

1. **MP4 dumps.** `dumps_detail` of `SrsMp4AvccBox`, `SrsMp4HvcCBox` and
`SrsMp4DecoderSpecificInfo` use `data()` instead of `&vec[0]`, which is
valid for an empty vector. The output does not change.
2. **Bounds checks in every utest build.** `configure` adds
`-D_GLIBCXX_ASSERTIONS` (libstdc++) or
`-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_FAST` (libc++ on macOS)
when `--utest=on`. The current CI image (GCC 9) and local macOS builds
now catch this kind of bug without needing GCC 15.
3. **The same bug in other modules**, found by turning on those checks
and auditing every `&vec[0]`:
- **SDP:** a `y=` line (GB28181 SSRC) before any `m=` line called
`media_descs_.back()` on an empty vector. A WHIP/WHEP offer can reach
this. It now fails as an SDP decode error.
- **HEVC:** an hvcC array with no NALU, or with a zero-length one,
reached `&nal_unit_data_[0]` in the hvcC demux, the VPS/SPS/PPS demux,
the TS muxer that inserts them before an IRAP frame, and the RTC STAP-A
packager. The empty NALU is now skipped, as the AVC code already does
for a zero-length SPS/PPS.

---------

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-authored-by: winlin <winlinvip@gmail.com>
Fixes #4781.

## Problem

The `o=` line of the WHIP/WHEP answer used the negotiator's address as
the sess-id, formatted as a signed int64:

```cpp
local_sdp.session_id_ = srs_strconv_format_int((int64_t)this);
```

On Android arm64 the allocator tags the top byte of heap pointers with
`0xb4`, so the id is negative. A packet capture from an Android (RK3588)
build of SRS 7.0.0 showed:

```
o=SRS/7.0.0(Hang) -5476376624034876576 2 IN IP4 0.0.0.0
```

That is `0xb4000079bc25f360`. RFC 8866 requires the sess-id to be digits
only, and JSEP (RFC 8829 5.2.1) requires it to be less than 2^63-1.
Firefox parses it as an unsigned 64-bit number, fails
`setRemoteDescription`, and no ICE or DTLS traffic follows the 201
response. Chromium browsers keep it as a string and work. Linux builds
are not affected, because user-space addresses there stay far below
2^63.

## Changes

1. **Random sess-id.** `srs_rtc_sdp_session_id()` draws 64 random bits
and clears the top two, so the id is always a number less than 2^63-1.
Both the publish and the play answer use it. JSEP recommends random
bits, and they do not leak the server clock.
2. **Testability.** The publisher negotiator owns an `ISrsRand`, like
the player negotiator, so tests can inject the random bytes.

The first version of this PR built the id from an NTP timestamp plus a
counter. It was replaced by the random id above, which follows JSEP and
can be pinned in tests.

## Tests

- `RtcSdpSessionIdTest.TaggedTopByteGivesNonNegativeId`: the bytes of
the Android address above give `3746995412819899232`; before the fix,
the same conversion gave `-5476376624034876576`.
- `RtcSdpSessionIdTest.AllBitsSetStaysBelowJsepLimit`: all bits set
stays below 2^63-1.
-
`RtcPublisherNegotiatorTest.GeneratePublishLocalSdpDrawsSessionIdThroughInjectedRand`
and
`RtcPlayerNegotiatorTest.GeneratePlayLocalSdpDrawsSessionIdThroughInjectedRand`:
both answers take the sess-id from the injected generator.

---------

Co-authored-by: luocanfeng <luocanfeng@kedacom.com>
Co-authored-by: winlin <winlinvip@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…68 (#4784)

Fix #4783

## Problem

Every WebRTC play leaks the track descriptions it negotiates, on success
and on every error.

`SrsRtcPlayerNegotiator::negotiate_play_capability` copies each source
track into the play relations of `SrsRtcConnection::add_player`. Every
user of the relations keeps a copy of its own: the answer SDP copies
them into `stream_desc`, `create_player` keeps only the SSRCs, and
`SrsRtcSendTrack` copies again in its constructor. So nothing freed the
relations, and each audio and video play leaked two descriptions with
their payloads. The leak dates from the play relations in SRS 4.0.

## Fix

`add_player` frees the relations on every return, and its old body moves
into `do_add_player` unchanged.

---------

Co-authored-by: luocanfeng <luocanfeng@kedacom.com>
Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: winlin <winlinvip@gmail.com>
….0.69 (#4788)

## Fixes

- **HEVC:** the sub-layer `reserved_zero_7bits`, `reserved_zero_33bits`
and `reserved_zero_35bits` vectors in profile_tier_level were never
resized, but were written by sub-layer index. A VPS or SPS whose
sub-layers use profile 2, or profiles 5, 9, 10 or 11, wrote past the
heap buffer.
- **HEVC:** an SPS that is not 4:4:4 has no
`separate_colour_plane_flag`, which is inferred to be 0, but the parser
never reset it, so the SPS table entry kept the value of an earlier SPS
or uninitialized memory. A 4:2:0 stream could then be cropped wrongly,
such as 1080p reported as 1084 on Windows.
- **Proxy:** `proxyApiToBackend` wrote the status before copying the
backend headers, and `net/http` drops headers set after `WriteHeader`.
So the origin's `Location` never reached a WHIP or WHEP client, which
could not DELETE its session, and the origin waited for the STUN
timeout. The proxy now copies the headers first, repairs
`Content-Length` when it rewrites the SDP, and passes a DELETE through.
- **Windows:** saving the config renamed its temporary file while it was
still open, which Windows refuses, so the save failed and left the
temporary file. The file is now closed first.
- **RTMP:** a player whose `start_play` fails now gets `on_stop`, and a
publisher whose publish fails after authorization gets `on_unpublish`,
pairing the accepted `on_play` and `on_publish` hooks.
- **RTSP:** a SETUP while a player plays is refused with 455, because it
replaces a track writer the player coroutine may be yielding inside.
- **GB28181:** the media connect timeout applies only when
`connecting_starttime_` is set.

`pion-whep` gains `PION_WHEP_REQUIRE_SESSION=on`, which fails the run
when the answer has no `Location` or the DELETE is not answered 2xx. The
proxy E2E scripts use it for WHEP, and the WHIP E2E checks that FFmpeg's
DELETE reaches the origin through the proxy.

The branch also carries the README release line for v7.0-a3.

## Coverage

Most `LCOV_EXCL` regions hid code the utest binary already runs, or
could run with the existing mocks, crafted input, temp files, loopback
sockets or in-process DTLS. This PR removes them so the coverage report
shows the real gaps, and keeps an exclusion only where a utest cannot
reach the code:

- `SrsServer` run loop, cycle and stop, since stop shuts down libsrt for
the whole process.
- The inotify watcher's start and cycle.
- `main()`, and the vendored llhttp and JSON parsers.

It also drops malformed markers: a nested START and a stray STOP in the
SRT protocol, and an unpaired START in the config that excluded
`parse_options` and everything after it.

New utests in `ai36` to `ai39`, plus `ai22` and `ai23`, cover the code
that lost its exclusion: server, RTMP connection, config, DTLS and SRTP,
RTC, SRT, edge, FFmpeg, process, ingest, HLS, DASH, MPEG-TS over UDP,
RTSP, GB28181, and HEVC, AVC, TS and MP4 parsing. `SrsEdgeIngester` now
creates its coroutine and upstreams through the app factory, so tests
can inject them; behavior is unchanged.

## SRS 7.0

Every SRS fix here is already in `7.0release`, so none needs a pick to
7.0 again:

- Proxy WHIP/WHEP `Location`: v7.0.203, with the #4718 backport.
- RTMP `on_stop` and `on_unpublish` pairing: v7.0.205, with the #4737
backport.
- RTSP SETUP while playing: v7.0.193, with the #4750 backport.
- GB28181 media connect timeout: v7.0.199, with the #4721 backport.
- HEVC sub-layer overflow: v7.0.206.
- HEVC `separate_colour_plane_flag`: v7.0.207.

The Windows config fix is only for SRS 8, which added the native Windows
build.

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…4789)

## Goal

Refine the WebRTC integration tests in `cmd/integ` to cover scenarios a
real client hits that were untested, and fix a server crash the new
tests uncovered.

## Integration tests

- **Address change** — a client that moves to another local port
mid-session (Wi-Fi to 4G, a NAT rebinding): SRS follows a signed STUN
binding from the new address and drops media from an address it does not
know.
- **Packet loss** — RTP the client itself loses, so NACK and RTX recover
it over a real loss point between the peers, not one the simulator
picks.
- **TWCC feedback** — the transport-wide feedback reports the packets
the client lost.
- **Corrupt and invalid packets** — a peer that sends media failing
SRTP, media that passes SRTP but decodes to nothing valid, malformed
RTCP, and packets of no known class. Over UDP SRS drops the bad packet
and the session goes on; over TCP it ends the session.

A raw WebRTC session gains SRTP from its DTLS handshake, so a test can
protect, corrupt, or forge exactly the bytes it sends.

## Fix

The corrupt-packet tests found a remote crash: `SrsRtcpSR::decode` and
`SrsRtcpRR::decode` trusted the report count in the header and read the
report blocks without checking the buffer held them, so a Sender or
Receiver Report that counted more blocks than it carried aborted the
process. An authenticated WebRTC peer could crash SRS with one SRTCP
packet. Each read is now guarded and returns an error instead.

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
… it found. (#4791)

Raise the C++ server utest line coverage from 90.75% to about 95.6%, and
fix the bugs the new tests found.

The tests come from real scenarios of each file, not from single lines.
Each bug was first proven by a test that failed, then fixed, and the
test now runs as a normal test.

## Coverage

On Linux arm64 in Docker: 2,343 lines missed of 52,398, down from 4,848;
91 of 118 files at or above 95%.

- Tests: new `srs_utest_ai40` to `ai46`, plus additions to `ai05`-`ai38`
and `manual_kernel`, registered in `auto/module_files.sh`.
- Server changes only to make code testable, with no behaviour change:
- `SrsAppFactory::create_process()` and `ISrsTime` in `SrsNgExec`, so
tests inject a mock process and clock.
  - `srs_detect_docker()` takes the cgroup file path.
  - `SrsDvrPlan` reads the config of its DVR.
- `srs_redirect_output()` and `srs_discover_local_ips()` exported;
`srs_backtrace_log()` split out of the assert handler.
- `SrsSslClient` takes an `ISrsProtocolReadWriter` instead of
`SrsTcpClient`.
- `LCOV_EXCL` markers on forked-child and abort paths that cannot write
gcov data.
- Tooling: `srs-utest-coverage.sh` for coverage reports,
`srs-utest-run.sh --disabled`, and Windows runner fixes.

## Crashes a client or a host could trigger

- RTMP aggregate: an empty audio tag aborted the server for an HTTP
.mp3/.aac player, and an HTTP-TS player re-sent a possibly freed frame.
- RTMP to WebRTC: a 1 or 2 byte HEVC slice, or a cut slice header,
aborted in `parse_hevc_bframe`.
- WebRTC play: an RTPFB packet other than NACK, such as TMMBR or CCFB,
was cast to `SrsRtcpNack` and crashed.
- WebRTC publish: an RTP header extension longer than the packet, or a
0xBEDE element longer than its block, asserted.
- WHIP/WHEP: an `a=rtcp-fb`, `a=ssrc` or `a=ssrc-group` line with one
word threw `std::out_of_range` and ended the server.
- HTTP remux: on a mount shared by two streams, a refused publish freed
the first stream's live stream.
- MPEG-TS UDP caster and GB28181: a cut SPS or an empty NALU aborted the
server or read past the pack.
- Security: a CIDR prefix length over 32 or negative read past the mask
table.
- HEVC: a PPS naming an SPS never sent read uninitialized memory and
could hang the server.
- `SrsLocker` asserted when `st_mutex_lock` failed with `EINTR`, so a
graceful quit could abort the server.

## A valid client refused or broken

- GB28181 TCP: an RTP packet ending inside a PES start code lost the
pack.
- HTTP-TS with `parse_sps off` disconnected every player.
- HTTP: a request with a URL in its query was routed by the query; a
chunk size with an extension was refused.
- RTP `merge_nalus on`: some frame sizes got an empty last FU-A, or one
FU-A with both start and end bits.
- RTSP: interleaved RTCP cut between reads, header lines without a space
after the colon, and a request cut between CR and LF.
- WHIP: an H.264 fmtp without `level-asymmetry-allowed`, or with an
unknown parameter, was refused or leaked an error. With `rtc_to_rtmp`, a
G.722 or Speex publish was refused; that audio is now dropped from the
RTMP stream, as for G.711.
- HEVC with in-band VPS, SPS and PPS was disconnected at its first key
frame with `rtmp_to_rtsp` and `rtmp_to_rtc`.
- HLS: an empty playlist left by a power loss refused every publish at
recover; with `hls_ts_ctx off`, a refreshing player's session expired
and a viewer kicked by the API kept its playlist.
- HEVC to WebRTC: the `slice_type` of a non-first slice was read from
the address bits, so P slices could be dropped as B.
- Transcode: a vhost's second transcode section was never read; the
vcodec must now name 264, 265 or hevc, and an engine with no acodec is
refused.

## Late, lost or wrong data

- RTSP and SRT players got each packet one late; an RTMP player closed
during `send_min_interval` was kept until the next frame.
- HLS fMP4 segments were cut one GOP late, and pure audio one frame
late; integ cases now expect TS-like cuts.
- The server did not exit on SIGTERM within 3s after a config change
with `inotify_auto_reload`.
- MPEG-TS caster and GB28181 queues replaced messages of one time after
11 of them.
- HLS playlist write errors were lost; a DVR file whose FLV header
failed was reported to `on_dvr`; an MP4 DVR with no frame left its
`.tmp`; DVR with `time_jitter` off cut every key frame from the second
file on.
- An FLV file cut inside its sequence headers is now refused for
`?start=`.
- `reduce_sequence_header` dropped every metadata; now only one
identical to the previous.
- WebRTC: NACK of a packet older than the buffer, the receiver report
and TWCC feedback at the 65535 to 0 wrap, a TWCC burst that overflowed
or was dropped, Opus held at the wrap for RTMP, and NACK after a
critical overload. `dtls_version dtls1.2` agreed on DTLS 1.0.
- Stream API: AAC sample rates 96000, 88200, 64000, 32000 and 7350
reported as 0; SRT video 0x0 after a cut SPS; a public IPv4 NIC counted
as intranet; long interface names not counted.
- Logs and options: the ASan backtrace symbol buffer, a 4 MB error
message, the RTC fid stats check, circuit breaker counters, `-c<file>`,
a vhost `rtsp` typo reported as `srt`, and GB28181 session logs.

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
The internal-chrome-control skill drives Chrome or Edge with Puppeteer,
and four Chrome cases test SRS with a real browser: WebRTC, NACK and RTX
loss recovery, HTTP-FLV/TS/HLS, and the WebRTC video codecs. They run on
the Mac as lane I of the Full tier, against SRS for Linux in Docker,
with Edge on the Windows test host, and in GitHub Actions.

The internal-chrome-control skill:

- chrome.js find-browser and launch --probe: CHROME_PATH, then Chrome,
Edge and Chromium in the standard places; a headless browser over a pipe
with its own profile and fake media. puppeteer-core 25.14.0 is pinned in
package.json and the lockfile.
- page/index.html and page/srs-test.js: one job per URL, mode whip,
whep, flv, ts or hls, with window.srsTest holding the state, errors,
events and one getStats() or <video> sample per second. serve is a
static server for the page and the vendored players.
- run: several jobs in one browser, one window each, publishers first. A
job passes when frames or currentTime rose over --seconds. --out writes
the stats JSON, --internals saves the chrome://webrtc-internals dump,
and LOCATION lines give each WHIP or WHEP session. Players of an H.265
stream get its 20 s ready timeout. Exit codes: 0 pass, 1 fail, 2 skip, 3
bad arguments, 6 SRS did not answer.
- SKILL.md: every command and option, the stats file, Windows and Edge,
the Testing SRS section, and the gotchas found with Chrome 156.
skill.test.js checks that SKILL.md and srs-develop name each other,
every option, and every chrome-*.sh script.
- Unit tests with fake browsers and pages, and live tests when a browser
is installed. srs-develop allows Node for this skill's scripts.

The Chrome cases in srs-develop/scripts:

- chrome-test-lib.sh: a 100-port slot, SRS env-only stopped by its own
pid (or in Docker with CHROME_SRS_DOCKER), FFmpeg publishing, driver
runs, jq checks on the API and the stats samples, the NACK simulator,
freeze checks, and PASS/KNOWN/SKIP counters within a 60 s budget.
chrome-test-lib-test.sh checks it with fakes, and --live with Chrome.
- chrome-webrtc-test.sh: WHIP H.264/Opus, WHEP of it, WHEP of an RTMP
stream, and HTTP-FLV of the WHIP stream.
- chrome-loss-test.sh: 30 packets dropped downlink and uplink, with
nack_prefer_rtx off and on; Chrome NACKs and SRS resends, plain or RTX.
- chrome-http-test.sh: one RTMP stream as HTTP-FLV, HTTP-TS and HLS.
- chrome-codec-test.sh: H.264, VP9, AV1 and H.265 with Opus over WHIP
and WHEP; H.265 in a browser of its own.
- KNOWN lines mark three SRS findings: F1 on a loopback-only host, F3
for the early FLV player's one-track header, and F5 for a player freeze
when its SRS logged a [LARGE_TIMER] stall.

Where they run:

- chrome-lane-test.sh: the unit tests, then the four cases in parallel
on 15600-15900. srs-full-tier.sh runs it as lane I, with
SRS_TEST_CHROME=0 to skip it.
- chrome-linux-test.sh: the cases against SRS for Linux in Docker on
16000-16300, built in the Full tier's Step 1 and run in lane I.
- chrome-windows-test.sh: the cases with Edge against srs.exe on the
Windows test host, in lane I with SRS_TEST_WINDOWS_HOST, or alone as
step 3 of lane W on native Windows.
- GitHub Actions: a chrome-test job on ubuntu-22.04 with Google Chrome,
every action pinned; chrome-test-lib-test.sh checks the job's steps.
- integration-tests.md: the scripts, the checks, lanes I and W, the Port
Plan rows and the Full tier times with lane I.

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…. v8.0.73

A WebRTC peer could crash the server with one RTCP packet:

- A header length of 0 made the payload length negative, so read_bytes
  failed its assert and aborted the process (BYE, TWCC and every other
  type decoded by SrsRtcpCommon).
- A feedback packet (generic FB, NACK, PLI, SLI, RPSI) with length 1
  at the end of the compound read the media SSRC past the buffer and
  aborted the same way.
- A packet over 1500 bytes copied past the fixed payload_ buffer in
  SrsRtcpCommon and SrsRtcpTWCC, a heap overflow, because the UDP read
  buffer takes up to 64KB.

decode_header now rejects length 0, the feedback decoders reject
length < 2 before the media SSRC, and Common and TWCC reject a payload
larger than kRtcpPacketSize. SrsRtcpApp now starts with the length of
an empty APP packet, which it used to leave unset and which the new
check rejects.

Adds 9 KernelRTCPTest.SrsRtcpCompound_Decode* tests that failed on
develop, with asserts and ASAN heap-buffer-overflow, and pass now.

---------

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fix bugs found while reviewing the security reports.

* Security: Refuse a `..` in the app or stream name, always on.
* GB28181: Fix heap overflow from a max-size RTP packet after a cut PS
pack.
* RTC: Check the DTLS certificate against the SDP fingerprint.
* RTC: Fix crash from a STUN attribute without padding.
* AMF0: Fix crash from deeply nested AMF0 objects.
* JSON: Fix crash from deeply nested JSON.
* TS: Fix crash from a malformed adaptation field.
* Docs: Add the RTCP advisory and the supported versions for security
fixes.

The RTCP fix for these reports is already on develop in v8.0.73.

## Thanks

We didn't accept every report as a security vulnerability, and some were
duplicates or already fixed. But we really appreciate the work of every
reporter. Because of all of you, the quality of SRS has improved. Thank
you!

| Report | Title | Author |
|---|---|---|
| GHSA-qr8h-p53p-x564 | RTCP crash and heap overflow | @ccsimplyspolit |
| GHSA-4p49-8phx-p9j9 | RTCP heap overflow | @divinepwner |
| GHSA-wv3p-399f-vxpc | RTCP length 0 crash | @jcross |
| GHSA-2mcm-ghmj-xcjm | TWCC length 0 crash | @bararchy |
| GHSA-jm96-w3mq-w7xh | Oversized TWCC overflow | @lyhtheori |
| GHSA-g557-c4m9-prr2 | RTCP length overflow | @tylzars |
| GHSA-7qgg-v57f-563q | RTCP heap overflow | @K-ANOY |
| GHSA-836c-9rw5-4h92 | RTCP heap overflow | @thaidn |
| GHSA-wv24-frvr-gv99 | RTCP and GB28181 overflows | @UnsignedWRLD |
| GHSA-pvr5-r78m-r7hw | GB28181 TCP overflow | @akoul |
| GHSA-f2rq-xx87-q8j9 | GB28181 TCP overflow | @TristanInSec |
| GHSA-2cx5-qq53-9928 | GB28181 TCP overflow | @manop55555 |
| GHSA-j8m9-p2mj-vr5j | RTP extension length crash | @afldl |
| GHSA-jj89-8c9f-3r6p | RTP extension length crash | @songxpu |
| GHSA-45p7-x4r8-fj9q | STUN padding crash | @K-ANOY |
| GHSA-pp5h-vq2w-79rx | STUN padding crash | @tylzars |
| GHSA-9xq6-j7r5-p3gw | STUN missing integrity check | @songxpu |
| GHSA-9vpj-5cqr-wv6h | STUN request changes media address | @songxpu |
| GHSA-4xc9-g94g-5c96 | DTLS fingerprint not checked | @songxpu |
| GHSA-vf7r-44wh-wq25 | WebRTC session hijack chain | @songxpu |
| GHSA-95hq-2fvc-gg2r | Client can turn off SRTP/DTLS | @songxpu |
| GHSA-4gjf-mp3h-7hpj | SDP parser crashes | @damseleng |
| GHSA-vpqj-6jqp-hmhw | WHIP SDP crash | @thaidn |
| GHSA-5gwv-fphq-gvvq | TS adaptation field crash | @damseleng |
| GHSA-6qgq-qx3x-4x2p | TS demuxer crash | @M0oo0ry |
| GHSA-34jg-x79f-3w4q | AMF0 deep nesting crash | @wildoranges |
| GHSA-88rx-78pg-w7cq | JSON deep nesting crash | @afldl |
| GHSA-4j6x-mm32-cpxc | RTC session flood | @afldl |
| GHSA-6cg9-jc65-g5c2 | Spoofed client IP, open control API | @Hama1cco
|
| GHSA-xgf8-p7r5-7xhq | `..` in stream name | @EgeBalci |
| GHSA-h697-6cw4-qqr9 | `..` in app name | @y1zh3e7-zjm |
| GHSA-hgf5-qh2r-4ph4 | `..` in app name | @am6539 |
| GHSA-pg7p-6q9c-wrxh | `..` in stream name | @Sharlong-Wen |
| GHSA-rhq3-46g9-q5wp | Proxy register API has no auth | @geo-chen |
| GHSA-6m34-6jgr-ppfr | `/metrics` and `/console` not behind auth |
@5ud0er |
| GHSA-v8p7-v7vw-qcvg | Bundled OpenSSL 1.1.1l | @kobihikri |
| GHSA-8vfx-p868-f5w9 | api-server demo path traversal | @DavidCarliez |
| GHSA-x6mw-3458-894p | ffmpeg-webrtc CVE | @vulgraph |

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A C++ memory audit of the media server, every class and global function,
looking for bugs a client, a publisher, an origin, a disk or a config
can trigger. Each bug was proven with a failing test in
`srs_utest_ai47.cpp` before it was fixed, and each fix enables its
proof.

## Fixes

Crashes, an `srs_assert` abort, an uncaught exception or a segfault:

- Codecs and containers: HEVC PPS scaling lists and one-byte HEVC
parameter sets, a short GB28181 PS system header, an MPEG PES header
without private data, a short H.264 SPS from WHIP, and the RTMP to
WebRTC audio resampler when the channel layout changes.
- WebRTC: a NACK with many sparse losses, an XR DLRR block, a long
GB28181 `y=` line, and a long STUN username.
- HTTP, edge and DVR: a seek on a full disk, an empty AAC sequence
header in DVR MP4, a non-string forward backend URL, a redirect to an
out-of-range port, and an HTTP viewer arriving during the stream
teardown.
- Config: `dash_window_size` below 1, a negative `hls_nb_notify`, and an
ingest without `rtmp.listen` are refused by the config check.

Memory corruption:

- Use-after-free and double free in the DASH reap, empty audio messages,
the RTC UDP dispatcher, the RTMP response flush, the GB28181 host
transform, HTTPS writes during renegotiation, the WebRTC player
teardown, DTLS sends inside OpenSSL, and WebRTC over TCP session
teardown.
- Overflow and out-of-bounds in the SRTP and SRTCP trailers of the
player, NACK and TWCC buffers, the TWCC extension parse, a WHIP
ssrc-group with fewer than two SSRCs, and TWCC feedback whose base is
not found.
- Wild or uninitialized memory in the HLS encryption IV and key line,
the edge FLV port, the RTMP chunk size warning, and the WebRTC frame
builder.
- Stack overflow in the recursive directory creation.

Leaks and stalls:

- Errors and objects dropped on failure paths.
- A single client holding a coroutine others depend on.
- A TCP accept loop that spun at 100% CPU when out of fds.
- WebRTC over TCP on the HTTP port, where one idle client blocked every
later client.
- A NACK list insert of a whole 32767-packet sequence gap.

## Skills

- Scripts for the memory audit: the C++ inventory, ASan frame grouping,
and the Linux ASan and LeakSanitizer utest runner.
- A memory safety guide for writing and auditing C++.
- `internal-audit-for-srs` must prove a bug with a failing test, checks
a PR's build files before running them, and cleans up its proof
worktrees.
- `internal-community-for-srs` for the community meeting.

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
A second audit of the C++ memory audit fixes in #4800. Each bug was
proven with a failing test in `srs_utest_ai47.cpp` before it was fixed.

## Fixes

- RTC: Fix abort when a WebRTC TCP conn closes before DTLS while another
send waits. The conn released the session's TCP network and closed the
socket while another coroutine, such as the DTLS ARQ, still waited in a
send on it, and the close failed with EBUSY and asserted. The conn now
waits for those sends before it releases the network.
- Server: Drop a client of the shared HTTP port that sends nothing. With
WebRTC over TCP on the HTTP port, the peek for the client's first bytes
had no timeout, so idle clients such as a browser preconnect or a port
scan filled `max_connections`. The peek now waits at most
`SRS_HTTP_RECV_TIMEOUT`.
- Config: Refuse a `dash_window_size` or `hls_nb_notify` out of the int
range. The check read them with `strtod` and the getters with `atoi`, so
`dash_window_size 4294967296` passed the check, was read as 0, and
aborted the server when a stream published. The check now takes only a
decimal integer in the int range.
- RTMP: Fix use-after-free when an MP3 audio tag has no data. A 1-byte
MP3 tag left `samples_[0]` pointing into the previous, freed frame, and
the RTMP to WebRTC transcoder decoded it. `SrsParsedPacket::initialize`
now clears the samples it drops.

The first commit also waited for timer and player sends in
`SrsRtcConnection::on_disposing`. A later commit removes that wait: the
shared timers lock their handlers for the whole callback and the session
frees them before its networks, so the session already outlives a
timer's send. A test with the real NACK timer shows this.

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Fixes #4796.

A multi-homed WHEP player, such as Chrome on Ethernet, Wi-Fi and Docker
bridges, checks its other candidate pairs for the first seconds without
USE-CANDIDATE. SRS moved the session's media to the source of every
authenticated binding request, so it sent RTP to addresses the browser
did not read, and most audio was concealed for about 15s.

As an ICE-lite agent, SRS now holds a nomination for 6s after the last
USE-CANDIDATE check of the selected address:

- A check with USE-CANDIDATE moves the media to its address.
- A check without USE-CANDIDATE from another address moves the media
only when no nomination holds: none yet, older than 6s, or the clock
went back.
- A check from the selected address changes nothing.

Only time tells the clients apart on the wire. Chrome repeats
USE-CANDIDATE on its pair at least every 2.5s, so its checks of other
pairs, also those to a second server candidate on the same port, no
longer move the media. pion nominates once and keeps the pair alive
without USE-CANDIDATE, so a NAT rebinding is still followed. A rule by
check order failed both ways: interleaved checks dropped Chrome's
nomination, and a retransmitted nomination latched pion's for good.

Every binding response now goes to the source of its request, with that
address in XOR-MAPPED-ADDRESS, and every authenticated address is routed
to the session.

A client that nominates only once and moves within 6s of its nomination
waits up to 6s for its media; after that it is followed at once.

---------

Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
…and skills.

Audit every comment in trunk/src (core, kernel, protocol, app, main) and the
Go proxy (cmd/proxy, internal/) against the srs-develop comment rule. Delete
comments that repeat the name or the code, and rewrite the rest to say what
the code cannot: why, ownership, protocol facts and spec references.

- Keep license headers, TODO and FIXME, URLs, commented-out code and tool
  directives; fix the TDOO and FIMXE typos.
- Fix comments that were wrong; suspected bugs are not fixed here.
- Add comment-only-check.sh and the comment inventory script to srs-develop,
  which prove the code is unchanged: the code without comments, the code
  line layout, the marker count, URLs and directives must all stay.

Comment-only lines go from 22,500 to 9,038 in 256 files (216 changed).
No code line changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fixes #4776.

With `srt_to_rtmp` on, an SRT publish whose TS has two AAC tracks, such
as two languages from FFmpeg, gave one RTMP audio stream with the frames
of both tracks interleaved, so every second frame went back in time and
players stuttered or dropped the audio. Two H.264 tracks were mixed the
same way into corrupt video.

## Fix

RTMP carries one video and one audio track, so the SRT frame builder now
converts only one track of each kind:

- The first H.264 or HEVC track and the first AAC track that send are
converted.
- The PES of every other PID are dropped, with one warning per PID.
- When the converted track stops and another track of its kind sends 8
PES in a row, as when a switcher moves the tracks to new PIDs, that
track takes its place.

The choice costs one compare per PES. The TS decoder and the stream API
are not changed, so HLS and the UDP stream caster behave as before.

## Trade-off

A PID change is supported only by the switch above: the first 7 PES on
the new PID are dropped, its key frame among them, so RTMP may show up
to one GOP of broken picture after it. Most publishers never change the
PIDs.

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.