From f86d6fd073a3b9341429bc5b81e330f5cc84dcdb Mon Sep 17 00:00:00 2001 From: winlin Date: Fri, 27 Aug 2021 07:57:02 +0800 Subject: [PATCH 1/2] Squash: Merge SRS 4.0 --- trunk/doc/CHANGELOG.md | 1 + trunk/src/core/srs_core_version4.hpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/trunk/doc/CHANGELOG.md b/trunk/doc/CHANGELOG.md index 2eb9a4d29..b130a6386 100644 --- a/trunk/doc/CHANGELOG.md +++ b/trunk/doc/CHANGELOG.md @@ -23,6 +23,7 @@ The changelog for SRS. ## SRS 4.0 Changelog +* v4.0, 2021-08-27, RTC: Merge [#2544](https://github.com/ossrs/srs/pull/2544), Support for multiple SPS/PPS, then pick the first one. 4.0.158 * v4.0, 2021-08-17, RTC: Merge [#2470](https://github.com/ossrs/srs/pull/2470), RTC: Fix rtc to rtmp sync timestamp using sender report. 4.0.157 * v4.0, 2021-08-14, Support Github Actions to publish SRS. 4.0.155 * v4.0, 2021-08-14, RTC: Merge [#2533](https://github.com/ossrs/srs/pull/2533), fix SDP comparison bug. 4.0.154 diff --git a/trunk/src/core/srs_core_version4.hpp b/trunk/src/core/srs_core_version4.hpp index ccc906f5e..ee1d2f44c 100644 --- a/trunk/src/core/srs_core_version4.hpp +++ b/trunk/src/core/srs_core_version4.hpp @@ -9,6 +9,6 @@ #define VERSION_MAJOR 4 #define VERSION_MINOR 0 -#define VERSION_REVISION 157 +#define VERSION_REVISION 158 #endif From 7abc9b640ad36adbae1e6d72f4395e4790fa3707 Mon Sep 17 00:00:00 2001 From: pyw Date: Sat, 28 Aug 2021 08:56:20 +0800 Subject: [PATCH 2/2] SRT: fix srt stream play map error (#1890) * fix url_sz memory out of bounds * fix srt play map error Co-authored-by: pengyouwei --- trunk/src/srt/srt_handle.cpp | 9 ++++----- trunk/src/srt/srt_to_rtmp.cpp | 25 +++++++++++++++++-------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/trunk/src/srt/srt_handle.cpp b/trunk/src/srt/srt_handle.cpp index bee5dc08f..296b4e4a0 100644 --- a/trunk/src/srt/srt_handle.cpp +++ b/trunk/src/srt/srt_handle.cpp @@ -97,14 +97,13 @@ void srt_handle::close_pull_conn(SRTSOCKET srtsocket, std::string stream_id) { auto streamid_iter = _streamid_map.find(stream_id); if (streamid_iter != _streamid_map.end()) { - auto srtsocket_map = streamid_iter->second; - if (srtsocket_map.size() == 0) { + if (streamid_iter->second.size() == 0) { _streamid_map.erase(stream_id); - } else if (srtsocket_map.size() == 1) { - srtsocket_map.erase(srtsocket); + } else if (streamid_iter->second.size() == 1) { + streamid_iter->second.erase(srtsocket); _streamid_map.erase(stream_id); } else { - srtsocket_map.erase(srtsocket); + streamid_iter->second.erase(srtsocket); } } else { assert(0); diff --git a/trunk/src/srt/srt_to_rtmp.cpp b/trunk/src/srt/srt_to_rtmp.cpp index 525239166..55e09b02b 100644 --- a/trunk/src/srt/srt_to_rtmp.cpp +++ b/trunk/src/srt/srt_to_rtmp.cpp @@ -15,6 +15,7 @@ #include #include #include +#include std::shared_ptr srt2rtmp::s_srt2rtmp_ptr; @@ -258,7 +259,7 @@ rtmp_client::rtmp_client(std::string key_path):_key_path(key_path) _appname = ret_vec[0]; _streamname = ret_vec[1]; } - char url_sz[128]; + std::stringstream url_ss; std::vector ip_ports = _srs_config->get_listens(); int port = 0; @@ -272,21 +273,29 @@ rtmp_client::rtmp_client(std::string key_path):_key_path(key_path) } port = (port == 0) ? 1935 : port; if (_vhost == DEF_VHOST) { - sprintf(url_sz, "rtmp://127.0.0.1:%d/%s/%s", port, - _appname.c_str(), _streamname.c_str()); + url_ss << "rtmp://127.0.0.1:" << port + << "/" << _appname + << "/" << _streamname; } else { - sprintf(url_sz, "rtmp://127.0.0.1:%d/%s?vhost=%s/%s", port, - _appname.c_str(), _vhost.c_str(), _streamname.c_str()); + if (_appname.find("?") == std::string::npos) { + url_ss << "rtmp://127.0.0.1:" << port + << "/" << _appname << "?vhost=" << _vhost + << "/" << _streamname; + } else { + url_ss << "rtmp://127.0.0.1:" << port + << "/" << _appname << "&vhost=" << _vhost + << "/" << _streamname; + } } - - _url = url_sz; + + _url = url_ss.str(); _h264_sps_changed = false; _h264_pps_changed = false; _h264_sps_pps_sent = false; _last_live_ts = now_ms(); - srs_trace("rtmp client construct url:%s", url_sz); + srs_trace("rtmp client construct url:%s", url_ss.str().c_str()); } rtmp_client::~rtmp_client() {