diff --git a/api/crypto/frame_decryptor_interface.h b/api/crypto/frame_decryptor_interface.h index 316a330f00..7b09547466 100644 --- a/api/crypto/frame_decryptor_interface.h +++ b/api/crypto/frame_decryptor_interface.h @@ -63,8 +63,8 @@ class FrameDecryptorInterface : public rtc::RefCountInterface { rtc::ArrayView additional_data, rtc::ArrayView encrypted_frame, rtc::ArrayView frame, - // RingRTC change to detect received dependency descriptor - bool has_dependency_descriptor) = 0; + // RingRTC change to encrypt media header + bool has_encrypted_media_header) = 0; // Returns the total required length in bytes for the output of the // decryption. This can be larger than the actual number of bytes you need but diff --git a/audio/channel_receive.cc b/audio/channel_receive.cc index 6c7fca5001..52b5d79555 100644 --- a/audio/channel_receive.cc +++ b/audio/channel_receive.cc @@ -713,14 +713,16 @@ void ChannelReceive::ReceivePacket(const uint8_t* packet, const std::vector csrcs(header.arrOfCSRCs, header.arrOfCSRCs + header.numCSRCs); + // RingRTC change to determine if TOC is encrypted + bool has_encrypted_toc = header.extension.hasAudioLevel && ((header.extension.audioLevel & 0x1) != 0); const FrameDecryptorInterface::Result decrypt_result = frame_decryptor_->Decrypt( cricket::MEDIA_TYPE_AUDIO, csrcs, /*additional_data=*/nullptr, rtc::ArrayView(payload, payload_data_length), decrypted_audio_payload, - // RingRTC change to detect received dependency descriptor - /*has_dependency_descriptor=*/false); + // RingRTC change to determine if TOC is encrypted + has_encrypted_toc); if (decrypt_result.IsOk()) { decrypted_audio_payload.SetSize(decrypt_result.bytes_written); diff --git a/ringrtc/rffi/api/peer_connection_observer_intf.h b/ringrtc/rffi/api/peer_connection_observer_intf.h index 9d8714a480..95200bf1d4 100644 --- a/ringrtc/rffi/api/peer_connection_observer_intf.h +++ b/ringrtc/rffi/api/peer_connection_observer_intf.h @@ -57,7 +57,7 @@ typedef struct { size_t (*getMediaCiphertextBufferSize)(void* observer_borrowed, bool, size_t); bool (*encryptMedia)(void* observer_borrowed, bool, const uint8_t* plaintext_borrowed, size_t, uint8_t* ciphertext_out, size_t, size_t* ciphertext_size_out); size_t (*getMediaPlaintextBufferSize)(void* observer_borrowed, uint32_t, bool, size_t); - bool (*decryptMedia)(void* observer_borrowed, uint32_t, bool, const uint8_t* ciphertext_borrowed, size_t, uint8_t* plaintext_out, size_t, size_t* plaintext_size_out, bool has_dependency_descriptor); + bool (*decryptMedia)(void* observer_borrowed, uint32_t, bool, const uint8_t* ciphertext_borrowed, size_t, uint8_t* plaintext_out, size_t, size_t* plaintext_size_out, bool has_encrypted_media_header); } PeerConnectionObserverCallbacks; // Passed-in observer must live at least as long as the PeerConnectionObserverRffi, diff --git a/ringrtc/rffi/src/peer_connection_observer.cc b/ringrtc/rffi/src/peer_connection_observer.cc index f8ff391cef..7ebac974ca 100644 --- a/ringrtc/rffi/src/peer_connection_observer.cc +++ b/ringrtc/rffi/src/peer_connection_observer.cc @@ -316,7 +316,7 @@ class Decryptor : public webrtc::FrameDecryptorInterface { rtc::ArrayView _generic_video_header, rtc::ArrayView ciphertext, rtc::ArrayView plaintext_buffer, - bool has_dependency_descriptor) override { + bool has_encrypted_media_header) override { bool is_audio = (media_type == cricket::MEDIA_TYPE_AUDIO); bool is_video = (media_type == cricket::MEDIA_TYPE_VIDEO); if (!is_audio && !is_video) { @@ -324,7 +324,7 @@ class Decryptor : public webrtc::FrameDecryptorInterface { return FrameDecryptorInterface::Result(FrameDecryptorInterface::Status::kUnknown, 0); } size_t plaintext_size = 0; - if (!callbacks_->decryptMedia(observer_, track_id_, is_audio, ciphertext.data(), ciphertext.size(), plaintext_buffer.data(), plaintext_buffer.size(), &plaintext_size, has_dependency_descriptor)) { + if (!callbacks_->decryptMedia(observer_, track_id_, is_audio, ciphertext.data(), ciphertext.size(), plaintext_buffer.data(), plaintext_buffer.size(), &plaintext_size, has_encrypted_media_header)) { return FrameDecryptorInterface::Result(FrameDecryptorInterface::Status::kFailedToDecrypt, 0); } return FrameDecryptorInterface::Result(FrameDecryptorInterface::Status::kOk, plaintext_size);