srs/trunk/conf
Haibo Chen(陈海博) 5dc292ce64
NEW PROTOCOL: Support viewing stream over RTSP. v7.0.47 (#4333)
## Introduce

This PR adds support for viewing streams via the RTSP protocol. Note
that it only supports viewing streams, not publishing streams via RTSP.

Currently, only publishing via RTMP is supported, which is then
converted to RTSP. Further work is needed to support publishing RTC/SRT
streams and converting them to RTSP.

## Usage

Build and run SRS with RTSP support:

```
cd srs/trunk && ./configure --rtsp=on && make -j16
./objs/srs -c conf/rtsp.conf
```

Push stream via RTMP by FFmpeg:

```
ffmpeg -re -i doc/source.flv -c copy -f flv rtmp://localhost/live/livestream
```

View the stream via RTSP protocol, try UDP first, then use TCP:

```
ffplay -i rtsp://localhost:8554/live/livestream
```

Or specify the transport protocol with TCP:

```
ffplay -rtsp_transport tcp -i rtsp://localhost:8554/live/livestream
```

## Unit Test

Run utest for RTSP:

```
./configure --utest=on & make utest -j16
./objs/srs_utest
```

## Regression Test

You need to start SRS for regression testing.

```
./objs/srs -c conf/regression-test-for-clion.conf
```

Then run regression tests for RTSP.

```
cd srs/trunk/3rdparty/srs-bench
go test ./srs -mod=vendor -v -count=1 -run=TestRtmpPublish_RtspPlay
```

## Blackbox Test

For blackbox testing, SRS will be started by utest, so there is no need
to start SRS manually.

```
cd srs/trunk/3rdparty/srs-bench
go test ./blackbox -mod=vendor -v -count=1 -run=TestFast_RtmpPublish_RtspPlay_Basic
```

## UDP Transport

As UDP requires port allocation, this PR doesn't support delivering
media stream via UDP transport, so it will fail if you try to use UDP as
transport:

```
ffplay -rtsp_transport udp -i rtsp://localhost:8554/live/livestream

[rtsp @ 0x7fbc99a14880] method SETUP failed: 461 Unsupported Transport
rtsp://localhost:8554/live/livestream: Protocol not supported

[2025-07-05 21:30:52.738][WARN][14916][7d7gf623][35] RTSP: setup failed: code=2057
(RtspTransportNotSupported) : UDP transport not supported, only TCP/interleaved mode is supported
```

There are no plans to support UDP transport for RTSP. In the real world,
UDP is rarely used; the vast majority of RTSP traffic uses TCP.

## Play Before Publish

RTSP supports audio with AAC and OPUS codecs, which is significantly
different from RTMP or WebRTC.

RTSP uses commands to exchange SDP and specify the audio track to play,
unlike WHEP or HTTP-FLV, which use the query string of the URL. RTSP
depends on the player’s behavior, making it very difficult to use and
describe.

Considering the feature that allows playing the stream before publishing
it, it requires generating some default parameters in the SDP. For OPUS,
the sample rate is 48 kHz with 2 channels, while AAC is more complex,
especially regarding the sample rate, which may be 44.1 kHz, 32 kHz, or
48 kHz.

Therefore, for RTSP, we cannot support play-then-publish. Instead, there
must already be a stream when playing it, so that the audio codec is
determined.

## Opus Codec

No Opus codec support for RTSP, because for RTC2RTSP, it always converts
RTC to RTMP frames, then converts them to RTSP packets. Therefore, the
audio codec is always AAC after converting RTC to RTMP.

This means the bridge architecture needs some changes. We need a new
bridge that binds to the target protocol. For example, RTC2RTMP converts
the audio codec, but RTC2RTSP keeps the original audio codec.

Furthermore, the RTC2RTMP bridge should also support bypassing the Opus
codec if we use enhanced-RTMP, which supports the Opus audio codec. I
think it should be configurable to either transcode or bypass the audio
codec. However, this is not relevant to RTSP.

## AI Contributor

Below commits are contributed by AI:

* [AI: Remove support for media transport via
UDP.](755686229f)
* [AI: Add crutial logs for each RTSP
stage.](9c8cbe7bde)
* [AI: Support AAC doec for
RTSP.](7d7cc12bae)
* [AI: Add option --rtsp for
RTSP.](f67414d9ee)
* [AI: Extract SrsRtpVideoBuilder for RTC and
RTSP.](562e76b904)

---------

Co-authored-by: Jacob Su <suzp1984@gmail.com>
Co-authored-by: winlin <winlinvip@gmail.com>
2025-07-11 08:18:40 -04:00
..
clion-ingest.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
clion-srt.conf STAT: Refine tcUrl for SRT/RTC. v5.0.54 2022-08-30 21:28:06 +08:00
clion.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
compatible.conf for #319, support raw update global.listen 2015-08-30 23:18:14 +08:00
console.conf NEW PROTOCOL: Support viewing stream over RTSP. v7.0.47 (#4333) 2025-07-11 08:18:40 -04:00
console.ipv46.conf RTMP: Add conf for listen at IPv6. 2022-05-17 21:37:59 +08:00
dash.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
demo.19350.conf Docs: Migrate to ossrs.net and ossrs.io 2022-07-31 16:26:35 +08:00
demo.conf Ingest: Still use -re for stream to ingest HLS better. 2022-08-31 13:30:13 +08:00
docker.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
dvr.mp4.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
dvr.path.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
dvr.segment.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
dvr.session.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
edge.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
edge.token.traverse.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
edge2.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
exec.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
ffmpeg.transcode.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
force.daemon.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
forward.backend.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
forward.master.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
forward.slave.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
full.conf NEW PROTOCOL: Support viewing stream over RTSP. v7.0.47 (#4333) 2025-07-11 08:18:40 -04:00
gb28181-without-sip.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
gb28181.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
go-oryx-edge.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
go-oryx-edge2.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
hds.conf Docs: Migrate to ossrs.net and ossrs.io 2022-07-31 16:26:35 +08:00
hevc.flv.conf WebRTC: Support configure CANDIDATE by env (#3470) 2023-03-27 19:24:08 +08:00
hevc.ts.conf WebRTC: Support configure CANDIDATE by env (#3470) 2023-03-27 19:24:08 +08:00
hls.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
hls.edge.conf Conf: Refine comments. 2022-05-10 22:17:55 +08:00
hls.origin.conf Solve the problem of inaccurate HLS TS duration. v5.0.187 v6.0.87 (#3824) 2023-10-09 06:22:41 -05:00
hls.realtime.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
http.aac.live.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
http.api.auth.conf Support composited bridges for 1:N protocols converting. v6.0.41 (#3392) 2023-04-01 21:34:59 +08:00
http.api.dedicated.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
http.api.one.port.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
http.api.one.port2.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
http.api.raw.conf Squash: Merge SRS 4.0 2021-10-10 12:05:26 +08:00
http.flv.live.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
http.flv.live.edge1.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
http.flv.live.edge2.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
http.heartbeat.conf Refine config directive token parsing. v6.0.135 (#4042) 2024-07-08 18:19:25 +08:00
http.hls.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
http.hooks.callback.conf Hooks: Remove on_connect and on_close from doc. 2022-08-26 10:39:00 +08:00
http.mp3.live.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
http.server.conf merge from srs2, fix #503 2017-02-09 14:33:56 +08:00
http.ts.live.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
https.docker.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
https.flv.live.conf For #1657, add https configs 2020-11-07 07:11:57 +08:00
https.hls.conf For #1657, add https configs 2020-11-07 07:11:57 +08:00
https.hooks.callback.conf Hooks: Remove on_connect and on_close from doc. 2022-08-26 10:39:00 +08:00
https.rtc.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
https.rtmp2rtc.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
https.srs.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
include.conf Update the demo config file for include directive (#2927) 2022-03-05 17:43:20 +08:00
include.vhost.conf Update the demo config file for include directive (#2927) 2022-03-05 17:43:20 +08:00
ingest.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
ingest.rtsp.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
live.conf Squash: Merge SRS 4.0 2021-09-25 10:09:25 +08:00
log-file.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
mp3.conf MP3: Add config examples for MP3. #296 2022-12-25 12:10:29 +08:00
mp3.http.conf MP3: Add config examples for MP3. #296 2022-12-25 12:10:29 +08:00
mp3.rtc.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
mp3.ts.conf MP3: Add config examples for MP3. #296 2022-12-25 12:10:29 +08:00
nginx.proxy.conf Conf: Refine comments. 2022-05-10 22:17:55 +08:00
openwrt.conf OpenWRT: Try to create dir for pidfile 2021-10-03 20:51:07 +08:00
origin.cluster.edge.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
origin.cluster.serverA.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
origin.cluster.serverB.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
origin.cluster.serverC.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
origin.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
origin.hls.only1.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
origin.hls.only2.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
origin1-for-proxy.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
origin2-for-proxy.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
origin3-for-proxy.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
prometheus.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
push.flv.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
push.gb28181.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
push.mpegts.over.udp.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
realtime.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
realtime.flv.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
regression-test-for-clion.conf NEW PROTOCOL: Support viewing stream over RTSP. v7.0.47 (#4333) 2025-07-11 08:18:40 -04:00
regression-test.conf NEW PROTOCOL: Support viewing stream over RTSP. v7.0.47 (#4333) 2025-07-11 08:18:40 -04:00
rtc.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
rtc.tcp.only.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
rtc.tcp.udp.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
rtc2rtmp.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
rtmp.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
rtmp.kickoff.conf Kickoff publisher when stream is idle, which means no players. v6.0.31, v5.0.144 (#3105) 2023-03-06 09:09:27 +08:00
rtmp2rtc.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
rtsp.conf NEW PROTOCOL: Support viewing stream over RTSP. v7.0.47 (#4333) 2025-07-11 08:18:40 -04:00
security.deny.publish.conf Fix RBSP issue, where 0x03 should be removed. v5.0.178 v6.0.75 (#3597) 2023-09-09 08:58:38 +08:00
server.crt For #1657, Support HTTPS API 2020-11-06 15:05:01 +08:00
server.key For #1657, Support HTTPS API 2020-11-06 15:05:01 +08:00
srs.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
srt.conf SRT: remove rtmp_to_srt 2022-06-14 20:02:25 +08:00
srt2rtc.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
srt2ts.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
transcode2hls.audio.only.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
transform.edge.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00
vm.conf Update docs link to latest in code. 2025-07-05 09:32:11 -04:00