Enables FrameDecryptor to do an initial key request on frame decryption.

This change enables the FrameDecryptor attached to an RtpVideoReceiver to do
an initial request for a KeyFrame if the first successfully decrypted payload
is not a key frame.

Bug: webrtc:9795
Change-Id: I401ce1f513cb51ce520b60dcaf8b825a68d00c7f
Reviewed-on: https://webrtc-review.googlesource.com/c/107246
Commit-Queue: Benjamin Wright <benwright@webrtc.org>
Reviewed-by: Åsa Persson <asapersson@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25295}
This commit is contained in:
Benjamin Wright 2018-10-22 13:33:09 -07:00 committed by Commit Bot
parent 201596f004
commit 39feabe35c
2 changed files with 20 additions and 6 deletions

View File

@ -378,6 +378,16 @@ int32_t RtpVideoStreamReceiver::ResendPackets(const uint16_t* sequence_numbers,
void RtpVideoStreamReceiver::OnReceivedFrame(
std::unique_ptr<video_coding::RtpFrameObject> frame) {
// Request a key frame as soon as possible.
bool key_frame_requested = false;
if (!has_received_frame_) {
has_received_frame_ = true;
if (frame->FrameType() != kVideoFrameKey) {
key_frame_requested = true;
keyframe_request_sender_->RequestKeyFrame();
}
}
// Optionally attempt to decrypt the raw video frame if it was provided.
if (frame_decryptor_ != nullptr) {
// When using encryption we expect the frame to have the generic descriptor.
@ -408,6 +418,14 @@ void RtpVideoStreamReceiver::OnReceivedFrame(
inline_decrypted_bitstream, &bytes_written) != 0) {
return;
}
if (!has_received_decrypted_frame_ && !key_frame_requested) {
has_received_decrypted_frame_ = true;
if (frame->FrameType() != kVideoFrameKey) {
keyframe_request_sender_->RequestKeyFrame();
}
}
RTC_CHECK(bytes_written <= max_plaintext_byte_size);
// Update the frame to contain just the written bytes.
frame->SetLength(bytes_written);
@ -417,12 +435,6 @@ void RtpVideoStreamReceiver::OnReceivedFrame(
return;
}
if (!has_received_frame_) {
has_received_frame_ = true;
if (frame->FrameType() != kVideoFrameKey)
keyframe_request_sender_->RequestKeyFrame();
}
reference_finder_->ManageFrame(std::move(frame));
}

View File

@ -208,6 +208,8 @@ class RtpVideoStreamReceiver : public RecoveredPacketReceiver,
// E2EE Video Frame Decryptor (Optional)
rtc::scoped_refptr<FrameDecryptorInterface> frame_decryptor_;
// Set to true on the first successsfully decrypted frame.
bool has_received_decrypted_frame_ = false;
};
} // namespace webrtc