From 9b07d840ed80fdb2f2b2ffc94b64b1b05b17b6af Mon Sep 17 00:00:00 2001 From: chundonglinlin Date: Mon, 23 Oct 2023 14:52:34 +0800 Subject: [PATCH] WebRTC: TCP transport should use read_fully instead of read. v5.0.194 v6.0.94 (#3847) SRS supports TCP WebRTC by reading 2 bytes of length, like `read(buf, 2)`. However, in some cases, it might receive 1 byte, causing subsequent data to be incorrect and making it unable to push or play streams. --------- Co-authored-by: john --- trunk/doc/CHANGELOG.md | 2 ++ trunk/src/app/srs_app_rtc_network.cpp | 2 +- trunk/src/core/srs_core_version5.hpp | 2 +- trunk/src/core/srs_core_version6.hpp | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/trunk/doc/CHANGELOG.md b/trunk/doc/CHANGELOG.md index 446d841097..b841a25b17 100644 --- a/trunk/doc/CHANGELOG.md +++ b/trunk/doc/CHANGELOG.md @@ -7,6 +7,7 @@ The changelog for SRS. ## SRS 6.0 Changelog +* v6.0, 2023-10-21, Merge [#3847](https://github.com/ossrs/srs/pull/3847): WebRTC: TCP transport should use read_fully instead of read. v6.0.94 (#3847) * v6.0, 2023-10-20, Merge [#3846](https://github.com/ossrs/srs/pull/3846): Added system library option for ffmpeg, srtp, srt libraries. v6.0.93 (#3846) * v6.0, 2023-10-17, Merge [#3840](https://github.com/ossrs/srs/pull/3840): Disable asan by default. v6.0.92 (#3840) * v6.0, 2023-10-17, Merge [#3837](https://github.com/ossrs/srs/pull/3837): Support set the ice-ufrag and ice-pwd for connectivity check. v6.0.91 (#3837) @@ -105,6 +106,7 @@ The changelog for SRS. ## SRS 5.0 Changelog +* v5.0, 2023-10-21, Merge [#3847](https://github.com/ossrs/srs/pull/3847): WebRTC: TCP transport should use read_fully instead of read. v5.0.194 (#3847) * v5.0, 2023-10-20, Merge [#3846](https://github.com/ossrs/srs/pull/3846): Added system library option for ffmpeg, srtp, srt libraries. v5.0.193 (#3846) * v5.0, 2023-10-17, Merge [#3840](https://github.com/ossrs/srs/pull/3840): Disable asan by default. v5.0.192 (#3840) * v5.0, 2023-10-17, Merge [#3837](https://github.com/ossrs/srs/pull/3837): Support set the ice-ufrag and ice-pwd for connectivity check. v5.0.191 (#3837) diff --git a/trunk/src/app/srs_app_rtc_network.cpp b/trunk/src/app/srs_app_rtc_network.cpp index 6ec0197acc..dabcf3bfea 100644 --- a/trunk/src/app/srs_app_rtc_network.cpp +++ b/trunk/src/app/srs_app_rtc_network.cpp @@ -883,7 +883,7 @@ srs_error_t SrsRtcTcpConn::read_packet(char* pkt, int* nb_pkt) // Read length in 2 bytes @doc: https://www.rfc-editor.org/rfc/rfc4571#section-2 ssize_t nread = 0; uint8_t b[2]; - if((err = skt_->read((char*)b, sizeof(b), &nread)) != srs_success) { + if((err = skt_->read_fully((char*)b, sizeof(b), &nread)) != srs_success) { return srs_error_wrap(err, "rtc tcp conn read len"); } diff --git a/trunk/src/core/srs_core_version5.hpp b/trunk/src/core/srs_core_version5.hpp index 5e09c49fe8..24c9e78ce6 100644 --- a/trunk/src/core/srs_core_version5.hpp +++ b/trunk/src/core/srs_core_version5.hpp @@ -9,6 +9,6 @@ #define VERSION_MAJOR 5 #define VERSION_MINOR 0 -#define VERSION_REVISION 193 +#define VERSION_REVISION 194 #endif diff --git a/trunk/src/core/srs_core_version6.hpp b/trunk/src/core/srs_core_version6.hpp index 4ec6c786f3..4bcb50582a 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 93 +#define VERSION_REVISION 94 #endif