簡體   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