diff --git a/3rdpart/ZLToolKit b/3rdpart/ZLToolKit index 1f87bc42..34b42499 160000 --- a/3rdpart/ZLToolKit +++ b/3rdpart/ZLToolKit @@ -1 +1 @@ -Subproject commit 1f87bc42900e88d5443fb63bfb82523a2ac3ea33 +Subproject commit 34b42499ce9ee055b5c7cac9a270239984d0e839 diff --git a/src/Rtp/RtpSelector.cpp b/src/Rtp/RtpSelector.cpp index f57081d2..bc8e7924 100644 --- a/src/Rtp/RtpSelector.cpp +++ b/src/Rtp/RtpSelector.cpp @@ -36,8 +36,8 @@ bool RtpSelector::inputRtp(const char *data, int data_len,const struct sockaddr _last_rtp_time.resetTime(); onManager(); } - auto ssrc = getSSRC(data,data_len); - if(!ssrc){ + uint32_t ssrc = 0; + if(!getSSRC(data,data_len,ssrc)){ WarnL << "get ssrc from rtp failed:" << data_len; return false; } @@ -48,12 +48,13 @@ bool RtpSelector::inputRtp(const char *data, int data_len,const struct sockaddr return false; } -uint32_t RtpSelector::getSSRC(const char *data, int data_len) { +bool RtpSelector::getSSRC(const char *data,int data_len, uint32_t &ssrc){ if(data_len < 12){ - return 0; + return false; } uint32_t *ssrc_ptr = (uint32_t *)(data + 8); - return ntohl(*ssrc_ptr); + ssrc = ntohl(*ssrc_ptr); + return true; } RtpProcess::Ptr RtpSelector::getProcess(uint32_t ssrc,bool makeNew) { diff --git a/src/Rtp/RtpSelector.h b/src/Rtp/RtpSelector.h index bbbd9665..a701a83d 100644 --- a/src/Rtp/RtpSelector.h +++ b/src/Rtp/RtpSelector.h @@ -42,7 +42,7 @@ public: static RtpSelector &Instance(); bool inputRtp(const char *data,int data_len,const struct sockaddr *addr ,uint32_t *dts_out = nullptr ); - static uint32_t getSSRC(const char *data,int data_len); + static bool getSSRC(const char *data,int data_len, uint32_t &ssrc); RtpProcess::Ptr getProcess(uint32_t ssrc,bool makeNew); void delProcess(uint32_t ssrc,const RtpProcess *ptr); private: diff --git a/src/Rtp/RtpSession.cpp b/src/Rtp/RtpSession.cpp index c765997f..f807a85d 100644 --- a/src/Rtp/RtpSession.cpp +++ b/src/Rtp/RtpSession.cpp @@ -36,7 +36,7 @@ RtpSession::RtpSession(const Socket::Ptr &sock) : TcpSession(sock) { } RtpSession::~RtpSession() { DebugP(this); - if(_ssrc){ + if(_process){ RtpSelector::Instance().delProcess(_ssrc,_process.get()); } } @@ -66,11 +66,13 @@ void RtpSession::onManager() { } void RtpSession::onRtpPacket(const char *data, uint64_t len) { - if(!_ssrc){ - _ssrc = RtpSelector::getSSRC(data + 2,len - 2); + if (!_process) { + if (!RtpSelector::getSSRC(data + 2, len - 2, _ssrc)) { + return; + } _process = RtpSelector::Instance().getProcess(_ssrc, true); } - _process->inputRtp(data + 2,len - 2,&addr); + _process->inputRtp(data + 2, len - 2, &addr); _ticker.resetTime(); }