Commit 0ed369d3 authored by Jeffrey Kardatzke's avatar Jeffrey Kardatzke Committed by Chromium LUCI CQ

vaapi: Periodically retrieve keys during protected content

For cases where we are video only decrypt, we need to make calls into
OEMCrypto to get the key material even if we already have it in order to
update the key usage times. The update interval should be ~1 min. This
ensures that we are making that call.

BUG=b:178208439
TEST=Key usage time updates are occurring during Netflix playback

Change-Id: I14d19e4a962c79206a8f41fa2ba5281bd0b95c77
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2644909Reviewed-by: default avatarJao-ke Chin-Lee <jchinlee@chromium.org>
Commit-Queue: Jao-ke Chin-Lee <jchinlee@chromium.org>
Auto-Submit: Jeffrey Kardatzke <jkardatzke@google.com>
Cr-Commit-Position: refs/heads/master@{#846326}
parent 2132f7fe
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/time/default_tick_clock.h"
#include "build/chromeos_buildflags.h" #include "build/chromeos_buildflags.h"
#include "media/base/bind_to_current_loop.h" #include "media/base/bind_to_current_loop.h"
#include "media/base/cdm_context.h" #include "media/base/cdm_context.h"
...@@ -15,6 +16,13 @@ ...@@ -15,6 +16,13 @@
#if BUILDFLAG(IS_CHROMEOS_ASH) #if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chromeos/components/cdm_factory_daemon/chromeos_cdm_factory.h" #include "chromeos/components/cdm_factory_daemon/chromeos_cdm_factory.h"
namespace {
// During playback of protected content, we need to request the keys at an
// interval no greater than this. This allows updating of key usage data.
constexpr base::TimeDelta kKeyRetrievalMaxPeriod =
base::TimeDelta::FromMinutes(1);
} // namespace
#endif #endif
namespace media { namespace media {
...@@ -141,11 +149,25 @@ VaapiVideoDecoderDelegate::SetupDecryptDecode( ...@@ -141,11 +149,25 @@ VaapiVideoDecoderDelegate::SetupDecryptDecode(
BindToCurrentLoop(base::BindOnce( BindToCurrentLoop(base::BindOnce(
&VaapiVideoDecoderDelegate::OnGetHwKeyData, &VaapiVideoDecoderDelegate::OnGetHwKeyData,
weak_factory_.GetWeakPtr(), decrypt_config_->key_id()))); weak_factory_.GetWeakPtr(), decrypt_config_->key_id())));
last_key_retrieval_time_ =
base::DefaultTickClock::GetInstance()->NowTicks();
// Don't change our state here because we are created, but we just return // Don't change our state here because we are created, but we just return
// kInProcess for now to trigger a wait/retry state. // kInProcess for now to trigger a wait/retry state.
return ProtectedSessionState::kInProcess; return ProtectedSessionState::kInProcess;
} }
// We may also need to request the key in order to update key usage times in
// OEMCrypto. We can ignore the return callback in this case since we already
// have the key information.
if (base::DefaultTickClock::GetInstance()->NowTicks() -
last_key_retrieval_time_ >
kKeyRetrievalMaxPeriod) {
chromeos_cdm_context_->GetHwKeyData(decrypt_config_.get(), hw_identifier_,
base::DoNothing());
last_key_retrieval_time_ =
base::DefaultTickClock::GetInstance()->NowTicks();
}
crypto_params->num_segments += subsamples.size(); crypto_params->num_segments += subsamples.size();
if (decrypt_config_->HasPattern()) { if (decrypt_config_->HasPattern()) {
if (subsamples.size() != 1) { if (subsamples.size() != 1) {
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "base/memory/scoped_refptr.h" #include "base/memory/scoped_refptr.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/sequence_checker.h" #include "base/sequence_checker.h"
#include "base/time/time.h"
#include "build/chromeos_buildflags.h" #include "build/chromeos_buildflags.h"
#include "media/base/decryptor.h" #include "media/base/decryptor.h"
#include "media/base/encryption_scheme.h" #include "media/base/encryption_scheme.h"
...@@ -118,6 +119,7 @@ class VaapiVideoDecoderDelegate { ...@@ -118,6 +119,7 @@ class VaapiVideoDecoderDelegate {
std::unique_ptr<DecryptConfig> decrypt_config_; std::unique_ptr<DecryptConfig> decrypt_config_;
std::vector<uint8_t> hw_identifier_; std::vector<uint8_t> hw_identifier_;
std::map<std::string, std::vector<uint8_t>> hw_key_data_map_; std::map<std::string, std::vector<uint8_t>> hw_key_data_map_;
base::TimeTicks last_key_retrieval_time_;
base::WeakPtrFactory<VaapiVideoDecoderDelegate> weak_factory_{this}; base::WeakPtrFactory<VaapiVideoDecoderDelegate> weak_factory_{this};
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment