Files
mobile-ios/tools/webrtc-custom-ios/patches/0001-audio-e2ee-pass-rtp-timestamp-as-additional-data.patch

57 lines
2.3 KiB
Diff

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<uint32_t> csrcs(header.arrOfCSRCs,
header.arrOfCSRCs + header.numCSRCs);
+ const uint8_t additional_data_bytes[8] = {
+ 0,
+ 0,
+ 0,
+ 0,
+ static_cast<uint8_t>((header.timestamp >> 24) & 0xff),
+ static_cast<uint8_t>((header.timestamp >> 16) & 0xff),
+ static_cast<uint8_t>((header.timestamp >> 8) & 0xff),
+ static_cast<uint8_t>(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<const uint8_t>(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<uint8_t>((additional_data_timestamp >> 24) & 0xff),
+ static_cast<uint8_t>((additional_data_timestamp >> 16) & 0xff),
+ static_cast<uint8_t>((additional_data_timestamp >> 8) & 0xff),
+ static_cast<uint8_t>(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: "