From d1c6085cb396601272b44546433de7adf595e59e Mon Sep 17 00:00:00 2001 From: Benjamin Wright Date: Fri, 5 Apr 2019 18:05:09 -0700 Subject: [PATCH] Added FrameDecryptorInterface::Result constructor and IsOk() member function. Bug: webrtc:10512 Change-Id: I48bdaad57739382b5c1040d94f4e3657e2054e4b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/131364 Reviewed-by: Steve Anton Commit-Queue: Benjamin Wright Cr-Commit-Position: refs/heads/master@{#27475} --- api/crypto/frame_decryptor_interface.h | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/api/crypto/frame_decryptor_interface.h b/api/crypto/frame_decryptor_interface.h index 84fc615484..69f137504c 100644 --- a/api/crypto/frame_decryptor_interface.h +++ b/api/crypto/frame_decryptor_interface.h @@ -38,8 +38,13 @@ class FrameDecryptorInterface : public rtc::RefCountInterface { enum class Status { kOk, kRecoverable, kFailedToDecrypt }; struct Result { - Status status; - size_t bytes_written; + Result(Status status, size_t bytes_written) + : status(status), bytes_written(bytes_written) {} + + bool IsOk() const { return status == Status::kOk; } + + const Status status; + const size_t bytes_written; }; ~FrameDecryptorInterface() override {} @@ -73,14 +78,8 @@ class FrameDecryptorInterface : public rtc::RefCountInterface { size_t bytes_written = 0; const int status = Decrypt(media_type, csrcs, additional_data, encrypted_frame, frame, &bytes_written); - Result decryption_result; - decryption_result.bytes_written = bytes_written; - if (status == 0) { - decryption_result.status = Status::kOk; - } else { - decryption_result.status = Status::kFailedToDecrypt; - } - return decryption_result; + return Result(status == 0 ? Status::kOk : Status::kFailedToDecrypt, + bytes_written); } // Returns the total required length in bytes for the output of the