1 /* 2 * Copyright (c) 2009-2011 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 VIDEO_DECODER_AVC_SECURE_H 18 #define VIDEO_DECODER_AVC_SECURE_H 19 20 #include "VideoDecoderBase.h" 21 #include "VideoDecoderAVC.h" 22 #include "VideoDecoderDefs.h" 23 24 class VideoDecoderAVCSecure : public VideoDecoderAVC { 25 public: 26 VideoDecoderAVCSecure(const char *mimeType); 27 virtual Decode_Status start(VideoConfigBuffer *buffer); 28 virtual void stop(void); 29 30 // data in the decoded buffer is all encrypted. 31 virtual Decode_Status decode(VideoDecodeBuffer *buffer); 32 protected: 33 virtual Decode_Status decodeFrame(VideoDecodeBuffer *buffer, vbp_data_h264 *data); 34 virtual Decode_Status continueDecodingFrame(vbp_data_h264 *data); 35 virtual Decode_Status beginDecodingFrame(vbp_data_h264 *data); 36 virtual Decode_Status getCodecSpecificConfigs(VAProfile profile, VAConfigID*config); 37 Decode_Status parseClassicSliceHeader(VideoDecodeBuffer *buffer, vbp_data_h264 *data); 38 Decode_Status parseModularSliceHeader(VideoDecodeBuffer *buffer, vbp_data_h264 *data); 39 40 Decode_Status updateSliceParameter(vbp_data_h264 *data, void *sliceheaderbuf); 41 virtual Decode_Status decodeSlice(vbp_data_h264 *data, uint32_t picIndex, uint32_t sliceIndex); 42 private: 43 Decode_Status processClassicInputBuffer(VideoDecodeBuffer *buffer, vbp_data_h264 **data); 44 Decode_Status processModularInputBuffer(VideoDecodeBuffer *buffer, vbp_data_h264 **data); 45 int32_t mIsEncryptData; 46 int32_t mFrameSize; 47 uint8_t* mFrameData; 48 uint8_t* mClearData; 49 uint8_t* mCachedHeader; 50 int32_t mFrameIdx; 51 int32_t mModularMode; 52 53 enum { 54 MAX_SLICE_HEADER_NUM = 256, 55 }; 56 int32_t mSliceNum; 57 // Information of Slices in the Modular DRM Mode 58 struct SliceInfo { 59 uint8_t sliceHeaderByte; // first byte of the slice header 60 uint32_t sliceStartOffset; // offset of Slice unit in the firewalled buffer 61 uint32_t sliceByteOffset; // extra offset from the blockAligned slice offset 62 uint32_t sliceSize; // block aligned length of slice unit 63 uint32_t sliceLength; // actual size of the slice 64 }; 65 66 SliceInfo mSliceInfo[MAX_SLICE_HEADER_NUM]; 67 }; 68 69 #endif 70