1 /* ------------------------------------------------------------------ 2 * Copyright (C) 1998-2009 PacketVideo 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 13 * express or implied. 14 * See the License for the specific language governing permissions 15 * and limitations under the License. 16 * ------------------------------------------------------------------- 17 */ 18 #if !defined(LEVEL1_H) 19 #define LEVEL1_H 20 #include "pduparcom.h" 21 22 #define LEVEL1_STUFFING_SZ 2 23 #define LEVEL1DF_STUFFING_SZ 4 24 #define LEVEL1_HDR_SZ 3 25 #define LEVEL1DF_HDR_SZ 5 26 27 class Level1PduParcom : public H223PduParcomBase 28 { 29 public: 30 typedef enum 31 { 32 ELookForStartFlag = 0, 33 ESkipFlags, 34 ELookForEndFlag 35 } EOperationId; 36 37 Level1PduParcom(bool df = false); ~Level1PduParcom()38 ~Level1PduParcom() 39 { 40 } GetLevel()41 TPVH223Level GetLevel() 42 { 43 return H223_LEVEL1; 44 } 45 UseDf(bool df)46 bool UseDf(bool df) 47 { 48 bool ret = iDf; 49 iDf = df; 50 return ret; 51 } 52 uint32 GetStuffing(uint8* buf, uint32 buf_size, uint8 mux_code = 0); GetHeaderSz()53 uint32 GetHeaderSz() 54 { 55 return (uint16)((iDf) ? LEVEL1DF_HDR_SZ : LEVEL1_HDR_SZ); 56 } GetStuffingSz()57 uint32 GetStuffingSz() 58 { 59 return (uint16)((iDf) ? LEVEL1DF_STUFFING_SZ : LEVEL1_STUFFING_SZ); 60 } 61 uint32 Parse(uint8* bsbuf, uint32 bsbsz); 62 PVMFStatus CompletePdu(OsclSharedPtr<PVMFMediaDataImpl>& pdu, int8 mt, uint8 pm); 63 protected: 64 void Construct(uint16 max_outstanding_pdus); 65 void GetHdrFragment(OsclRefCounterMemFrag& frag); 66 private: CheckForFlag(uint8 * bsbuf)67 inline bool CheckForFlag(uint8* bsbuf) 68 { 69 if (iDf) 70 return (bsbuf[0] == 0xe1 && bsbuf[1] == 0x4d && bsbuf[2] == 0xe1 && bsbuf[3] == 0x4d); 71 return (bsbuf[0] == 0xe1 && bsbuf[1] == 0x4d); 72 } 73 inline void IndicatePdu(); 74 75 PVMFBufferPoolAllocator iHdrFragmentAlloc; 76 77 uint8 iHecCrc[20]; 78 bool iDf; 79 int iCurrentInt32; 80 int iSkipBytes; 81 int iClosingNext; 82 EOperationId iCurrentOp; 83 }; 84 85 #endif 86 87