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 "VideoDecoderAVC.h" 21 22 23 class VideoDecoderAVCSecure : public VideoDecoderAVC { 24 public: 25 VideoDecoderAVCSecure(const char *mimeType); 26 virtual ~VideoDecoderAVCSecure(); 27 28 virtual Decode_Status start(VideoConfigBuffer *buffer); 29 virtual void stop(void); 30 31 // data in the decoded buffer is all encrypted. 32 virtual Decode_Status decode(VideoDecodeBuffer *buffer); 33 34 private: 35 enum { 36 MAX_SLICE_HEADER_SIZE = 30, 37 MAX_NALU_HEADER_BUFFER = 8192, 38 MAX_NALU_NUMBER = 400, // > 4096/12 39 }; 40 41 // Information of Network Abstraction Layer Unit 42 struct NaluInfo { 43 int32_t naluOffset; // offset of NAL unit in the firewalled buffer 44 int32_t naluLen; // length of NAL unit 45 int32_t naluHeaderLen; // length of NAL unit header 46 }; 47 48 struct NaluMetadata { 49 NaluInfo *naluInfo; 50 int32_t naluNumber; // number of NAL units 51 }; 52 53 struct NaluByteStream { 54 int32_t naluOffset; 55 int32_t naluLen; 56 int32_t streamPos; 57 uint8_t *byteStream; // 4 bytes of naluCount, 4 bytes of naluOffset, 4 bytes of naulLen, 4 bytes of naluHeaderLen, followed by naluHeaderData 58 int32_t naluCount; 59 }; 60 61 virtual Decode_Status decodeSlice(vbp_data_h264 *data, uint32_t picIndex, uint32_t sliceIndex); 62 int32_t findNalUnitOffset(uint8_t *stream, int32_t offset, int32_t length); 63 Decode_Status copyNaluHeader(uint8_t *stream, NaluByteStream *naluStream); 64 Decode_Status parseAnnexBStream(uint8_t *stream, int32_t length, NaluByteStream *naluStream); 65 66 private: 67 NaluMetadata mMetadata; 68 NaluByteStream mByteStream; 69 uint8_t *mNaluHeaderBuffer; 70 uint8_t *mInputBuffer; 71 }; 72 73 74 75 #endif /* VIDEO_DECODER_AVC_SECURE_H_ */ 76