From 43028c99c8bfd81248353f1d973631ecd661e86e Mon Sep 17 00:00:00 2001 From: winlin Date: Mon, 8 Mar 2021 10:41:42 +0800 Subject: [PATCH] Fix bug when client DTLS is passive. 4.0.82 --- README.md | 1 + trunk/src/app/srs_app_rtc_conn.cpp | 2 +- trunk/src/app/srs_app_rtc_sdp.hpp | 3 ++- trunk/src/app/srs_app_rtc_server.cpp | 13 +++++++++---- trunk/src/core/srs_core_version4.hpp | 2 +- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 0d258e561..5bc0dec70 100755 --- a/README.md +++ b/README.md @@ -186,6 +186,7 @@ Other documents: ## V4 changes +* v4.0, 2021-03-08, Fix bug when client DTLS is passive. 4.0.82 * v4.0, 2021-03-03, Fix [#2106][bug #2106], [#2011][bug #2011], RTMP/AAC transcode to Opus bug. 4.0.81 * v4.0, 2021-03-02, Refine build script for FFmpeg and SRTP. 4.0.80 * v4.0, 2021-03-02, Upgrade libsrtp from 2.0.0 to 2.3.0, with source code. 4.0.79 diff --git a/trunk/src/app/srs_app_rtc_conn.cpp b/trunk/src/app/srs_app_rtc_conn.cpp index 27dd2a903..c82241052 100644 --- a/trunk/src/app/srs_app_rtc_conn.cpp +++ b/trunk/src/app/srs_app_rtc_conn.cpp @@ -1920,7 +1920,7 @@ srs_error_t SrsRtcConnection::initialize(SrsRequest* r, bool dtls, bool srtp, st } } - SrsSessionConfig* cfg = &local_sdp.session_config_; + SrsSessionConfig* cfg = &local_sdp.session_negotiate_; if ((err = transport_->initialize(cfg)) != srs_success) { return srs_error_wrap(err, "init"); } diff --git a/trunk/src/app/srs_app_rtc_sdp.hpp b/trunk/src/app/srs_app_rtc_sdp.hpp index 372c893a1..16c3f8e01 100644 --- a/trunk/src/app/srs_app_rtc_sdp.hpp +++ b/trunk/src/app/srs_app_rtc_sdp.hpp @@ -37,7 +37,7 @@ const std::string kTWCCExt = "http://www.ietf.org/id/draft-holmer-rmcat-transpor // TDOO: FIXME: Rename it, and add utest. extern std::vector split_str(const std::string& str, const std::string& delim); -struct SrsSessionConfig +class SrsSessionConfig { public: std::string dtls_role; @@ -237,6 +237,7 @@ public: SrsSessionInfo session_info_; SrsSessionConfig session_config_; + SrsSessionConfig session_negotiate_; std::vector groups_; std::string group_policy_; diff --git a/trunk/src/app/srs_app_rtc_server.cpp b/trunk/src/app/srs_app_rtc_server.cpp index 617337889..9b0300682 100644 --- a/trunk/src/app/srs_app_rtc_server.cpp +++ b/trunk/src/app/srs_app_rtc_server.cpp @@ -590,18 +590,23 @@ srs_error_t SrsRtcServer::do_create_session( srs_trace("RTC: Use candidates %s", srs_join_vector_string(candidate_ips, ", ").c_str()); } + // Setup the negotiate DTLS by config. + local_sdp.session_negotiate_ = local_sdp.session_config_; + + // Setup the negotiate DTLS role. if (remote_sdp.get_dtls_role() == "active") { - local_sdp.set_dtls_role("passive"); + local_sdp.session_negotiate_.dtls_role = "passive"; } else if (remote_sdp.get_dtls_role() == "passive") { - local_sdp.set_dtls_role("active"); + local_sdp.session_negotiate_.dtls_role = "active"; } else if (remote_sdp.get_dtls_role() == "actpass") { - local_sdp.set_dtls_role(local_sdp.session_config_.dtls_role); + local_sdp.session_negotiate_.dtls_role = local_sdp.session_config_.dtls_role; } else { // @see: https://tools.ietf.org/html/rfc4145#section-4.1 // The default value of the setup attribute in an offer/answer exchange // is 'active' in the offer and 'passive' in the answer. - local_sdp.set_dtls_role("passive"); + local_sdp.session_negotiate_.dtls_role = "passive"; } + local_sdp.set_dtls_role(local_sdp.session_negotiate_.dtls_role); session->set_remote_sdp(remote_sdp); // We must setup the local SDP, then initialize the session object. diff --git a/trunk/src/core/srs_core_version4.hpp b/trunk/src/core/srs_core_version4.hpp index 63540429b..44a734725 100644 --- a/trunk/src/core/srs_core_version4.hpp +++ b/trunk/src/core/srs_core_version4.hpp @@ -24,6 +24,6 @@ #ifndef SRS_CORE_VERSION4_HPP #define SRS_CORE_VERSION4_HPP -#define SRS_VERSION4_REVISION 81 +#define SRS_VERSION4_REVISION 82 #endif