diff --git a/src/rtcpnackresponder.cpp b/src/rtcpnackresponder.cpp index 88d1face2..48f70d91a 100644 --- a/src/rtcpnackresponder.cpp +++ b/src/rtcpnackresponder.cpp @@ -79,10 +79,14 @@ optional RtcpNackResponder::Storage::get(uint16_t sequenceNumber) { : nullopt; } -void RtcpNackResponder::Storage::store(binary_ptr packet) { - if (!packet || packet->size() < sizeof(RtpHeader)) +void RtcpNackResponder::Storage::store(binary_ptr message) { + if (!message || message->size() < sizeof(RtpHeader)) return; + // We need to create a deep copy of the message binary here because the content + // of the binary will be modified by the srtp_protect() function when the message is sent. + auto packet = std::make_shared(message->begin(), message->end()); + auto rtp = reinterpret_cast(packet->data()); auto sequenceNumber = rtp->seqNumber();