From 4e69250e69e77501e3192eaf1925a950a9f597bf Mon Sep 17 00:00:00 2001 From: Thulinma Date: Thu, 9 Feb 2023 09:40:58 +0100 Subject: [PATCH] Make WebRTC replayed packets no longer print messages, removed duplicate error messages Change-Id: If9e13c802fd9ffa5296475ec730a76fbb0667a2b --- src/output/output_webrtc.cpp | 4 ++-- src/output/output_webrtc_srtp.cpp | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/output/output_webrtc.cpp b/src/output/output_webrtc.cpp index 2bd33f44..0f5ce503 100644 --- a/src/output/output_webrtc.cpp +++ b/src/output/output_webrtc.cpp @@ -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(); diff --git a/src/output/output_webrtc_srtp.cpp b/src/output/output_webrtc_srtp.cpp index 5c330fc1..53c9ff45 100644 --- a/src/output/output_webrtc_srtp.cpp +++ b/src/output/output_webrtc_srtp.cpp @@ -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; }