diff --git a/audio/channel_receive.cc b/audio/channel_receive.cc index 17cf859ed8..b9d9ab14c8 100644 --- a/audio/channel_receive.cc +++ b/audio/channel_receive.cc @@ -693,10 +693,20 @@ void ChannelReceive::ReceivePacket(const uint8_t* packet, const std::vector csrcs(header.arrOfCSRCs, header.arrOfCSRCs + header.numCSRCs); + const uint8_t additional_data_bytes[8] = { + 0, + 0, + 0, + 0, + static_cast((header.timestamp >> 24) & 0xff), + static_cast((header.timestamp >> 16) & 0xff), + static_cast((header.timestamp >> 8) & 0xff), + static_cast(header.timestamp & 0xff), + }; const FrameDecryptorInterface::Result decrypt_result = frame_decryptor_->Decrypt( cricket::MEDIA_TYPE_AUDIO, csrcs, - /*additional_data=*/nullptr, + /*additional_data=*/additional_data_bytes, rtc::ArrayView(payload, payload_data_length), decrypted_audio_payload); diff --git a/audio/channel_send.cc b/audio/channel_send.cc index 4a2700177b..7ebb501704 100644 --- a/audio/channel_send.cc +++ b/audio/channel_send.cc @@ -320,10 +320,23 @@ int32_t ChannelSend::SendRtpAudio(AudioFrameType frameType, // Encrypt the audio payload into the buffer. size_t bytes_written = 0; + const uint32_t additional_data_timestamp = + rtp_timestamp_without_offset + rtp_rtcp_->StartTimestamp(); + const uint8_t additional_data_bytes[8] = { + 0, + 0, + 0, + 0, + static_cast((additional_data_timestamp >> 24) & 0xff), + static_cast((additional_data_timestamp >> 16) & 0xff), + static_cast((additional_data_timestamp >> 8) & 0xff), + static_cast(additional_data_timestamp & 0xff), + }; + int encrypt_status = frame_encryptor_->Encrypt( cricket::MEDIA_TYPE_AUDIO, rtp_rtcp_->SSRC(), - /*additional_data=*/nullptr, payload, encrypted_audio_payload, - &bytes_written); + /*additional_data=*/additional_data_bytes, payload, + encrypted_audio_payload, &bytes_written); if (encrypt_status != 0) { RTC_DLOG(LS_ERROR) << "Channel::SendData() failed encrypt audio payload: "