From fc6a851d5f892d35609e1f4dd93edb2adfb7f373 Mon Sep 17 00:00:00 2001 From: OSSRS-AI Date: Wed, 1 Oct 2025 22:04:36 -0400 Subject: [PATCH] SRT: Support configurable default_streamid option. v6.0.180 v7.0.95 (#4515) --- trunk/conf/full.conf | 8 +++- trunk/conf/srt.conf | 1 + trunk/conf/srt.vlc.conf | 58 ++++++++++++++++++++++++++++ trunk/doc/CHANGELOG.md | 2 + trunk/src/app/srs_app_config.cpp | 19 ++++++++- trunk/src/app/srs_app_config.hpp | 2 + trunk/src/app/srs_app_srt_conn.cpp | 2 +- trunk/src/core/srs_core_version6.hpp | 2 +- trunk/src/core/srs_core_version7.hpp | 2 +- 9 files changed, 91 insertions(+), 5 deletions(-) create mode 100644 trunk/conf/srt.vlc.conf diff --git a/trunk/conf/full.conf b/trunk/conf/full.conf index 9281834cb..d69c20aa8 100644 --- a/trunk/conf/full.conf +++ b/trunk/conf/full.conf @@ -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; diff --git a/trunk/conf/srt.conf b/trunk/conf/srt.conf index c5d7a1195..027a22e18 100644 --- a/trunk/conf/srt.conf +++ b/trunk/conf/srt.conf @@ -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 diff --git a/trunk/conf/srt.vlc.conf b/trunk/conf/srt.vlc.conf new file mode 100644 index 000000000..698b9c008 --- /dev/null +++ b/trunk/conf/srt.vlc.conf @@ -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; +} + diff --git a/trunk/doc/CHANGELOG.md b/trunk/doc/CHANGELOG.md index 0f1de5108..e18bb949d 100644 --- a/trunk/doc/CHANGELOG.md +++ b/trunk/doc/CHANGELOG.md @@ -7,6 +7,7 @@ The changelog for SRS. ## 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. ## 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) diff --git a/trunk/src/app/srs_app_config.cpp b/trunk/src/app/srs_app_config.cpp index 2f7432657..9c1e71293 100644 --- a/trunk/src/app/srs_app_config.cpp +++ b/trunk/src/app/srs_app_config.cpp @@ -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); diff --git a/trunk/src/app/srs_app_config.hpp b/trunk/src/app/srs_app_config.hpp index 8589afac0..138670c2f 100644 --- a/trunk/src/app/srs_app_config.hpp +++ b/trunk/src/app/srs_app_config.hpp @@ -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); diff --git a/trunk/src/app/srs_app_srt_conn.cpp b/trunk/src/app/srs_app_srt_conn.cpp index 58e345612..18e535790 100644 --- a/trunk/src/app/srs_app_srt_conn.cpp +++ b/trunk/src/app/srs_app_srt_conn.cpp @@ -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()); } diff --git a/trunk/src/core/srs_core_version6.hpp b/trunk/src/core/srs_core_version6.hpp index 2152ad512..ebe08aa2f 100644 --- a/trunk/src/core/srs_core_version6.hpp +++ b/trunk/src/core/srs_core_version6.hpp @@ -9,6 +9,6 @@ #define VERSION_MAJOR 6 #define VERSION_MINOR 0 -#define VERSION_REVISION 179 +#define VERSION_REVISION 180 #endif diff --git a/trunk/src/core/srs_core_version7.hpp b/trunk/src/core/srs_core_version7.hpp index cab4a8651..0f3bcaa57 100644 --- a/trunk/src/core/srs_core_version7.hpp +++ b/trunk/src/core/srs_core_version7.hpp @@ -9,6 +9,6 @@ #define VERSION_MAJOR 7 #define VERSION_MINOR 0 -#define VERSION_REVISION 94 +#define VERSION_REVISION 95 #endif \ No newline at end of file