From af9bd2dd0a81ee52bd7ddfc31b2019e3ff6ced18 Mon Sep 17 00:00:00 2001 From: xiongguangjie Date: Sat, 4 Jun 2022 12:03:56 +0800 Subject: [PATCH] fix streamid zero error --- srt/HSExt.cpp | 4 +++- srt/SrtSession.cpp | 3 +++ srt/SrtTransport.cpp | 5 +++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/srt/HSExt.cpp b/srt/HSExt.cpp index 20a5b89c..ab4d4ff2 100644 --- a/srt/HSExt.cpp +++ b/srt/HSExt.cpp @@ -81,7 +81,9 @@ bool HSExtStreamID::loadFromData(uint8_t *buf, size_t len) { ptr+=4; } char zero = 0x00; - streamid.erase(streamid.find_first_of(zero),streamid.size()); + if(streamid.back() == zero){ + streamid.erase(streamid.find_first_of(zero),streamid.size()); + } return true; } diff --git a/srt/SrtSession.cpp b/srt/SrtSession.cpp index 47b0b11f..17a2eff0 100644 --- a/srt/SrtSession.cpp +++ b/srt/SrtSession.cpp @@ -10,7 +10,10 @@ using namespace mediakit; SrtSession::SrtSession(const Socket::Ptr &sock) : UdpSession(sock) { socklen_t addr_len = sizeof(_peer_addr); + memset(&_peer_addr,0,addr_len); + TraceL<<"before addr len "<rawFD(), (struct sockaddr *)&_peer_addr, &addr_len); + TraceL<<"after addr len "< +#include "Util/onceToken.h" #include "SrtTransport.hpp" #include "Packet.hpp" @@ -297,7 +298,7 @@ void SrtTransport::handleACKACK(uint8_t *buf, int len, struct sockaddr_storage * pkt->loadFromData(buf,len); uint32_t rtt = DurationCountMicroseconds(_now - _ack_send_timestamp[pkt->ack_number]); - _rtt_variance = (3*_rtt_variance+abs(_rtt - rtt))/4; + _rtt_variance = (3*_rtt_variance+abs((long)(_rtt - rtt)))/4; _rtt = (7*rtt+_rtt)/8; _ack_send_timestamp.erase(pkt->ack_number);