Skip to content

Commit f47e3ab

Browse files
authored
SRT: Support default_mode config for short streamid format. v7.0.131 (#4598)
1 parent 18c30dc commit f47e3ab

19 files changed

+406
-44
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
title: CDK
3+
sidebar_label: CDK
4+
hide_title: false
5+
hide_table_of_contents: false
6+
---
7+
8+
# CDK
9+
10+
Please use [srs-cdk](https://github.com/ossrs/srs-cdk) to deploy SRS on AWS.
11+
12+
![](https://ossrs.io/gif/v1/sls.gif?site=ossrs.io&path=/lts/doc/en/v7/getting-started-cdk)
13+

trunk/3rdparty/srs-docs/doc/getting-started-k8s.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@ hide_table_of_contents: false
77

88
# K8s
99

10-
We recommend using the HELM method to deploy SRS, see [srs-helm](https://github.com/ossrs/srs-helm). Of course,
10+
> **Note:** SRS K8s is deprecated. Please use [CDK](./getting-started-cdk.md) instead.
11+
12+
We recommend using the HELM method to deploy SRS, see [srs-helm](https://github.com/ossrs/srs-helm). Of course,
1113
SRS also supports direct deployment with K8s, refer to [SRS K8s](./k8s.md).
1214

13-
Actually, HELM is based on K8s and deploys K8s pods, which can be managed with kubectl. However, HELM offers a
15+
Actually, HELM is based on K8s and deploys K8s pods, which can be managed with kubectl. However, HELM offers a
1416
more convenient way to manage and install applications, so SRS will mainly support HELM in the future.
1517

16-
Compared to Docker, HELM and K8s are mainly for medium to large scale deployments. If your business is not that
17-
big, we recommend using Docker or Oryx directly. Generally, if you have less than a thousand streams, please
18+
Compared to Docker, HELM and K8s are mainly for medium to large scale deployments. If your business is not that
19+
big, we recommend using Docker or Oryx directly. Generally, if you have less than a thousand streams, please
1820
do not use HELM or K8s.
1921

2022
![](https://ossrs.io/gif/v1/sls.gif?site=ossrs.io&path=/lts/doc/en/v7/getting-started-k8s)

trunk/3rdparty/srs-docs/doc/k8s.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ hide_table_of_contents: false
77

88
# K8S
99

10+
> **Note:** SRS K8s is deprecated. Please use [CDK](./getting-started-cdk.md) instead.
11+
1012
> Cloud+Docker+K8S enable everyone to build live video streaming cluster and service.
1113
1214
Why should you use [k8s](https://docs.kubernetes.io/docs/concepts/overview/what-is-kubernetes) to build your SRS cluster?

trunk/3rdparty/srs-docs/doc/srt.md

Lines changed: 92 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,13 @@ srt_server {
5858
# Overwrite by env SRS_SRT_SERVER_ENABLED
5959
# default: off
6060
enabled on;
61-
# The UDP listen port for SRT.
61+
# The UDP listen endpoints for SRT, each with format as <[ip:]port>. The ip can be either ipv4 or ipv6,
62+
# or both. For example:
63+
# listen 10080 [::]:10080 192.168.1.100:10080 10.10.10.100:10080;
6264
# Overwrite by env SRS_SRT_SERVER_LISTEN
6365
listen 10080;
6466
# For detail parameters, please read wiki:
65-
# @see https://ossrs.net/lts/zh-cn/docs/v5/doc/srt-params
66-
# @see https://ossrs.io/lts/en-us/docs/v5/doc/srt-params
67+
# @see https://ossrs.io/lts/en-us/docs/v7/doc/srt#config
6768
# The maxbw is the max bandwidth of the sender side.
6869
# -1: Means the biggest bandwidth is infinity.
6970
# 0: Means the bandwidth is determined by SRTO_INPUTBW.
@@ -77,12 +78,12 @@ srt_server {
7778
# Overwrite by env SRS_SRT_SERVER_MSS
7879
# default: 1500
7980
mss 1500;
80-
# The timeout time of the SRT connection on the sender side in ms. When SRT connects to a peer costs time
81+
# The timeout time of the SRT connection on the sender side in ms. When SRT connects to a peer costs time
8182
# more than this config, it will be close.
8283
# Overwrite by env SRS_SRT_SERVER_CONNECT_TIMEOUT
8384
# default: 3000
8485
connect_timeout 4000;
85-
# The timeout time of SRT connection on the receiver side in ms. When the SRT connection is idle
86+
# The timeout time of SRT connection on the receiver side in ms. When the SRT connection is idle
8687
# more than this config, it will be close.
8788
# Overwrite by env SRS_SRT_SERVER_PEER_IDLE_TIMEOUT
8889
# default: 10000
@@ -91,36 +92,52 @@ srt_server {
9192
# Overwrite by env SRS_SRT_SERVER_DEFAULT_APP
9293
# default: live
9394
default_app live;
94-
# The peerlatency is set by the sender side and will notify the receiver side.
95+
# Default mode for short streamid format (without #!:: prefix).
96+
# When client uses short streamid like "live/stream" or "stream", this config
97+
# determines whether it's a publisher or player by default.
98+
# Options: publish, request
99+
# - publish: short streamid is treated as publisher
100+
# - request: short streamid is treated as player (default)
101+
# Example: with default_mode=publish, "srt://host:port?streamid=live/stream" publishes.
102+
# Overwrite by env SRS_SRT_SERVER_DEFAULT_MODE
103+
# default: request
104+
default_mode request;
105+
# Default streamid when client doesn't provide one.
106+
# This is used when SRT client connects without setting SRTO_STREAMID socket option.
107+
# The streamid format follows SRT standard: #!::r=app/stream,m=publish|request
108+
# Overwrite by env SRS_SRT_SERVER_DEFAULT_STREAMID
109+
# default: #!::r=live/livestream,m=request
110+
default_streamid "#!::r=live/livestream,m=request";
111+
# The peerlatency is set by the sender side and will notify the receiver side.
95112
# Overwrite by env SRS_SRT_SERVER_PEERLATENCY
96113
# default: 0
97114
peerlatency 0;
98-
# The recvlatency means latency from sender to receiver.
115+
# The recvlatency means latency from sender to receiver.
99116
# Overwrite by env SRS_SRT_SERVER_RECVLATENCY
100117
# default: 120
101118
recvlatency 0;
102-
# This latency configuration configures both recvlatency and peerlatency to the same value.
119+
# This latency configuration configures both recvlatency and peerlatency to the same value.
103120
# Overwrite by env SRS_SRT_SERVER_LATENCY
104121
# default: 120
105122
latency 0;
106-
# The tsbpd mode means timestamp based packet delivery.
107-
# SRT sender side will pack timestamp in each packet. If this config is true,
108-
# the receiver will read the packet according to the timestamp in the head of the packet.
123+
# The tsbpd mode means timestamp based packet delivery.
124+
# SRT sender side will pack timestamp in each packet. If this config is true,
125+
# the receiver will read the packet according to the timestamp in the head of the packet.
109126
# Overwrite by env SRS_SRT_SERVER_TSBPDMODE
110127
# default: on
111128
tsbpdmode off;
112-
# The tlpkdrop means too-late Packet Drop
113-
# SRT sender side will pack timestamp in each packet, When the network is congested,
114-
# the packet will drop if latency is bigger than the configuration in both sender side and receiver side.
115-
# And on the sender side, it also will be dropped because latency is bigger than configuration.
129+
# The tlpkdrop means too-late Packet Drop
130+
# SRT sender side will pack timestamp in each packet, When the network is congested,
131+
# the packet will drop if latency is bigger than the configuration in both sender side and receiver side.
132+
# And on the sender side, it also will be dropped because latency is bigger than configuration.
116133
# Overwrite by env SRS_SRT_SERVER_TLPKTDROP
117134
# default: on
118135
tlpktdrop off;
119-
# The send buffer size of SRT.
136+
# The send buffer size of SRT.
120137
# Overwrite by env SRS_SRT_SERVER_SENDBUF
121138
# default: 8192 * (1500-28)
122139
sendbuf 2000000;
123-
# The recv buffer size of SRT.
140+
# The recv buffer size of SRT.
124141
# Overwrite by env SRS_SRT_SERVER_RECVBUF
125142
# default: 8192 * (1500-28)
126143
recvbuf 2000000;
@@ -336,6 +353,64 @@ In other words, the following two addresses are equivalent:
336353
* `srt://127.0.0.1:10080`
337354
* `srt://127.0.0.1:10080?streamid=#!::r=live/livestream,m=publish`
338355

356+
## SRT URL with short streamid
357+
358+
SRS supports a short streamid format without the `#!::` prefix for simpler URLs. When using short streamid format like `live/livestream` or just `livestream`, SRS uses the `default_mode` configuration to determine whether it's a publish or play request.
359+
360+
The `default_mode` configuration accepts two values:
361+
* `publish`: Short streamid will be treated as publish/push mode.
362+
* `request`: Short streamid will be treated as request/play/pull mode (this is the default).
363+
364+
For publisher-friendly setup where clients can push with simple URLs, configure `default_mode` to `publish`:
365+
366+
```bash
367+
srt_server {
368+
enabled on;
369+
listen 10080;
370+
# Short streamid format will be treated as publisher
371+
default_mode publish;
372+
}
373+
```
374+
375+
With this configuration, you can publish with a simple URL:
376+
377+
```bash
378+
# Publish with short streamid (uses default_mode=publish)
379+
ffmpeg -re -i source.flv -c copy -pes_payload_size 0 -f mpegts \
380+
'srt://127.0.0.1:10080?streamid=live/livestream'
381+
382+
# Play with explicit mode (must specify m=request)
383+
ffplay 'srt://127.0.0.1:10080?streamid=#!::r=live/livestream,m=request'
384+
```
385+
386+
For player-friendly setup where clients can play with simple URLs, use the default `default_mode=request`:
387+
388+
```bash
389+
srt_server {
390+
enabled on;
391+
listen 10080;
392+
# Short streamid format will be treated as player (default)
393+
default_mode request;
394+
}
395+
```
396+
397+
With this configuration, you can play with a simple URL:
398+
399+
```bash
400+
# Publish with explicit mode (must specify m=publish)
401+
ffmpeg -re -i source.flv -c copy -pes_payload_size 0 -f mpegts \
402+
'srt://127.0.0.1:10080?streamid=#!::r=live/livestream,m=publish'
403+
404+
# Play with short streamid (uses default_mode=request)
405+
ffplay 'srt://127.0.0.1:10080?streamid=live/livestream'
406+
```
407+
408+
SRS provides two ready-to-use configuration files:
409+
* `conf/srt.shortstreamid.publish.conf`: For publisher-friendly setup with `default_mode publish`.
410+
* `conf/srt.shortstreamid.play.conf`: For player-friendly setup with `default_mode request`.
411+
412+
Note that explicit mode specification with the full `#!::` prefix always takes precedence over `default_mode`. This allows clients that support full streamid format to override the default behavior.
413+
339414
## Authentication
340415

341416
For the definition of SRT URLs, please refer to [SRT URL Schema](#srt-url).

trunk/conf/full.conf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,16 @@ srt_server {
689689
# Overwrite by env SRS_SRT_SERVER_DEFAULT_APP
690690
# default: live
691691
default_app live;
692+
# Default mode for short streamid format (without #!:: prefix).
693+
# When client uses short streamid like "live/stream" or "stream", this config
694+
# determines whether it's a publisher or player by default.
695+
# Options: publish, request
696+
# - publish: short streamid is treated as publisher
697+
# - request: short streamid is treated as player (default)
698+
# Example: with default_mode=publish, "srt://host:port?streamid=live/stream" publishes.
699+
# Overwrite by env SRS_SRT_SERVER_DEFAULT_MODE
700+
# default: request
701+
default_mode request;
692702
# Default streamid when client doesn't provide one.
693703
# This is used when SRT client connects without setting SRTO_STREAMID socket option.
694704
# The streamid format follows SRT standard: #!::r=app/stream,m=publish|request
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# SRT with short streamid format and default_mode=request (play/pull)
2+
# For publishing: ffmpeg -re -i source.flv -c copy -pes_payload_size 0 -f mpegts 'srt://127.0.0.1:10080?streamid=#!::r=live/livestream,m=publish'
3+
# For playing: ffprobe 'srt://127.0.0.1:10080?streamid=live/livestream'
4+
# For playing HTTP-FLV: ffprobe 'http://127.0.0.1:8080/live/livestream.flv'
5+
6+
listen 1935;
7+
max_connections 1000;
8+
daemon off;
9+
srs_log_tank console;
10+
11+
http_api {
12+
enabled on;
13+
listen 1985;
14+
}
15+
16+
http_server {
17+
enabled on;
18+
listen 8080;
19+
dir ./objs/nginx/html;
20+
}
21+
22+
srt_server {
23+
enabled on;
24+
listen 10080;
25+
maxbw 1000000000;
26+
connect_timeout 4000;
27+
peerlatency 0;
28+
recvlatency 0;
29+
latency 0;
30+
tsbpdmode off;
31+
tlpktdrop off;
32+
sendbuf 2000000;
33+
recvbuf 2000000;
34+
payloadsize 1316;
35+
# Short streamid format (without #!::) will be treated as player/puller by default.
36+
# This allows: srt://host:port?streamid=live/stream to play directly.
37+
default_mode request;
38+
}
39+
40+
vhost __defaultVhost__ {
41+
srt {
42+
enabled on;
43+
srt_to_rtmp on;
44+
}
45+
46+
http_remux {
47+
enabled on;
48+
mount [vhost]/[app]/[stream].flv;
49+
}
50+
}
51+
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# SRT with short streamid format and default_mode=publish
2+
# For publishing: ffmpeg -re -i source.flv -c copy -pes_payload_size 0 -f mpegts 'srt://127.0.0.1:10080?streamid=live/livestream'
3+
# For playing: ffprobe 'srt://127.0.0.1:10080?streamid=#!::r=live/livestream,m=request'
4+
# For playing HTTP-FLV: ffprobe 'http://127.0.0.1:8080/live/livestream.flv'
5+
6+
listen 1935;
7+
max_connections 1000;
8+
daemon off;
9+
srs_log_tank console;
10+
11+
http_api {
12+
enabled on;
13+
listen 1985;
14+
}
15+
16+
http_server {
17+
enabled on;
18+
listen 8080;
19+
dir ./objs/nginx/html;
20+
}
21+
22+
srt_server {
23+
enabled on;
24+
listen 10080;
25+
maxbw 1000000000;
26+
connect_timeout 4000;
27+
peerlatency 0;
28+
recvlatency 0;
29+
latency 0;
30+
tsbpdmode off;
31+
tlpktdrop off;
32+
sendbuf 2000000;
33+
recvbuf 2000000;
34+
payloadsize 1316;
35+
# Short streamid format (without #!::) will be treated as publisher by default.
36+
# This allows: srt://host:port?streamid=live/stream to publish directly.
37+
default_mode publish;
38+
}
39+
40+
vhost __defaultVhost__ {
41+
srt {
42+
enabled on;
43+
srt_to_rtmp on;
44+
}
45+
46+
http_remux {
47+
enabled on;
48+
mount [vhost]/[app]/[stream].flv;
49+
}
50+
}
51+

trunk/doc/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ The changelog for SRS.
77
<a name="v7-changes"></a>
88

99
## SRS 7.0 Changelog
10+
* v7.0, 2025-11-30, SRT: Support default_mode config for short streamid format. v7.0.131
1011
* v7.0, 2025-11-28, SRT: Fix player not exiting when publisher disconnects. v7.0.130 (#4591)
1112
* v7.0, 2025-11-27, Merge [#4588](https://github.com/ossrs/srs/pull/4588): RTMP: Ignore FMLE start packet after flash publish. v7.0.129 (#4588)
1213
* v7.0, 2025-11-18, AI: API: Change pagination default count to 10, minimum 1. v7.0.128

trunk/src/app/srs_app_config.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1935,7 +1935,7 @@ srs_error_t SrsConfig::check_normal_config()
19351935
SrsConfDirective *conf = root_->get("srt_server");
19361936
for (int i = 0; conf && i < (int)conf->directives_.size(); i++) {
19371937
string n = conf->at(i)->name_;
1938-
if (n != "enabled" && n != "listen" && n != "maxbw" && n != "mss" && n != "latency" && n != "recvlatency" && n != "peerlatency" && n != "connect_timeout" && n != "peer_idle_timeout" && n != "sendbuf" && n != "recvbuf" && n != "payloadsize" && n != "default_app" && n != "sei_filter" && n != "mix_correct" && n != "tlpktdrop" && n != "tsbpdmode" && n != "passphrase" && n != "pbkeylen" && n != "default_streamid") {
1938+
if (n != "enabled" && n != "listen" && n != "maxbw" && n != "mss" && n != "latency" && n != "recvlatency" && n != "peerlatency" && n != "connect_timeout" && n != "peer_idle_timeout" && n != "sendbuf" && n != "recvbuf" && n != "payloadsize" && n != "default_app" && n != "sei_filter" && n != "mix_correct" && n != "tlpktdrop" && n != "tsbpdmode" && n != "passphrase" && n != "pbkeylen" && n != "default_streamid" && n != "default_mode") {
19391939
return srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "illegal srt_server.%s", n.c_str());
19401940
}
19411941
}
@@ -7687,6 +7687,23 @@ string SrsConfig::get_srt_default_streamid()
76877687
return conf->arg0();
76887688
}
76897689

7690+
string SrsConfig::get_srt_default_mode()
7691+
{
7692+
SRS_OVERWRITE_BY_ENV_STRING("srs.srt_server.default_mode"); // SRS_SRT_SERVER_DEFAULT_MODE
7693+
7694+
static string DEFAULT = "request";
7695+
SrsConfDirective *conf = root_->get("srt_server");
7696+
if (!conf) {
7697+
return DEFAULT;
7698+
}
7699+
7700+
conf = conf->get("default_mode");
7701+
if (!conf || conf->arg0().empty()) {
7702+
return DEFAULT;
7703+
}
7704+
return conf->arg0();
7705+
}
7706+
76907707
SrsConfDirective *SrsConfig::get_srt(std::string vhost)
76917708
{
76927709
SrsConfDirective *conf = get_vhost(vhost);

trunk/src/app/srs_app_config.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,7 @@ class ISrsAppConfig : public ISrsConfig
488488
virtual bool get_srt_enabled() = 0;
489489
virtual bool get_srt_enabled(std::string vhost) = 0;
490490
virtual std::string get_srt_default_streamid() = 0;
491+
virtual std::string get_srt_default_mode() = 0;
491492
virtual bool get_srt_to_rtmp(std::string vhost) = 0;
492493
virtual bool get_rtc_to_rtmp(std::string vhost) = 0;
493494
virtual srs_utime_t get_rtc_stun_timeout(std::string vhost) = 0;
@@ -1078,6 +1079,9 @@ class SrsConfig : public ISrsAppConfig
10781079
virtual std::string get_default_app_name();
10791080
// Get the default streamid when client doesn't provide one.
10801081
virtual std::string get_srt_default_streamid();
1082+
// Get the default mode for short streamid format.
1083+
// @return "publish" or "request", default is "request".
1084+
virtual std::string get_srt_default_mode();
10811085

10821086
// clang-format off
10831087
SRS_DECLARE_PRIVATE: // clang-format on

0 commit comments

Comments
 (0)