Skip to content

Commit

Permalink
Support secure and non-secure
Browse files Browse the repository at this point in the history
Signed-off-by: Nana Zhang <[email protected]>
  • Loading branch information
nanazhan committed Jan 22, 2025
1 parent b59f9d0 commit b218bce
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 4 deletions.
3 changes: 2 additions & 1 deletion _studio/mfx_lib/shared/src/mfx_common_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,8 @@ mfxStatus CheckDecodersExtendedBuffers(mfxVideoParam const* par)
#ifndef MFX_ADAPTIVE_PLAYBACK_DISABLE
MFX_EXTBUFF_DEC_ADAPTIVE_PLAYBACK,
#endif
MFX_EXTBUFF_ALLOCATION_HINTS
MFX_EXTBUFF_ALLOCATION_HINTS,
MFX_EXTBUFF_SECURE_CODEC
};

static const mfxU32 g_decoderSupportedExtBuffersAVC[] = {
Expand Down
4 changes: 4 additions & 0 deletions _studio/shared/src/libmfx_core_vaapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1162,6 +1162,10 @@ mfxStatus VAAPIVideoCORE_T<Base>::CreateVideoAccelerator(
params.m_surf = (void **)RenderTargets;

params.m_protectedVA = param->Protected;
params.m_secure = false;
const mfxExtSecureCodec* secureCodec = (mfxExtSecureCodec*)mfx::GetExtBuffer(param->ExtParam, param->NumExtParam, MFX_EXTBUFF_SECURE_CODEC);
if (secureCodec && secureCodec->on)
params.m_secure = true;

#ifndef MFX_DEC_VIDEO_POSTPROCESS_DISABLE
/* There are following conditions for post processing via HW fixed function engine:
Expand Down
6 changes: 4 additions & 2 deletions _studio/shared/umc/codec/h264_dec/src/umc_h264_va_packer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,8 @@ int32_t PackerVA::PackSliceParams(H264Slice *pSlice, int32_t sliceNum, int32_t c
TRACE_BUFFER_EVENT(VA_TRACE_API_AVC_SLICEPARAMETER_TASK, EVENT_TYPE_INFO, TR_KEY_DECODE_SLICEPARAM,
pSlice_H264, H264DecodeSliceParam, SLICEPARAM_AVC);

SetupDecryptDecode(pSlice, &crypto_params_, &encryption_segment_info_, NalUnitSize);
if (m_va->IsSecure())
SetupDecryptDecode(pSlice, &crypto_params_, &encryption_segment_info_, NalUnitSize);
return partial_data;
}

Expand Down Expand Up @@ -914,7 +915,8 @@ void PackerVA::PackAU(const H264DecoderFrame *pFrame, int32_t isTop)
if (m_va->GetVideoProcessingVA())
PackProcessingInfo(sliceInfo);
#endif
PackEncryptedParams(&crypto_params_);
if (m_va->IsSecure())
PackEncryptedParams(&crypto_params_);

Status sts = m_va->Execute();
if (sts != UMC_OK)
Expand Down
1 change: 1 addition & 0 deletions _studio/shared/umc/core/umc/include/umc_va_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ class VideoAccelerator
virtual int32_t GetSurfaceID(int32_t idx) const { return idx; }

virtual bool DecryptCTR(const mfxExtDecryptConfig& decryptConfig, VAEncryptionParameters* pEncryptionParam) = 0;
virtual bool IsSecure() = 0;

#if defined(MFX_ENABLE_PROTECT)
virtual ProtectedVA * GetProtectedVA() { return m_protectedVA.get(); }
Expand Down
3 changes: 3 additions & 0 deletions _studio/shared/umc/io/umc_va/include/umc_va_linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class LinuxVideoAcceleratorParams : public VideoAcceleratorParams
VAContextID* m_pContext;
bool* m_pKeepVAState;
int m_CreateFlags;
bool m_secure;
};

/* LinuxVideoAccelerator -----------------------------------------------------*/
Expand Down Expand Up @@ -136,6 +137,7 @@ class LinuxVideoAccelerator : public VideoAccelerator
{ return UMC_ERR_UNSUPPORTED; }

bool DecryptCTR(const mfxExtDecryptConfig& , VAEncryptionParameters*);
bool IsSecure();

protected:

Expand Down Expand Up @@ -165,6 +167,7 @@ class LinuxVideoAccelerator : public VideoAccelerator
VAContextID* m_pContext;
bool* m_pKeepVAState;
lvaFrameState m_FrameState;
bool m_secure;

uint32_t m_uiCompBuffersNum;
uint32_t m_uiCompBuffersUsed;
Expand Down
8 changes: 7 additions & 1 deletion _studio/shared/umc/io/umc_va/src/umc_va_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ Status LinuxVideoAccelerator::Init(VideoAcceleratorParams* pInfo)
height = pParams->m_pVideoStreamInfo->clip_info.height;
m_allocator = pParams->m_allocator;
m_FrameState = lvaBeforeBegin;
m_secure = pParams->m_secure;

// profile or stream type should be set
if (UNKNOWN == (m_Profile & VA_CODEC))
Expand Down Expand Up @@ -552,7 +553,7 @@ Status LinuxVideoAccelerator::Init(VideoAcceleratorParams* pInfo)
umcRes = va_to_umc_res(va_res);
}

if (1)
if (m_secure)
{
m_protectedSessionID = CreateProtectedSession(VA_PC_SESSION_MODE_HEAVY,
VA_PC_SESSION_TYPE_DISPLAY, VAEntrypointProtectedContent, EncryptionScheme::kCenc);
Expand Down Expand Up @@ -873,6 +874,11 @@ bool LinuxVideoAccelerator::DecryptCTR(const mfxExtDecryptConfig& decryptConfig,
return true;
}

bool LinuxVideoAccelerator::IsSecure()
{
return m_secure;
}

Status LinuxVideoAccelerator::Close(void)
{
MFX_AUTO_LTRACE(MFX_TRACE_LEVEL_HOTSPOTS, "LinuxVideoAccelerator::Close");
Expand Down
1 change: 1 addition & 0 deletions api/mediasdk_structures/ts_ext_buffers_decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,4 @@ EXTBUF(mfxExtEncodeStatsOutput, MFX_EXTBUFF_ENCODESTATS)

// encrytion
EXTBUF(mfxExtDecryptConfig, MFX_EXTBUFF_DECRYPT_CONFIG)
EXTBUF(mfxExtSecureCodec, MFX_EXTBUFF_SECURE_CODEC)
6 changes: 6 additions & 0 deletions api/vpl/mfxstructures.h
Original file line number Diff line number Diff line change
Expand Up @@ -2399,6 +2399,7 @@ enum {
#endif

MFX_EXTBUFF_DECRYPT_CONFIG = MFX_MAKEFOURCC('D', 'E', 'C', 'R'),
MFX_EXTBUFF_SECURE_CODEC = MFX_MAKEFOURCC('S', 'E', 'C', 'U'),
};

/* VPP Conf: Do not use certain algorithms */
Expand Down Expand Up @@ -5141,6 +5142,11 @@ typedef struct {
SubsampleEntry *subsamples;
} mfxExtDecryptConfig;

typedef struct {
mfxExtBuffer Header;
mfxU8 on;
} mfxExtSecureCodec;

#ifdef __cplusplus
} // extern "C"

Expand Down

0 comments on commit b218bce

Please sign in to comment.