diff options
| author | Andy Qiu <junhai.qiu@intel.com> | 2011-09-13 10:49:27 -0700 |
|---|---|---|
| committer | Patrick Tjin <pattjin@google.com> | 2014-07-21 22:02:44 -0700 |
| commit | 7994731eb9593e1f2a7d1dade54845753e2a8688 (patch) | |
| tree | 041a294c12ba8ffb55fad7df0e7ed6d004155bdb /videocodec/OMXVideoDecoderPAVC.cpp | |
| parent | 88cefcfdc460d30a6774325ec20c0d5b593df71d (diff) | |
| download | android_hardware_intel_common_omx-components-7994731eb9593e1f2a7d1dade54845753e2a8688.tar.gz android_hardware_intel_common_omx-components-7994731eb9593e1f2a7d1dade54845753e2a8688.tar.bz2 android_hardware_intel_common_omx-components-7994731eb9593e1f2a7d1dade54845753e2a8688.zip | |
Support playing protected contents.
BZ: 7358
Add OMXVideoDecoderPAVC class for playing protected contents.
Change-Id: Ibb93bf560c7f21262eebd66fa3fa8d1c3cdf24aa
Signed-off-by: Andy Qiu <junhai.qiu@intel.com>
Reviewed-on: http://android.intel.com:8080/20277
Reviewed-by: Sun, Hang L <hang.l.sun@intel.com>
Tested-by: Sun, Hang L <hang.l.sun@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
Diffstat (limited to 'videocodec/OMXVideoDecoderPAVC.cpp')
| -rw-r--r-- | videocodec/OMXVideoDecoderPAVC.cpp | 205 |
1 files changed, 205 insertions, 0 deletions
diff --git a/videocodec/OMXVideoDecoderPAVC.cpp b/videocodec/OMXVideoDecoderPAVC.cpp new file mode 100644 index 0000000..30ec9ca --- /dev/null +++ b/videocodec/OMXVideoDecoderPAVC.cpp @@ -0,0 +1,205 @@ +/* +* Copyright (c) 2009-2011 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 "OMXVideoDecoderPAVC" +#include <utils/Log.h> +#include "OMXVideoDecoderPAVC.h" + +// Be sure to have an equal string in VideoDecoderHost.cpp (libmix) +static const char* PAVC_MIME_TYPE = "video/PAVC"; +#define INVALID_PTS (OMX_S64)-1 + + +OMXVideoDecoderPAVC::OMXVideoDecoderPAVC() { + LOGV("OMXVideoDecoderPAVC is constructed."); + mVideoDecoder = createVideoDecoder(PAVC_MIME_TYPE); + if (!mVideoDecoder) { + LOGE("createVideoDecoder failed for \"%s\"", PAVC_MIME_TYPE); + } + + BuildHandlerList(); +} + +OMXVideoDecoderPAVC::~OMXVideoDecoderPAVC() { + LOGV("OMXVideoDecoderPAVC is destructed."); +} + +OMX_ERRORTYPE OMXVideoDecoderPAVC::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)PAVC_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; + + mCurrentProfile = mParamAvc.eProfile; + mCurrentLevel = mParamAvc.eLevel; + + return OMX_ErrorNone; +} + +OMX_ERRORTYPE OMXVideoDecoderPAVC::ProcessorInit(void) { + return OMXVideoDecoderBase::ProcessorInit(); +} + +OMX_ERRORTYPE OMXVideoDecoderPAVC::ProcessorDeinit(void) { + return OMXVideoDecoderBase::ProcessorDeinit(); +} + +OMX_ERRORTYPE OMXVideoDecoderPAVC::ProcessorFlush(OMX_U32 portIndex) { + return OMXVideoDecoderBase::ProcessorFlush(portIndex); +} + +OMX_ERRORTYPE OMXVideoDecoderPAVC::ProcessorProcess( + OMX_BUFFERHEADERTYPE **buffers, + buffer_retain_t *retains, + OMX_U32 numberBuffers) { + + return OMXVideoDecoderBase::ProcessorProcess(buffers, retains, numberBuffers); +} + +OMX_ERRORTYPE OMXVideoDecoderPAVC::PrepareConfigBuffer(VideoConfigBuffer *p) { + OMX_ERRORTYPE ret; + ret = OMXVideoDecoderBase::PrepareConfigBuffer(p); + CHECK_RETURN_VALUE("OMXVideoDecoderBase::PrepareConfigBuffer"); + + p->flag |= WANT_SURFACE_PROTECTION; + return OMX_ErrorNone; +} + +OMX_ERRORTYPE OMXVideoDecoderPAVC::PrepareDecodeBuffer(OMX_BUFFERHEADERTYPE *buffer, buffer_retain_t *retain, VideoDecodeBuffer *p) { + OMX_ERRORTYPE ret; + ret = OMXVideoDecoderBase::PrepareDecodeBuffer(buffer, retain, p); + CHECK_RETURN_VALUE("OMXVideoDecoderBase::PrepareDecodeBuffer"); + + // 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 codec data for Protected AVC."); + return ret; + } + + if (buffer->nFlags & OMX_BUFFERFLAG_EXTRADATA) { + p->flag |= HAS_EXTRADATA; + } else { + LOGW("No extra data found."); + } + return ret; +} + +OMX_ERRORTYPE OMXVideoDecoderPAVC::BuildHandlerList(void) { + OMXVideoDecoderBase::BuildHandlerList(); + AddHandler(OMX_IndexParamVideoAvc, GetParamVideoAvc, SetParamVideoAvc); + AddHandler(OMX_IndexParamVideoProfileLevelQuerySupported, GetVideoProfileLevelQuerySupported, SetVideoProfileLevelQuerySupported); + AddHandler(OMX_IndexParamVideoProfileLevelCurrent, GetVideoProfileLevelCurrent, SetVideoProfileLevelCurrent); + + return OMX_ErrorNone; +} + +OMX_ERRORTYPE OMXVideoDecoderPAVC::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 OMXVideoDecoderPAVC::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 OMXVideoDecoderPAVC::GetVideoProfileLevelQuerySupported(OMX_PTR pStructure) { + OMX_ERRORTYPE ret; + OMX_VIDEO_PARAM_PROFILELEVELTYPE *p = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pStructure; + + CHECK_TYPE_HEADER(p); + CHECK_PORT_INDEX_RANGE(p); + + if (p->nProfileIndex != 0) { + LOGE("No more profile index for GetVideoProfileLevelQuerySupported."); + return OMX_ErrorNoMore; + } + p->eProfile = mParamAvc.eProfile; + p->eLevel = mParamAvc.eLevel; + + return OMX_ErrorNone; +} + +OMX_ERRORTYPE OMXVideoDecoderPAVC::SetVideoProfileLevelQuerySupported(OMX_PTR pStructure) { + LOGE("SetVideoProfileLevelQuerySupported is not supported."); + return OMX_ErrorUnsupportedSetting; +} + +OMX_ERRORTYPE OMXVideoDecoderPAVC::GetVideoProfileLevelCurrent(OMX_PTR pStructure) { + OMX_ERRORTYPE ret; + OMX_VIDEO_PARAM_PROFILELEVELTYPE *p = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pStructure; + + CHECK_TYPE_HEADER(p); + CHECK_PORT_INDEX_RANGE(p); + + if (p->nProfileIndex != 0) { + LOGE("No more profile index for GetVideoProfileLevelCurrent."); + return OMX_ErrorNoMore; + } + + p->eProfile = mCurrentProfile; + p->eLevel = mCurrentLevel; + + return OMX_ErrorNone; +} + +OMX_ERRORTYPE OMXVideoDecoderPAVC::SetVideoProfileLevelCurrent(OMX_PTR pStructure) { + OMX_ERRORTYPE ret; + OMX_VIDEO_PARAM_PROFILELEVELTYPE *p = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pStructure; + + CHECK_TYPE_HEADER(p); + CHECK_PORT_INDEX_RANGE(p); + + if (p->nProfileIndex != 0) { + LOGE("Invalid profile index for SetVideoProfileLevelCurrent."); + return OMX_ErrorBadParameter; + } + + mCurrentProfile = (OMX_VIDEO_AVCPROFILETYPE) p->eProfile; + mCurrentLevel = (OMX_VIDEO_AVCLEVELTYPE) p->eLevel; + + return OMX_ErrorNone; +} + + +DECLARE_OMX_COMPONENT("OMX.Intel.VideoDecoder.PAVC", "video_decoder.pavc", OMXVideoDecoderPAVC); + |
