Restructure the OpenClaw workspace so all SRS project directories are accessible via symlinks from `.openclaw/`, eliminating the need for parent traversal or absolute paths. All AI tools (OpenClaw, Claude Code, Codex, Kiro) now see the same relative paths from the workspace root. **Workspace restructuring** - Add symlinks in `.openclaw/` for `trunk/`, `cmd/`, `internal/`, `cmake/`, `docs/`, `objs/`, and a self-referential `.openclaw` link - Add root-level `memory` symlink pointing to `.openclaw/memory` - Simplify `TOOLS.md` working directory rules: everything is relative from CWD - Update `.gitignore` patterns for `personal*`, `support*`, `srs-consults*` directories **New codebase map (`memory/srs-codebase-map.md`)** - Comprehensive map of the entire SRS codebase: C++ media server modules (`core/`, `kernel/`, `protocol/`, `app/`), State Threads, Go next-gen server (`cmd/` + `internal/`), documentation, and testing structure - Enables AI to reason about which files are relevant to a question instead of blind grepping - Added "Codebase map first" rule to `MEMORY.md`: always load the map before searching code **Skill updates** The `srs-support` has been reorganized into a three-phase workflow consisting of Setup, Load Knowledge, and Answer by Topic. It now features a tiered approach to knowledge integration, with the codebase map being incorporated as the third layer. - `st-develop`: Simplified setup, added codebase map reference For both skills, the dynamic resolution logic for `SRS_ROOT` has been eliminated. Now, all paths are relative. **Documentation rewrite (`getting-started-ai.md`)** - Replaced Augment Code / GitHub Copilot / PR review content with current AI tooling: SRS Robot (Telegram/Discord), Claude Code, Codex, Kiro, and OpenClaw - Added sections on skills and the knowledge base philosophy **Cleanup** - Removed `docs/ideas.md`, `docs/youtube/` transcripts, and `proxy/README.md` - Removed "Ideas Capture" and "YouTube Channel Content" sections from `MEMORY.md` - Fixed origin cluster doc build command (`cd srs && make`) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
26 KiB
SRS Codebase Map
⚠️ CRITICAL RULE: Only files explicitly listed in this document are trusted. AI must NOT discover, reference, or use any file that is not listed here. If a file is not in this map, it does not exist for AI purposes.
This file helps AI navigate the SRS project. Instead of grepping blindly, AI should use this map to reason about which part of the codebase is relevant to a question, then go directly to the right files.
Code Structure
SRS has three codebases:
C++ Media Server
The C++ media server (trunk/src/) serves as both origin server and edge server. It uses the ST (State Threads) coroutine library and is the full-featured server with all SRS capabilities.
main/ — Entry point:
main_server— Themain()function, starts the server
core/ — Foundational definitions:
core— Core includes, macros, config generated by configurecore_versionthroughcore_version7— Version definitions per major releasecore_autofree— SrsUniquePtr smart pointer (RAII)core_deprecated— Deprecated SrsAutoFree, kept for compatcore_performance— Performance tuning constants (merge-read, etc.)core_platform— Platform abstraction (32/64-bit, PRId64, large file support)core_time— Time types and conversions (srs_utime_t, ms/us)
kernel/ — Low-level building blocks, no network, no protocol logic:
Media codecs/containers:
kernel_codec— Codec definitions, H.264/H.265/AAC parsing, sequence headerskernel_aac— AAC transmuxer (raw AAC stream output)kernel_mp3— MP3 transmuxerkernel_flv— FLV tag reader/writer, muxer/demuxerkernel_mp4— MP4/fMP4 box reader/writerkernel_ts— MPEG-TS muxer/demuxerkernel_ps— PS (Program Stream) muxer/demuxer (GB28181)kernel_packet— Media packet: raw undecoded frame with timing info
Buffers & I/O:
kernel_buffer— SrsBuffer: binary read/write cursor over a byte arraykernel_stream— SrsSimpleStream: growable byte bufferkernel_io— Abstract I/O interfaces (ISrsReader, ISrsSeeker, ISrsWriter)kernel_file— File reader/writer implementations
RTC primitives:
kernel_rtc_rtp— RTP packet structure, encode/decodekernel_rtc_rtcp— RTCP packet types, encode/decodekernel_rtc_queue— RTP ring buffer and reorder queue
Utilities:
kernel_error— Error code definitions and SrsCplxErrorkernel_log— Log levels and ISrsLog interfacekernel_consts— Global constants (chunk sizes, timeouts, limits)kernel_utility— System time, string helpers, bit bufferkernel_kbps— Bandwidth statistics (ISrsProtocolStatistic, ISrsClock)kernel_balance— Load balancing algorithms (round-robin)kernel_hourglass— Timer/hourglass coroutine (periodic callbacks)kernel_pithy_print— Sampled logging (print every N seconds, not every call)kernel_factory— Abstract factory interfaces (ISrsKernelFactory)kernel_resource— Resource management interfaces (ISrsResource, disposing)kernel_st— ST coroutine wrappers (ISrsCoroutine, ISrsCoroutineHandler)
protocol/ — Protocol implementations (wire formats, parsing, serialization):
RTMP:
protocol_rtmp_stack— RTMP chunk stream, message parsing, AMF commandsprotocol_rtmp_conn— RTMP client/server handshake and command exchangeprotocol_rtmp_handshake— RTMP handshake (simple and complex)protocol_rtmp_msg_array— Shared message array with auto-freeprotocol_amf0— AMF0 encoding/decoding
HTTP:
protocol_http_stack— HTTP message, header, URI, serve mux, handlerprotocol_http_conn— HTTP connection parsing (request/response)protocol_http_client— HTTP client for outbound requestsprotocol_http_stack_llhttp— llhttp parser (from Node.js)protocol_http_stack_llhttpadapter— llhttp adapter for SRSprotocol_http_stack_llhttpapi— llhttp API integrationprotocol_http_stack_llhttphttp— llhttp HTTP integration
RTC/WebRTC:
protocol_rtc_stun— STUN packet parsing/buildingprotocol_sdp— SDP parsing/buildingprotocol_rtp— RTP packetizer (H.264/Opus → RTP packets)
Other protocols:
protocol_srt— SRT socket wrapperprotocol_rtsp_stack— RTSP message parsing
Media:
protocol_raw_avc— Raw H.264/H.265 stream (Annex-B ↔ AVCC conversion)protocol_format— Media format: extract metadata, codec info from RTMP stream
Infrastructure:
protocol_io— Protocol-level I/O interfaces (ISrsProtocolReader/Writer)protocol_st— ST initialization, socket helpers, TCP/UDP wrappersprotocol_stream— SrsFastStream: merge-read buffered streamprotocol_conn— Base connection interface (ISrsConnection)protocol_log— Thread context for logging (SrsThreadContext)protocol_json— JSON parsing (SrsJsonAny)protocol_utility— URL parsing, stream URL helpersprotocol_protobuf— Protobuf encoding helpers (for Prometheus/exporter)
app/ — Application logic (server features, connections, business logic):
Server core:
app_server— SrsServer: main server, manages listeners and connectionsapp_config— Configuration parsing and accessapp_listener— TCP/UDP listener managementapp_reload— Config hot-reload handler interfaceapp_st— Coroutine implementations (SrsFastCoroutine, SrsExecutorCoroutine)app_log— File-based logger implementation
RTMP:
app_rtmp_conn— RTMP client connection lifecycle (publish, play)app_rtmp_source— RTMP live source: manages consumers, GOP cache, hub
HTTP:
app_http_api— HTTP API endpoints (/api/v1/...)app_http_conn— HTTP connection handler (routes to static/stream/api)app_http_hooks— HTTP callback hooks (on_connect, on_publish, etc.)app_http_static— HTTP static file servingapp_http_stream— HTTP live streaming (FLV, TS, AAC, MP3 over HTTP)app_http_client— HTTP client utilities
WebRTC:
app_rtc_server— RTC server: manages RTC connectionsapp_rtc_conn— RTC connection: publish/play session, DTLS/SRTPapp_rtc_source— RTC source: manages RTC consumers and tracksapp_rtc_api— WHIP/WHEP API endpointsapp_rtc_codec— Audio transcoding (AAC ↔ Opus via FFmpeg)app_rtc_dtls— DTLS certificate and handshakeapp_rtc_network— RTC network I/O, UDP mux
SRT:
app_srt_server— SRT server: manages SRT connectionsapp_srt_conn— SRT connection lifecycle (publish, play)app_srt_source— SRT source: manages SRT consumersapp_srt_listener— SRT listener (bind/accept)
RTSP:
app_rtsp_conn— RTSP connection handlerapp_rtsp_source— RTSP source
GB28181:
app_gb28181— GB28181 SIP signaling and PS stream ingestion
HLS/DASH:
app_hls— HLS muxer (TS segments + M3U8 playlist)app_dash— DASH muxer (fMP4 segments + MPD manifest)app_fragment— Fragment/segment interface for HLS/DASH
DVR:
app_dvr— DVR recording (FLV/MP4 to disk)
Edge/Forward/Bridge:
app_edge— Edge mode: pull/push from originapp_forward— Forward: push stream to another RTMP serverapp_stream_bridge— Bridge between sources (RTMP↔RTC↔SRT)
Ingest/Transcode:
app_ingest— Ingest: pull external streams via FFmpegapp_encoder— Transcode: FFmpeg transcoding managementapp_ffmpeg— FFmpeg process wrapper
Utilities:
app_security— Security: allow/deny rules for publish/playapp_refer— Referer checkapp_statistic— Server/stream/client statisticsapp_heartbeat— HTTP heartbeat to API serverapp_utility— System info, disk/CPU/memory statsapp_process— Child process managementapp_async_call— Async HTTP callback executionapp_recv_thread— Background RTMP message receive threadapp_ng_exec— exec hooks (on_publish exec)app_factory— Application-level factory (file I/O, paths)app_coworkers— Origin cluster coordinationapp_latest_version— Version check against upstreamapp_caster_flv— HTTP-FLV push ingest (stream caster)app_mpegts_udp— MPEG-TS over UDP ingestapp_stream_token— Stream publish token managementapp_circuit_breaker— Circuit breaker for overload protectionapp_hds— HDS (Adobe HTTP Dynamic Streaming)
File naming convention: All C++ source files use srs_{module}_{topic}.cpp/.hpp — e.g. srs_app_rtmp_conn.cpp, srs_protocol_amf0.hpp, srs_kernel_flv.cpp.
Config
Config (trunk/conf/) is only for the C++ media server. The next-generation Go server does not use these config files.
srs.conf— Default configfull.conf— Full reference config with all options documented- Feature-specific configs:
rtc.conf,srt.conf,hls.conf,dvr.*.conf,edge.conf,forward.*.conf,gb28181.conf,dash.conf, etc.
State Threads
State Threads (trunk/3rdparty/st-srs/) is the coroutine library used by the C++ media server only. The Go server does not use ST.
sched.c— Scheduler (thread creation, context switch, run loop)io.c— I/O: poll/epoll/kqueue wrappers, socket operationsevent.c— Event systemstk.c— Stack allocation and managementsync.c— Mutex, condition variablekey.c— Thread-local storagecommon.c/common.h— Shared internalspublic.h— Public APImd.h— Platform detection and context switch macrosmd_linux.S,md_linux2.S,md_darwin.S,md_cygwin64.S— Assembly context switch per platform
Next-Generation Server
The next-generation server (cmd/ + internal/) is written in Go and maintained by AI. It is the future of SRS. Currently it only supports proxy, but work is ongoing to support the full feature set including origin, edge, and proxy servers.
cmd/proxy — A stateless reverse proxy that sits in front of one or more SRS C++ origin servers. Accepts client connections (RTMP, HTTP-FLV/HLS, WebRTC WHIP/WHEP, SRT), resolves a backend origin via the load balancer, and transparently proxies traffic. Does not cache streams or process media — only forwards bytes. Configuration entirely via environment variables (or .env file), no config file. Supports two deployment modes: single-proxy (in-memory LB) and multi-proxy (Redis-based shared LB for horizontal scaling behind a network load balancer).
internal/bootstrap — Server startup and lifecycle orchestration. Sets up logging context, signal handlers, loads environment, installs force-quit timer, optionally starts pprof, initializes the load balancer (memory or Redis based on PROXY_LOAD_BALANCER_TYPE), then starts all six servers sequentially (RTMP, WebRTC, HTTP API, SRT, System API, HTTP Stream) and blocks until context is cancelled. Deferred Close() on each server ensures graceful shutdown.
internal/protocol — Protocol proxy servers. Each server accepts client connections, parses just enough of the protocol to extract the stream URL, picks a backend via the load balancer, and proxies traffic bidirectionally. Contains five proxy servers: (1) RTMP proxy — TCP listener, simple handshake, parses connect/publish/play to get stream URL, bidirectional RTMP message copying, stateless. (2) HTTP stream proxy — serves static files, proxies HTTP-FLV/TS via reverse-proxy, proxies HLS m3u8 with spbhid rewriting so TS segment requests route to the same backend. (3) WebRTC proxy — two-phase: WHIP/WHEP signaling (SDP rewrite to replace backend UDP port with proxy's) + UDP media transport (identifies connections by STUN ufrag, supports address migration), stateful. (4) SRT proxy — intercepts SRT 4-step handshake locally, parses stream ID on handshake 2, replays full handshake with backend, then proxies UDP bidirectionally, stateful per-connection. (5) HTTP API + System API — HTTP API delegates WHIP/WHEP to WebRTC server; System API provides /api/v1/srs/register where backend SRS C++ servers register themselves so the load balancer knows about them.
internal/rtmp — RTMP protocol implementation (parsing, not proxying). Full RTMP chunk stream and message protocol: simple handshake (C0/C1/C2), chunk stream reader/writer with all four format types, extended timestamp, message reassembly from chunks. Defines all RTMP message types, chunk stream IDs, and command names. Packet types include ConnectApp, CreateStream, Publish, Play, Call, SetChunkSize, WindowAcknowledgementSize, SetPeerBandwidth, UserControl. Uses Go generics (ExpectPacket[T]) to read until a specific packet type arrives. Also includes full AMF0 encoder/decoder supporting Number, Boolean, String, Object, Null, Undefined, EcmaArray, StrictArray, Date, LongString — with ordered key-value maps, auto-type-discovery, and safe type converters.
internal/lb — Load balancer abstraction and two implementations. Defines SRSLoadBalancer interface (Initialize, Update, Pick, HLS/WebRTC state management) and SRSServer struct representing a backend origin (IP, listen endpoints for RTMP/HTTP/API/SRT/RTC, heartbeat tracking). Memory LB — in-memory using sync.Map, sticky random pick per stream URL, single-proxy deployment. Redis LB — Redis-backed shared state with TTL-based expiration, enables multi-proxy horizontal scaling behind a network load balancer. Also includes a debug helper that creates a fake backend from env vars when PROXY_DEFAULT_BACKEND_ENABLED=on for development without real SRS registration.
internal/logger — Structured logging with context IDs. Four log levels: Verbose (discarded), Debug (stdout), Warn (stderr), Error (stderr). Format: [level][pid][cid] message. Each connection/request gets a unique 7-char hex context ID for log correlation, stored in context.Context.
internal/env — Environment-based configuration. All settings via env vars (or .env file via godotenv). Exposes an Environment interface with methods for each config value. Default ports: RTMP=11935, HTTP API=11985, HTTP Stream=18080, WebRTC=18000, SRT=20080, System API=12025. Timeouts: grace=20s, force=30s. Supports Redis config and default backend config for debugging.
internal/version — Version constants. SRSProxy v1.5.0. Used in HTTP API responses and startup logging.
internal/errors — Error handling with stack traces, forked from github.com/pkg/errors. Provides New, Errorf, Wrap, Wrapf, WithMessage, WithStack, Cause. Every error captures a stack trace at creation; %+v prints the full trace. Cause() walks the error chain to find the root error.
internal/sync — Generic sync primitives. Map[K, V]: type-safe generic wrapper around sync.Map with proper Go generics typing. Used throughout the codebase to avoid raw type assertions.
internal/signal — OS signal handling. Listens for SIGINT/SIGTERM, cancels the root context. Installs a force-quit timer (default 30s) as a safety net if graceful shutdown hangs.
internal/debug — Profiling. Starts a net/http/pprof server if GO_PPROF env var is set. Optional, for runtime profiling and debugging.
internal/utils — Shared utility functions. HTTP helpers (JSON response, error response, CORS, body parsing). URL helpers (normalize to vhost/app/stream format, extract app/stream from HTTP requests). Protocol helpers (classify UDP payload as STUN/RTP/SRT, parse ICE ufrag/pwd from SDP, parse SRT stream ID). Network helpers (detect peer-closed/connection-closed errors, parse listen endpoints).
Knowledge Base Structure
The knowledge base (memory/srs-*.md) captures William's knowledge about SRS — architecture, design decisions, protocols, and how things work. This is the AI's first stop for understanding why things are the way they are.
memory/srs-overview.md— What SRS is, protocols, ecosystem tools, and features listmemory/srs-coroutines.md— State Threads coroutine library, why SRS uses coroutines, how context switching works, platform matrix, multi-CPU strategymemory/srs-codebase-map.md— This file: codebase structure, file navigation, module boundaries
Documentation Structure
Tracking — Project changelog and version history:
trunk/doc/CHANGELOG.md— Full changelog of all SRS versions, one entry per merged PR with version bump
C++ Media Server Docs (trunk/3rdparty/srs-docs/doc/) — User-facing documentation:
introduction.md— SRS overview: what it is, supported protocols (RTMP/WebRTC/HLS/SRT/etc.), features list, ST coroutine architecture, and learning pathgetting-started.md— Quick start with Docker: live streaming (RTMP publish, HTTP-FLV/HLS play), WebRTC publish/play, RTMP-to-WebRTC conversion, HTTPS for WebRTC on remote servers, SRT publishing, and multiple streams with flexible URL patternsgetting-started-ai.md— AI tools for SRS: SRS Robot (Telegram/Discord), local agents (Claude Code, Codex, Kiro, OpenClaw) with pre-configured knowledge base, skills system for task-specific workflows, and the knowledge base philosophy (implicit knowledge made explicit)getting-started-build.md— Build SRS from source: configure/make, live streaming and WebRTC setup, cross-build for ARM/MIPSgetting-started-cdk.md— Deploy SRS on AWS using srs-cdk (stub page, links to GitHub repo)getting-started-oryx.md— Oryx (SRS Stack): out-of-the-box cloud solution with recording, forwarding, AI subtitles, HTTPS, Docker/HELM/aaPanel deploymentrtmp.md— RTMP protocol: usage, Enhanced RTMP (HEVC/AV1), config, RTMPS, comparison with SRT/WebRTC, codec support historyhls.md— HLS streaming: cross-platform compatibility, latency tradeoffs, config (segment duration, cleanup), HTTPS, audio transcoding from WebRTCwebrtc.md— WebRTC: WHIP/WHEP signaling, SFU architecture, RTMP-to-RTC conversion, TURN/ICE config, audio transcoding (AAC↔Opus), multi-platform usageflv.md— HTTP-FLV live streaming: chunked HTTP delivery, ~3-5s latency, config, comparison with HLS and RTMP, browser compatibility (MSE)srt.md— SRT protocol: UDP-based low-latency (300-500ms), TS encapsulation, HEVC support, config, streamid format, weak network advantages over RTMPrtsp.md— RTSP playback server (v7.0.47+): TCP transport only, publish via RTMP then play via RTSP, config, compile with --rtsp=onhttp-server.md— Embedded HTTP server: serves HLS/static files, API endpoint, config for port/root, works with NGINX/Caddy reverse proxyhevc.md— H.265/HEVC support: Enhanced RTMP, protocol compatibility matrix (TS/SRT/HLS/RTMP/WebRTC), encoder setup, bandwidth savings vs H.264dvr.md— DVR recording: save RTMP streams to FLV/MP4 files, config (plan/path), HTTP callbacks for dynamic DVR, Oryx for advanced features (S3, filters)ingest.md— Ingest: pull external streams (files, RTSP cameras, HTTP) via FFmpeg and republish as RTMP to SRS, virtual live streaming use caseforward.md— Forward streams to other RTMP servers for fault backup, master/slave roles, config per vhost/app, comparison with edge modesecurity.md— IP-based security: allow/deny rules for publish/play per vhost using IP addresses or CIDR rangessnapshot.md— Stream thumbnails: capture snapshots via HTTP callbacks (on_publish/on_unpublish triggering FFmpeg) or transcoderhttp-api.md— HTTP API (/api/v1/...): JSON endpoints for server/stream/client stats, srs-console integration, CORS supporthttp-callback.md— HTTP callbacks: SRS notifies your business server on events (on_connect, on_publish, on_play, on_dvr, etc.) for auth and custom logicexporter.md— Prometheus exporter: metrics endpoint for Grafana integration, config for labels/tags, cloud-native observabilityorigin-cluster.md— Origin cluster: proxy-based load balancing across multiple origin servers, Go proxy architecture, replaces old RTMP-based origin clusteredge.md— Edge server: caches streams from origin for massive playback scale, pull-on-play and push-on-publish, multi-level edge topology for CDNnginx-for-hls.md— HLS/DASH distribution via NGINX reverse proxy with caching, edge cluster for file-based streaming (not RTMP edge)resource.md— Ports reference: RTMP(1935), HTTP API(1985), HTTP streaming(8080), WebRTC(8000/udp), SRT(10080/udp), HTTPS, and optional converterslow-latency.md— Low-latency live streaming: RTMP tuning (0.8-3s), GOP/queue config, merge-write optimization, protocol comparisonperformance.md— Performance tools: RTC UDP buffer tuning, perf/gprof/valgrind profiling, memory leak detection, ASAN, benchmarking methodologyffmpeg.md— FFmpeg transcoding: SRS forks FFmpeg for 1-in-N-out transcoding, multi-bitrate output, stream filters (logo), config per vhost/app/stream
C++ Media Server Pages (trunk/3rdparty/srs-docs/pages/) — Website pages (how SRS presents itself publicly):
faq-oryx-en.md— Oryx FAQ: getting started, upgrade, domain/HTTPS setup, push auth, recording (S3/filters/merge), re-streaming, FFmpeg replacementfaq-server-en.md— SRS server FAQ: CDN/VoD questions, common errors, protocol issues, links to Stack Overflow/GitHub Issues/Discord for supportlicense-en.md— License details: SRS is MIT, State Threads is MPL/GPL dual-license, plus licenses for all third-party libraries (OpenSSL, libsrt, ffmpeg, etc.)product-en.md— Release history: milestones from v1.0 (2013) to v7.0 (2025+), codenames, key achievements per release, AI contributor era (2025+)security-advisories-en.md— CVE reports: CVE-2024-29882 (JSONP XSS), CVE-2023-34105 (command injection in demo api-server), with patch versions and links
Next-Generation Server Docs (docs/proxy/) — Documentation for the Go server:
proxy-design.md— Architecture: stateless proxy with built-in load balancing, single-proxy vs multi-proxy (Redis) deployment modes, horizontal scaling behind NLBproxy-protocol.md— Backend registration protocol: default backend for debugging, automatic registration via SRS system API, heartbeat mechanism, env varsproxy-usage.md— Step-by-step guide: build proxy, start SRS origin, verify registration, publish with FFmpeg, verify playback with ffprobeproxy-files.md— Go codebase layout: cmd/proxy entry point, internal packages (debug, env, errors, lb, logger, protocol, rtmp, signal, sync, utils, version)proxy-load-balancer.md— Load balancer design: memory vs Redis implementations, stream-to-server mapping, server health via heartbeats, protocol-specific stateproxy-origin-cluster.md— Origin cluster tutorial: build proxy + SRS, configure multi-origin with proxy, stream publishing and playback verification
Testing and Verification Structure
How to verify SRS works correctly.
trunk/src/utest/ — Unit tests (white-box, testing internal logic):
- What it tests: Internal logic — functions, classes, parsing, codec handling, config parsing — all without starting SRS. Links directly against SRS source code, uses mock objects (e.g.,
MockSrsConfig). No network, no server process. ~2,351 tests. - Binary:
./objs/srs_utest(build withcd trunk && ./configure --utest && make utest) - 3 categories:
srs_utest_ai01–ai24— AI-written testssrs_utest_manual_*— Manually written testssrs_utest_workflow_*— Workflow/integration tests
trunk/3rdparty/srs-bench/blackbox/ — Black-box tests (testing SRS as a running server from outside):
- What it tests: SRS as a running process, from the outside. Each test starts its own SRS server via
NewSRSServer(), then uses FFmpeg/FFprobe to publish/play streams and verify output. The test manages the full SRS lifecycle. ~30 tests. - Binary:
./objs/srs_blackbox_test(build withmakeintrunk/3rdparty/srs-bench/) rtmp_test.go— RTMP black-box testshls_test.go— HLS black-box testssrt_test.go— SRT black-box testsrtsp_test.go— RTSP black-box testshevc_test.go— HEVC black-box testsdvr_test.go— DVR black-box testshttp_api_test.go— HTTP API black-box testsmp3_test.go— MP3 black-box tests
trunk/3rdparty/srs-bench/srs/ — E2E tests (end-to-end protocol testing):
- What it tests: End-to-end protocol correctness against a pre-running SRS server (you start SRS yourself). Uses real protocol clients — Pion WebRTC library for RTC (WHIP/WHEP), RTMP client, HTTP API — to publish, play, and verify stream behavior. Heavy focus on WebRTC protocol correctness. ~45 tests.
- Binary:
./objs/srs_test(build withmakeintrunk/3rdparty/srs-bench/) rtc_test.go— WebRTC E2E testsrtmp_test.go— RTMP E2E testssrs_test.go— General SRS E2E tests
trunk/3rdparty/srs-bench/ — Load test benchmark:
- What it tests: Performance and load capacity — not correctness. A CLI tool that simulates many concurrent WHIP publishers, WHEP players, RTMP clients, etc. against a running SRS. Not a test suite — no pass/fail assertions, it's a benchmarking/stress tool.
- Binary:
./objs/srs_bench(entry:main.go, build withmakeintrunk/3rdparty/srs-bench/) - Publisher for WHIP
- Player for WHEP
- Multiple WHIP or WHEP for RTC
- DVR for RTC Benchmark
- RTC Plaintext
- Reconnecting Load Test
- Janus
Summary: The Key Differences
| Unit Tests | Black-box | E2E | Benchmark | |
|---|---|---|---|---|
| SRS running? | No | Yes (self-managed) | Yes (external) | Yes (external) |
| Tests what? | Internal logic | Whole server behavior | Protocol correctness | Performance/load |
| Language | C++ | Go | Go | Go |
| Network? | No | Yes (real protocols) | Yes (real protocols) | Yes (real protocols) |
| Pass/fail? | Yes | Yes | Yes | No (metrics only) |
| Count | ~2,351 | ~30 | ~45 | N/A |
Progression: unit (isolated logic) → black-box (server as a whole, self-contained) → E2E (protocol-level against live server) → benchmark (stress/capacity). Each layer catches different classes of bugs.