1 /* 2 * Copyright (c) 2009-2012 Intel Corporation. All rights reserved. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef OMX_VIDEO_DECODER_AVC_SECURE_H_ 18 #define OMX_VIDEO_DECODER_AVC_SECURE_H_ 19 20 21 #include "OMXVideoDecoderBase.h" 22 extern "C" { 23 #include "drm_vendor_api.h" 24 } 25 26 class OMXVideoDecoderAVCSecure : public OMXVideoDecoderBase { 27 public: 28 OMXVideoDecoderAVCSecure(); 29 virtual ~OMXVideoDecoderAVCSecure(); 30 31 protected: 32 virtual OMX_ERRORTYPE InitInputPortFormatSpecific(OMX_PARAM_PORTDEFINITIONTYPE *paramPortDefinitionInput); 33 virtual OMX_ERRORTYPE ProcessorInit(void); 34 virtual OMX_ERRORTYPE ProcessorDeinit(void); 35 virtual OMX_ERRORTYPE ProcessorStart(void); 36 virtual OMX_ERRORTYPE ProcessorStop(void); 37 virtual OMX_ERRORTYPE ProcessorPause(void); 38 virtual OMX_ERRORTYPE ProcessorResume(void); 39 virtual OMX_ERRORTYPE ProcessorFlush(OMX_U32 portIndex); 40 virtual OMX_ERRORTYPE ProcessorProcess( 41 OMX_BUFFERHEADERTYPE ***pBuffers, 42 buffer_retain_t *retains, 43 OMX_U32 numberBuffers); 44 45 virtual OMX_ERRORTYPE PrepareConfigBuffer(VideoConfigBuffer *p); 46 virtual OMX_ERRORTYPE PrepareDecodeBuffer(OMX_BUFFERHEADERTYPE *buffer, buffer_retain_t *retain, VideoDecodeBuffer *p); 47 48 virtual OMX_ERRORTYPE BuildHandlerList(void); 49 virtual OMX_ERRORTYPE SetMaxOutputBufferCount(OMX_PARAM_PORTDEFINITIONTYPE *p); 50 DECLARE_HANDLER(OMXVideoDecoderAVCSecure, ExtAllocateNativeHandle); 51 DECLARE_HANDLER(OMXVideoDecoderAVCSecure, ParamVideoAvc); 52 DECLARE_HANDLER(OMXVideoDecoderAVCSecure, ParamVideoAVCProfileLevel); 53 54 private: 55 static OMX_U8* MemAllocDataBuffer(OMX_U32 nSizeBytes, OMX_PTR pUserData); 56 static void MemFreeDataBuffer(OMX_U8 *pBuffer, OMX_PTR pUserData); 57 OMX_U8* MemAllocDataBuffer(OMX_U32 nSizeBytes); 58 void MemFreeDataBuffer(OMX_U8 *pBuffer); 59 static void KeepAliveTimerCallback(sigval v); 60 void KeepAliveTimerCallback(); 61 void WaitForFrameDisplayed(); 62 bool EnableIEDSession(bool enable); 63 OMX_ERRORTYPE PrepareWVCDecodeBuffer(OMX_BUFFERHEADERTYPE *buffer, buffer_retain_t *retain, VideoDecodeBuffer *p); 64 OMX_ERRORTYPE PrepareCENCDecodeBuffer(OMX_BUFFERHEADERTYPE *buffer, buffer_retain_t *retain, VideoDecodeBuffer *p); 65 OMX_ERRORTYPE PreparePRASFDecodeBuffer(OMX_BUFFERHEADERTYPE *buffer, buffer_retain_t *retain, VideoDecodeBuffer *p); 66 private: 67 enum { 68 // OMX_PARAM_PORTDEFINITIONTYPE 69 INPORT_MIN_BUFFER_COUNT = 1, 70 INPORT_ACTUAL_BUFFER_COUNT = 5, 71 INPORT_BUFFER_SIZE = 1572864, 72 73 // for OMX_VIDEO_PARAM_INTEL_AVC_DECODE_SETTINGS 74 // default number of reference frame 75 NUM_REFERENCE_FRAME = 4, 76 77 // a typical value for 1080p clips 78 OUTPORT_NATIVE_BUFFER_COUNT = 17, 79 }; 80 81 OMX_VIDEO_PARAM_AVCTYPE mParamAvc; 82 uint32_t mDrmScheme; 83 84 struct IMRSlot { 85 uint32_t offset; 86 uint8_t *owner; // pointer to OMX buffer that owns this slot 87 } mDataBufferSlot[INPORT_ACTUAL_BUFFER_COUNT]; 88 89 timer_t mKeepAliveTimer; 90 91 // Keep track of number of allocated inport buffers 92 uint32_t mNumInportBuffers; 93 bool mSessionPaused; 94 struct drm_vendor_api drm_vendor_api; 95 int mDrmDevFd; 96 }; 97 98 #endif /* OMX_VIDEO_DECODER_AVC_SECURE_H_ */ 99