Commit 91d60e84 authored by Jeffrey Kardatzke's avatar Jeffrey Kardatzke Committed by Commit Bot

VaapiWrapper changes for protected media playback

This adds usage of the protected media VAAPI APIs to VaapiWrapper. This
is currently based on an upstream pull request located here:
https://github.com/intel/libva/pull/457

That pull request will be patched onto the ChromeOS version of libva
before this CL is merged.

BUG=b:153111783,b:155509236
TEST=Builds, protected playback works w/ full set of changes,
vaapi_unittest, also verified vaapi playback & vaapi_unittest on eve

Change-Id: Id086dd33d692b86d810ea56645a63fb977d6bfc7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2526171
Commit-Queue: Jeffrey Kardatzke <jkardatzke@google.com>
Reviewed-by: default avatarJeffrey Kardatzke <jkardatzke@google.com>
Reviewed-by: default avatarJ Kardatzke <jkardatzke@chromium.org>
Reviewed-by: default avatarMiguel Casas <mcasas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#829034}
parent 3998608d
......@@ -20,6 +20,9 @@ generate_stubs("libva_stubs") {
if (use_x11) {
sigs += [ "va_x11.sigs" ]
}
if (is_chromeos_ash) {
sigs += [ "va_prot.sigs" ]
}
sigs += [ "va_drm.sigs" ]
output_name = "va_stubs"
......
include_rules = [
"+third_party/libva_protected_content/va_protected_content.h",
]
specific_include_rules = {
".*_unittest\.cc": [
"+third_party/libwebp",
......
......@@ -8,3 +8,6 @@ per-file *jpeg*=andrescj@chromium.org
# General VA-API decoding related stuff
per-file *image_decoder*=andrescj@chromium.org
# For protected-mode video decoding.
jkardatzke@google.com
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//------------------------------------------------
// Functions from libva protected content interface used in chromium code.
//------------------------------------------------
VAStatus vaCreateProtectedSession(VADisplay dpy, VAConfigID config_id, VAProtectedSessionID *protected_session);
VAStatus vaDestroyProtectedSession(VADisplay dpy, VAProtectedSessionID protected_session);
VAStatus vaAttachProtectedSession(VADisplay dpy, VAContextID reserved, VAProtectedSessionID protected_session);
VAStatus vaDetachProtectedSession(VADisplay dpy, VAContextID reserved);
VAStatus vaProtectedSessionHwUpdate(VADisplay dpy, VAProtectedSessionID protected_session, VABufferID buf_id);
This diff is collapsed.
......@@ -109,6 +109,17 @@ class MEDIA_GPU_EXPORT VaapiWrapper
public:
enum CodecMode {
kDecode,
#if BUILDFLAG(IS_CHROMEOS_ASH)
// NOTE: A kDecodeProtected VaapiWrapper is created using the actual video
// profile and an extra VAProfileProtected, each with some special added
// VAConfigAttribs. Then when CreateProtectedSession() is called, it will
// then create a protected session using protected profile & entrypoint
// which gets attached to the decoding context (or attached when the
// decoding context is created or re-created). This then enables
// decrypt + decode support in the driver and encrypted frame data can then
// be submitted.
kDecodeProtected, // Decrypt + decode to protected surface.
#endif
kEncode, // Encode with Constant Bitrate algorithm.
kEncodeConstantQuantizationParameter, // Encode with Constant Quantization
// Parameter algorithm.
......@@ -250,13 +261,29 @@ class MEDIA_GPU_EXPORT VaapiWrapper
const gfx::Size& size,
const base::Optional<gfx::Size>& visible_size = base::nullopt);
// Attempts to create a protected session that will be attached to the
// decoding context to enable encrypted video decoding. If it cannot be
// attached now, it will be attached when the decoding context is created or
// re-created. |encryption| should be the encryption scheme from the
// DecryptConfig, |full_sample| should be true if full sample (i.e. CENC v1)
// encryption is used. |hw_config| should have been obtained from the
// OEMCrypto implementation via the CdmFactoryDaemonProxy. |hw_identifier_out|
// is an output parameter which will return session specific information which
// can be passed through the ChromeOsCdmContext to retrieve encrypted key
// information. Returns true on success and false otherwise.
bool CreateProtectedSession(media::EncryptionScheme encryption,
bool full_sample,
const std::vector<uint8_t>& hw_config,
std::vector<uint8_t>* hw_identifier_out);
// Releases the |va_surfaces| and destroys |va_context_id_|.
void DestroyContextAndSurfaces(std::vector<VASurfaceID> va_surfaces);
// Creates a VAContextID of |size| (unless it's a Vpp context in which case
// |size| is ignored and 0x0 is used instead). The client is responsible for
// releasing said context via DestroyContext() or DestroyContextAndSurfaces(),
// or it will be released on dtor.
// or it will be released on dtor. If a valid |va_protected_session_id_|
// exists, it will be attached to the newly created |va_context_id_| as well.
virtual bool CreateContext(const gfx::Size& size) WARN_UNUSED_RESULT;
// Destroys the context identified by |va_context_id_|.
......@@ -476,6 +503,10 @@ class MEDIA_GPU_EXPORT VaapiWrapper
// consumption and maximum speed.
void MaybeSetLowQualityEncoding_Locked() EXCLUSIVE_LOCKS_REQUIRED(va_lock_);
// If a protected session is active, attaches it to the decoding context.
bool MaybeAttachProtectedSession_Locked()
EXCLUSIVE_LOCKS_REQUIRED(va_lock_) WARN_UNUSED_RESULT;
const CodecMode mode_;
// Pointer to VADisplayState's member |va_lock_|. Guaranteed to be valid for
......@@ -485,10 +516,10 @@ class MEDIA_GPU_EXPORT VaapiWrapper
// VA handles.
// All valid after successful Initialize() and until Deinitialize().
VADisplay va_display_ GUARDED_BY(va_lock_);
VAConfigID va_config_id_;
VAConfigID va_config_id_{VA_INVALID_ID};
// Created in CreateContext() or CreateContextAndSurfaces() and valid until
// DestroyContext() or DestroyContextAndSurfaces().
VAContextID va_context_id_;
VAContextID va_context_id_{VA_INVALID_ID};
// Profile and entrypoint configured for the corresponding |va_context_id_|.
VAProfile va_profile_;
......@@ -502,6 +533,12 @@ class MEDIA_GPU_EXPORT VaapiWrapper
// and reused afterwards.
std::unique_ptr<ScopedVABuffer> va_buffer_for_vpp_;
#if BUILDFLAG(IS_CHROMEOS_ASH)
// For protected decode mode.
VAConfigID va_protected_config_id_{VA_INVALID_ID};
VAProtectedSessionID va_protected_session_id_{VA_INVALID_ID};
#endif
// Called to report codec errors to UMA. Errors to clients are reported via
// return values from public methods.
ReportErrorToUMACB report_error_to_uma_cb_;
......
......@@ -75009,7 +75009,12 @@ Full version information for the fingerprint enum values:
<int value="22" label="vaSyncSurface()"/>
<int value="23" label="vaTerminate()"/>
<int value="24" label="vaUnmapBuffer()"/>
<int value="25" label="Other VA functions"/>
<int value="25" label="vaCreateProtectedSession()"/>
<int value="26" label="vaDestroyProtectedSession()"/>
<int value="27" label="vaAttachProtectedSession()"/>
<int value="28" label="vaDetachProtectedSession()"/>
<int value="29" label="vaProtectedSessionHwUpdate()"/>
<int value="30" label="Other VA functions"/>
</enum>
<enum name="VAIPFailure">
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