Make WebRTC replayed packets no longer print messages, removed duplicate error messages

Change-Id: If9e13c802fd9ffa5296475ec730a76fbb0667a2b
This commit is contained in:
Thulinma 2023-02-09 09:40:58 +01:00
parent e9ea839996
commit 4e69250e69
2 changed files with 8 additions and 4 deletions

View file

@ -1228,9 +1228,9 @@ namespace Mist{
int len = udp.data.size();
if (srtpReader.unprotectRtp((uint8_t *)(char*)udp.data, &len) != 0){
if (packetLog.is_open()){packetLog << "[" << Util::bootMS() << "]" << "RTP decrypt failure" << std::endl;}
FAIL_MSG("Failed to unprotect a RTP packet.");
return;
}
if (!len){return;}
lastRecv = Util::bootMS();
RTP::Packet unprotPack(udp.data, len);
DONTEVEN_MSG("%s", unprotPack.toString().c_str());
@ -1262,9 +1262,9 @@ namespace Mist{
if (doDTLS){
if (srtpReader.unprotectRtcp((uint8_t *)(char*)udp.data, &len) != 0){
if (packetLog.is_open()){packetLog << "[" << Util::bootMS() << "]" << "RTCP decrypt failure" << std::endl;}
FAIL_MSG("Failed to unprotect RTCP.");
return;
}
if (!len){return;}
}
lastRecv = Util::bootMS();

View file

@ -151,10 +151,12 @@ int SRTPReader::unprotectRtp(uint8_t *data, int *nbytes){
}
srtp_err_status_t status = srtp_unprotect(session, data, nbytes);
if (srtp_err_status_ok != status){
if (srtp_err_status_ok != status && status != srtp_err_status_replay_fail){
ERROR_MSG("Failed to unprotect the given SRTP. %s.", srtp_status_to_string(status).c_str());
return -5;
}
//For replayed packets, set bytes to zero
if (status == srtp_err_status_replay_fail){*nbytes = 0;}
DONTEVEN_MSG("Unprotected SRTP into %d bytes.", *nbytes);
@ -184,10 +186,12 @@ int SRTPReader::unprotectRtcp(uint8_t *data, int *nbytes){
}
srtp_err_status_t status = srtp_unprotect_rtcp(session, data, nbytes);
if (srtp_err_status_ok != status){
if (srtp_err_status_ok != status && status != srtp_err_status_replay_fail){
ERROR_MSG("Failed to unprotect the given SRTCP. %s.", srtp_status_to_string(status).c_str());
return -5;
}
//For replayed packets, set bytes to zero
if (status == srtp_err_status_replay_fail){*nbytes = 0;}
return 0;
}