繁体   English   中英

使用MediaCodec将加密的数据解密并解码到SurfaceTexture

[英]Decrypt & Decode encrypted data to a SurfaceTexture using MediaCodec

是否可以使用MediaCodec API解密和解码数据? 我想对通过Widevine或其他DRM机制加密的数据进行解密和解码。 我想尝试的基本方法是使用从SurfaceTexure创建的Surface配置MediaCodec。 MediaCodec->configure(..????., with mediacrypto instance, ...)在这种情况MediaCodec->configure(..????., with mediacrypto instance, ...)我不确定是否可以传递SurfaceTexture? 还是我应该做的任何安全配置?

MediaCodec->start()
MediaCodec->queuesecureinputbuffer(...,with cryptoinfo,...)
MediaCodec->dequeoutputbuffer() to get the decoded data back....

我可以找到的示例是将解密的数据直接呈现到SurfaceView上。

但我只想获取解码的缓冲区或由MediaCodec呈现的SurfaceTexture。

如果我没有设置任何安全配置,例如MediaFormat->SetFeatureEnabled("secure-playback", true) ; 使用OMX.qcom.video.decoder.avc创建解码器。 我会得到这样的错误,

E/OMX-VDEC-1080P(23290): 
E/OMX-VDEC-1080P(23290): ERROR: Sending OMX_EventError to Client
E/        (23290): not in avi mode
E/ACodec  ( 1930): [OMX.qcom.video.decoder.avc] ERROR(0x80001009)
E/ACodec  ( 1930): signalError(omxError 0x80001009, internalError -2147483648)
E/MediaCodec( 1930): Codec reported err 0x80001009, actionCode 0, while in state 6
W/System.err( 1930): java.lang.IllegalStateException
W/System.err( 1930):  at android.media.MediaCodec.native_dequeueOutputBuffer(Native Method)
W/System.err( 1930):  at android.media.MediaCodec.dequeueOutputBuffer(MediaCodec.java:1033)

一旦我设置了安全配置并使用MediaCodec :: CreateByCodecName(附加了“ .secure”),我将得到这种错误...

E/ACodec: native window could not be authenticated
E/ACodec: Failed to allocate buffers after transitioning to IDLE state (error 0xffffffff)
E/ACodec: signalError(omxError 0x80001001, internalError -1)

它在某种程度上取决于设备的硬件,但通常来说,受DRM保护的视频只能发送到SurfaceView。 此外,SurfaceView的Surface必须位于硬件覆盖上。

受DRM保护的视频由视频解码器硬件解密,并将解码后的帧写入软件无法访问的内存中。 甚至Linux内核都无法读取它。 这些帧通过句柄传递给Hardware Composer,后者告诉显示硬件在覆盖平面上显示它们。

由于内存只能由视频解码器和显示器访问,因此GPU无法访问该内存,这意味着数据不能用作GLES外部纹理。 该帧无法与GLES合成,因此,如果HWC无法分配叠加层,则视频将不会出现。 (有关HWC和组成的更多信息,请参阅图形拱文档 。)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM