SRT: Support configurable default_streamid option. v6.0.180 v7.0.95 (#4515)

This commit is contained in:
OSSRS-AI 2025-10-01 22:04:36 -04:00 committed by winlin
parent 3f876d324e
commit fc6a851d5f
9 changed files with 91 additions and 5 deletions

View File

@ -689,7 +689,13 @@ srt_server {
# Overwrite by env SRS_SRT_SERVER_DEFAULT_APP
# default: live
default_app live;
# The peerlatency is set by the sender side and will notify the receiver side.
# Default streamid when client doesn't provide one.
# This is used when SRT client connects without setting SRTO_STREAMID socket option.
# The streamid format follows SRT standard: #!::r=app/stream,m=publish|request
# Overwrite by env SRS_SRT_SERVER_DEFAULT_STREAMID
# default: #!::r=live/livestream,m=publish
default_streamid "#!::r=live/livestream,m=publish";
# The peerlatency is set by the sender side and will notify the receiver side.
# Overwrite by env SRS_SRT_SERVER_PEERLATENCY
# default: 0
peerlatency 0;

View File

@ -31,6 +31,7 @@ srt_server {
tlpktdrop off;
sendbuf 2000000;
recvbuf 2000000;
default_streamid "#!::r=live/livestream,m=publish";
}
# @doc https://github.com/ossrs/srs/issues/1147#issuecomment-577607026

58
trunk/conf/srt.vlc.conf Normal file
View File

@ -0,0 +1,58 @@
# SRT config.
max_connections 1000;
daemon off;
srs_log_tank console;
rtmp {
listen 1935;
}
http_api {
enabled on;
listen 1985;
}
http_server {
enabled on;
listen 8080;
dir ./objs/nginx/html;
}
srt_server {
enabled on;
listen 10080;
maxbw 1000000000;
connect_timeout 4000;
peerlatency 0;
recvlatency 0;
latency 0;
tsbpdmode off;
tlpktdrop off;
sendbuf 2000000;
recvbuf 2000000;
default_streamid "#!::r=live/livestream,m=request";
}
# @doc https://github.com/ossrs/srs/issues/1147#issuecomment-577607026
vhost __defaultVhost__ {
srt {
enabled on;
srt_to_rtmp on;
}
http_remux {
enabled on;
mount [vhost]/[app]/[stream].flv;
}
}
# For SRT to use vhost.
vhost srs.srt.com.cn {
}
stats {
network 0;
disk sda sdb xvda xvdb;
}

View File

@ -7,6 +7,7 @@ The changelog for SRS.
<a name="v7-changes"></a>
## SRS 7.0 Changelog
* v7.0, 2025-10-01, SRT: Support configurable default_streamid option. v7.0.95 (#4515)
* v7.0, 2025-09-27, Merge [#4513](https://github.com/ossrs/srs/pull/4513): For Edge, only support RTMP or HTTP-FLV. v7.0.94 (#4513)
* v7.0, 2025-09-21, Merge [#4505](https://github.com/ossrs/srs/pull/4505): improve blackbox test for rtsp. v7.0.93 (#4505)
* v7.0, 2025-09-21, Fix WHIP with transcoding bug. v7.0.92 (#4495)
@ -108,6 +109,7 @@ The changelog for SRS.
<a name="v6-changes"></a>
## SRS 6.0 Changelog
* v6.0, 2025-10-01, SRT: Support configurable default_streamid option. v6.0.180 (#4515)
* v6.0, 2025-09-27, For Edge, only support RTMP or HTTP-FLV. v6.0.179 (#4512)
* v6.0, 2025-09-21, Fix WHIP with transcoding bug. v6.0.178 (#4495)
* v6.0, 2025-09-15, RTC2RTMP: Fix sequence number wraparound assertion crashes. v6.0.177 (#4491)

View File

@ -1933,7 +1933,7 @@ srs_error_t SrsConfig::check_normal_config()
SrsConfDirective *conf = root_->get("srt_server");
for (int i = 0; conf && i < (int)conf->directives_.size(); i++) {
string n = conf->at(i)->name_;
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") {
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") {
return srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "illegal srt_server.%s", n.c_str());
}
}
@ -7613,6 +7613,23 @@ string SrsConfig::get_default_app_name()
return conf->arg0();
}
string SrsConfig::get_srt_default_streamid()
{
SRS_OVERWRITE_BY_ENV_STRING("srs.srt_server.default_streamid"); // SRS_SRT_SERVER_DEFAULT_STREAMID
static string DEFAULT = "#!::r=live/livestream,m=publish";
SrsConfDirective *conf = root_->get("srt_server");
if (!conf) {
return DEFAULT;
}
conf = conf->get("default_streamid");
if (!conf || conf->arg0().empty()) {
return DEFAULT;
}
return conf->arg0();
}
SrsConfDirective *SrsConfig::get_srt(std::string vhost)
{
SrsConfDirective *conf = get_vhost(vhost);

View File

@ -756,6 +756,8 @@ public:
virtual int get_srto_pbkeylen();
// Get the default app.
virtual std::string get_default_app_name();
// Get the default streamid when client doesn't provide one.
virtual std::string get_srt_default_streamid();
private:
SrsConfDirective *get_srt(std::string vhost);

View File

@ -262,7 +262,7 @@ srs_error_t SrsMpegtsSrtConn::do_cycle()
// If streamid empty, using default streamid instead.
if (streamid.empty()) {
streamid = "#!::r=live/livestream,m=publish";
streamid = _srs_config->get_srt_default_streamid();
srs_warn("srt get empty streamid, using default streamid %s instead", streamid.c_str());
}

View File

@ -9,6 +9,6 @@
#define VERSION_MAJOR 6
#define VERSION_MINOR 0
#define VERSION_REVISION 179
#define VERSION_REVISION 180
#endif

View File

@ -9,6 +9,6 @@
#define VERSION_MAJOR 7
#define VERSION_MINOR 0
#define VERSION_REVISION 94
#define VERSION_REVISION 95
#endif