diff options
author | Ryan Saffores <ryan.d.saffores@intel.com> | 2014-07-03 12:55:04 -0700 |
---|---|---|
committer | Patrick Tjin <pattjin@google.com> | 2014-07-21 22:02:59 -0700 |
commit | c5ee8e14c1975ee6122c9a7d95954bf0967f63bb (patch) | |
tree | ef7d9e5c99fcee3ddcba006d243cdc594bea6b56 | |
parent | 26a110c2a29667599733db5173a751e670b366a5 (diff) | |
download | android_hardware_intel_common_omx-components-c5ee8e14c1975ee6122c9a7d95954bf0967f63bb.tar.gz android_hardware_intel_common_omx-components-c5ee8e14c1975ee6122c9a7d95954bf0967f63bb.tar.bz2 android_hardware_intel_common_omx-components-c5ee8e14c1975ee6122c9a7d95954bf0967f63bb.zip |
Delete non-fugu projects
Deleting all code for non-fugu platforms
Change-Id: I36037bd95f7ddfd7e6c50f5e3b2ca511ec89787d
Signed-off-by: Ryan Saffores <ryan.d.saffores@intel.com>
Reviewed-on: https://android.intel.com/214258
Reviewed-by: Imberton, Guilhem <guilhem.imberton@intel.com>
Tested-by: Imberton, Guilhem <guilhem.imberton@intel.com>
-rw-r--r-- | videocodec/Android.mk | 42 | ||||
-rw-r--r-- | videocodec/securevideo/baytrail/OMXVideoDecoderAVCSecure.cpp | 745 | ||||
-rw-r--r-- | videocodec/securevideo/baytrail/OMXVideoDecoderAVCSecure.h | 237 | ||||
-rw-r--r-- | videocodec/securevideo/baytrail/secvideoparser.h | 141 | ||||
-rw-r--r-- | videocodec/securevideo/baytrail/widevine.h | 500 | ||||
-rw-r--r-- | videocodec/securevideo/cherrytrail/OMXVideoDecoderAVCSecure.cpp | 538 | ||||
-rw-r--r-- | videocodec/securevideo/cherrytrail/OMXVideoDecoderAVCSecure.h | 123 | ||||
-rw-r--r-- | videocodec/securevideo/cherrytrail/secvideoparser.h | 141 | ||||
-rw-r--r-- | videocodec/securevideo/cherrytrail/widevine.h | 491 | ||||
-rw-r--r-- | videocodec/securevideo/ctp/OMXVideoDecoderAVCSecure.cpp | 455 | ||||
-rw-r--r-- | videocodec/securevideo/ctp/OMXVideoDecoderAVCSecure.h | 87 | ||||
-rwxr-xr-x | videocodec/securevideo/merrifield/OMXVideoDecoderAVCSecure.cpp | 499 | ||||
-rwxr-xr-x | videocodec/securevideo/merrifield/OMXVideoDecoderAVCSecure.h | 89 |
13 files changed, 1 insertions, 4087 deletions
diff --git a/videocodec/Android.mk b/videocodec/Android.mk index b8ce362..937f392 100644 --- a/videocodec/Android.mk +++ b/videocodec/Android.mk @@ -342,55 +342,15 @@ LOCAL_SRC_FILES := \ OMXComponentCodecBase.cpp\ OMXVideoDecoderBase.cpp -ifeq ($(TARGET_BOARD_PLATFORM),clovertrail) -# Secure AVC decoder for Clovertrail (uses IMR) -LOCAL_SHARED_LIBRARIES += libsepdrm - -LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/libsepdrm - -LOCAL_SRC_FILES += securevideo/ctp/OMXVideoDecoderAVCSecure.cpp - -LOCAL_CFLAGS += -DVED_TILING - -else ifeq ($(TARGET_BOARD_PLATFORM),merrifield) -#Secure AVC decoder for Merrifield (uses IED) -LOCAL_SHARED_LIBRARIES += \ - libsepdrm_cc54 \ - libdx_cc7 - -LOCAL_SRC_FILES += securevideo/merrifield/OMXVideoDecoderAVCSecure.cpp - -LOCAL_CFLAGS += -DVED_TILING - -else ifeq ($(TARGET_BOARD_PLATFORM),moorefield) +ifeq ($(TARGET_BOARD_PLATFORM),moorefield) #Secure AVC decoder for Moorefield V0 (uses IED) LOCAL_SHARED_LIBRARIES += \ libsepdrm_cc54 \ libdx_cc7 -LOCAL_C_INCLUDES += $(TOP)/vendor/intel/hardware/cc54/libsepdrm/libdrm/common/inc \ - $(TOP)/vendor/intel/hardware/cc54/libsepdrm/libdrm/inc \ - LOCAL_SRC_FILES += securevideo/moorefield/OMXVideoDecoderAVCSecure.cpp LOCAL_CFLAGS += -DVED_TILING - -else ifeq ($(TARGET_BOARD_PLATFORM),baytrail) -#Secure AVC decoder for Baytrail (uses PAVP) -LOCAL_C_INCLUDES += $(TOP)/vendor/intel/hardware/PRIVATE/ufo/inc/libpavp - -LOCAL_SHARED_LIBRARIES += libpavp - -LOCAL_SRC_FILES += securevideo/baytrail/OMXVideoDecoderAVCSecure.cpp - -else ifeq ($(TARGET_BOARD_PLATFORM),cherrytrail) -#Secure AVC decoder for Cherrytrail (uses PAVP) -LOCAL_C_INCLUDES += $(TOP)/vendor/intel/hardware/PRIVATE/ufo/inc/libpavp - -LOCAL_SHARED_LIBRARIES += libpavp - -LOCAL_SRC_FILES += securevideo/cherrytrail/OMXVideoDecoderAVCSecure.cpp - endif LOCAL_MODULE_TAGS := optional diff --git a/videocodec/securevideo/baytrail/OMXVideoDecoderAVCSecure.cpp b/videocodec/securevideo/baytrail/OMXVideoDecoderAVCSecure.cpp deleted file mode 100644 index 9543b28..0000000 --- a/videocodec/securevideo/baytrail/OMXVideoDecoderAVCSecure.cpp +++ /dev/null @@ -1,745 +0,0 @@ -/* -* Copyright (c) 2009-2013 Intel Corporation. All rights reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -//#define LOG_NDEBUG 0 -#define LOG_TAG "OMXVideoDecoder" -#include <wrs_omxil_core/log.h> -#include "OMXVideoDecoderAVCSecure.h" -#include <time.h> -#include <signal.h> -#include <pthread.h> -#include <stdlib.h> -#include <stdint.h> -#include <byteswap.h> - -#define LOGVAR(v) LOGD("LOGVAR: " #v " = %d", v) - -// Be sure to have an equal string in VideoDecoderHost.cpp (libmix) -static const char* AVC_MIME_TYPE = "video/avc"; -static const char* AVC_SECURE_MIME_TYPE = "video/avc-secure"; - -OMXVideoDecoderAVCSecure::OMXVideoDecoderAVCSecure() - : mpLibInstance(NULL), - mPAVPAppID(0xFF), - mDropUntilIDR(false) { - LOGV("OMXVideoDecoderAVCSecure is constructed."); - mVideoDecoder = createVideoDecoder(AVC_SECURE_MIME_TYPE); - if (!mVideoDecoder) { - LOGE("createVideoDecoder failed for \"%s\"", AVC_SECURE_MIME_TYPE); - } - // Override default native buffer count defined in the base class - mNativeBufferCount = OUTPORT_NATIVE_BUFFER_COUNT; - - memset(mOMXSecureBuffers, 0, sizeof(mOMXSecureBuffers)); - memset(mParsedFrames, 0, sizeof(mParsedFrames)); - - BuildHandlerList(); -} - -OMXVideoDecoderAVCSecure::~OMXVideoDecoderAVCSecure() { - // Cleanup any buffers that weren't freed - for(int i = 0; i < INPORT_ACTUAL_BUFFER_COUNT; i++) { - if(mOMXSecureBuffers[i]) { - delete mOMXSecureBuffers[i]; - } - } - LOGV("OMXVideoDecoderAVCSecure is destructed."); -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::InitInputPortFormatSpecific(OMX_PARAM_PORTDEFINITIONTYPE *paramPortDefinitionInput) { - // OMX_PARAM_PORTDEFINITIONTYPE - paramPortDefinitionInput->nBufferCountActual = INPORT_ACTUAL_BUFFER_COUNT; - paramPortDefinitionInput->nBufferCountMin = INPORT_MIN_BUFFER_COUNT; - paramPortDefinitionInput->nBufferSize = INPORT_BUFFER_SIZE; - paramPortDefinitionInput->format.video.cMIMEType = (OMX_STRING)AVC_MIME_TYPE; - paramPortDefinitionInput->format.video.eCompressionFormat = OMX_VIDEO_CodingAVC; - - // OMX_VIDEO_PARAM_AVCTYPE - memset(&mParamAvc, 0, sizeof(mParamAvc)); - SetTypeHeader(&mParamAvc, sizeof(mParamAvc)); - mParamAvc.nPortIndex = INPORT_INDEX; - // TODO: check eProfile/eLevel - mParamAvc.eProfile = OMX_VIDEO_AVCProfileHigh; //OMX_VIDEO_AVCProfileBaseline; - mParamAvc.eLevel = OMX_VIDEO_AVCLevel41; //OMX_VIDEO_AVCLevel1; - - // Set memory allocator - this->ports[INPORT_INDEX]->SetMemAllocator(MemAllocSecure, MemFreeSecure, this); - - return OMX_ErrorNone; -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::ProcessorStop(void) { - // destroy PAVP session - if(mpLibInstance) { - pavp_lib_session::pavp_lib_code rc = pavp_lib_session::status_ok; - LOGI("Destroying the PAVP session...\n"); - rc = mpLibInstance->pavp_destroy_session(); - if (rc != pavp_lib_session::status_ok) - LOGE("pavp_destroy_session failed with error 0x%x\n", rc); - } - return OMXVideoDecoderBase::ProcessorStop(); -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::ProcessorProcess( - OMX_BUFFERHEADERTYPE ***pBuffers, - buffer_retain_t *retains, - OMX_U32 numberBuffers) { - - OMX_ERRORTYPE ret; - ret = OMXVideoDecoderBase::ProcessorProcess(pBuffers, retains, numberBuffers); - if (ret != OMX_ErrorNone) { - LOGE("OMXVideoDecoderBase::ProcessorProcess failed. Result: %#x", ret); - return ret; - } - - if (mDropUntilIDR) { - retains[OUTPORT_INDEX] = BUFFER_RETAIN_NOT_RETAIN; - OMX_BUFFERHEADERTYPE *pOutput = *pBuffers[OUTPORT_INDEX]; - pOutput->nFilledLen = 0; - return OMX_ErrorNone; - } - - return ret; -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::PrepareConfigBuffer(VideoConfigBuffer *p) { - OMX_ERRORTYPE ret; - ret = OMXVideoDecoderBase::PrepareConfigBuffer(p); - CHECK_RETURN_VALUE("OMXVideoDecoderBase::PrepareConfigBuffer"); - p->flag |= WANT_SURFACE_PROTECTION; - return ret; -} - -// Temp placeholder for NALU merge -static uint8_t config_nalu[1024]; -static uint32_t config_nalu_len; -// Merge NALU for config (SPS & PPS) with Slice data for MDRM. -static void update_config_nalu(uint8_t* nalu_data, uint32_t* nalu_size) -{ - //move NALU for encrypted portion behind config info - uint8_t temp[1024]; - memset(temp, 0, 1024); - - uint32_t* enc_dword_ptr = NULL; - uint32_t enc_num_nalus = 0; - uint32_t* clr_dword_ptr = NULL; - uint32_t clr_num_nalus = 0; - - if (*nalu_size > 4) { - memcpy(temp, nalu_data+4, ((*nalu_size)-4)); - } else { - LOGI("%s: NALU size < 4!"); - return; - } - - enc_dword_ptr = (uint32_t*)nalu_data; - enc_num_nalus = bswap_32(*enc_dword_ptr); - clr_dword_ptr = (uint32_t*)config_nalu; - clr_num_nalus = bswap_32(*clr_dword_ptr); - - enc_dword_ptr = (uint32_t*)(config_nalu + (config_nalu_len-16)); - (*enc_dword_ptr) = bswap_32(0); - //copy config nalu - memcpy(nalu_data, config_nalu, config_nalu_len); - // ignore first 4 len bytes - memcpy((nalu_data + config_nalu_len), temp, ((*nalu_size)-4)); - - enc_dword_ptr = (uint32_t*)nalu_data; - (*enc_dword_ptr) = bswap_32(enc_num_nalus + clr_num_nalus); - enc_num_nalus = (*enc_dword_ptr); - *nalu_size = ((*nalu_size) + config_nalu_len - 4); - - enc_dword_ptr = (uint32_t*)nalu_data; - enc_dword_ptr++; - (*enc_dword_ptr) = bswap_32(0); - -} -// Create PAVP Session & retrieve associated PAVP AppID. -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::CreatePavpSession(void) { - if(!mpLibInstance) { - LOGE("mpLibInstance is NULL!"); - return OMX_ErrorNotReady; - } - pavp_lib_session::pavp_lib_code rc = pavp_lib_session::status_ok; - - LOGI("PAVP Heavy session creation..."); - - rc = mpLibInstance->pavp_create_session(true); - if (rc != pavp_lib_session::status_ok) { - LOGE("PAVP Heavy: pavp_create_session failed with error 0x%x", rc); - return OMX_ErrorNotReady; - } - - LOGI("Get AppId of the PAVP Heavy session..."); - - rc = mpLibInstance->pavp_get_app_id(reinterpret_cast<UINT&>(mPAVPAppID)); - if (rc != pavp_lib_session::status_ok) { - LOGE("PAVP Heavy: pavp_get_app_id failed with error 0x%x", rc); - return OMX_ErrorNotReady; - } else { - LOGE("pavp_get_app_id succesful, uiAppId = 0x%x", mPAVPAppID); - } - return OMX_ErrorNone; -} -//PAVP SecPassThrough to communicate with SEC. -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::SecPassThrough(uint8_t* pInput, uint32_t inSize, uint8_t* pOutput, uint32_t outSize) { - - pavp_lib_session::pavp_lib_code rc = pavp_lib_session::status_ok; - - if(!mpLibInstance) { - LOGE("mpLibInstance is NULL!"); - return OMX_ErrorNotReady; - } - - rc = mpLibInstance->sec_pass_through( - reinterpret_cast<BYTE*>(pInput), - inSize, - reinterpret_cast<BYTE*>(pOutput), - outSize); - - if (rc != pavp_lib_session::status_ok) { - LOGE("PAVP Failed: 0x%x", rc); - return OMX_ErrorNotReady; - } - PAVP_CMD_HEADER *pHeader = (PAVP_CMD_HEADER*)pOutput; - if (pHeader->Status) { - LOGE("SEC failed: wv_set_xcript_key() FAILED 0x%x", pHeader->Status); - return OMX_ErrorNotReady; - } - return OMX_ErrorNone; -} - -// MDRM - Key injection -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::MdrmInjectKey(uint8_t in_session_id, uint8_t* in_key_id) { - LOGV("%s", __FUNCTION__); - if(!mpLibInstance) { - LOGE("mpLibInstance is NULL!"); - return OMX_ErrorNotReady; - } - wv2_inject_key_in input; - wv2_inject_key_out output; - transcript_conf conf; - - conf.drm_type_1_0 = 2;//PR 1 //SS - conf.dest_encrypt_mode_25_24 = 1;//PR 0 - - input.conf = conf; - input.Header.ApiVersion = 0x00010005; - input.Header.CommandId = wv2_inject_key; - input.Header.Status = 0; - input.Header.BufferLength = sizeof(input)-sizeof(PAVP_CMD_HEADER); - input.session_id = in_session_id; - input.StreamId = mPAVPAppID; - memcpy(input.key_id, in_key_id, 16); - - return SecPassThrough((uint8_t*)&input, sizeof(input), (uint8_t*)&output, sizeof(output)); -} - -// Classic - Key injection -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::WvSetTranscriptKey(void) { - LOGV("%s", __FUNCTION__); - if(!mpLibInstance) { - LOGE("mpLibInstance is NULL!"); - return OMX_ErrorNotReady; - } - wv_set_xcript_key_in input; - wv_set_xcript_key_out output; - - input.Header.ApiVersion = WV_API_VERSION; - input.Header.CommandId = wv_set_xcript_key; - input.Header.Status = 0; - input.StreamId = mPAVPAppID; - input.Header.BufferLength = sizeof(input)-sizeof(PAVP_CMD_HEADER); - - return SecPassThrough((uint8_t*)&input, sizeof(input), (uint8_t*)&output, sizeof(output)); -} - -//Classic ProcessVideoFrame -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::ClassicProcessVideoFrame(SECVideoBuffer *secBuffer, uint32_t *parsed_data_size) { - OMX_ERRORTYPE ret = OMX_ErrorNone; - - LOGV("%s", __FUNCTION__); - - if(!mpLibInstance) { - LOGE("mpLibInstance is NULL!"); - return OMX_ErrorNotReady; - } - - wv_heci_process_video_frame_in input; - wv_heci_process_video_frame_out output; - - pavp_lib_session::pavp_lib_code rc = pavp_lib_session::status_ok; - input.Header.ApiVersion = WV_API_VERSION; - input.Header.CommandId = wv_process_video_frame; - input.Header.Status = 0; - input.Header.BufferLength = sizeof(input) - sizeof(PAVP_CMD_HEADER); - input.num_of_packets = secBuffer->pes_packet_count; - input.is_frame_not_encrypted = secBuffer->clear; - input.src_offset = secBuffer->base_offset + secBuffer->partitions.src.offset; - input.dest_offset = secBuffer->base_offset + secBuffer->partitions.dest.offset; - input.metadata_offset = secBuffer->base_offset + secBuffer->partitions.metadata.offset; - input.header_offset = secBuffer->base_offset + secBuffer->partitions.headers.offset; - - memset(&output, 0, sizeof(wv_heci_process_video_frame_out)); - - ret = SecPassThrough((uint8_t*)&input, sizeof(input), (uint8_t*)&output, sizeof(output)); - *parsed_data_size = output.parsed_data_size; - memcpy(secBuffer->iv, output.iv, 16); - secBuffer->mdrm_info.config_len = 0; - - return ret; -} - -//MDRM ProcessVideoFrame -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::ModularProcessVideoFrame(SECVideoBuffer *secBuffer, uint32_t *parsed_data_size) { - OMX_ERRORTYPE ret = OMX_ErrorNone; - LOGV("%s", __FUNCTION__); - if(!mpLibInstance) { - LOGE("mpLibInstance is NULL!"); - return OMX_ErrorNotReady; - } - - wv2_process_video_frame_in input; - wv2_process_video_frame_out output; - transcript_conf conf; - memset(&conf, 0, sizeof(conf)); - memset(&input, 0, sizeof(input)); - memset(&output, 0, sizeof(wv2_process_video_frame_out)); - - input.Header.ApiVersion = 0x00010005; - input.Header.CommandId = wv2_process_video_frame; - input.Header.Status = 0; - input.Header.BufferLength = sizeof(input) - sizeof(PAVP_CMD_HEADER); - - memcpy(input.key_id, secBuffer->mdrm_info.key_id, 16); - input.key_id_len = secBuffer->mdrm_info.key_id_len; - input.session_id = secBuffer->mdrm_info.session_id; //mSessionID? - input.header_offset = secBuffer->base_offset + secBuffer->partitions.headers.offset; - input.dest_offset = secBuffer->base_offset + secBuffer->partitions.dest.offset; - - conf.drm_type_1_0 = 2;//PR 1 //SS - conf.dest_encrypt_mode_25_24 = 1;//PR 0 - if ( secBuffer->mdrm_info.config_len) { - memset(config_nalu, 0, sizeof(config_nalu)); - pavp_lib_session::pavp_lib_code rc = pavp_lib_session::status_ok; - conf.num_headers_or_packets_15_8 = 2; //SPS/PPS - conf.src_encrypt_mode_17_16 = 0;//clear=0;//PR 1 - input.conf = conf; - input.frame_offset = secBuffer->base_offset + secBuffer->partitions.src.offset; - input.metadata_offset = secBuffer->base_offset + secBuffer->partitions.metadata.offset; - - ret = SecPassThrough((uint8_t*)&input, sizeof(input), (uint8_t*)&output, sizeof(output)); - - if(ret == OMX_ErrorNone) { - // Assemble parsed frame information - // NALU data - uint8_t *nalu_data = secBuffer->base + secBuffer->partitions.headers.offset; - uint32_t nalu_data_size = output.parsed_data_size; - memcpy(config_nalu, nalu_data, nalu_data_size); - config_nalu_len = nalu_data_size; - } - } - - if ( ret == OMX_ErrorNone) { - conf.num_headers_or_packets_15_8 = secBuffer->pes_packet_count; //SS - conf.src_encrypt_mode_17_16 = secBuffer->clear?0:1;//clear=0;//PR 1 - input.conf = conf; - - if (secBuffer->mdrm_info.config_len) { - input.metadata_offset =SEC_DMA_ALIGN( secBuffer->base_offset + secBuffer->partitions.metadata.offset + 24); - input.frame_offset = secBuffer->mdrm_info.config_frame_offset; - } else { - input.frame_offset = secBuffer->base_offset + secBuffer->partitions.src.offset; - input.metadata_offset = secBuffer->base_offset + secBuffer->partitions.metadata.offset; - } - ret = SecPassThrough((uint8_t*)&input, sizeof(input), (uint8_t*)&output, sizeof(output)); - *parsed_data_size = output.parsed_data_size; - } - secBuffer->pes_packet_count = 0; - return ret; -} - -// Manage PAVP Session - destroy & re-create for Auto-tear-down -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::ManagePAVPSession(bool force_recreate) { - LOGV("%s", __FUNCTION__); - - // PAVP auto teardown: check if PAVP session is alive - bool balive = false; - pavp_lib_session::pavp_lib_code rc = pavp_lib_session::status_ok; - rc = mpLibInstance->pavp_is_session_alive(&balive); - if (rc != pavp_lib_session::status_ok) { - LOGE("pavp_is_session_alive failed with error 0x%x", rc); - return OMX_ErrorNotReady; - } - - if (!balive || force_recreate) { - - LOGI("PAVP session is %s", balive?"active":"in-active"); - //Destroy & re-create - LOGI("Destroying the PAVP session..."); - rc = mpLibInstance->pavp_destroy_session(); - if (rc != pavp_lib_session::status_ok) { - LOGE("pavp_destroy_session failed with error 0x%x", rc); - return OMX_ErrorNotReady; - } - - // Frames in the video decoder DPB are encrypted with the - // PAVP heavy mode key (IED key) for the destroyed session. - // Flush video decoder to remove them. - mVideoDecoder->flush(); - - mpLibInstance = NULL; - mDropUntilIDR = true; - } - return OMX_ErrorNone; - -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::PrepareDecodeBuffer(OMX_BUFFERHEADERTYPE *buffer, buffer_retain_t *retain, VideoDecodeBuffer *p) { - OMX_ERRORTYPE ret; - ret = OMXVideoDecoderBase::PrepareDecodeBuffer(buffer, retain, p); - CHECK_RETURN_VALUE("OMXVideoDecoderBase::PrepareDecodeBuffer"); - - if (buffer->nFilledLen == 0) { - return OMX_ErrorNone; - } - p->flag |= HAS_COMPLETE_FRAME; - - if (buffer->nOffset != 0) { - LOGW("buffer offset %lu is not zero!!!", buffer->nOffset); - } - - OMXSecureBuffer *secureBuffer = (OMXSecureBuffer*)buffer->pBuffer; - if(!secureBuffer) { - LOGE("OMXSecureBuffer is NULL"); - return OMX_ErrorBadParameter; - } - SECVideoBuffer *secBuffer = (SECVideoBuffer*)secureBuffer->secBuffer; - if(!secureBuffer) { - LOGE("SECVideoBuffer is NULL"); - return OMX_ErrorBadParameter; - } - - // OMX_BUFFERFLAG_CODECCONFIG is an optional flag - // if flag is set, buffer will only contain codec data. - if ( (buffer->nFlags & OMX_BUFFERFLAG_CODECCONFIG) && - (secBuffer->drm_type == DRM_TYPE_CLASSIC_WV)) { - LOGV("Received AVC codec data."); - return ret; - } - - uint32_t parsed_data_size = 0; - - if(secBuffer->drm_type == DRM_TYPE_CLASSIC_WV) { - - if(!mpLibInstance && secBuffer->pLibInstance) { - mpLibInstance = secBuffer->pLibInstance; - if( CreatePavpSession() == OMX_ErrorNone) { - ret = WvSetTranscriptKey(); - } - } - ret = ManagePAVPSession(ret == OMX_ErrorNotReady); - - if ( ret == OMX_ErrorNone) { - ret = ClassicProcessVideoFrame(secBuffer, &parsed_data_size); - } - } - else if(secBuffer->drm_type == DRM_TYPE_MDRM) { - - if(!mpLibInstance && secBuffer->pLibInstance) { - mpLibInstance = secBuffer->pLibInstance; - if( CreatePavpSession() == OMX_ErrorNone) { - ret = MdrmInjectKey(secBuffer->mdrm_info.session_id, secBuffer->mdrm_info.key_id); - } - } - ret = ManagePAVPSession(ret == OMX_ErrorNotReady); - if( ret == OMX_ErrorNone) { - ret = ModularProcessVideoFrame(secBuffer, &parsed_data_size); - } - } else { - LOGE("Invalid DRM_TYPE: 0x%x passed!", secBuffer->drm_type); - ret = OMX_ErrorNotReady; - } - - SECParsedFrame* parsedFrame = &(mParsedFrames[secureBuffer->index]); - if(ret == OMX_ErrorNone) { - // Assemble parsed frame information - // NALU data - parsedFrame->nalu_data = secBuffer->base + secBuffer->partitions.headers.offset; - parsedFrame->nalu_data_size = parsed_data_size; - if (secBuffer->mdrm_info.config_len) { - update_config_nalu(parsedFrame->nalu_data, &(parsedFrame->nalu_data_size)); - } - memcpy(parsedFrame->pavp_info.iv, secBuffer->iv, 16); - - ret = ConstructFrameInfo(secBuffer->base + secBuffer->partitions.dest.offset, buffer->nFilledLen, - &(parsedFrame->pavp_info), parsedFrame->nalu_data, parsedFrame->nalu_data_size, - &(parsedFrame->frame_info)); - - if(parsedFrame->frame_info.num_nalus == 0 ) { - LOGE("NALU parsing failed - num_nalus = 0!"); - ret = OMX_ErrorNotReady; - } - if(mDropUntilIDR) { - bool idr = false; - for(uint32_t n = 0; n < parsedFrame->frame_info.num_nalus; n++) { - if((parsedFrame->frame_info.nalus[n].type & 0x1F) == h264_NAL_UNIT_TYPE_IDR) { - idr = true; - break; - } - } - if(idr) { - LOGD("IDR frame found; restoring playback."); - mDropUntilIDR = false; - } else { - LOGD("Dropping non-IDR frame."); - ret = OMX_ErrorNotReady; - } - } - } - if(ret == OMX_ErrorNone) { - // Pass frame info to VideoDecoderAVCSecure in VideoDecodeBuffer - p->data = (uint8_t *)&(parsedFrame->frame_info); - p->size = sizeof(frame_info_t); - p->flag |= IS_SECURE_DATA; - } - - return ret; -} - -OMX_COLOR_FORMATTYPE OMXVideoDecoderAVCSecure::GetOutputColorFormat(int width, int height) { - // BYT HWC expects Tiled output color format for all resolution - return OMX_INTEL_COLOR_FormatYUV420PackedSemiPlanar_Tiled; -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::BuildHandlerList(void) { - OMXVideoDecoderBase::BuildHandlerList(); - AddHandler(OMX_IndexParamVideoAvc, GetParamVideoAvc, SetParamVideoAvc); - AddHandler(OMX_IndexParamVideoProfileLevelQuerySupported, GetParamVideoAVCProfileLevel, SetParamVideoAVCProfileLevel); - AddHandler(static_cast<OMX_INDEXTYPE> (OMX_IndexExtEnableNativeBuffer), GetNativeBufferMode, SetNativeBufferMode); - return OMX_ErrorNone; -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::GetParamVideoAvc(OMX_PTR pStructure) { - OMX_ERRORTYPE ret; - OMX_VIDEO_PARAM_AVCTYPE *p = (OMX_VIDEO_PARAM_AVCTYPE *)pStructure; - CHECK_TYPE_HEADER(p); - CHECK_PORT_INDEX(p, INPORT_INDEX); - - memcpy(p, &mParamAvc, sizeof(*p)); - return OMX_ErrorNone; -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::SetParamVideoAvc(OMX_PTR pStructure) { - OMX_ERRORTYPE ret; - OMX_VIDEO_PARAM_AVCTYPE *p = (OMX_VIDEO_PARAM_AVCTYPE *)pStructure; - CHECK_TYPE_HEADER(p); - CHECK_PORT_INDEX(p, INPORT_INDEX); - CHECK_SET_PARAM_STATE(); - - // TODO: do we need to check if port is enabled? - // TODO: see SetPortAvcParam implementation - Can we make simple copy???? - memcpy(&mParamAvc, p, sizeof(mParamAvc)); - return OMX_ErrorNone; -} - - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::GetParamVideoAVCProfileLevel(OMX_PTR pStructure) { - OMX_ERRORTYPE ret; - OMX_VIDEO_PARAM_PROFILELEVELTYPE *p = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pStructure; - CHECK_TYPE_HEADER(p); - CHECK_PORT_INDEX(p, INPORT_INDEX); - CHECK_ENUMERATION_RANGE(p->nProfileIndex,1); - - p->eProfile = mParamAvc.eProfile; - p->eLevel = mParamAvc.eLevel; - - return OMX_ErrorNone; -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::SetParamVideoAVCProfileLevel(OMX_PTR pStructure) { - LOGW("SetParamVideoAVCProfileLevel is not supported."); - return OMX_ErrorUnsupportedSetting; -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::GetNativeBufferMode(OMX_PTR pStructure) { - LOGE("GetNativeBufferMode is not implemented"); - return OMX_ErrorNotImplemented; -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::SetNativeBufferMode(OMX_PTR pStructure) { - OMXVideoDecoderBase::SetNativeBufferMode(pStructure); - PortVideo *port = NULL; - port = static_cast<PortVideo *>(this->ports[OUTPORT_INDEX]); - - OMX_PARAM_PORTDEFINITIONTYPE port_def; - memcpy(&port_def,port->GetPortDefinition(),sizeof(port_def)); - port_def.format.video.eColorFormat = OMX_INTEL_COLOR_FormatYUV420PackedSemiPlanar_Tiled; - port->SetPortDefinition(&port_def,true); - - return OMX_ErrorNone; -} - -OMX_U8* OMXVideoDecoderAVCSecure::MemAllocSecure(OMX_U32 nSizeBytes, OMX_PTR pUserData) { - OMXVideoDecoderAVCSecure* p = (OMXVideoDecoderAVCSecure *)pUserData; - if (p) { - return p->MemAllocSecure(nSizeBytes); - } - LOGE("NULL pUserData."); - return NULL; -} - -void OMXVideoDecoderAVCSecure::MemFreeSecure(OMX_U8 *pBuffer, OMX_PTR pUserData) { - OMXVideoDecoderAVCSecure* p = (OMXVideoDecoderAVCSecure *)pUserData; - if (p) { - p->MemFreeSecure(pBuffer); - return; - } - LOGE("NULL pUserData."); -} - -OMX_U8* OMXVideoDecoderAVCSecure::MemAllocSecure(OMX_U32 nSizeBytes) { - // Ignore passed nSizeBytes, use INPORT_BUFFER_SIZE instead - - uint32_t index = 0; - do { - if(mOMXSecureBuffers[index] == NULL) { - break; - } - } while(++index < INPORT_ACTUAL_BUFFER_COUNT); - - if(index >= INPORT_ACTUAL_BUFFER_COUNT) { - LOGE("No free buffers"); - return NULL; - } - - mOMXSecureBuffers[index] = new OMXSecureBuffer; - if(!mOMXSecureBuffers[index]) { - LOGE("Failed to allocate OMXSecureBuffer."); - return NULL; - } - - mOMXSecureBuffers[index]->index = index; - // SEC buffer will by assigned by WVCrypto - mOMXSecureBuffers[index]->secBuffer = NULL; - - return (OMX_U8*)mOMXSecureBuffers[index]; -} - -void OMXVideoDecoderAVCSecure::MemFreeSecure(OMX_U8 *pBuffer) { - OMXSecureBuffer *p = (OMXSecureBuffer*) pBuffer; - if (p == NULL) { - return; - } - - uint32_t index = p->index; - if(mOMXSecureBuffers[index] == p) { - delete(p); - mOMXSecureBuffers[index] = NULL; - } else { - LOGE("ERROR: pBuffer (%p) does not match mOMXSecureBuffer[%d] pointer (%p)", p, index, mOMXSecureBuffers[index]); - } -} - -// Byteswap slice header (SEC returns the slice header with fields in big-endian byte order) -inline void byteswap_slice_header(slice_header_t* slice_header) { - // Byteswap the fields of slice_header - slice_header->first_mb_in_slice = bswap_32(slice_header->first_mb_in_slice); - slice_header->frame_num = bswap_32(slice_header->frame_num); - slice_header->idr_pic_id = bswap_16(slice_header->idr_pic_id); - slice_header->pic_order_cnt_lsb = bswap_16(slice_header->pic_order_cnt_lsb); - slice_header->delta_pic_order_cnt_bottom = bswap_32(slice_header->delta_pic_order_cnt_bottom); - slice_header->delta_pic_order_cnt[0] = bswap_32(slice_header->delta_pic_order_cnt[0]); - slice_header->delta_pic_order_cnt[1] = bswap_32(slice_header->delta_pic_order_cnt[1]); -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::ConstructFrameInfo( - uint8_t* frame_data, - uint32_t frame_size, - pavp_info_t* pavp_info, - uint8_t* nalu_data, - uint32_t nalu_data_size, - frame_info_t* frame_info) { - - uint32_t* dword_ptr = (uint32_t*)nalu_data; - uint8_t* byte_ptr = NULL; - uint32_t data_size = 0; - - frame_info->data = frame_data; - frame_info->length = frame_size; - frame_info->pavp = pavp_info; - frame_info->dec_ref_pic_marking = NULL; - - // Byteswap nalu data (SEC returns fields in big-endian byte order) - frame_info->num_nalus = bswap_32(*dword_ptr); - dword_ptr++; - for(uint32_t n = 0; n < frame_info->num_nalus; n++) { - // Byteswap offset - frame_info->nalus[n].offset = bswap_32(*dword_ptr); - dword_ptr++; - - // Byteswap nalu_size - frame_info->nalus[n].length = bswap_32(*dword_ptr); - dword_ptr++; - - // Byteswap data_size - data_size = bswap_32(*dword_ptr); - dword_ptr++; - - byte_ptr = (uint8_t*)dword_ptr; - frame_info->nalus[n].type = *byte_ptr; - switch(frame_info->nalus[n].type & 0x1F) { - case h264_NAL_UNIT_TYPE_SPS: - case h264_NAL_UNIT_TYPE_PPS: - case h264_NAL_UNIT_TYPE_SEI: - // Point to cleartext in nalu data buffer - frame_info->nalus[n].data = byte_ptr; - frame_info->nalus[n].slice_header = NULL; - break; - case h264_NAL_UNIT_TYPE_SLICE: - case h264_NAL_UNIT_TYPE_IDR: - // Point to ciphertext in frame buffer - frame_info->nalus[n].data = frame_info->data + frame_info->nalus[n].offset; - byteswap_slice_header((slice_header_t*)byte_ptr); - frame_info->nalus[n].slice_header = (slice_header_t*)byte_ptr; - if(data_size > sizeof(slice_header_t)) { - byte_ptr += sizeof(slice_header_t); - frame_info->dec_ref_pic_marking = (dec_ref_pic_marking_t*)byte_ptr; - } - break; - default: - LOGE("ERROR: SEC returned an unsupported NALU type: %x", frame_info->nalus[n].type); - frame_info->nalus[n].data = NULL; - frame_info->nalus[n].slice_header = NULL; - break; - } - - // Advance to next NALU (including padding) - dword_ptr += (data_size + 3) >> 2; - } - - return OMX_ErrorNone; -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::SetMaxOutputBufferCount(OMX_PARAM_PORTDEFINITIONTYPE *p) { - OMX_ERRORTYPE ret; - CHECK_TYPE_HEADER(p); - CHECK_PORT_INDEX(p, OUTPORT_INDEX); - - p->nBufferCountActual = OUTPORT_NATIVE_BUFFER_COUNT; - return OMXVideoDecoderBase::SetMaxOutputBufferCount(p); -} -DECLARE_OMX_COMPONENT("OMX.Intel.hw_vd.h264.secure", "video_decoder.avc", OMXVideoDecoderAVCSecure); diff --git a/videocodec/securevideo/baytrail/OMXVideoDecoderAVCSecure.h b/videocodec/securevideo/baytrail/OMXVideoDecoderAVCSecure.h deleted file mode 100644 index 9f4de21..0000000 --- a/videocodec/securevideo/baytrail/OMXVideoDecoderAVCSecure.h +++ /dev/null @@ -1,237 +0,0 @@ -/* -* Copyright (c) 2009-2013 Intel Corporation. All rights reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef OMX_VIDEO_DECODER_AVC_SECURE_H_ -#define OMX_VIDEO_DECODER_AVC_SECURE_H_ - -#include <utils/Mutex.h> -#include "OMXVideoDecoderBase.h" -#include "libpavp.h" -#include "widevine.h" -#include "secvideoparser.h" - -#define SEC_DMA_ALIGN(x) (((x)+0x1F)&(~0x1F)) -#define DRM_TYPE_CLASSIC_WV 0x0 -#define DRM_TYPE_MDRM 0x1 - -// Must match the same structs defined in WVCrypto.h -#pragma pack(push, 1) -typedef struct { - uint32_t offset; - uint32_t size; -} sec_partition_t; -typedef struct { - sec_partition_t src; - sec_partition_t dest; - sec_partition_t metadata; - sec_partition_t headers; -} video_partition_t; -typedef struct { - uint8_t config[64]; - uint8_t config_len; - uint32_t config_frame_offset; - uint8_t key_id[16]; - uint32_t key_id_len; - uint8_t session_id; -} mdrm_meta; -typedef struct { - pavp_lib_session* pLibInstance; - uint8_t* base; - uint32_t size; - uint32_t base_offset; - video_partition_t partitions; - uint32_t frame_size; - uint32_t src_fill; - uint8_t pes_packet_count; - uint8_t clear; - mdrm_meta mdrm_info; - uint8_t drm_type; //0 -> Classic, 1 -> MDRM - uint8_t iv[16]; -} SECVideoBuffer; -typedef struct { - uint32_t index; - SECVideoBuffer* secBuffer; -} OMXSecureBuffer; -#pragma pack(pop) - -//Function Codes -typedef enum { - wv2_begin = 0x000C0001, - wv2_open_session = wv2_begin, - wv2_generate_nonce, - wv2_generate_derived_keys, - wv2_generate_hmac_signature, - wv2_load_keys, - wv2_refresh_keys, - wv2_select_key, - wv2_inject_key, - wv2_rewrap_device_RSA_key, - wv2_load_device_RSA_key, - wv2_generate_RSA_signature, - wv2_derived_sessionkeys, - wv2_process_video_frame, - wv2_decrypt_ctr, - wv2_generic_encrypt, - wv2_generic_decrypt, - wv2_generic_sign, - wv2_generic_verify_signature, - wv2_close_session, - wv2_dbg_get_keys, - wv2_delete_nonce, -} wv2_heci_command_id; - - -typedef struct { - uint32_t dest_encrypt_mode_25_24 : 2; - uint32_t reserved_31_26 : 6; - uint32_t src_encrypt_mode_17_16 : 2; - uint32_t reserved_23_18 : 6; - uint32_t num_headers_or_packets_15_8 : 8; - uint32_t drm_type_1_0 : 2; - uint32_t reserved_7_2 : 6; -} transcript_conf; -/*processvidoe frame*/ -typedef struct { - PAVP_CMD_HEADER Header; - transcript_conf conf; - uint32_t key_index; - uint32_t frame_offset; - uint32_t metadata_offset; - uint32_t header_offset; - uint32_t dest_offset; - uint8_t key_id[16]; -} process_video_frame_in; -typedef struct { - PAVP_CMD_HEADER Header; - uint32_t parsed_data_size; - uint8_t key_id[16]; - uint8_t key[16]; - // uint32_t frame_size; - uint8_t iv[16]; -} process_video_frame_out; - -/*wv2_inject_key*/ -typedef struct { - PAVP_CMD_HEADER Header; - uint32_t session_id; - uint32_t StreamId; - transcript_conf conf; - uint32_t key_id_len; - uint8_t key_id[16]; -} wv2_inject_key_in; - -typedef struct { - PAVP_CMD_HEADER Header; -// uint8_t enc_content_key[16]; -} wv2_inject_key_out; - - -/*wv2_process_video_frame*/ -typedef struct { - PAVP_CMD_HEADER Header; - transcript_conf conf; - uint32_t session_id; - uint32_t frame_offset; - uint32_t metadata_offset; - uint32_t header_offset; - uint32_t dest_offset; - uint32_t key_id_len; - uint8_t key_id[16]; -} wv2_process_video_frame_in; - -//typedef PAVP_CMD_NODATA wv2_process_video_frame_out -typedef struct { - PAVP_CMD_HEADER Header; - uint32_t parsed_data_size;; - //uint8_t iv[16]; ////////this is temporary -} wv2_process_video_frame_out; - -class OMXVideoDecoderAVCSecure : public OMXVideoDecoderBase { -public: - OMXVideoDecoderAVCSecure(); - virtual ~OMXVideoDecoderAVCSecure(); - -protected: - virtual OMX_ERRORTYPE InitInputPortFormatSpecific(OMX_PARAM_PORTDEFINITIONTYPE *paramPortDefinitionInput);; - virtual OMX_ERRORTYPE ProcessorStop(void); - virtual OMX_ERRORTYPE ProcessorProcess( - OMX_BUFFERHEADERTYPE ***pBuffers, - buffer_retain_t *retains, - OMX_U32 numberBuffers); - - virtual OMX_ERRORTYPE PrepareConfigBuffer(VideoConfigBuffer *p); - virtual OMX_ERRORTYPE PrepareDecodeBuffer(OMX_BUFFERHEADERTYPE *buffer, buffer_retain_t *retain, VideoDecodeBuffer *p); - virtual OMX_COLOR_FORMATTYPE GetOutputColorFormat(int width, int height); - - virtual OMX_ERRORTYPE BuildHandlerList(void); - virtual OMX_ERRORTYPE SetMaxOutputBufferCount(OMX_PARAM_PORTDEFINITIONTYPE *p); - DECLARE_HANDLER(OMXVideoDecoderAVCSecure, ParamVideoAvc); - DECLARE_HANDLER(OMXVideoDecoderAVCSecure, ParamVideoAVCProfileLevel); - DECLARE_HANDLER(OMXVideoDecoderAVCSecure, NativeBufferMode); - - static OMX_U8* MemAllocSecure(OMX_U32 nSizeBytes, OMX_PTR pUserData); - static void MemFreeSecure(OMX_U8 *pBuffer, OMX_PTR pUserData); - OMX_U8* MemAllocSecure(OMX_U32 nSizeBytes); - void MemFreeSecure(OMX_U8 *pBuffer); - - OMX_ERRORTYPE ConstructFrameInfo(uint8_t* frame_data, uint32_t frame_size, - pavp_info_t* pavp_info, uint8_t* nalu_data, uint32_t nalu_data_size, - frame_info_t* frame_info); - -private: - - enum { - // WARNING: if these values are changed, please make corresponding changes - // in the SEC memory region partitioning in the OEMCrypto for BYT (secregion.h) - - // OMX_PARAM_PORTDEFINITIONTYPE - INPORT_MIN_BUFFER_COUNT = 1, - INPORT_ACTUAL_BUFFER_COUNT = 5, - INPORT_BUFFER_SIZE = 1382400, - - // for OMX_VIDEO_PARAM_INTEL_AVC_DECODE_SETTINGS - // default number of reference frame - NUM_REFERENCE_FRAME = 4, - - OUTPORT_NATIVE_BUFFER_COUNT = 20, - }; - - OMX_VIDEO_PARAM_AVCTYPE mParamAvc; - - OMXSecureBuffer* mOMXSecureBuffers[INPORT_ACTUAL_BUFFER_COUNT]; - - struct SECParsedFrame { - uint8_t* nalu_data; - uint32_t nalu_data_size; - pavp_info_t pavp_info; - frame_info_t frame_info; - }; - - SECParsedFrame mParsedFrames[INPORT_ACTUAL_BUFFER_COUNT]; - - pavp_lib_session *mpLibInstance; - bool mDropUntilIDR; - uint32_t mPAVPAppID; - OMX_ERRORTYPE CreatePavpSession(void); - OMX_ERRORTYPE SecPassThrough(uint8_t*, uint32_t, uint8_t*, uint32_t); - OMX_ERRORTYPE MdrmInjectKey(uint8_t, uint8_t*); - OMX_ERRORTYPE WvSetTranscriptKey(void); - OMX_ERRORTYPE ManagePAVPSession(bool); - OMX_ERRORTYPE ClassicProcessVideoFrame(SECVideoBuffer *secBuffer, uint32_t*); - OMX_ERRORTYPE ModularProcessVideoFrame(SECVideoBuffer *secBuffer, uint32_t*); -}; - -#endif /* OMX_VIDEO_DECODER_AVC_SECURE_H_ */ diff --git a/videocodec/securevideo/baytrail/secvideoparser.h b/videocodec/securevideo/baytrail/secvideoparser.h deleted file mode 100644 index bf10a71..0000000 --- a/videocodec/securevideo/baytrail/secvideoparser.h +++ /dev/null @@ -1,141 +0,0 @@ -/* INTEL CONFIDENTIAL -* Copyright (c) 2013 Intel Corporation. All rights reserved. -* -* The source code contained or described herein and all documents -* related to the source code ("Material") are owned by Intel -* Corporation or its suppliers or licensors. Title to the -* Material remains with Intel Corporation or its suppliers and -* licensors. The Material contains trade secrets and proprietary -* and confidential information of Intel or its suppliers and -* licensors. The Material is protected by worldwide copyright and -* trade secret laws and treaty provisions. No part of the Material -* may be used, copied, reproduced, modified, published, uploaded, -* posted, transmitted, distributed, or disclosed in any way without -* Intel's prior express written permission. -* -* No license under any patent, copyright, trade secret or other -* intellectual property right is granted to or conferred upon you -* by disclosure or delivery of the Materials, either expressly, by -* implication, inducement, estoppel or otherwise. Any license -* under such intellectual property rights must be express and -* approved by Intel in writing. -*/ - -#ifndef SEC_VIDEO_PARSER_H_ -#define SEC_VIDEO_PARSER_H_ - -#include <stdint.h> - -/* H264 start code values */ -typedef enum _h264_nal_unit_type -{ - h264_NAL_UNIT_TYPE_unspecified = 0, - h264_NAL_UNIT_TYPE_SLICE, - h264_NAL_UNIT_TYPE_DPA, - h264_NAL_UNIT_TYPE_DPB, - h264_NAL_UNIT_TYPE_DPC, - h264_NAL_UNIT_TYPE_IDR, - h264_NAL_UNIT_TYPE_SEI, - h264_NAL_UNIT_TYPE_SPS, - h264_NAL_UNIT_TYPE_PPS, - h264_NAL_UNIT_TYPE_Acc_unit_delimiter, - h264_NAL_UNIT_TYPE_EOSeq, - h264_NAL_UNIT_TYPE_EOstream, - h264_NAL_UNIT_TYPE_filler_data, - h264_NAL_UNIT_TYPE_SPS_extension, - h264_NAL_UNIT_TYPE_ACP = 19, - h264_NAL_UNIT_TYPE_Slice_extension = 20 -} h264_nal_unit_type_t; - -#define MAX_OP 16 - -enum dec_ref_pic_marking_flags { - IDR_PIC_FLAG = 0, - NO_OUTPUT_OF_PRIOR_PICS_FLAG, - LONG_TERM_REFERENCE_FLAG, - ADAPTIVE_REF_PIC_MARKING_MODE_FLAG -}; - -typedef struct _dec_ref_pic_marking_t { - union { - uint8_t flags; - struct { - uint8_t idr_pic_flag:1; - uint8_t no_output_of_prior_pics_flag:1; - uint8_t long_term_reference_flag:1; - uint8_t adaptive_ref_pic_marking_mode_flag:1; - }; - }; - struct { - uint8_t memory_management_control_operation; - union { - struct { - uint8_t difference_of_pic_nums_minus1; - } op1; - struct { - uint8_t long_term_pic_num; - } op2; - struct { - uint8_t difference_of_pic_nums_minus1; - uint8_t long_term_frame_idx; - } op3; - struct { - uint8_t max_long_term_frame_idx_plus1; - } op4; - struct { - uint8_t long_term_frame_idx; - } op6; - }; - } op[MAX_OP]; -} dec_ref_pic_marking_t; - -enum slice_header_flags { - FIELD_PIC_FLAG = 0, - BOTTOM_FIELD_FLAG -}; - -typedef struct _slice_header_t { - uint8_t nal_unit_type; - union { - uint8_t flags; - struct { - uint8_t field_pic_flag:1; - uint8_t bottom_field_flag:1; - }; - }; - uint8_t pps_id; - uint8_t padding; // Align the next field to a 32-bit address - uint32_t first_mb_in_slice; - uint32_t frame_num; - uint16_t idr_pic_id; - uint16_t pic_order_cnt_lsb; - int32_t delta_pic_order_cnt_bottom; - int32_t delta_pic_order_cnt[2]; -} slice_header_t; - -typedef struct { - uint8_t type; - uint32_t offset; - uint8_t* data; - uint32_t length; - slice_header_t* slice_header; -} nalu_info_t; - -typedef struct { - uint32_t iv[4]; - uint32_t mode; - uint32_t app_id; -} pavp_info_t; - -#define MAX_NUM_NALUS 20 - -typedef struct { - uint8_t* data; - uint32_t length; - pavp_info_t* pavp; - dec_ref_pic_marking_t* dec_ref_pic_marking; - uint32_t num_nalus; - nalu_info_t nalus[MAX_NUM_NALUS]; -} frame_info_t; - -#endif /* SEC_VIDEO_PARSER_H_ */ diff --git a/videocodec/securevideo/baytrail/widevine.h b/videocodec/securevideo/baytrail/widevine.h deleted file mode 100644 index 0bd0224..0000000 --- a/videocodec/securevideo/baytrail/widevine.h +++ /dev/null @@ -1,500 +0,0 @@ -/*++
-
- INTEL CONFIDENTIAL
- Copyright (c) 2013- Intel Corporation All Rights Reserved.
-
- The source code contained or described herein and all documents related to
- the source code ("Material") are owned by Intel Corporation or its
- suppliers or licensors. Title to the Material remains with Intel
- Corporation or its suppliers and licensors. The Material contains trade
- secrets and proprietary and confidential information of Intel or its
- suppliers and licensors. The Material is protected by worldwide copyright
- and trade secret laws and treaty provisions. No part of the Material may be
- used, copied, reproduced, modified, published, uploaded, posted, transmitted,
- distributed, or disclosed in any way without Intel's prior express written
- permission.
-
- No license under any patent, copyright, trade secret or other intellectual
- property right is granted to or conferred upon you by disclosure or delivery
- of the Materials, either expressly, by implication, inducement, estoppel or
- otherwise. Any license under such intellectual property rights must be
- express and approved by Intel in writing.
-
-File Name:
-
- widevine.h
-
-Abstract:
-
-
-
-Author:
-
- Ruan, Xiaoyu
- Patel, Arpit A
-
-Revision history:
-
- 3/17/2013: WV SEC FW API v0.19
- 3/21/2013: v0.30
- 3/29/2013: v0.40
- 4/4/2013: v0.43
- 4/8/2013: v0.45
- 4/11/2013: v0.50
- 4/24/2013: v0.51
-
---*/
-
-#ifndef __WIDEVINE_H
-#define __WIDEVINE_H
-
-#if 0
-#include "CompMgmt.h"
-#include "Heci.h"
-#include "Crypto.h"
-#include "Storage.h"
-#include "Memory.h"
-#include "MemDefs.h"
-#include <string.h>
-
-#include "PavpHeciApiCommonDefs.h"
-#include "PavpHeciApi.h"
-#include "PavpVideoKeyMgr.h"
-#include "PavpBaseKeyMgr.h"
-#include "GfxKeyMgrDefs.h"
-
-#include "dbg.h"
-#include "romapi.h"
-
-#include "bitstream.h"
-#include "decoder.h"
-#include "nalu.h"
-#include "sei.h"
-#include "sps.h"
-#include "pps.h"
-#include "slice_header.h"
-#include "flag.h"
-#endif
-
-#define WV_USE_SATT 1
-
-#define WV_1KB 1024
-#define WV_DEVICE_ID_SIZE 32
-#define WV_DEVICE_KEY_SIZE 16
-#define WV_KEY_DATA_SIZE 72
-#define MV_KEYBOX_MAGIC_SIZE 4
-#define WV_CRC_SIZE 4
-#define WV_MAGIC_SIZE 4
-#define WV_AES_IV_SIZE 16
-#define WV_AES_KEY_SIZE 16
-#define WV_AES_BLOCK_SIZE 16
-#define WV_MAX_PACKETS_IN_FRAME 20 /* 20*64K=1.3M, max frame size */
-#define WV_MAX_PACKET_SIZE (64*WV_1KB-1)
-#define WV_PARSED_BUFFER_SIZE (4*WV_1KB)
-#define WV_PER_DMA_SIZE (8*WV_1KB + 16 + 16) /* 16 is AES block size, for CTS last block. add 16 more for DMA alignment */
-#define WV_PARSER_BUF_EDGE 64
-#define WV_WORK_BUFFER_SIZE (WV_PER_DMA_SIZE+WV_PARSER_BUF_EDGE)
-#define WV_ECM_SIZE 32
-#define WV_FLAGS_SIZE 4
-#define WV_RAND_SIZE 32
-#define WV_API_VERSION 0x00010000
-#define WV_FRAME_METADATA_SIZE (WV_MAX_PACKETS_IN_FRAME*sizeof(wv_frame_metadata))
-#define WV_MALLOC_ALIGNMENT 32
-#define WV_MALLOC_TIMEOUT 0
-#define WV_DMA_ALIGNMENT 32
-#define WV_XCRIPT_DMA_OUT_SWAP (CIPHER_DST_SWAP)
-#define WV_OUT_MSG_FLAG 0x80000000
-#define WV_SATT_BASE SATT_2
-
-#define WV_CEILING(a,b) ((a)%(b)==0?(a):((a)/(b)+1)*(b))
-#define PREPRODUCTION (RomData.gBringupDataPtr->FuseMap.DevModeEnabled || RomData.gBringupDataPtr->FuseMap.JtagEnabled)
-#define WV_SWAP_DWORD(dword) (((dword) & 0x000000ff) << 24 | ((dword) & 0x0000ff00) << 8 | ((dword) & 0x00ff0000) >> 8 | ((dword) & 0xff000000) >> 24)
-#define WV_SWAP_SHORT(sho) (((sho) & (0x00ff)) << 8 | ((sho) & (0xff00)) >> 8)
-
-/**
- * @brief PAVP HECI message header.
- */
-typedef struct _PAVP_CMD_HEADER
-{
- UINT32 ApiVersion;
- UINT32 CommandId;
- UINT32 Status;
- UINT32 BufferLength;
-} PAVP_CMD_HEADER;
-
-typedef struct _PAVP_CMD_NODATA
-{
- PAVP_CMD_HEADER Header;
- // no data follows header
-} PAVP_CMD_NODATA;
-
-typedef int BOOL;
-
-typedef struct {
- uint8_t device_id[WV_DEVICE_ID_SIZE];
- uint8_t device_key[WV_DEVICE_KEY_SIZE];
- uint8_t key_data[WV_KEY_DATA_SIZE];
- uint8_t magic[WV_MAGIC_SIZE];
- uint8_t key_data_crc[WV_CRC_SIZE];
-} wv_keybox;
-
-typedef struct {
- uint32_t packet_byte_size; // number of bytes in this PES packet, same for input and output
- uint8_t packet_iv[WV_AES_IV_SIZE]; // IV used for CBC-CTS decryption, if the PES packet is encrypted
-} sec_wv_packet_metadata;
-
-typedef struct {
- sec_wv_packet_metadata *metadata_buffer;//WV_MAX_PACKETS_IN_FRAME * sizeof(wv_packet_metadata)
- uint32_t title_video_size;
-} wv_frame_metadata;
-
-/* wv_nalu and wv_nalu_headers are for host only. FW does not use */
-typedef struct {
- uint32_t imr_offset;
- uint32_t nalu_size;
- uint32_t data_size;
- uint8_t data[1]; //place holder. actual size is data_size
-} wv_nalu;
-
-/* wv_nalu and wv_nalu_headers are for host only. FW does not use */
-typedef struct {
- uint32_t num_nalu;
- wv_nalu drm_nalu[1];// place holder. actual size is num_nalu
-} wv_nalu_headers;
-
-#if 0
-typedef struct {
- wv_frame_metadata frame_metadata;
- uint32_t *frame_header; //WV_PARSED_BUFFER_SIZE, dynamic allocation from locked memory
- uint8_t *frame_proc_buffer;// size = WV_PER_DMA_SIZE, dynamic allocation from locked memory
- uint8_t *work_buffer;// size = WV_WORK_BUFFER_SIZE, dynamic allocation from locked memory
- uint8_t *parser_work_buffer;// size = WV_WORK_BUFFER_SIZE, dynamic allocation from locked memory
- uint8_t asset_key[WV_AES_KEY_SIZE];
- BOOL asset_key_valid;
- uint8_t title_key[WV_AES_KEY_SIZE];
- uint8_t title_decrypt_key[WV_AES_KEY_SIZE];
- BOOL title_key_valid;
- uint8_t pavp_key[WV_AES_KEY_SIZE];
- BOOL pavp_key_valid;
- uint8_t pavp_counter[WV_AES_IV_SIZE];
- decoder_ctx_t decoder;
- uint32_t video_frame_count;
- BOOL bypass_transcryption;
- uint32_t audio_frame_count;
- uint32_t time_start; /*timer starts at first frame of a video frame*/
- uint32_t time_end; /*timer ends at title_complete*/
- uint32_t time_start_heci;
- uint32_t time_heci;
- uint32_t time_dma_in;
- uint32_t time_decrypt;
- uint32_t time_parse;
- uint32_t time_encrypt_dma_out;
-} wv_title_context;
-
-typedef struct {
-#if !WV_USE_SATT
- uint32_t host_phy_mem_lo;
- uint32_t host_phy_mem_hi;
- uint32_t host_phy_mem_size;
- BOOL host_phy_mem_valid;
-#endif
- wv_keybox keybox;
- BOOL keybox_valid;
- wv_title_context title;
- PAVP_STREAM_ID wvVideoStreamSlot;
-} wv_context;
-#endif
-
-/*******************
- * HECI APIs
- *******************/
-
-typedef enum {
- WV_SUCCESS = 0,
- WV_SUCCESS_PRIV_DATA = 0x80000000,
- WV_FAIL_INVALID_PARAMS = 0x000F0001,
- WV_FAIL_INVALID_INPUT_HEADER,
- WV_FAIL_NOT_PROVISIONED,
- WV_FAIL_BAD_KEYBOX_CRC,
- WV_FAIL_UNKNOWN_ERROR,
- WV_FAIL_HDCP_OFF,
- WV_FAIL_NO_HOST_MEM,
- WV_FAIL_NOT_EXPECTED,
- WV_FAIL_INVALID_AUDIO_FRAME,
- WV_FAIL_KEYBOX_INVALID_BAD_PROVISIONING,
- WV_FAIL_KEYBOX_INVALID_BAD_MAGIC,
- WV_FAIL_WV_NO_ASSET_KEY,
- WV_FAIL_WV_NO_CEK,
- WV_FAIL_REACHED_HOST_MEM_LIMIT,
- WV_FAIL_WV_SESSION_NALU_PARSE_FAILURE,
- WV_FAIL_WV_SESSION_NALU_PARSE_TOO_MANY_HEADERS,
- WV_FAIL_GENERATE_RANDOM_NUMBER_FAILURE,
- WV_FAIL_AES_CBC_FAILURE,
- WV_FAIL_AES_XCRIPT_FAILURE,
- WV_FAIL_AES_ECB_FAILURE,
- WV_FAIL_BLOB_ERROR,
- WV_FAIL_BAD_AUDIO_CLEAR_PKT,
- WV_FAIL_NO_TITLE_KEY,
- WV_FAIL_OUT_OF_MEMORY,
- WV_FAIL_PAVP_INJECT_KEY_ERROR,
- WV_FAIL_MSG_NOT_FROM_RING_0,
- WV_FAIL_DMA_READ,
- WV_FAIL_DMA_WRITE,
- WV_FAIL_DMA_WRITE_HEADER,
- WV_FAIL_INVALID_TITLE_KEY,
- WV_FAIL_INVALID_PAVP_KEY,
- WV_FAIL_INVALID_NUM_OF_PACKETS,
- WV_FAIL_PAVP_INIT_NOT_COMPLETE,
- WV_FAIL_STATUS_CHAIN_NOT_INITIALIZED,
- WV_FAIL_OUTPUT_HOST_MEM_OVERLAP,
- WV_FAIL_NOT_SUPPORTED
-} wv_heci_status;
-
-typedef enum {
- wv_init_dma = 0x000A0002,
- wv_heci_begin = wv_init_dma,
- wv_get_random,
- wv_get_keybox_data,
- wv_set_xcript_key,
- wv_set_entitlement_key,
- wv_derive_control_word,
- wv_process_video_frame,
- wv_process_audio_frame,
- wv_title_completed,
- wv_uninit_dma,
- wv_heci_end = wv_uninit_dma,
- wv_dbg_get_title_key = 0x000A00F0,
- wv_heci_dbg_begin = wv_dbg_get_title_key,
- wv_dbg_get_xcript_key,
- wv_dbg_dis_xcript_enc,
- wv_dbg_en_xcript_enc,
- wv_dbg_get_diag,
- wv_dbg_set_keybox,
- wv_dbg_reset_keybox,
- wv_dbg_set_xcript_key_wo_pavp,
- wv_dbg_reset_xcript_key_wo_pavp,
- wv_heci_dbg_end = wv_dbg_reset_xcript_key_wo_pavp,
-
- wv_init_dma_rsp = (WV_OUT_MSG_FLAG | wv_init_dma),
- wv_get_random_rsp,
- wv_get_keybox_data_rsp,
- wv_set_xcript_key_rsp,
- wv_set_entitlement_key_rsp,
- wv_derive_control_word_rsp,
- wv_process_video_frame_rsp,
- wv_process_audio_frame_rsp,
- wv_title_completed_rsp,
- wv_uninit_dma_rsp,
- wv_dbg_get_title_key_rsp = (WV_OUT_MSG_FLAG | wv_dbg_get_title_key),
- wv_dbg_get_xcript_key_rsp,
- wv_dbg_dis_xcript_enc_rsp,
- wv_dbg_en_xcript_enc_rsp,
- wv_dbg_get_diag_rsp,
- wv_dbg_set_keybox_rsp,
- wv_dbg_reset_keybox_rsp,
- wv_dbg_set_xcript_key_wo_pavp_rsp,
- wv_dbg_reset_xcript_key_wo_pavp_rsp,
-} wv_heci_command_id;
-
-
-/*wv_init_dma*/
-typedef struct {
- PAVP_CMD_HEADER Header;
- uint32_t phy_mem_lo;
- uint32_t phy_mem_hi;
- uint32_t phy_mem_size;
-} wv_init_dma_in;
-
-typedef PAVP_CMD_NODATA wv_init_dma_out;
-
-/*wv_heci_get_random*/
-typedef struct {
- PAVP_CMD_HEADER Header;
- uint32_t size_in_bytes;
-} wv_heci_get_random_in;
-
-typedef struct {
- PAVP_CMD_HEADER Header;
- uint8_t random_bytes[WV_RAND_SIZE];
-} wv_heci_get_random_out;
-
-/*wv_heci_get_keybox_data*/
-typedef PAVP_CMD_NODATA wv_heci_get_keybox_data_in;
-
-typedef struct {
- PAVP_CMD_HEADER Header;
- uint8_t key_data[WV_KEY_DATA_SIZE];
- uint8_t device_id[WV_DEVICE_ID_SIZE];
-} wv_heci_get_keybox_data_out;
-
-//orig
-#if 0
-/*wv_set_xcript_key*/
-typedef PAVP_CMD_NODATA wv_set_xcript_key_in;
-#endif
-
-//for app-ID
-typedef struct {
- PAVP_CMD_HEADER Header;
- uint32_t StreamId;
-} wv_set_xcript_key_in;
-
-typedef struct {
- PAVP_CMD_HEADER Header;
- /* private data for driver. Size excluded in Header.Length
- * app caller: do not include this field*/
- //uint8_t wrapped_xcript_key[WV_AES_KEY_SIZE];// libpcp will take care of this. Remove this from OMX.
-} wv_set_xcript_key_out;
-
-/*wv_heci_set_entitlement_key*/
-typedef struct {
- PAVP_CMD_HEADER Header;
- uint8_t entitlement_key[WV_AES_KEY_SIZE];
-} wv_heci_set_entitlement_key_in;
-
-typedef PAVP_CMD_NODATA wv_heci_set_entitlement_key_out;
-
-/*wv_heci_derive_control_word*/
-typedef struct {
- PAVP_CMD_HEADER Header;
- uint8_t ecm[WV_ECM_SIZE];
-} wv_heci_derive_control_word_in;
-
-typedef struct {
- PAVP_CMD_HEADER Header;
- uint8_t flags[WV_FLAGS_SIZE];
-} wv_heci_derive_control_word_out;
-
-/*wv_heci_process_video_frame*/
-typedef struct {
- PAVP_CMD_HEADER Header;
- uint32_t num_of_packets;//<=20
- BOOL is_frame_not_encrypted;
- uint32_t src_offset;
- uint32_t dest_offset;
- uint32_t metadata_offset;
- uint32_t header_offset;
-} wv_heci_process_video_frame_in;
-
-typedef struct {
- PAVP_CMD_HEADER Header;
- uint32_t parsed_data_size;
- /* private data for driver. Size excluded in Header.Length
- * app caller: do not include this field*/ //Remove comment
- uint8_t iv[WV_AES_IV_SIZE];
-} wv_heci_process_video_frame_out;
-
-/*wv_heci_process_audio_frame*/
-typedef struct {
- PAVP_CMD_HEADER Header;
- uint32_t num_of_packets;//<=20
- BOOL is_frame_not_encrypted;
- uint32_t src_offset;
- uint32_t dest_offset;
- uint32_t metadata_offset;
-} wv_heci_process_audio_frame_in;
-
-typedef PAVP_CMD_NODATA wv_heci_process_audio_frame_out;
-
-/*wv_title_completed*/
-typedef PAVP_CMD_NODATA wv_title_completed_in;
-typedef PAVP_CMD_NODATA wv_title_completed_out;
-
-/*wv_dbg_get_title_key*/
-typedef PAVP_CMD_NODATA wv_dbg_get_title_key_in;
-
-typedef struct {
- PAVP_CMD_HEADER Header;
- BOOL title_key_valid;
- uint8_t title_key[WV_AES_KEY_SIZE];
-} wv_dbg_get_title_key_out;
-
-/*wv_uninit_dma*/
-typedef PAVP_CMD_NODATA wv_uninit_dma_in;
-typedef PAVP_CMD_NODATA wv_uninit_dma_out;
-
-/*wv_dbg_get_xcript_key*/
-typedef PAVP_CMD_NODATA wv_dbg_get_xcript_key_in;
-
-typedef struct {
- PAVP_CMD_HEADER Header;
- BOOL xcript_key_valid;
- uint8_t xcript_key[WV_AES_KEY_SIZE];
- uint8_t xcript_counter[WV_AES_IV_SIZE];
-} wv_dbg_get_xcript_key_out;
-
-/*wv_dbg_dis_xcript_enc*/
-typedef PAVP_CMD_NODATA wv_dbg_dis_xcript_enc_in;
-typedef PAVP_CMD_NODATA wv_dbg_dis_xcript_enc_out;
-
-/*wv_dbg_en_xcript_enc*/
-typedef PAVP_CMD_NODATA wv_dbg_en_xcript_enc_in;
-typedef PAVP_CMD_NODATA wv_dbg_en_xcript_enc_out;
-
-/*wv_dbg_get_diag*/
-typedef PAVP_CMD_NODATA wv_dbg_get_diag_in;
-
-typedef struct {
- PAVP_CMD_HEADER Header;
- uint16_t fw_major_ver;
- uint16_t fw_minor_ver;
- uint16_t fw_hotfix;
- uint16_t fw_build;
- BOOL production_part;
-#if !WV_USE_SATT
- uint32_t host_phy_mem_lo;
- uint32_t host_phy_mem_hi;
- uint32_t host_phy_mem_size;
- BOOL host_phy_mem_valid;
-#endif
- uint32_t video_frame_count;
- uint32_t audio_frame_count;
- uint32_t slice_count_for_this_frame;
- uint32_t total_slice_count_for_this_title;
- uint32_t bypass_transcryption : 1;
- uint32_t frame_header_valid : 1;
- uint32_t frame_proc_buffer_valid : 1;
- uint32_t work_buffer_valid : 1;
- uint32_t parser_work_buffer_valid : 1;
- uint32_t asset_key_valid_valid : 1;
- uint32_t title_key_valid_valid : 1;
- uint32_t pavp_key_valid : 1;
- uint32_t keybox_valid : 1;
- uint32_t reserved1 : 7;
- uint32_t wvVideoStreamSlot : 8;
- uint32_t reserved2 : 8;
- uint32_t time_start; /*timer starts at first frame of a video frame*/
- uint32_t time_end; /*timer ends at title_complete*/
- uint32_t time_elapsed; /*time_end - time_start, unit is microsecond*/
- uint32_t video_size;
- uint32_t throughput; /*bits/microsecond*/
- uint32_t time_heci;
- uint32_t time_dma_in;
- uint32_t time_decrypt;
- uint32_t time_parse;
- uint32_t time_encrypt_dma_out;
-} wv_dbg_get_diag_out;
-//C_ASSERT(sizeof(wv_dbg_get_diag_out) == WV_USE_SATT ? 64 : 48);
-
-/*wv_dbg_set_keybox*/
-typedef struct {
- PAVP_CMD_HEADER Header;
- wv_keybox keybox;
-} wv_dbg_set_keybox_in;
-
-typedef PAVP_CMD_NODATA wv_dbg_set_keybox_out;
-
-/*wv_dbg_reset_keybox*/
-typedef PAVP_CMD_NODATA wv_dbg_reset_keybox_in;
-typedef PAVP_CMD_NODATA wv_dbg_reset_keybox_out;
-
-/*wv_dbg_set_xcript_key_wo_pavp*/
-typedef PAVP_CMD_NODATA wv_dbg_set_xcript_key_wo_pavp_in;
-typedef PAVP_CMD_NODATA wv_dbg_set_xcript_key_wo_pavp_out;
-
-/*wv_dbg_reset_xcript_key_wo_pavp*/
-typedef PAVP_CMD_NODATA wv_dbg_reset_xcript_key_wo_pavp_in;
-typedef PAVP_CMD_NODATA wv_dbg_reset_xcript_key_wo_pavp_out;
-
-#endif
-
diff --git a/videocodec/securevideo/cherrytrail/OMXVideoDecoderAVCSecure.cpp b/videocodec/securevideo/cherrytrail/OMXVideoDecoderAVCSecure.cpp deleted file mode 100644 index 2e2fd09..0000000 --- a/videocodec/securevideo/cherrytrail/OMXVideoDecoderAVCSecure.cpp +++ /dev/null @@ -1,538 +0,0 @@ -/* -* Copyright (c) 2009-2013 Intel Corporation. All rights reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -//#define LOG_NDEBUG 0 -#define LOG_TAG "OMXVideoDecoder" -#include <wrs_omxil_core/log.h> -#include "OMXVideoDecoderAVCSecure.h" -#include <time.h> -#include <signal.h> -#include <pthread.h> -#include <stdlib.h> -#include <stdint.h> -#include <byteswap.h> - -#define LOGVAR(v) LOGD("LOGVAR: " #v " = %d", v) - -// Be sure to have an equal string in VideoDecoderHost.cpp (libmix) -static const char* AVC_MIME_TYPE = "video/avc"; -static const char* AVC_SECURE_MIME_TYPE = "video/avc-secure"; - -OMXVideoDecoderAVCSecure::OMXVideoDecoderAVCSecure() - : mpLibInstance(NULL), - mDropUntilIDR(false) { - LOGV("OMXVideoDecoderAVCSecure is constructed."); - mVideoDecoder = createVideoDecoder(AVC_SECURE_MIME_TYPE); - if (!mVideoDecoder) { - LOGE("createVideoDecoder failed for \"%s\"", AVC_SECURE_MIME_TYPE); - } - // Override default native buffer count defined in the base class - mNativeBufferCount = OUTPORT_NATIVE_BUFFER_COUNT; - - memset(mOMXSecureBuffers, 0, sizeof(mOMXSecureBuffers)); - memset(mParsedFrames, 0, sizeof(mParsedFrames)); - - BuildHandlerList(); -} - -OMXVideoDecoderAVCSecure::~OMXVideoDecoderAVCSecure() { - // Cleanup any buffers that weren't freed - for(int i = 0; i < INPORT_ACTUAL_BUFFER_COUNT; i++) { - if(mOMXSecureBuffers[i]) { - delete mOMXSecureBuffers[i]; - } - } - LOGV("OMXVideoDecoderAVCSecure is destructed."); -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::InitInputPortFormatSpecific(OMX_PARAM_PORTDEFINITIONTYPE *paramPortDefinitionInput) { - // OMX_PARAM_PORTDEFINITIONTYPE - paramPortDefinitionInput->nBufferCountActual = INPORT_ACTUAL_BUFFER_COUNT; - paramPortDefinitionInput->nBufferCountMin = INPORT_MIN_BUFFER_COUNT; - paramPortDefinitionInput->nBufferSize = INPORT_BUFFER_SIZE; - paramPortDefinitionInput->format.video.cMIMEType = (OMX_STRING)AVC_MIME_TYPE; - paramPortDefinitionInput->format.video.eCompressionFormat = OMX_VIDEO_CodingAVC; - - // OMX_VIDEO_PARAM_AVCTYPE - memset(&mParamAvc, 0, sizeof(mParamAvc)); - SetTypeHeader(&mParamAvc, sizeof(mParamAvc)); - mParamAvc.nPortIndex = INPORT_INDEX; - // TODO: check eProfile/eLevel - mParamAvc.eProfile = OMX_VIDEO_AVCProfileHigh; //OMX_VIDEO_AVCProfileBaseline; - mParamAvc.eLevel = OMX_VIDEO_AVCLevel41; //OMX_VIDEO_AVCLevel1; - - // Set memory allocator - this->ports[INPORT_INDEX]->SetMemAllocator(MemAllocSecure, MemFreeSecure, this); - - return OMX_ErrorNone; -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::ProcessorStop(void) { - // destroy PAVP session - if(mpLibInstance) { - pavp_lib_session::pavp_lib_code rc = pavp_lib_session::status_ok; - LOGI("Destroying the PAVP session...\n"); - rc = mpLibInstance->pavp_destroy_session(); - if (rc != pavp_lib_session::status_ok) - LOGE("pavp_destroy_session failed with error 0x%x\n", rc); - } - return OMXVideoDecoderBase::ProcessorStop(); -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::ProcessorProcess( - OMX_BUFFERHEADERTYPE ***pBuffers, - buffer_retain_t *retains, - OMX_U32 numberBuffers) { - - OMX_ERRORTYPE ret; - ret = OMXVideoDecoderBase::ProcessorProcess(pBuffers, retains, numberBuffers); - if (ret != OMX_ErrorNone) { - LOGE("OMXVideoDecoderBase::ProcessorProcess failed. Result: %#x", ret); - return ret; - } - - if (mDropUntilIDR) { - retains[OUTPORT_INDEX] = BUFFER_RETAIN_NOT_RETAIN; - OMX_BUFFERHEADERTYPE *pOutput = *pBuffers[OUTPORT_INDEX]; - pOutput->nFilledLen = 0; - return OMX_ErrorNone; - } - - return ret; -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::PrepareConfigBuffer(VideoConfigBuffer *p) { - OMX_ERRORTYPE ret; - ret = OMXVideoDecoderBase::PrepareConfigBuffer(p); - CHECK_RETURN_VALUE("OMXVideoDecoderBase::PrepareConfigBuffer"); - p->flag |= WANT_SURFACE_PROTECTION; - return ret; -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::PrepareDecodeBuffer(OMX_BUFFERHEADERTYPE *buffer, buffer_retain_t *retain, VideoDecodeBuffer *p) { - OMX_ERRORTYPE ret; - ret = OMXVideoDecoderBase::PrepareDecodeBuffer(buffer, retain, p); - CHECK_RETURN_VALUE("OMXVideoDecoderBase::PrepareDecodeBuffer"); - - if (buffer->nFilledLen == 0) { - return OMX_ErrorNone; - } - // OMX_BUFFERFLAG_CODECCONFIG is an optional flag - // if flag is set, buffer will only contain codec data. - if (buffer->nFlags & OMX_BUFFERFLAG_CODECCONFIG) { - LOGV("Received AVC codec data."); - return ret; - } - p->flag |= HAS_COMPLETE_FRAME; - - if (buffer->nOffset != 0) { - LOGW("buffer offset %lu is not zero!!!", buffer->nOffset); - } - - OMXSecureBuffer *secureBuffer = (OMXSecureBuffer*)buffer->pBuffer; - if(!secureBuffer) { - LOGE("OMXSecureBuffer is NULL"); - return OMX_ErrorBadParameter; - } - SECVideoBuffer *secBuffer = (SECVideoBuffer*)secureBuffer->secBuffer; - if(!secureBuffer) { - LOGE("SECVideoBuffer is NULL"); - return OMX_ErrorBadParameter; - } - - pavp_lib_session::pavp_lib_code rc = pavp_lib_session::status_ok; - - if(!mpLibInstance && secBuffer->pLibInstance) { - LOGE("PAVP Heavy session creation..."); - rc = secBuffer->pLibInstance->pavp_create_session(true); - if (rc != pavp_lib_session::status_ok) { - LOGE("PAVP Heavy: pavp_create_session failed with error 0x%x", rc); - ret = OMX_ErrorNotReady; - } else { - LOGE("PAVP Heavy session created succesfully"); - mpLibInstance = secBuffer->pLibInstance; - } - if ( ret == OMX_ErrorNone) { - pavp_lib_session::pavp_lib_code rc = pavp_lib_session::status_ok; - wv_set_xcript_key_in input; - wv_set_xcript_key_out output; - - input.Header.ApiVersion = WV_API_VERSION; - input.Header.CommandId = wv_set_xcript_key; - input.Header.Status = 0; - input.Header.BufferLength = sizeof(input)-sizeof(PAVP_CMD_HEADER); - - - if (secBuffer->pLibInstance) { - LOGV("calling wv_set_xcript_key"); - rc = secBuffer->pLibInstance->sec_pass_through( - reinterpret_cast<BYTE*>(&input), - sizeof(input), - reinterpret_cast<BYTE*>(&output), - sizeof(output)); - LOGV("wv_set_xcript_key returned %d", rc); - } - - if (rc != pavp_lib_session::status_ok) - LOGE("sec_pass_through:wv_set_xcript_key() failed with error 0x%x", rc); - - if (output.Header.Status) { - LOGE("SEC failed: wv_set_xcript_key() FAILED 0x%x", output.Header.Status); - ret = OMX_ErrorNotReady; - } - } - } - - if(mpLibInstance) { - // PAVP auto teardown: check if PAVP session is alive - bool balive = false; - pavp_lib_session::pavp_lib_code rc = pavp_lib_session::status_ok; - rc = mpLibInstance->pavp_is_session_alive(&balive); - if (rc != pavp_lib_session::status_ok) { - LOGE("pavp_is_session_alive failed with error 0x%x", rc); - } - - if (balive == false || (ret == OMX_ErrorNotReady)) { - - LOGE("PAVP session is %s", balive?"active":"in-active"); - ret = OMX_ErrorNotReady; - //Destroy & re-create - LOGI("Destroying the PAVP session..."); - rc = mpLibInstance->pavp_destroy_session(); - if (rc != pavp_lib_session::status_ok) - LOGE("pavp_destroy_session failed with error 0x%x", rc); - - // Frames in the video decoder DPB are encrypted with the - // PAVP heavy mode key (IED key) for the destroyed session. - // Flush video decoder to remove them. - mVideoDecoder->flush(); - - mpLibInstance = NULL; - mDropUntilIDR = true; - } - } - - wv_heci_process_video_frame_in input; - wv_heci_process_video_frame_out output; - if ( ret == OMX_ErrorNone) { - - input.Header.ApiVersion = WV_API_VERSION; - input.Header.CommandId = wv_process_video_frame; - input.Header.Status = 0; - input.Header.BufferLength = sizeof(input) - sizeof(PAVP_CMD_HEADER); - - input.num_of_packets = secBuffer->pes_packet_count; - input.is_frame_not_encrypted = secBuffer->clear; - input.src_offset = secBuffer->base_offset + secBuffer->partitions.src.offset; - input.dest_offset = secBuffer->base_offset + secBuffer->partitions.dest.offset; - input.metadata_offset = secBuffer->base_offset + secBuffer->partitions.metadata.offset; - input.header_offset = secBuffer->base_offset + secBuffer->partitions.headers.offset; - - memset(&output, 0, sizeof(wv_heci_process_video_frame_out)); - - if (secBuffer->pLibInstance) { - LOGV("calling wv_process_video_frame"); - rc = secBuffer->pLibInstance->sec_pass_through( - reinterpret_cast<BYTE*>(&input), - sizeof(input), - reinterpret_cast<BYTE*>(&output), - sizeof(output)); - LOGV("wv_process_video_frame returned %d", rc); - - if (rc != pavp_lib_session::status_ok) { - LOGE("%s PAVP Failed: 0x%x", __FUNCTION__, rc); - ret = OMX_ErrorNotReady; - } - - if (output.Header.Status != 0x0) { - LOGE("%s SEC Failed: wv_process_video_frame: 0x%x", __FUNCTION__, output.Header.Status); - ret = OMX_ErrorNotReady; - } - } - } - - SECParsedFrame* parsedFrame = &(mParsedFrames[secureBuffer->index]); - if(ret == OMX_ErrorNone) { - // Assemble parsed frame information - - // NALU data - parsedFrame->nalu_data = secBuffer->base + secBuffer->partitions.headers.offset; - parsedFrame->nalu_data_size = output.parsed_data_size; - - // Set up PAVP info - memcpy(parsedFrame->pavp_info.iv, output.iv, WV_AES_IV_SIZE); - - // construct frame_info - ret = ConstructFrameInfo(secBuffer->base + secBuffer->partitions.dest.offset, secBuffer->frame_size, - &(parsedFrame->pavp_info), parsedFrame->nalu_data, parsedFrame->nalu_data_size, - &(parsedFrame->frame_info)); - - if (parsedFrame->frame_info.num_nalus == 0 ) { - LOGE("NALU parsing failed - num_nalus = 0!"); - ret = OMX_ErrorNotReady; - } - - if(mDropUntilIDR) { - bool idr = false; - for(uint32_t n = 0; n < parsedFrame->frame_info.num_nalus; n++) { - if((parsedFrame->frame_info.nalus[n].type & 0x1F) == h264_NAL_UNIT_TYPE_IDR) { - idr = true; - break; - } - } - if(idr) { - LOGD("IDR frame found; restoring playback."); - mDropUntilIDR = false; - } else { - LOGD("Dropping non-IDR frame."); - ret = OMX_ErrorNotReady; - } - } - } - - if(ret == OMX_ErrorNone) { - // Pass frame info to VideoDecoderAVCSecure in VideoDecodeBuffer - p->data = (uint8_t *)&(parsedFrame->frame_info); - p->size = sizeof(frame_info_t); - p->flag = p->flag | IS_SECURE_DATA; - } - - return ret; -} - -OMX_COLOR_FORMATTYPE OMXVideoDecoderAVCSecure::GetOutputColorFormat(int width, int height) { - // CHT HWC expects Tiled output color format for all resolution - return OMX_INTEL_COLOR_FormatYUV420PackedSemiPlanar_Tiled; -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::BuildHandlerList(void) { - OMXVideoDecoderBase::BuildHandlerList(); - AddHandler(OMX_IndexParamVideoAvc, GetParamVideoAvc, SetParamVideoAvc); - AddHandler(OMX_IndexParamVideoProfileLevelQuerySupported, GetParamVideoAVCProfileLevel, SetParamVideoAVCProfileLevel); - AddHandler(static_cast<OMX_INDEXTYPE> (OMX_IndexExtEnableNativeBuffer), GetNativeBufferMode, SetNativeBufferMode); - return OMX_ErrorNone; -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::GetParamVideoAvc(OMX_PTR pStructure) { - OMX_ERRORTYPE ret; - OMX_VIDEO_PARAM_AVCTYPE *p = (OMX_VIDEO_PARAM_AVCTYPE *)pStructure; - CHECK_TYPE_HEADER(p); - CHECK_PORT_INDEX(p, INPORT_INDEX); - - memcpy(p, &mParamAvc, sizeof(*p)); - return OMX_ErrorNone; -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::SetParamVideoAvc(OMX_PTR pStructure) { - OMX_ERRORTYPE ret; - OMX_VIDEO_PARAM_AVCTYPE *p = (OMX_VIDEO_PARAM_AVCTYPE *)pStructure; - CHECK_TYPE_HEADER(p); - CHECK_PORT_INDEX(p, INPORT_INDEX); - CHECK_SET_PARAM_STATE(); - - // TODO: do we need to check if port is enabled? - // TODO: see SetPortAvcParam implementation - Can we make simple copy???? - memcpy(&mParamAvc, p, sizeof(mParamAvc)); - return OMX_ErrorNone; -} - - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::GetParamVideoAVCProfileLevel(OMX_PTR pStructure) { - OMX_ERRORTYPE ret; - OMX_VIDEO_PARAM_PROFILELEVELTYPE *p = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pStructure; - CHECK_TYPE_HEADER(p); - CHECK_PORT_INDEX(p, INPORT_INDEX); - CHECK_ENUMERATION_RANGE(p->nProfileIndex,1); - - p->eProfile = mParamAvc.eProfile; - p->eLevel = mParamAvc.eLevel; - - return OMX_ErrorNone; -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::SetParamVideoAVCProfileLevel(OMX_PTR pStructure) { - LOGW("SetParamVideoAVCProfileLevel is not supported."); - return OMX_ErrorUnsupportedSetting; -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::GetNativeBufferMode(OMX_PTR pStructure) { - LOGE("GetNativeBufferMode is not implemented"); - return OMX_ErrorNotImplemented; -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::SetNativeBufferMode(OMX_PTR pStructure) { - OMXVideoDecoderBase::SetNativeBufferMode(pStructure); - PortVideo *port = NULL; - port = static_cast<PortVideo *>(this->ports[OUTPORT_INDEX]); - - OMX_PARAM_PORTDEFINITIONTYPE port_def; - memcpy(&port_def,port->GetPortDefinition(),sizeof(port_def)); - port_def.format.video.eColorFormat = OMX_INTEL_COLOR_FormatYUV420PackedSemiPlanar_Tiled; - port->SetPortDefinition(&port_def,true); - - return OMX_ErrorNone; -} - -OMX_U8* OMXVideoDecoderAVCSecure::MemAllocSecure(OMX_U32 nSizeBytes, OMX_PTR pUserData) { - OMXVideoDecoderAVCSecure* p = (OMXVideoDecoderAVCSecure *)pUserData; - if (p) { - return p->MemAllocSecure(nSizeBytes); - } - LOGE("NULL pUserData."); - return NULL; -} - -void OMXVideoDecoderAVCSecure::MemFreeSecure(OMX_U8 *pBuffer, OMX_PTR pUserData) { - OMXVideoDecoderAVCSecure* p = (OMXVideoDecoderAVCSecure *)pUserData; - if (p) { - p->MemFreeSecure(pBuffer); - return; - } - LOGE("NULL pUserData."); -} - -OMX_U8* OMXVideoDecoderAVCSecure::MemAllocSecure(OMX_U32 nSizeBytes) { - // Ignore passed nSizeBytes, use INPORT_BUFFER_SIZE instead - - uint32_t index = 0; - do { - if(mOMXSecureBuffers[index] == NULL) { - break; - } - } while(++index < INPORT_ACTUAL_BUFFER_COUNT); - - if(index >= INPORT_ACTUAL_BUFFER_COUNT) { - LOGE("No free buffers"); - return NULL; - } - - mOMXSecureBuffers[index] = new OMXSecureBuffer; - if(!mOMXSecureBuffers[index]) { - LOGE("Failed to allocate OMXSecureBuffer."); - return NULL; - } - - mOMXSecureBuffers[index]->index = index; - // SEC buffer will by assigned by WVCrypto - mOMXSecureBuffers[index]->secBuffer = NULL; - - return (OMX_U8*)mOMXSecureBuffers[index]; -} - -void OMXVideoDecoderAVCSecure::MemFreeSecure(OMX_U8 *pBuffer) { - OMXSecureBuffer *p = (OMXSecureBuffer*) pBuffer; - if (p == NULL) { - return; - } - - uint32_t index = p->index; - if(mOMXSecureBuffers[index] == p) { - delete(p); - mOMXSecureBuffers[index] = NULL; - } else { - LOGE("ERROR: pBuffer (%p) does not match mOMXSecureBuffer[%d] pointer (%p)", p, index, mOMXSecureBuffers[index]); - } -} - -// Byteswap slice header (SEC returns the slice header with fields in big-endian byte order) -inline void byteswap_slice_header(slice_header_t* slice_header) { - // Byteswap the fields of slice_header - slice_header->first_mb_in_slice = bswap_32(slice_header->first_mb_in_slice); - slice_header->frame_num = bswap_32(slice_header->frame_num); - slice_header->idr_pic_id = bswap_16(slice_header->idr_pic_id); - slice_header->pic_order_cnt_lsb = bswap_16(slice_header->pic_order_cnt_lsb); - slice_header->delta_pic_order_cnt_bottom = bswap_32(slice_header->delta_pic_order_cnt_bottom); - slice_header->delta_pic_order_cnt[0] = bswap_32(slice_header->delta_pic_order_cnt[0]); - slice_header->delta_pic_order_cnt[1] = bswap_32(slice_header->delta_pic_order_cnt[1]); -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::ConstructFrameInfo( - uint8_t* frame_data, - uint32_t frame_size, - pavp_info_t* pavp_info, - uint8_t* nalu_data, - uint32_t nalu_data_size, - frame_info_t* frame_info) { - - uint32_t* dword_ptr = (uint32_t*)nalu_data; - uint8_t* byte_ptr = NULL; - uint32_t data_size = 0; - - frame_info->data = frame_data; - frame_info->length = frame_size; - frame_info->pavp = pavp_info; - frame_info->dec_ref_pic_marking = NULL; - - // Byteswap nalu data (SEC returns fields in big-endian byte order) - frame_info->num_nalus = bswap_32(*dword_ptr); - dword_ptr++; - for(uint32_t n = 0; n < frame_info->num_nalus; n++) { - // Byteswap offset - frame_info->nalus[n].offset = bswap_32(*dword_ptr); - dword_ptr++; - - // Byteswap nalu_size - frame_info->nalus[n].length = bswap_32(*dword_ptr); - dword_ptr++; - - // Byteswap data_size - data_size = bswap_32(*dword_ptr); - dword_ptr++; - - byte_ptr = (uint8_t*)dword_ptr; - frame_info->nalus[n].type = *byte_ptr; - switch(frame_info->nalus[n].type & 0x1F) { - case h264_NAL_UNIT_TYPE_SPS: - case h264_NAL_UNIT_TYPE_PPS: - case h264_NAL_UNIT_TYPE_SEI: - // Point to cleartext in nalu data buffer - frame_info->nalus[n].data = byte_ptr; - frame_info->nalus[n].slice_header = NULL; - break; - case h264_NAL_UNIT_TYPE_SLICE: - case h264_NAL_UNIT_TYPE_IDR: - // Point to ciphertext in frame buffer - frame_info->nalus[n].data = frame_info->data + frame_info->nalus[n].offset; - byteswap_slice_header((slice_header_t*)byte_ptr); - frame_info->nalus[n].slice_header = (slice_header_t*)byte_ptr; - if(data_size > sizeof(slice_header_t)) { - byte_ptr += sizeof(slice_header_t); - frame_info->dec_ref_pic_marking = (dec_ref_pic_marking_t*)byte_ptr; - } - break; - default: - LOGE("ERROR: SEC returned an unsupported NALU type: %x", frame_info->nalus[n].type); - frame_info->nalus[n].data = NULL; - frame_info->nalus[n].slice_header = NULL; - break; - } - - // Advance to next NALU (including padding) - dword_ptr += (data_size + 3) >> 2; - } - - return OMX_ErrorNone; -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::SetMaxOutputBufferCount(OMX_PARAM_PORTDEFINITIONTYPE *p) { - OMX_ERRORTYPE ret; - CHECK_TYPE_HEADER(p); - CHECK_PORT_INDEX(p, OUTPORT_INDEX); - - p->nBufferCountActual = OUTPORT_NATIVE_BUFFER_COUNT; - return OMXVideoDecoderBase::SetMaxOutputBufferCount(p); -} -DECLARE_OMX_COMPONENT("OMX.Intel.hw_vd.h264.secure", "video_decoder.avc", OMXVideoDecoderAVCSecure); diff --git a/videocodec/securevideo/cherrytrail/OMXVideoDecoderAVCSecure.h b/videocodec/securevideo/cherrytrail/OMXVideoDecoderAVCSecure.h deleted file mode 100644 index 3c8ceaf..0000000 --- a/videocodec/securevideo/cherrytrail/OMXVideoDecoderAVCSecure.h +++ /dev/null @@ -1,123 +0,0 @@ -/* -* Copyright (c) 2009-2013 Intel Corporation. All rights reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef OMX_VIDEO_DECODER_AVC_SECURE_H_ -#define OMX_VIDEO_DECODER_AVC_SECURE_H_ - -#include <utils/Mutex.h> -#include "OMXVideoDecoderBase.h" -#include "libpavp.h" -#include "widevine.h" -#include "secvideoparser.h" - -// Must match the same structs defined in WVCrypto.h -#pragma pack(push, 1) -typedef struct { - uint32_t offset; - uint32_t size; -} sec_partition_t; -typedef struct { - sec_partition_t src; - sec_partition_t dest; - sec_partition_t metadata; - sec_partition_t headers; -} video_partition_t; -typedef struct { - pavp_lib_session* pLibInstance; - uint8_t* base; - uint32_t size; - uint32_t base_offset; - video_partition_t partitions; - uint32_t frame_size; - uint32_t src_fill; - uint8_t pes_packet_count; - uint8_t clear; -} SECVideoBuffer; -typedef struct { - uint32_t index; - SECVideoBuffer* secBuffer; -} OMXSecureBuffer; -#pragma pack(pop) - - -class OMXVideoDecoderAVCSecure : public OMXVideoDecoderBase { -public: - OMXVideoDecoderAVCSecure(); - virtual ~OMXVideoDecoderAVCSecure(); - -protected: - virtual OMX_ERRORTYPE InitInputPortFormatSpecific(OMX_PARAM_PORTDEFINITIONTYPE *paramPortDefinitionInput);; - virtual OMX_ERRORTYPE ProcessorStop(void); - virtual OMX_ERRORTYPE ProcessorProcess( - OMX_BUFFERHEADERTYPE ***pBuffers, - buffer_retain_t *retains, - OMX_U32 numberBuffers); - - virtual OMX_ERRORTYPE PrepareConfigBuffer(VideoConfigBuffer *p); - virtual OMX_ERRORTYPE PrepareDecodeBuffer(OMX_BUFFERHEADERTYPE *buffer, buffer_retain_t *retain, VideoDecodeBuffer *p); - virtual OMX_COLOR_FORMATTYPE GetOutputColorFormat(int width, int height); - - virtual OMX_ERRORTYPE BuildHandlerList(void); - virtual OMX_ERRORTYPE SetMaxOutputBufferCount(OMX_PARAM_PORTDEFINITIONTYPE *p); - DECLARE_HANDLER(OMXVideoDecoderAVCSecure, ParamVideoAvc); - DECLARE_HANDLER(OMXVideoDecoderAVCSecure, ParamVideoAVCProfileLevel); - DECLARE_HANDLER(OMXVideoDecoderAVCSecure, NativeBufferMode); - - static OMX_U8* MemAllocSecure(OMX_U32 nSizeBytes, OMX_PTR pUserData); - static void MemFreeSecure(OMX_U8 *pBuffer, OMX_PTR pUserData); - OMX_U8* MemAllocSecure(OMX_U32 nSizeBytes); - void MemFreeSecure(OMX_U8 *pBuffer); - - OMX_ERRORTYPE ConstructFrameInfo(uint8_t* frame_data, uint32_t frame_size, - pavp_info_t* pavp_info, uint8_t* nalu_data, uint32_t nalu_data_size, - frame_info_t* frame_info); - -private: - - enum { - // WARNING: if these values are changed, please make corresponding changes - // in the SEC memory region partitioning in the OEMCrypto for BYT (secregion.h) - - // OMX_PARAM_PORTDEFINITIONTYPE - INPORT_MIN_BUFFER_COUNT = 1, - INPORT_ACTUAL_BUFFER_COUNT = 5, - INPORT_BUFFER_SIZE = 1382400, - - // for OMX_VIDEO_PARAM_INTEL_AVC_DECODE_SETTINGS - // default number of reference frame - NUM_REFERENCE_FRAME = 4, - - OUTPORT_NATIVE_BUFFER_COUNT = 20, - }; - - OMX_VIDEO_PARAM_AVCTYPE mParamAvc; - - OMXSecureBuffer* mOMXSecureBuffers[INPORT_ACTUAL_BUFFER_COUNT]; - - struct SECParsedFrame { - uint8_t* nalu_data; - uint32_t nalu_data_size; - pavp_info_t pavp_info; - frame_info_t frame_info; - }; - - SECParsedFrame mParsedFrames[INPORT_ACTUAL_BUFFER_COUNT]; - - pavp_lib_session *mpLibInstance; - bool mDropUntilIDR; -}; - -#endif /* OMX_VIDEO_DECODER_AVC_SECURE_H_ */ diff --git a/videocodec/securevideo/cherrytrail/secvideoparser.h b/videocodec/securevideo/cherrytrail/secvideoparser.h deleted file mode 100644 index bf10a71..0000000 --- a/videocodec/securevideo/cherrytrail/secvideoparser.h +++ /dev/null @@ -1,141 +0,0 @@ -/* INTEL CONFIDENTIAL -* Copyright (c) 2013 Intel Corporation. All rights reserved. -* -* The source code contained or described herein and all documents -* related to the source code ("Material") are owned by Intel -* Corporation or its suppliers or licensors. Title to the -* Material remains with Intel Corporation or its suppliers and -* licensors. The Material contains trade secrets and proprietary -* and confidential information of Intel or its suppliers and -* licensors. The Material is protected by worldwide copyright and -* trade secret laws and treaty provisions. No part of the Material -* may be used, copied, reproduced, modified, published, uploaded, -* posted, transmitted, distributed, or disclosed in any way without -* Intel's prior express written permission. -* -* No license under any patent, copyright, trade secret or other -* intellectual property right is granted to or conferred upon you -* by disclosure or delivery of the Materials, either expressly, by -* implication, inducement, estoppel or otherwise. Any license -* under such intellectual property rights must be express and -* approved by Intel in writing. -*/ - -#ifndef SEC_VIDEO_PARSER_H_ -#define SEC_VIDEO_PARSER_H_ - -#include <stdint.h> - -/* H264 start code values */ -typedef enum _h264_nal_unit_type -{ - h264_NAL_UNIT_TYPE_unspecified = 0, - h264_NAL_UNIT_TYPE_SLICE, - h264_NAL_UNIT_TYPE_DPA, - h264_NAL_UNIT_TYPE_DPB, - h264_NAL_UNIT_TYPE_DPC, - h264_NAL_UNIT_TYPE_IDR, - h264_NAL_UNIT_TYPE_SEI, - h264_NAL_UNIT_TYPE_SPS, - h264_NAL_UNIT_TYPE_PPS, - h264_NAL_UNIT_TYPE_Acc_unit_delimiter, - h264_NAL_UNIT_TYPE_EOSeq, - h264_NAL_UNIT_TYPE_EOstream, - h264_NAL_UNIT_TYPE_filler_data, - h264_NAL_UNIT_TYPE_SPS_extension, - h264_NAL_UNIT_TYPE_ACP = 19, - h264_NAL_UNIT_TYPE_Slice_extension = 20 -} h264_nal_unit_type_t; - -#define MAX_OP 16 - -enum dec_ref_pic_marking_flags { - IDR_PIC_FLAG = 0, - NO_OUTPUT_OF_PRIOR_PICS_FLAG, - LONG_TERM_REFERENCE_FLAG, - ADAPTIVE_REF_PIC_MARKING_MODE_FLAG -}; - -typedef struct _dec_ref_pic_marking_t { - union { - uint8_t flags; - struct { - uint8_t idr_pic_flag:1; - uint8_t no_output_of_prior_pics_flag:1; - uint8_t long_term_reference_flag:1; - uint8_t adaptive_ref_pic_marking_mode_flag:1; - }; - }; - struct { - uint8_t memory_management_control_operation; - union { - struct { - uint8_t difference_of_pic_nums_minus1; - } op1; - struct { - uint8_t long_term_pic_num; - } op2; - struct { - uint8_t difference_of_pic_nums_minus1; - uint8_t long_term_frame_idx; - } op3; - struct { - uint8_t max_long_term_frame_idx_plus1; - } op4; - struct { - uint8_t long_term_frame_idx; - } op6; - }; - } op[MAX_OP]; -} dec_ref_pic_marking_t; - -enum slice_header_flags { - FIELD_PIC_FLAG = 0, - BOTTOM_FIELD_FLAG -}; - -typedef struct _slice_header_t { - uint8_t nal_unit_type; - union { - uint8_t flags; - struct { - uint8_t field_pic_flag:1; - uint8_t bottom_field_flag:1; - }; - }; - uint8_t pps_id; - uint8_t padding; // Align the next field to a 32-bit address - uint32_t first_mb_in_slice; - uint32_t frame_num; - uint16_t idr_pic_id; - uint16_t pic_order_cnt_lsb; - int32_t delta_pic_order_cnt_bottom; - int32_t delta_pic_order_cnt[2]; -} slice_header_t; - -typedef struct { - uint8_t type; - uint32_t offset; - uint8_t* data; - uint32_t length; - slice_header_t* slice_header; -} nalu_info_t; - -typedef struct { - uint32_t iv[4]; - uint32_t mode; - uint32_t app_id; -} pavp_info_t; - -#define MAX_NUM_NALUS 20 - -typedef struct { - uint8_t* data; - uint32_t length; - pavp_info_t* pavp; - dec_ref_pic_marking_t* dec_ref_pic_marking; - uint32_t num_nalus; - nalu_info_t nalus[MAX_NUM_NALUS]; -} frame_info_t; - -#endif /* SEC_VIDEO_PARSER_H_ */ diff --git a/videocodec/securevideo/cherrytrail/widevine.h b/videocodec/securevideo/cherrytrail/widevine.h deleted file mode 100644 index a53a822..0000000 --- a/videocodec/securevideo/cherrytrail/widevine.h +++ /dev/null @@ -1,491 +0,0 @@ -/*++
-
- INTEL CONFIDENTIAL
- Copyright (c) 2013- Intel Corporation All Rights Reserved.
-
- The source code contained or described herein and all documents related to
- the source code ("Material") are owned by Intel Corporation or its
- suppliers or licensors. Title to the Material remains with Intel
- Corporation or its suppliers and licensors. The Material contains trade
- secrets and proprietary and confidential information of Intel or its
- suppliers and licensors. The Material is protected by worldwide copyright
- and trade secret laws and treaty provisions. No part of the Material may be
- used, copied, reproduced, modified, published, uploaded, posted, transmitted,
- distributed, or disclosed in any way without Intel's prior express written
- permission.
-
- No license under any patent, copyright, trade secret or other intellectual
- property right is granted to or conferred upon you by disclosure or delivery
- of the Materials, either expressly, by implication, inducement, estoppel or
- otherwise. Any license under such intellectual property rights must be
- express and approved by Intel in writing.
-
-File Name:
-
- widevine.h
-
-Abstract:
-
-
-
-Author:
-
- Ruan, Xiaoyu
- Patel, Arpit A
-
-Revision history:
-
- 3/17/2013: WV SEC FW API v0.19
- 3/21/2013: v0.30
- 3/29/2013: v0.40
- 4/4/2013: v0.43
- 4/8/2013: v0.45
- 4/11/2013: v0.50
- 4/24/2013: v0.51
-
---*/
-
-#ifndef __WIDEVINE_H
-#define __WIDEVINE_H
-
-#if 0
-#include "CompMgmt.h"
-#include "Heci.h"
-#include "Crypto.h"
-#include "Storage.h"
-#include "Memory.h"
-#include "MemDefs.h"
-#include <string.h>
-
-#include "PavpHeciApiCommonDefs.h"
-#include "PavpHeciApi.h"
-#include "PavpVideoKeyMgr.h"
-#include "PavpBaseKeyMgr.h"
-#include "GfxKeyMgrDefs.h"
-
-#include "dbg.h"
-#include "romapi.h"
-
-#include "bitstream.h"
-#include "decoder.h"
-#include "nalu.h"
-#include "sei.h"
-#include "sps.h"
-#include "pps.h"
-#include "slice_header.h"
-#include "flag.h"
-#endif
-
-#define WV_USE_SATT 1
-
-#define WV_1KB 1024
-#define WV_DEVICE_ID_SIZE 32
-#define WV_DEVICE_KEY_SIZE 16
-#define WV_KEY_DATA_SIZE 72
-#define MV_KEYBOX_MAGIC_SIZE 4
-#define WV_CRC_SIZE 4
-#define WV_MAGIC_SIZE 4
-#define WV_AES_IV_SIZE 16
-#define WV_AES_KEY_SIZE 16
-#define WV_AES_BLOCK_SIZE 16
-#define WV_MAX_PACKETS_IN_FRAME 20 /* 20*64K=1.3M, max frame size */
-#define WV_MAX_PACKET_SIZE (64*WV_1KB-1)
-#define WV_PARSED_BUFFER_SIZE (4*WV_1KB)
-#define WV_PER_DMA_SIZE (8*WV_1KB + 16 + 16) /* 16 is AES block size, for CTS last block. add 16 more for DMA alignment */
-#define WV_PARSER_BUF_EDGE 64
-#define WV_WORK_BUFFER_SIZE (WV_PER_DMA_SIZE+WV_PARSER_BUF_EDGE)
-#define WV_ECM_SIZE 32
-#define WV_FLAGS_SIZE 4
-#define WV_RAND_SIZE 32
-#define WV_API_VERSION 0x00010000
-#define WV_FRAME_METADATA_SIZE (WV_MAX_PACKETS_IN_FRAME*sizeof(wv_frame_metadata))
-#define WV_MALLOC_ALIGNMENT 32
-#define WV_MALLOC_TIMEOUT 0
-#define WV_DMA_ALIGNMENT 32
-#define WV_XCRIPT_DMA_OUT_SWAP (CIPHER_DST_SWAP)
-#define WV_OUT_MSG_FLAG 0x80000000
-#define WV_SATT_BASE SATT_2
-
-#define WV_CEILING(a,b) ((a)%(b)==0?(a):((a)/(b)+1)*(b))
-#define PREPRODUCTION (RomData.gBringupDataPtr->FuseMap.DevModeEnabled || RomData.gBringupDataPtr->FuseMap.JtagEnabled)
-#define WV_SWAP_DWORD(dword) (((dword) & 0x000000ff) << 24 | ((dword) & 0x0000ff00) << 8 | ((dword) & 0x00ff0000) >> 8 | ((dword) & 0xff000000) >> 24)
-#define WV_SWAP_SHORT(sho) (((sho) & (0x00ff)) << 8 | ((sho) & (0xff00)) >> 8)
-
-/**
- * @brief PAVP HECI message header.
- */
-typedef struct _PAVP_CMD_HEADER
-{
- UINT32 ApiVersion;
- UINT32 CommandId;
- UINT32 Status;
- UINT32 BufferLength;
-} PAVP_CMD_HEADER;
-
-typedef struct _PAVP_CMD_NODATA
-{
- PAVP_CMD_HEADER Header;
- // no data follows header
-} PAVP_CMD_NODATA;
-
-typedef int BOOL;
-
-typedef struct {
- uint8_t device_id[WV_DEVICE_ID_SIZE];
- uint8_t device_key[WV_DEVICE_KEY_SIZE];
- uint8_t key_data[WV_KEY_DATA_SIZE];
- uint8_t magic[WV_MAGIC_SIZE];
- uint8_t key_data_crc[WV_CRC_SIZE];
-} wv_keybox;
-
-typedef struct {
- uint32_t packet_byte_size; // number of bytes in this PES packet, same for input and output
- uint8_t packet_iv[WV_AES_IV_SIZE]; // IV used for CBC-CTS decryption, if the PES packet is encrypted
-} sec_wv_packet_metadata;
-
-typedef struct {
- sec_wv_packet_metadata *metadata_buffer;//WV_MAX_PACKETS_IN_FRAME * sizeof(wv_packet_metadata)
- uint32_t title_video_size;
-} wv_frame_metadata;
-
-/* wv_nalu and wv_nalu_headers are for host only. FW does not use */
-typedef struct {
- uint32_t imr_offset;
- uint32_t nalu_size;
- uint32_t data_size;
- uint8_t data[1]; //place holder. actual size is data_size
-} wv_nalu;
-
-/* wv_nalu and wv_nalu_headers are for host only. FW does not use */
-typedef struct {
- uint32_t num_nalu;
- wv_nalu drm_nalu[1];// place holder. actual size is num_nalu
-} wv_nalu_headers;
-
-#if 0
-typedef struct {
- wv_frame_metadata frame_metadata;
- uint32_t *frame_header; //WV_PARSED_BUFFER_SIZE, dynamic allocation from locked memory
- uint8_t *frame_proc_buffer;// size = WV_PER_DMA_SIZE, dynamic allocation from locked memory
- uint8_t *work_buffer;// size = WV_WORK_BUFFER_SIZE, dynamic allocation from locked memory
- uint8_t *parser_work_buffer;// size = WV_WORK_BUFFER_SIZE, dynamic allocation from locked memory
- uint8_t asset_key[WV_AES_KEY_SIZE];
- BOOL asset_key_valid;
- uint8_t title_key[WV_AES_KEY_SIZE];
- uint8_t title_decrypt_key[WV_AES_KEY_SIZE];
- BOOL title_key_valid;
- uint8_t pavp_key[WV_AES_KEY_SIZE];
- BOOL pavp_key_valid;
- uint8_t pavp_counter[WV_AES_IV_SIZE];
- decoder_ctx_t decoder;
- uint32_t video_frame_count;
- BOOL bypass_transcryption;
- uint32_t audio_frame_count;
- uint32_t time_start; /*timer starts at first frame of a video frame*/
- uint32_t time_end; /*timer ends at title_complete*/
- uint32_t time_start_heci;
- uint32_t time_heci;
- uint32_t time_dma_in;
- uint32_t time_decrypt;
- uint32_t time_parse;
- uint32_t time_encrypt_dma_out;
-} wv_title_context;
-
-typedef struct {
-#if !WV_USE_SATT
- uint32_t host_phy_mem_lo;
- uint32_t host_phy_mem_hi;
- uint32_t host_phy_mem_size;
- BOOL host_phy_mem_valid;
-#endif
- wv_keybox keybox;
- BOOL keybox_valid;
- wv_title_context title;
- PAVP_STREAM_ID wvVideoStreamSlot;
-} wv_context;
-#endif
-
-/*******************
- * HECI APIs
- *******************/
-
-typedef enum {
- WV_SUCCESS = 0,
- WV_SUCCESS_PRIV_DATA = 0x80000000,
- WV_FAIL_INVALID_PARAMS = 0x000F0001,
- WV_FAIL_INVALID_INPUT_HEADER,
- WV_FAIL_NOT_PROVISIONED,
- WV_FAIL_BAD_KEYBOX_CRC,
- WV_FAIL_UNKNOWN_ERROR,
- WV_FAIL_HDCP_OFF,
- WV_FAIL_NO_HOST_MEM,
- WV_FAIL_NOT_EXPECTED,
- WV_FAIL_INVALID_AUDIO_FRAME,
- WV_FAIL_KEYBOX_INVALID_BAD_PROVISIONING,
- WV_FAIL_KEYBOX_INVALID_BAD_MAGIC,
- WV_FAIL_WV_NO_ASSET_KEY,
- WV_FAIL_WV_NO_CEK,
- WV_FAIL_REACHED_HOST_MEM_LIMIT,
- WV_FAIL_WV_SESSION_NALU_PARSE_FAILURE,
- WV_FAIL_WV_SESSION_NALU_PARSE_TOO_MANY_HEADERS,
- WV_FAIL_GENERATE_RANDOM_NUMBER_FAILURE,
- WV_FAIL_AES_CBC_FAILURE,
- WV_FAIL_AES_XCRIPT_FAILURE,
- WV_FAIL_AES_ECB_FAILURE,
- WV_FAIL_BLOB_ERROR,
- WV_FAIL_BAD_AUDIO_CLEAR_PKT,
- WV_FAIL_NO_TITLE_KEY,
- WV_FAIL_OUT_OF_MEMORY,
- WV_FAIL_PAVP_INJECT_KEY_ERROR,
- WV_FAIL_MSG_NOT_FROM_RING_0,
- WV_FAIL_DMA_READ,
- WV_FAIL_DMA_WRITE,
- WV_FAIL_DMA_WRITE_HEADER,
- WV_FAIL_INVALID_TITLE_KEY,
- WV_FAIL_INVALID_PAVP_KEY,
- WV_FAIL_INVALID_NUM_OF_PACKETS,
- WV_FAIL_PAVP_INIT_NOT_COMPLETE,
- WV_FAIL_STATUS_CHAIN_NOT_INITIALIZED,
- WV_FAIL_OUTPUT_HOST_MEM_OVERLAP,
- WV_FAIL_NOT_SUPPORTED
-} wv_heci_status;
-
-typedef enum {
- wv_init_dma = 0x000A0002,
- wv_heci_begin = wv_init_dma,
- wv_get_random,
- wv_get_keybox_data,
- wv_set_xcript_key,
- wv_set_entitlement_key,
- wv_derive_control_word,
- wv_process_video_frame,
- wv_process_audio_frame,
- wv_title_completed,
- wv_uninit_dma,
- wv_heci_end = wv_uninit_dma,
- wv_dbg_get_title_key = 0x000A00F0,
- wv_heci_dbg_begin = wv_dbg_get_title_key,
- wv_dbg_get_xcript_key,
- wv_dbg_dis_xcript_enc,
- wv_dbg_en_xcript_enc,
- wv_dbg_get_diag,
- wv_dbg_set_keybox,
- wv_dbg_reset_keybox,
- wv_dbg_set_xcript_key_wo_pavp,
- wv_dbg_reset_xcript_key_wo_pavp,
- wv_heci_dbg_end = wv_dbg_reset_xcript_key_wo_pavp,
-
- wv_init_dma_rsp = (WV_OUT_MSG_FLAG | wv_init_dma),
- wv_get_random_rsp,
- wv_get_keybox_data_rsp,
- wv_set_xcript_key_rsp,
- wv_set_entitlement_key_rsp,
- wv_derive_control_word_rsp,
- wv_process_video_frame_rsp,
- wv_process_audio_frame_rsp,
- wv_title_completed_rsp,
- wv_uninit_dma_rsp,
- wv_dbg_get_title_key_rsp = (WV_OUT_MSG_FLAG | wv_dbg_get_title_key),
- wv_dbg_get_xcript_key_rsp,
- wv_dbg_dis_xcript_enc_rsp,
- wv_dbg_en_xcript_enc_rsp,
- wv_dbg_get_diag_rsp,
- wv_dbg_set_keybox_rsp,
- wv_dbg_reset_keybox_rsp,
- wv_dbg_set_xcript_key_wo_pavp_rsp,
- wv_dbg_reset_xcript_key_wo_pavp_rsp,
-} wv_heci_command_id;
-
-
-/*wv_init_dma*/
-typedef struct {
- PAVP_CMD_HEADER Header;
- uint32_t phy_mem_lo;
- uint32_t phy_mem_hi;
- uint32_t phy_mem_size;
-} wv_init_dma_in;
-
-typedef PAVP_CMD_NODATA wv_init_dma_out;
-
-/*wv_heci_get_random*/
-typedef struct {
- PAVP_CMD_HEADER Header;
- uint32_t size_in_bytes;
-} wv_heci_get_random_in;
-
-typedef struct {
- PAVP_CMD_HEADER Header;
- uint8_t random_bytes[WV_RAND_SIZE];
-} wv_heci_get_random_out;
-
-/*wv_heci_get_keybox_data*/
-typedef PAVP_CMD_NODATA wv_heci_get_keybox_data_in;
-
-typedef struct {
- PAVP_CMD_HEADER Header;
- uint8_t key_data[WV_KEY_DATA_SIZE];
- uint8_t device_id[WV_DEVICE_ID_SIZE];
-} wv_heci_get_keybox_data_out;
-
-/*wv_set_xcript_key*/
-typedef PAVP_CMD_NODATA wv_set_xcript_key_in;
-
-typedef struct {
- PAVP_CMD_HEADER Header;
- /* private data for driver. Size excluded in Header.Length
- * app caller: do not include this field*/
- //uint8_t wrapped_xcript_key[WV_AES_KEY_SIZE];// libpcp will take care of this. Remove this from OMX.
-} wv_set_xcript_key_out;
-
-/*wv_heci_set_entitlement_key*/
-typedef struct {
- PAVP_CMD_HEADER Header;
- uint8_t entitlement_key[WV_AES_KEY_SIZE];
-} wv_heci_set_entitlement_key_in;
-
-typedef PAVP_CMD_NODATA wv_heci_set_entitlement_key_out;
-
-/*wv_heci_derive_control_word*/
-typedef struct {
- PAVP_CMD_HEADER Header;
- uint8_t ecm[WV_ECM_SIZE];
-} wv_heci_derive_control_word_in;
-
-typedef struct {
- PAVP_CMD_HEADER Header;
- uint8_t flags[WV_FLAGS_SIZE];
-} wv_heci_derive_control_word_out;
-
-/*wv_heci_process_video_frame*/
-typedef struct {
- PAVP_CMD_HEADER Header;
- uint32_t num_of_packets;//<=20
- BOOL is_frame_not_encrypted;
- uint32_t src_offset;
- uint32_t dest_offset;
- uint32_t metadata_offset;
- uint32_t header_offset;
-} wv_heci_process_video_frame_in;
-
-typedef struct {
- PAVP_CMD_HEADER Header;
- uint32_t parsed_data_size;
- /* private data for driver. Size excluded in Header.Length
- * app caller: do not include this field*/ //Remove comment
- uint8_t iv[WV_AES_IV_SIZE];
-} wv_heci_process_video_frame_out;
-
-/*wv_heci_process_audio_frame*/
-typedef struct {
- PAVP_CMD_HEADER Header;
- uint32_t num_of_packets;//<=20
- BOOL is_frame_not_encrypted;
- uint32_t src_offset;
- uint32_t dest_offset;
- uint32_t metadata_offset;
-} wv_heci_process_audio_frame_in;
-
-typedef PAVP_CMD_NODATA wv_heci_process_audio_frame_out;
-
-/*wv_title_completed*/
-typedef PAVP_CMD_NODATA wv_title_completed_in;
-typedef PAVP_CMD_NODATA wv_title_completed_out;
-
-/*wv_dbg_get_title_key*/
-typedef PAVP_CMD_NODATA wv_dbg_get_title_key_in;
-
-typedef struct {
- PAVP_CMD_HEADER Header;
- BOOL title_key_valid;
- uint8_t title_key[WV_AES_KEY_SIZE];
-} wv_dbg_get_title_key_out;
-
-/*wv_uninit_dma*/
-typedef PAVP_CMD_NODATA wv_uninit_dma_in;
-typedef PAVP_CMD_NODATA wv_uninit_dma_out;
-
-/*wv_dbg_get_xcript_key*/
-typedef PAVP_CMD_NODATA wv_dbg_get_xcript_key_in;
-
-typedef struct {
- PAVP_CMD_HEADER Header;
- BOOL xcript_key_valid;
- uint8_t xcript_key[WV_AES_KEY_SIZE];
- uint8_t xcript_counter[WV_AES_IV_SIZE];
-} wv_dbg_get_xcript_key_out;
-
-/*wv_dbg_dis_xcript_enc*/
-typedef PAVP_CMD_NODATA wv_dbg_dis_xcript_enc_in;
-typedef PAVP_CMD_NODATA wv_dbg_dis_xcript_enc_out;
-
-/*wv_dbg_en_xcript_enc*/
-typedef PAVP_CMD_NODATA wv_dbg_en_xcript_enc_in;
-typedef PAVP_CMD_NODATA wv_dbg_en_xcript_enc_out;
-
-/*wv_dbg_get_diag*/
-typedef PAVP_CMD_NODATA wv_dbg_get_diag_in;
-
-typedef struct {
- PAVP_CMD_HEADER Header;
- uint16_t fw_major_ver;
- uint16_t fw_minor_ver;
- uint16_t fw_hotfix;
- uint16_t fw_build;
- BOOL production_part;
-#if !WV_USE_SATT
- uint32_t host_phy_mem_lo;
- uint32_t host_phy_mem_hi;
- uint32_t host_phy_mem_size;
- BOOL host_phy_mem_valid;
-#endif
- uint32_t video_frame_count;
- uint32_t audio_frame_count;
- uint32_t slice_count_for_this_frame;
- uint32_t total_slice_count_for_this_title;
- uint32_t bypass_transcryption : 1;
- uint32_t frame_header_valid : 1;
- uint32_t frame_proc_buffer_valid : 1;
- uint32_t work_buffer_valid : 1;
- uint32_t parser_work_buffer_valid : 1;
- uint32_t asset_key_valid_valid : 1;
- uint32_t title_key_valid_valid : 1;
- uint32_t pavp_key_valid : 1;
- uint32_t keybox_valid : 1;
- uint32_t reserved1 : 7;
- uint32_t wvVideoStreamSlot : 8;
- uint32_t reserved2 : 8;
- uint32_t time_start; /*timer starts at first frame of a video frame*/
- uint32_t time_end; /*timer ends at title_complete*/
- uint32_t time_elapsed; /*time_end - time_start, unit is microsecond*/
- uint32_t video_size;
- uint32_t throughput; /*bits/microsecond*/
- uint32_t time_heci;
- uint32_t time_dma_in;
- uint32_t time_decrypt;
- uint32_t time_parse;
- uint32_t time_encrypt_dma_out;
-} wv_dbg_get_diag_out;
-//C_ASSERT(sizeof(wv_dbg_get_diag_out) == WV_USE_SATT ? 64 : 48);
-
-/*wv_dbg_set_keybox*/
-typedef struct {
- PAVP_CMD_HEADER Header;
- wv_keybox keybox;
-} wv_dbg_set_keybox_in;
-
-typedef PAVP_CMD_NODATA wv_dbg_set_keybox_out;
-
-/*wv_dbg_reset_keybox*/
-typedef PAVP_CMD_NODATA wv_dbg_reset_keybox_in;
-typedef PAVP_CMD_NODATA wv_dbg_reset_keybox_out;
-
-/*wv_dbg_set_xcript_key_wo_pavp*/
-typedef PAVP_CMD_NODATA wv_dbg_set_xcript_key_wo_pavp_in;
-typedef PAVP_CMD_NODATA wv_dbg_set_xcript_key_wo_pavp_out;
-
-/*wv_dbg_reset_xcript_key_wo_pavp*/
-typedef PAVP_CMD_NODATA wv_dbg_reset_xcript_key_wo_pavp_in;
-typedef PAVP_CMD_NODATA wv_dbg_reset_xcript_key_wo_pavp_out;
-
-#endif
-
diff --git a/videocodec/securevideo/ctp/OMXVideoDecoderAVCSecure.cpp b/videocodec/securevideo/ctp/OMXVideoDecoderAVCSecure.cpp deleted file mode 100644 index 3983b46..0000000 --- a/videocodec/securevideo/ctp/OMXVideoDecoderAVCSecure.cpp +++ /dev/null @@ -1,455 +0,0 @@ -/* -* Copyright (c) 2009-2012 Intel Corporation. All rights reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - - -//#define LOG_NDEBUG 0 -#define LOG_TAG "OMXVideoDecoder" -#include <wrs_omxil_core/log.h> -#include "OMXVideoDecoderAVCSecure.h" -#include <time.h> -#include <signal.h> -#include <pthread.h> - -extern "C" { -#include <sepdrm.h> -#include <fcntl.h> -#include <linux/psb_drm.h> -#include "xf86drm.h" -#include "xf86drmMode.h" -} - -// Be sure to have an equal string in VideoDecoderHost.cpp (libmix) -static const char* AVC_MIME_TYPE = "video/avc"; -static const char* AVC_SECURE_MIME_TYPE = "video/avc-secure"; - -#define IMR_INITIAL_OFFSET 0 //1024 -#define IMR_BUFFER_SIZE (8 * 1024 * 1024) -#define KEEP_ALIVE_INTERVAL 5 // seconds -#define DRM_KEEP_ALIVE_TIMER 1000000 -#define WV_SESSION_ID 0x00000011 -#define NALU_BUFFER_SIZE 8192 -#define FLUSH_WAIT_INTERVAL (30 * 1000) //30 ms - - -#pragma pack(push, 1) -struct IMRDataBuffer { - uint32_t offset; - uint32_t size; - uint8_t *data; - uint8_t clear; // 0 when IMR offset is valid, 1 when data is valid -}; -#pragma pack(pop) - -OMXVideoDecoderAVCSecure::OMXVideoDecoderAVCSecure() - : mKeepAliveTimer(0), - mSessionPaused(false), - mDrmDevFd(-1) { - LOGV("OMXVideoDecoderAVCSecure is constructed."); - mVideoDecoder = createVideoDecoder(AVC_SECURE_MIME_TYPE); - if (!mVideoDecoder) { - LOGE("createVideoDecoder failed for \"%s\"", AVC_SECURE_MIME_TYPE); - } - // Override default native buffer count defined in the base class - mNativeBufferCount = OUTPORT_NATIVE_BUFFER_COUNT; - - BuildHandlerList(); - - mDrmDevFd = open("/dev/card0", O_RDWR, 0); - if (mDrmDevFd < 0) { - LOGE("Failed to open drm device."); - } -} - -OMXVideoDecoderAVCSecure::~OMXVideoDecoderAVCSecure() { - LOGV("OMXVideoDecoderAVCSecure is destructed."); - - if (mDrmDevFd) { - close(mDrmDevFd); - mDrmDevFd = 0; - } -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::InitInputPortFormatSpecific(OMX_PARAM_PORTDEFINITIONTYPE *paramPortDefinitionInput) { - // OMX_PARAM_PORTDEFINITIONTYPE - paramPortDefinitionInput->nBufferCountActual = INPORT_ACTUAL_BUFFER_COUNT; - paramPortDefinitionInput->nBufferCountMin = INPORT_MIN_BUFFER_COUNT; - paramPortDefinitionInput->nBufferSize = INPORT_BUFFER_SIZE; - paramPortDefinitionInput->format.video.cMIMEType = (OMX_STRING)AVC_MIME_TYPE; - paramPortDefinitionInput->format.video.eCompressionFormat = OMX_VIDEO_CodingAVC; - - // OMX_VIDEO_PARAM_AVCTYPE - memset(&mParamAvc, 0, sizeof(mParamAvc)); - SetTypeHeader(&mParamAvc, sizeof(mParamAvc)); - mParamAvc.nPortIndex = INPORT_INDEX; - // TODO: check eProfile/eLevel - mParamAvc.eProfile = OMX_VIDEO_AVCProfileHigh; //OMX_VIDEO_AVCProfileBaseline; - mParamAvc.eLevel = OMX_VIDEO_AVCLevel41; //OMX_VIDEO_AVCLevel1; - - this->ports[INPORT_INDEX]->SetMemAllocator(MemAllocIMR, MemFreeIMR, this); - - for (int i = 0; i < INPORT_ACTUAL_BUFFER_COUNT; i++) { - mIMRSlot[i].offset = IMR_INITIAL_OFFSET + i * INPORT_BUFFER_SIZE; - mIMRSlot[i].owner = NULL; - } - - return OMX_ErrorNone; -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::ProcessorInit(void) { - sec_result_t sepres = Drm_Library_Init(); - if (sepres != 0) { - LOGE("Drm_Library_Init returned %08X", (unsigned int)sepres); - } - mSessionPaused = false; - return OMXVideoDecoderBase::ProcessorInit(); -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::ProcessorDeinit(void) { - // Session should be torn down in ProcessorStop, delayed to ProcessorDeinit - // to allow remaining frames completely rendered. - LOGI("Calling Drm_DestroySession."); - sec_result_t sepres = Drm_DestroySession(WV_SESSION_ID); - if (sepres != 0) { - LOGW("Drm_DestroySession returns %#x", sepres); - } - EnableIEDSession(false); - - return OMXVideoDecoderBase::ProcessorDeinit(); -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::ProcessorStart(void) { - uint32_t imrOffset = 0; - uint32_t imrBufferSize = IMR_BUFFER_SIZE; - uint32_t sessionID; - - EnableIEDSession(true); - sec_result_t sepres = Drm_WV_CreateSession(&imrOffset, &imrBufferSize, &sessionID); - if (sepres != 0) { - LOGW("Drm_WV_CreateSession failed. Result = %#x", sepres); - // Returning error will cause OMX client to crash. - //return OMX_ErrorHardware; - } - if (sessionID != WV_SESSION_ID) { - LOGE("Invalid session ID %#x created", sessionID); - //return OMX_ErrorHardware; - } - LOGI("Drm_WV_CreateSession: IMR Offset = %d, IMR size = %#x", imrOffset, imrBufferSize); - if (imrBufferSize != IMR_BUFFER_SIZE) { - LOGE("Mismatch in IMR size: Requested: %#x Obtained: %#x", IMR_BUFFER_SIZE, imrBufferSize); - } - drmCommandNone(mDrmDevFd, DRM_PSB_HDCP_DISPLAY_IED_OFF); - - - int ret; - struct sigevent sev; - memset(&sev, 0, sizeof(sev)); - sev.sigev_notify = SIGEV_THREAD; - sev.sigev_value.sival_ptr = this; - sev.sigev_notify_function = KeepAliveTimerCallback; - - ret = timer_create(CLOCK_REALTIME, &sev, &mKeepAliveTimer); - if (ret != 0) { - LOGE("Failed to create timer."); - } else { - struct itimerspec its; - its.it_value.tv_sec = -1; // never expire - its.it_value.tv_nsec = 0; - its.it_interval.tv_sec = KEEP_ALIVE_INTERVAL; - its.it_interval.tv_nsec = 0; - - ret = timer_settime(mKeepAliveTimer, TIMER_ABSTIME, &its, NULL); - if (ret != 0) { - LOGE("Failed to set timer."); - } - } - mSessionPaused = false; - return OMXVideoDecoderBase::ProcessorStart(); -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::ProcessorStop(void) { - if (mKeepAliveTimer != 0) { - timer_delete(mKeepAliveTimer); - mKeepAliveTimer = 0; - } - - return OMXVideoDecoderBase::ProcessorStop(); -} - - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::ProcessorFlush(OMX_U32 portIndex) { - return OMXVideoDecoderBase::ProcessorFlush(portIndex); -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::ProcessorProcess( - OMX_BUFFERHEADERTYPE ***pBuffers, - buffer_retain_t *retains, - OMX_U32 numberBuffers) { - - OMX_BUFFERHEADERTYPE *pInput = *pBuffers[INPORT_INDEX]; - IMRDataBuffer *imrBuffer = (IMRDataBuffer *)pInput->pBuffer; - if (imrBuffer->size == 0) { - // error occurs during decryption. - LOGW("size of returned IMR buffer is 0, decryption fails."); - mVideoDecoder->flush(); - usleep(FLUSH_WAIT_INTERVAL); - OMX_BUFFERHEADERTYPE *pOutput = *pBuffers[OUTPORT_INDEX]; - pOutput->nFilledLen = 0; - // reset IMR buffer size - imrBuffer->size = INPORT_BUFFER_SIZE; - this->ports[INPORT_INDEX]->FlushPort(); - this->ports[OUTPORT_INDEX]->FlushPort(); - return OMX_ErrorNone; - } - - OMX_ERRORTYPE ret; - ret = OMXVideoDecoderBase::ProcessorProcess(pBuffers, retains, numberBuffers); - if (ret != OMX_ErrorNone) { - LOGE("OMXVideoDecoderBase::ProcessorProcess failed. Result: %#x", ret); - return ret; - } - - if (mSessionPaused && (retains[OUTPORT_INDEX] == BUFFER_RETAIN_GETAGAIN)) { - retains[OUTPORT_INDEX] = BUFFER_RETAIN_NOT_RETAIN; - OMX_BUFFERHEADERTYPE *pOutput = *pBuffers[OUTPORT_INDEX]; - pOutput->nFilledLen = 0; - this->ports[INPORT_INDEX]->FlushPort(); - this->ports[OUTPORT_INDEX]->FlushPort(); - } - - return ret; -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::ProcessorPause(void) { - sec_result_t sepres = Drm_Playback_Pause(WV_SESSION_ID); - if (sepres != 0) { - LOGE("Drm_Playback_Pause failed. Result = %#x", sepres); - } - return OMXVideoDecoderBase::ProcessorPause(); -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::ProcessorResume(void) { - sec_result_t sepres = Drm_Playback_Resume(WV_SESSION_ID); - if (sepres != 0) { - LOGE("Drm_Playback_Resume failed. Result = %#x", sepres); - } - return OMXVideoDecoderBase::ProcessorResume(); -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::PrepareConfigBuffer(VideoConfigBuffer *p) { - OMX_ERRORTYPE ret; - ret = OMXVideoDecoderBase::PrepareConfigBuffer(p); - CHECK_RETURN_VALUE("OMXVideoDecoderBase::PrepareConfigBuffer"); - p->flag |= WANT_SURFACE_PROTECTION; - return ret; -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::PrepareDecodeBuffer(OMX_BUFFERHEADERTYPE *buffer, buffer_retain_t *retain, VideoDecodeBuffer *p) { - OMX_ERRORTYPE ret; - ret = OMXVideoDecoderBase::PrepareDecodeBuffer(buffer, retain, p); - CHECK_RETURN_VALUE("OMXVideoDecoderBase::PrepareDecodeBuffer"); - - if (buffer->nFilledLen == 0) { - return OMX_ErrorNone; - } - // OMX_BUFFERFLAG_CODECCONFIG is an optional flag - // if flag is set, buffer will only contain codec data. - if (buffer->nFlags & OMX_BUFFERFLAG_CODECCONFIG) { - LOGV("Received AVC codec data."); - return ret; - } - p->flag |= HAS_COMPLETE_FRAME; - - if (buffer->nOffset != 0) { - LOGW("buffer offset %d is not zero!!!", buffer->nOffset); - } - - IMRDataBuffer *imrBuffer = (IMRDataBuffer *)buffer->pBuffer; - if (imrBuffer->clear) { - p->data = imrBuffer->data + buffer->nOffset; - p->size = buffer->nFilledLen; - } else { - imrBuffer->size = NALU_BUFFER_SIZE; - sec_result_t res = Drm_WV_ReturnNALUHeaders(WV_SESSION_ID, imrBuffer->offset, buffer->nFilledLen, imrBuffer->data, (uint32_t *)&(imrBuffer->size)); - if (res == DRM_FAIL_FW_SESSION) { - LOGW("Drm_WV_ReturnNALUHeaders failed. Session is disabled."); - mSessionPaused = true; - ret = OMX_ErrorNotReady; - } else if (res != 0) { - mSessionPaused = false; - LOGE("Drm_WV_ReturnNALUHeaders failed. Error = %#x, IMR offset = %d, len = %d", res, imrBuffer->offset, buffer->nFilledLen); - ret = OMX_ErrorHardware; - } else { - mSessionPaused = false; - p->data = imrBuffer->data; - p->size = imrBuffer->size; - p->flag |= IS_SECURE_DATA; - } - } - - //reset IMR size - imrBuffer->size = NALU_BUFFER_SIZE; - return ret; -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::BuildHandlerList(void) { - OMXVideoDecoderBase::BuildHandlerList(); - AddHandler(OMX_IndexParamVideoAvc, GetParamVideoAvc, SetParamVideoAvc); - AddHandler(OMX_IndexParamVideoProfileLevelQuerySupported, GetParamVideoAVCProfileLevel, SetParamVideoAVCProfileLevel); - return OMX_ErrorNone; -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::GetParamVideoAvc(OMX_PTR pStructure) { - OMX_ERRORTYPE ret; - OMX_VIDEO_PARAM_AVCTYPE *p = (OMX_VIDEO_PARAM_AVCTYPE *)pStructure; - CHECK_TYPE_HEADER(p); - CHECK_PORT_INDEX(p, INPORT_INDEX); - - memcpy(p, &mParamAvc, sizeof(*p)); - return OMX_ErrorNone; -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::SetParamVideoAvc(OMX_PTR pStructure) { - OMX_ERRORTYPE ret; - OMX_VIDEO_PARAM_AVCTYPE *p = (OMX_VIDEO_PARAM_AVCTYPE *)pStructure; - CHECK_TYPE_HEADER(p); - CHECK_PORT_INDEX(p, INPORT_INDEX); - CHECK_SET_PARAM_STATE(); - - // TODO: do we need to check if port is enabled? - // TODO: see SetPortAvcParam implementation - Can we make simple copy???? - memcpy(&mParamAvc, p, sizeof(mParamAvc)); - return OMX_ErrorNone; -} - - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::GetParamVideoAVCProfileLevel(OMX_PTR pStructure) { - OMX_ERRORTYPE ret; - OMX_VIDEO_PARAM_PROFILELEVELTYPE *p = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pStructure; - CHECK_TYPE_HEADER(p); - CHECK_PORT_INDEX(p, INPORT_INDEX); - CHECK_ENUMERATION_RANGE(p->nProfileIndex,1); - - p->eProfile = mParamAvc.eProfile; - p->eLevel = mParamAvc.eLevel; - - return OMX_ErrorNone; -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::SetParamVideoAVCProfileLevel(OMX_PTR pStructure) { - LOGW("SetParamVideoAVCProfileLevel is not supported."); - return OMX_ErrorUnsupportedSetting; -} - -OMX_U8* OMXVideoDecoderAVCSecure::MemAllocIMR(OMX_U32 nSizeBytes, OMX_PTR pUserData) { - OMXVideoDecoderAVCSecure* p = (OMXVideoDecoderAVCSecure *)pUserData; - if (p) { - return p->MemAllocIMR(nSizeBytes); - } - LOGE("NULL pUserData."); - return NULL; -} - -void OMXVideoDecoderAVCSecure::MemFreeIMR(OMX_U8 *pBuffer, OMX_PTR pUserData) { - OMXVideoDecoderAVCSecure* p = (OMXVideoDecoderAVCSecure *)pUserData; - if (p) { - p->MemFreeIMR(pBuffer); - return; - } - LOGE("NULL pUserData."); -} - -OMX_U8* OMXVideoDecoderAVCSecure::MemAllocIMR(OMX_U32 nSizeBytes) { - // Ignore passed nSizeBytes, use INPORT_BUFFER_SIZE instead - - for (int i = 0; i < INPORT_ACTUAL_BUFFER_COUNT; i++) { - if (mIMRSlot[i].owner == NULL) { - IMRDataBuffer *pBuffer = new IMRDataBuffer; - if (pBuffer == NULL) { - LOGE("Failed to allocate memory."); - return NULL; - } - - pBuffer->data = new uint8_t [INPORT_BUFFER_SIZE]; - if (pBuffer->data == NULL) { - delete pBuffer; - LOGE("Failed to allocate memory, size to allocate %d.", INPORT_BUFFER_SIZE); - return NULL; - } - - pBuffer->offset = mIMRSlot[i].offset; - pBuffer->size = INPORT_BUFFER_SIZE; - mIMRSlot[i].owner = (OMX_U8 *)pBuffer; - - LOGV("Allocating buffer = %#x, IMR offset = %#x, data = %#x", (uint32_t)pBuffer, mIMRSlot[i].offset, (uint32_t)pBuffer->data); - return (OMX_U8 *) pBuffer; - } - } - LOGE("IMR slot is not available."); - return NULL; -} - -void OMXVideoDecoderAVCSecure::MemFreeIMR(OMX_U8 *pBuffer) { - IMRDataBuffer *p = (IMRDataBuffer*) pBuffer; - if (p == NULL) { - return; - } - for (int i = 0; i < INPORT_ACTUAL_BUFFER_COUNT; i++) { - if (pBuffer == mIMRSlot[i].owner) { - LOGV("Freeing IMR offset = %d, data = %#x", mIMRSlot[i].offset, (uint32_t)p->data); - delete [] p->data; - delete p; - mIMRSlot[i].owner = NULL; - return; - } - } - LOGE("Invalid buffer %#x to de-allocate", (uint32_t)pBuffer); -} - -void OMXVideoDecoderAVCSecure::KeepAliveTimerCallback(sigval v) { - OMXVideoDecoderAVCSecure *p = (OMXVideoDecoderAVCSecure *)v.sival_ptr; - if (p) { - p->KeepAliveTimerCallback(); - } -} - -void OMXVideoDecoderAVCSecure::KeepAliveTimerCallback() { - uint32_t timeout = DRM_KEEP_ALIVE_TIMER; - sec_result_t sepres = Drm_KeepAlive(WV_SESSION_ID, &timeout); - if (sepres != 0) { - LOGE("Drm_KeepAlive failed. Result = %#x", sepres); - } -} - - -bool OMXVideoDecoderAVCSecure::EnableIEDSession(bool enable) -{ - if (mDrmDevFd < 0) { - return false; - } - int request = enable ? DRM_PSB_ENABLE_IED_SESSION : DRM_PSB_DISABLE_IED_SESSION; - int ret = drmCommandNone(mDrmDevFd, request); - return ret == 0; -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::SetMaxOutputBufferCount(OMX_PARAM_PORTDEFINITIONTYPE *p) { - OMX_ERRORTYPE ret; - CHECK_TYPE_HEADER(p); - CHECK_PORT_INDEX(p, OUTPORT_INDEX); - - p->nBufferCountActual = OUTPORT_NATIVE_BUFFER_COUNT; - return OMXVideoDecoderBase::SetMaxOutputBufferCount(p); -} -DECLARE_OMX_COMPONENT("OMX.Intel.VideoDecoder.AVC.secure", "video_decoder.avc", OMXVideoDecoderAVCSecure); diff --git a/videocodec/securevideo/ctp/OMXVideoDecoderAVCSecure.h b/videocodec/securevideo/ctp/OMXVideoDecoderAVCSecure.h deleted file mode 100644 index 5c16a70..0000000 --- a/videocodec/securevideo/ctp/OMXVideoDecoderAVCSecure.h +++ /dev/null @@ -1,87 +0,0 @@ -/* -* Copyright (c) 2009-2012 Intel Corporation. All rights reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef OMX_VIDEO_DECODER_AVC_SECURE_H_ -#define OMX_VIDEO_DECODER_AVC_SECURE_H_ - - -#include "OMXVideoDecoderBase.h" - -class OMXVideoDecoderAVCSecure : public OMXVideoDecoderBase { -public: - OMXVideoDecoderAVCSecure(); - virtual ~OMXVideoDecoderAVCSecure(); - -protected: - virtual OMX_ERRORTYPE InitInputPortFormatSpecific(OMX_PARAM_PORTDEFINITIONTYPE *paramPortDefinitionInput); - virtual OMX_ERRORTYPE ProcessorInit(void); - virtual OMX_ERRORTYPE ProcessorDeinit(void); - virtual OMX_ERRORTYPE ProcessorStart(void); - virtual OMX_ERRORTYPE ProcessorStop(void); - virtual OMX_ERRORTYPE ProcessorPause(void); - virtual OMX_ERRORTYPE ProcessorResume(void); - virtual OMX_ERRORTYPE ProcessorFlush(OMX_U32 portIndex); - virtual OMX_ERRORTYPE ProcessorProcess( - OMX_BUFFERHEADERTYPE ***pBuffers, - buffer_retain_t *retains, - OMX_U32 numberBuffers); - - virtual OMX_ERRORTYPE PrepareConfigBuffer(VideoConfigBuffer *p); - virtual OMX_ERRORTYPE PrepareDecodeBuffer(OMX_BUFFERHEADERTYPE *buffer, buffer_retain_t *retain, VideoDecodeBuffer *p); - - virtual OMX_ERRORTYPE BuildHandlerList(void); - virtual OMX_ERRORTYPE SetMaxOutputBufferCount(OMX_PARAM_PORTDEFINITIONTYPE *p); - DECLARE_HANDLER(OMXVideoDecoderAVCSecure, ParamVideoAvc); - DECLARE_HANDLER(OMXVideoDecoderAVCSecure, ParamVideoAVCProfileLevel); - -private: - static OMX_U8* MemAllocIMR(OMX_U32 nSizeBytes, OMX_PTR pUserData); - static void MemFreeIMR(OMX_U8 *pBuffer, OMX_PTR pUserData); - OMX_U8* MemAllocIMR(OMX_U32 nSizeBytes); - void MemFreeIMR(OMX_U8 *pBuffer); - static void KeepAliveTimerCallback(sigval v); - void KeepAliveTimerCallback(); - bool EnableIEDSession(bool enable); - -private: - enum { - // OMX_PARAM_PORTDEFINITIONTYPE - INPORT_MIN_BUFFER_COUNT = 1, - INPORT_ACTUAL_BUFFER_COUNT = 5, - INPORT_BUFFER_SIZE = 1382400, - - // for OMX_VIDEO_PARAM_INTEL_AVC_DECODE_SETTINGS - // default number of reference frame - NUM_REFERENCE_FRAME = 4, - - // a typical value for 1080p clips - OUTPORT_NATIVE_BUFFER_COUNT = 17, - }; - - OMX_VIDEO_PARAM_AVCTYPE mParamAvc; - - struct IMRSlot { - uint32_t offset; - uint8_t *owner; // pointer to OMX buffer that owns this slot - } mIMRSlot[INPORT_ACTUAL_BUFFER_COUNT]; - - timer_t mKeepAliveTimer; - - bool mSessionPaused; - int mDrmDevFd; -}; - -#endif /* OMX_VIDEO_DECODER_AVC_SECURE_H_ */ diff --git a/videocodec/securevideo/merrifield/OMXVideoDecoderAVCSecure.cpp b/videocodec/securevideo/merrifield/OMXVideoDecoderAVCSecure.cpp deleted file mode 100755 index 8c810e2..0000000 --- a/videocodec/securevideo/merrifield/OMXVideoDecoderAVCSecure.cpp +++ /dev/null @@ -1,499 +0,0 @@ -/* -* Copyright (c) 2009-2012 Intel Corporation. All rights reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - - -//#define LOG_NDEBUG 0 -#define LOG_TAG "OMXVideoDecoder" -#include <wrs_omxil_core/log.h> -#include "OMXVideoDecoderAVCSecure.h" -#include <time.h> -#include <signal.h> -#include <pthread.h> - - -extern "C" { -#include <sepdrm.h> -#include <fcntl.h> -#include <linux/psb_drm.h> -#include "xf86drm.h" -#include "xf86drmMode.h" -} - -#include "VideoFrameInfo.h" - -// Be sure to have an equal string in VideoDecoderHost.cpp (libmix) -static const char* AVC_MIME_TYPE = "video/avc"; -static const char* AVC_SECURE_MIME_TYPE = "video/avc-secure"; - -#define DATA_BUFFER_INITIAL_OFFSET 0 //1024 -#define DATA_BUFFER_SIZE (8 * 1024 * 1024) -#define KEEP_ALIVE_INTERVAL 5 // seconds -#define DRM_KEEP_ALIVE_TIMER 1000000 -#define WV_SESSION_ID 0x00000011 -#define NALU_BUFFER_SIZE 8192 -#define NALU_HEADER_LENGTH 1024 // THis should be changed to 4K -#define FLUSH_WAIT_INTERVAL (30 * 1000) //30 ms - -#define DRM_SCHEME_NONE 0 -#define DRM_SCHEME_WV_CLASSIC 1 -#define DRM_SCHEME_WV_MODULAR 2 - -//#pragma pack(push, 1) -struct DataBuffer { - uint32_t size; - uint8_t *data; - uint8_t clear; - uint32_t drmScheme; -}; -//#pragma pack(pop) - -OMXVideoDecoderAVCSecure::OMXVideoDecoderAVCSecure() - : mKeepAliveTimer(0), - mSessionPaused(false){ - LOGV("OMXVideoDecoderAVCSecure is constructed."); - mVideoDecoder = createVideoDecoder(AVC_SECURE_MIME_TYPE); - if (!mVideoDecoder) { - LOGE("createVideoDecoder failed for \"%s\"", AVC_SECURE_MIME_TYPE); - } - // Override default native buffer count defined in the base class - mNativeBufferCount = OUTPORT_NATIVE_BUFFER_COUNT; - - BuildHandlerList(); -} - -OMXVideoDecoderAVCSecure::~OMXVideoDecoderAVCSecure() { - LOGI("OMXVideoDecoderAVCSecure is destructed."); - -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::InitInputPortFormatSpecific(OMX_PARAM_PORTDEFINITIONTYPE *paramPortDefinitionInput) { - // OMX_PARAM_PORTDEFINITIONTYPE - paramPortDefinitionInput->nBufferCountActual = INPORT_ACTUAL_BUFFER_COUNT; - paramPortDefinitionInput->nBufferCountMin = INPORT_MIN_BUFFER_COUNT; - paramPortDefinitionInput->nBufferSize = INPORT_BUFFER_SIZE; - paramPortDefinitionInput->format.video.cMIMEType = (OMX_STRING)AVC_MIME_TYPE; - paramPortDefinitionInput->format.video.eCompressionFormat = OMX_VIDEO_CodingAVC; - - // OMX_VIDEO_PARAM_AVCTYPE - memset(&mParamAvc, 0, sizeof(mParamAvc)); - SetTypeHeader(&mParamAvc, sizeof(mParamAvc)); - mParamAvc.nPortIndex = INPORT_INDEX; - // TODO: check eProfile/eLevel - mParamAvc.eProfile = OMX_VIDEO_AVCProfileHigh; //OMX_VIDEO_AVCProfileBaseline; - mParamAvc.eLevel = OMX_VIDEO_AVCLevel41; //OMX_VIDEO_AVCLevel1; - - this->ports[INPORT_INDEX]->SetMemAllocator(MemAllocDataBuffer, MemFreeDataBuffer, this); - - for (int i = 0; i < INPORT_ACTUAL_BUFFER_COUNT; i++) { - mDataBufferSlot[i].offset = DATA_BUFFER_INITIAL_OFFSET + i * INPORT_BUFFER_SIZE; - mDataBufferSlot[i].owner = NULL; - } - - return OMX_ErrorNone; -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::ProcessorInit(void) { - mSessionPaused = false; - return OMXVideoDecoderBase::ProcessorInit(); -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::ProcessorDeinit(void) { - // Session should be torn down in ProcessorStop, delayed to ProcessorDeinit - // to allow remaining frames completely rendered. - LOGI("Calling Drm_DestroySession."); - if (mDrmScheme == DRM_SCHEME_WV_CLASSIC) { - uint32_t sepres = drm_destroy_session(WV_SESSION_ID); - if (sepres != 0) { - LOGW("Drm_DestroySession returns %#x", sepres); - } - } - else if(mDrmScheme == DRM_SCHEME_WV_MODULAR) { - uint32_t ret = drm_wv_mod_stop_playback(WV_SESSION_ID); - if (ret != DRM_WV_MOD_SUCCESS) { - LOGW("Modular WV - drm_wv_mod_stop_playback returns %#x", ret); - } - } - return OMXVideoDecoderBase::ProcessorDeinit(); -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::ProcessorStart(void) { - uint32_t imrOffset = 0; - uint32_t dataBufferSize = DATA_BUFFER_SIZE; - - mSessionPaused = false; - return OMXVideoDecoderBase::ProcessorStart(); -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::ProcessorStop(void) { - if (mKeepAliveTimer != 0) { - timer_delete(mKeepAliveTimer); - mKeepAliveTimer = 0; - } - - return OMXVideoDecoderBase::ProcessorStop(); -} - - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::ProcessorFlush(OMX_U32 portIndex) { - return OMXVideoDecoderBase::ProcessorFlush(portIndex); -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::ProcessorProcess( - OMX_BUFFERHEADERTYPE ***pBuffers, - buffer_retain_t *retains, - OMX_U32 numberBuffers) { - - int ret_value; - - OMX_BUFFERHEADERTYPE *pInput = *pBuffers[INPORT_INDEX]; - DataBuffer *dataBuffer = (DataBuffer *)pInput->pBuffer; - - if((dataBuffer->drmScheme == DRM_SCHEME_WV_CLASSIC) && (!mKeepAliveTimer)){ - struct sigevent sev; - memset(&sev, 0, sizeof(sev)); - sev.sigev_notify = SIGEV_THREAD; - sev.sigev_value.sival_ptr = this; - sev.sigev_notify_function = KeepAliveTimerCallback; - - ret_value = timer_create(CLOCK_REALTIME, &sev, &mKeepAliveTimer); - if (ret_value != 0) { - LOGE("Failed to create timer."); - } else { - struct itimerspec its; - its.it_value.tv_sec = -1; // never expire - its.it_value.tv_nsec = 0; - its.it_interval.tv_sec = KEEP_ALIVE_INTERVAL; - its.it_interval.tv_nsec = 0; - - ret_value = timer_settime(mKeepAliveTimer, TIMER_ABSTIME, &its, NULL); - if (ret_value != 0) { - LOGE("Failed to set timer."); - } - } - } - - if (dataBuffer->size == 0) { - // error occurs during decryption. - LOGW("size of returned data buffer is 0, decryption fails."); - mVideoDecoder->flush(); - usleep(FLUSH_WAIT_INTERVAL); - OMX_BUFFERHEADERTYPE *pOutput = *pBuffers[OUTPORT_INDEX]; - pOutput->nFilledLen = 0; - // reset Data buffer size - dataBuffer->size = INPORT_BUFFER_SIZE; - this->ports[INPORT_INDEX]->FlushPort(); - this->ports[OUTPORT_INDEX]->FlushPort(); - return OMX_ErrorNone; - } - - OMX_ERRORTYPE ret; - ret = OMXVideoDecoderBase::ProcessorProcess(pBuffers, retains, numberBuffers); - if (ret != OMX_ErrorNone) { - LOGE("OMXVideoDecoderBase::ProcessorProcess failed. Result: %#x", ret); - return ret; - } - - if (mSessionPaused && (retains[OUTPORT_INDEX] == BUFFER_RETAIN_GETAGAIN)) { - retains[OUTPORT_INDEX] = BUFFER_RETAIN_NOT_RETAIN; - OMX_BUFFERHEADERTYPE *pOutput = *pBuffers[OUTPORT_INDEX]; - pOutput->nFilledLen = 0; - this->ports[INPORT_INDEX]->FlushPort(); - this->ports[OUTPORT_INDEX]->FlushPort(); - } - - return ret; -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::ProcessorPause(void) { - return OMXVideoDecoderBase::ProcessorPause(); -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::ProcessorResume(void) { - return OMXVideoDecoderBase::ProcessorResume(); -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::PrepareConfigBuffer(VideoConfigBuffer *p) { - OMX_ERRORTYPE ret; - ret = OMXVideoDecoderBase::PrepareConfigBuffer(p); - CHECK_RETURN_VALUE("OMXVideoDecoderBase::PrepareConfigBuffer"); - p->flag |= WANT_SURFACE_PROTECTION; - return ret; -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::PrepareClassicWVDecodeBuffer(OMX_BUFFERHEADERTYPE *buffer, buffer_retain_t *retain, VideoDecodeBuffer *p){ - - OMX_ERRORTYPE ret = OMX_ErrorNone; - - - p->flag |= HAS_COMPLETE_FRAME; - - if (buffer->nOffset != 0) { - LOGW("buffer offset %lu is not zero!!!", buffer->nOffset); - } - - DataBuffer *dataBuffer = (DataBuffer *)buffer->pBuffer; - if (dataBuffer->clear) { - p->data = dataBuffer->data + buffer->nOffset; - p->size = buffer->nFilledLen; - } else { - dataBuffer->size = NALU_BUFFER_SIZE; - struct drm_wv_nalu_headers nalu_headers; - nalu_headers.p_enc_ciphertext = dataBuffer->data; - - // TODO: NALU Buffer is supposed to be 4k but using 1k, fix it once chaabi fix is there - - nalu_headers.hdrs_buf_len = NALU_HEADER_LENGTH; - nalu_headers.frame_size = buffer->nFilledLen; - // Make sure that NALU header frame size is 16 bytes aligned - nalu_headers.frame_size = (nalu_headers.frame_size + 0xF) & (~0xF); - // Use same video buffer to fill NALU headers returned by chaabi, - // Adding 4 because the first 4 bytes after databuffer will be used to store length of NALU headers - if((nalu_headers.frame_size + NALU_HEADER_LENGTH) > INPORT_BUFFER_SIZE){ - LOGE("Not enough buffer for NALU headers"); - return OMX_ErrorOverflow; - } - - nalu_headers.p_hdrs_buf = (uint8_t *)(dataBuffer->data + nalu_headers.frame_size + 4); - nalu_headers.parse_size = buffer->nFilledLen; - - uint32_t res = drm_wv_return_naluheaders(WV_SESSION_ID, &nalu_headers); - if (res == DRM_FAIL_FW_SESSION) { - LOGW("Drm_WV_ReturnNALUHeaders failed. Session is disabled."); - mSessionPaused = true; - ret = OMX_ErrorNotReady; - } else if (res != 0) { - mSessionPaused = false; - LOGE("Drm_WV_ReturnNALUHeaders failed. Error = %#x, frame_size: %d, len = %lu", res, nalu_headers.frame_size, buffer->nFilledLen); - ret = OMX_ErrorHardware; - } else { - mSessionPaused = false; - - // If chaabi returns 0 NALU headers fill the frame size to zero. - if (!nalu_headers.hdrs_buf_len) { - p->size = 0; - return ret; - } - else{ - // NALU headers are appended to encrypted video bitstream - // |...encrypted video bitstream (16 bytes aligned)...| 4 bytes of header size |...NALU headers..| - uint32_t *ptr = (uint32_t*)(dataBuffer->data + nalu_headers.frame_size); - *ptr = nalu_headers.hdrs_buf_len; - p->data = dataBuffer->data; - p->size = nalu_headers.frame_size; - p->flag |= IS_SECURE_DATA; - } - } - } - - // reset Data size - dataBuffer->size = NALU_BUFFER_SIZE; - return ret; -} -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::PrepareModularWVDecodeBuffer(OMX_BUFFERHEADERTYPE *buffer, buffer_retain_t *retain, VideoDecodeBuffer *p){ - OMX_ERRORTYPE ret = OMX_ErrorNone; - - // OMX_BUFFERFLAG_CODECCONFIG is an optional flag - // if flag is set, buffer will only contain codec data. - if (buffer->nFlags & OMX_BUFFERFLAG_CODECCONFIG) { - LOGI("Received AVC codec data."); - // return ret; - } - p->flag |= HAS_COMPLETE_FRAME | IS_SUBSAMPLE_ENCRYPTION; - - if (buffer->nOffset != 0) { - LOGW("buffer offset %lu is not zero!!!", buffer->nOffset); - } - - DataBuffer *dataBuffer = (DataBuffer *)buffer->pBuffer; - p->data = dataBuffer->data; - p->size = sizeof(frame_info_t); - p->flag |= IS_SECURE_DATA; - return ret; -} - - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::PrepareDecodeBuffer(OMX_BUFFERHEADERTYPE *buffer, buffer_retain_t *retain, VideoDecodeBuffer *p) { - OMX_ERRORTYPE ret; - - ret = OMXVideoDecoderBase::PrepareDecodeBuffer(buffer, retain, p); - CHECK_RETURN_VALUE("OMXVideoDecoderBase::PrepareDecodeBuffer"); - - if (buffer->nFilledLen == 0) { - return OMX_ErrorNone; - } - - DataBuffer *dataBuffer = (DataBuffer *)buffer->pBuffer; - if(dataBuffer->drmScheme == DRM_SCHEME_WV_CLASSIC){ - - // OMX_BUFFERFLAG_CODECCONFIG is an optional flag - // if flag is set, buffer will only contain codec data. - mDrmScheme = DRM_SCHEME_WV_CLASSIC; - if (buffer->nFlags & OMX_BUFFERFLAG_CODECCONFIG) { - LOGV("Received AVC codec data."); - return ret; - } - return PrepareClassicWVDecodeBuffer(buffer, retain, p); - } - else if(dataBuffer->drmScheme == DRM_SCHEME_WV_MODULAR) { - mDrmScheme = DRM_SCHEME_WV_MODULAR; - return PrepareModularWVDecodeBuffer(buffer, retain, p); - } - return ret; -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::BuildHandlerList(void) { - OMXVideoDecoderBase::BuildHandlerList(); - AddHandler(OMX_IndexParamVideoAvc, GetParamVideoAvc, SetParamVideoAvc); - AddHandler(OMX_IndexParamVideoProfileLevelQuerySupported, GetParamVideoAVCProfileLevel, SetParamVideoAVCProfileLevel); - return OMX_ErrorNone; -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::GetParamVideoAvc(OMX_PTR pStructure) { - OMX_ERRORTYPE ret; - OMX_VIDEO_PARAM_AVCTYPE *p = (OMX_VIDEO_PARAM_AVCTYPE *)pStructure; - CHECK_TYPE_HEADER(p); - CHECK_PORT_INDEX(p, INPORT_INDEX); - - memcpy(p, &mParamAvc, sizeof(*p)); - return OMX_ErrorNone; -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::SetParamVideoAvc(OMX_PTR pStructure) { - OMX_ERRORTYPE ret; - OMX_VIDEO_PARAM_AVCTYPE *p = (OMX_VIDEO_PARAM_AVCTYPE *)pStructure; - CHECK_TYPE_HEADER(p); - CHECK_PORT_INDEX(p, INPORT_INDEX); - CHECK_SET_PARAM_STATE(); - - // TODO: do we need to check if port is enabled? - // TODO: see SetPortAvcParam implementation - Can we make simple copy???? - memcpy(&mParamAvc, p, sizeof(mParamAvc)); - return OMX_ErrorNone; -} - - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::GetParamVideoAVCProfileLevel(OMX_PTR pStructure) { - OMX_ERRORTYPE ret; - OMX_VIDEO_PARAM_PROFILELEVELTYPE *p = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pStructure; - CHECK_TYPE_HEADER(p); - CHECK_PORT_INDEX(p, INPORT_INDEX); - CHECK_ENUMERATION_RANGE(p->nProfileIndex,1); - - p->eProfile = mParamAvc.eProfile; - p->eLevel = mParamAvc.eLevel; - - return OMX_ErrorNone; -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::SetParamVideoAVCProfileLevel(OMX_PTR pStructure) { - LOGW("SetParamVideoAVCProfileLevel is not supported."); - return OMX_ErrorUnsupportedSetting; -} - -OMX_U8* OMXVideoDecoderAVCSecure::MemAllocDataBuffer(OMX_U32 nSizeBytes, OMX_PTR pUserData) { - OMXVideoDecoderAVCSecure* p = (OMXVideoDecoderAVCSecure *)pUserData; - if (p) { - return p->MemAllocDataBuffer(nSizeBytes); - } - LOGE("NULL pUserData."); - return NULL; -} - -void OMXVideoDecoderAVCSecure::MemFreeDataBuffer(OMX_U8 *pBuffer, OMX_PTR pUserData) { - OMXVideoDecoderAVCSecure* p = (OMXVideoDecoderAVCSecure *)pUserData; - if (p) { - p->MemFreeDataBuffer(pBuffer); - return; - } - LOGE("NULL pUserData."); -} - -OMX_U8* OMXVideoDecoderAVCSecure::MemAllocDataBuffer(OMX_U32 nSizeBytes) { - if (nSizeBytes > INPORT_BUFFER_SIZE) { - LOGE("Invalid size (%lu) of memory to allocate.", nSizeBytes); - return NULL; - } - LOGW_IF(nSizeBytes != INPORT_BUFFER_SIZE, "Size of memory to allocate is %lu", nSizeBytes); - for (int i = 0; i < INPORT_ACTUAL_BUFFER_COUNT; i++) { - if (mDataBufferSlot[i].owner == NULL) { - DataBuffer *pBuffer = new DataBuffer; - if (pBuffer == NULL) { - LOGE("Failed to allocate memory."); - return NULL; - } - - pBuffer->data = new uint8_t [INPORT_BUFFER_SIZE]; - if (pBuffer->data == NULL) { - delete pBuffer; - LOGE("Failed to allocate memory, size to allocate %d.", INPORT_BUFFER_SIZE); - return NULL; - } - - // Is this required for classic or not? - // pBuffer->offset = mDataBufferSlot[i].offset; - pBuffer->size = INPORT_BUFFER_SIZE; - mDataBufferSlot[i].owner = (OMX_U8 *)pBuffer; - - LOGV("Allocating buffer = %#x, Data offset = %#x, data = %#x", (uint32_t)pBuffer, mDataBufferSlot[i].offset, (uint32_t)pBuffer->data); - return (OMX_U8 *) pBuffer; - } - } - LOGE("Data buffer slot is not available."); - return NULL; -} - -void OMXVideoDecoderAVCSecure::MemFreeDataBuffer(OMX_U8 *pBuffer) { - DataBuffer *p = (DataBuffer*) pBuffer; - if (p == NULL) { - return; - } - for (int i = 0; i < INPORT_ACTUAL_BUFFER_COUNT; i++) { - if (pBuffer == mDataBufferSlot[i].owner) { - LOGV("Freeing Data buffer offset = %d, data = %#x", mDataBufferSlot[i].offset, (uint32_t)p->data); - delete [] p->data; - delete p; - mDataBufferSlot[i].owner = NULL; - return; - } - } - LOGE("Invalid buffer %#x to de-allocate", (uint32_t)pBuffer); -} - -void OMXVideoDecoderAVCSecure::KeepAliveTimerCallback(sigval v) { - OMXVideoDecoderAVCSecure *p = (OMXVideoDecoderAVCSecure *)v.sival_ptr; - if (p) { - p->KeepAliveTimerCallback(); - } -} - -void OMXVideoDecoderAVCSecure::KeepAliveTimerCallback() { - uint32_t timeout = DRM_KEEP_ALIVE_TIMER; - uint32_t sepres = drm_keep_alive(WV_SESSION_ID, &timeout); - if (sepres != 0) { - LOGE("Drm_KeepAlive failed. Result = %#x", sepres); - } -} - -OMX_ERRORTYPE OMXVideoDecoderAVCSecure::SetMaxOutputBufferCount(OMX_PARAM_PORTDEFINITIONTYPE *p) { - OMX_ERRORTYPE ret; - CHECK_TYPE_HEADER(p); - CHECK_PORT_INDEX(p, OUTPORT_INDEX); - - p->nBufferCountActual = OUTPORT_NATIVE_BUFFER_COUNT; - return OMXVideoDecoderBase::SetMaxOutputBufferCount(p); -} - -DECLARE_OMX_COMPONENT("OMX.Intel.VideoDecoder.AVC.secure", "video_decoder.avc", OMXVideoDecoderAVCSecure); diff --git a/videocodec/securevideo/merrifield/OMXVideoDecoderAVCSecure.h b/videocodec/securevideo/merrifield/OMXVideoDecoderAVCSecure.h deleted file mode 100755 index 6281c23..0000000 --- a/videocodec/securevideo/merrifield/OMXVideoDecoderAVCSecure.h +++ /dev/null @@ -1,89 +0,0 @@ -/* -* Copyright (c) 2009-2012 Intel Corporation. All rights reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef OMX_VIDEO_DECODER_AVC_SECURE_H_ -#define OMX_VIDEO_DECODER_AVC_SECURE_H_ - - -#include "OMXVideoDecoderBase.h" - -class OMXVideoDecoderAVCSecure : public OMXVideoDecoderBase { -public: - OMXVideoDecoderAVCSecure(); - virtual ~OMXVideoDecoderAVCSecure(); - -protected: - virtual OMX_ERRORTYPE InitInputPortFormatSpecific(OMX_PARAM_PORTDEFINITIONTYPE *paramPortDefinitionInput); - virtual OMX_ERRORTYPE ProcessorInit(void); - virtual OMX_ERRORTYPE ProcessorDeinit(void); - virtual OMX_ERRORTYPE ProcessorStart(void); - virtual OMX_ERRORTYPE ProcessorStop(void); - virtual OMX_ERRORTYPE ProcessorPause(void); - virtual OMX_ERRORTYPE ProcessorResume(void); - virtual OMX_ERRORTYPE ProcessorFlush(OMX_U32 portIndex); - virtual OMX_ERRORTYPE ProcessorProcess( - OMX_BUFFERHEADERTYPE ***pBuffers, - buffer_retain_t *retains, - OMX_U32 numberBuffers); - - virtual OMX_ERRORTYPE PrepareConfigBuffer(VideoConfigBuffer *p); - virtual OMX_ERRORTYPE PrepareDecodeBuffer(OMX_BUFFERHEADERTYPE *buffer, buffer_retain_t *retain, VideoDecodeBuffer *p); - - virtual OMX_ERRORTYPE BuildHandlerList(void); - virtual OMX_ERRORTYPE SetMaxOutputBufferCount(OMX_PARAM_PORTDEFINITIONTYPE *p); - DECLARE_HANDLER(OMXVideoDecoderAVCSecure, ParamVideoAvc); - DECLARE_HANDLER(OMXVideoDecoderAVCSecure, ParamVideoAVCProfileLevel); - -private: - static OMX_U8* MemAllocDataBuffer(OMX_U32 nSizeBytes, OMX_PTR pUserData); - static void MemFreeDataBuffer(OMX_U8 *pBuffer, OMX_PTR pUserData); - OMX_U8* MemAllocDataBuffer(OMX_U32 nSizeBytes); - void MemFreeDataBuffer(OMX_U8 *pBuffer); - static void KeepAliveTimerCallback(sigval v); - void KeepAliveTimerCallback(); - //bool EnableIEDSession(bool enable); - OMX_ERRORTYPE PrepareClassicWVDecodeBuffer(OMX_BUFFERHEADERTYPE *buffer, buffer_retain_t *retain, VideoDecodeBuffer *p); - OMX_ERRORTYPE PrepareModularWVDecodeBuffer(OMX_BUFFERHEADERTYPE *buffer, buffer_retain_t *retain, VideoDecodeBuffer *p); - -private: - enum { - // OMX_PARAM_PORTDEFINITIONTYPE - INPORT_MIN_BUFFER_COUNT = 1, - INPORT_ACTUAL_BUFFER_COUNT = 5, - INPORT_BUFFER_SIZE = 1572864, - - // for OMX_VIDEO_PARAM_INTEL_AVC_DECODE_SETTINGS - // default number of reference frame - NUM_REFERENCE_FRAME = 4, - - // a typical value for 1080p clips - OUTPORT_NATIVE_BUFFER_COUNT = 17, - }; - - OMX_VIDEO_PARAM_AVCTYPE mParamAvc; - uint32_t mDrmScheme; - - struct IMRSlot { - uint32_t offset; - uint8_t *owner; // pointer to OMX buffer that owns this slot - } mDataBufferSlot[INPORT_ACTUAL_BUFFER_COUNT]; - - timer_t mKeepAliveTimer; - - bool mSessionPaused; -}; - -#endif /* OMX_VIDEO_DECODER_AVC_SECURE_H_ */ |