1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

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 <hondaxiao@tencent.com>
This commit is contained in:
chundonglinlin 2023-10-23 14:52:34 +08:00 committed by GitHub
parent 29eff1a242
commit 9b07d840ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 3 deletions

View file

@ -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");
}