Home | History | Annotate | Download | only in moorefield
      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, ParamVideoAvc);
     51    DECLARE_HANDLER(OMXVideoDecoderAVCSecure, ParamVideoAVCProfileLevel);
     52 
     53 private:
     54     static OMX_U8* MemAllocDataBuffer(OMX_U32 nSizeBytes, OMX_PTR pUserData);
     55     static void MemFreeDataBuffer(OMX_U8 *pBuffer, OMX_PTR pUserData);
     56     OMX_U8* MemAllocDataBuffer(OMX_U32 nSizeBytes);
     57     void  MemFreeDataBuffer(OMX_U8 *pBuffer);
     58     static void KeepAliveTimerCallback(sigval v);
     59     void KeepAliveTimerCallback();
     60     void WaitForFrameDisplayed();
     61     bool EnableIEDSession(bool enable);
     62     OMX_ERRORTYPE PrepareWVCDecodeBuffer(OMX_BUFFERHEADERTYPE *buffer, buffer_retain_t *retain, VideoDecodeBuffer *p);
     63     OMX_ERRORTYPE PrepareCENCDecodeBuffer(OMX_BUFFERHEADERTYPE *buffer, buffer_retain_t *retain, VideoDecodeBuffer *p);
     64     OMX_ERRORTYPE PreparePRASFDecodeBuffer(OMX_BUFFERHEADERTYPE *buffer, buffer_retain_t *retain, VideoDecodeBuffer *p);
     65 private:
     66     enum {
     67         // OMX_PARAM_PORTDEFINITIONTYPE
     68         INPORT_MIN_BUFFER_COUNT = 1,
     69         INPORT_ACTUAL_BUFFER_COUNT = 5,
     70         INPORT_BUFFER_SIZE = 1572864,
     71 
     72         // for OMX_VIDEO_PARAM_INTEL_AVC_DECODE_SETTINGS
     73         // default number of reference frame
     74         NUM_REFERENCE_FRAME = 4,
     75 
     76         // a typical value for 1080p clips
     77         OUTPORT_NATIVE_BUFFER_COUNT = 17,
     78     };
     79 
     80     OMX_VIDEO_PARAM_AVCTYPE mParamAvc;
     81     uint32_t mDrmScheme;
     82 
     83     struct IMRSlot {
     84         uint32_t offset;
     85         uint8_t *owner;  // pointer to OMX buffer that owns this slot
     86     } mDataBufferSlot[INPORT_ACTUAL_BUFFER_COUNT];
     87 
     88     timer_t mKeepAliveTimer;
     89 
     90     // Keep track of number of allocated inport buffers
     91     uint32_t mNumInportBuffers;
     92     bool mSessionPaused;
     93     struct drm_vendor_api drm_vendor_api;
     94     int mDrmDevFd;
     95 };
     96 
     97 #endif /* OMX_VIDEO_DECODER_AVC_SECURE_H_ */
     98