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(LEVEL0_H) 19 #define LEVEL0_H 20 #include "pduparcom.h" 21 22 #define LEVEL0_STUFFING_SZ 1 23 #define LEVEL0_HDR_SZ 2 24 25 class Level0PduParcom : public H223PduParcomBase 26 { 27 public: 28 Level0PduParcom(); 29 TPVH223Level GetLevel() 30 { 31 return H223_LEVEL0; 32 } 33 uint32 GetStuffing(uint8* buf, uint32 buf_size, uint8 mux_code = 0); 34 uint32 GetHeaderSz() 35 { 36 return LEVEL0_HDR_SZ; 37 } 38 uint32 GetStuffingSz() 39 { 40 return LEVEL0_STUFFING_SZ; 41 } 42 uint32 Parse(uint8* bsbuf, uint32 bsbsz); 43 PVMFStatus CompletePdu(OsclSharedPtr<PVMFMediaDataImpl>& pdu, int8 mt, uint8 pm); 44 45 protected: 46 void Construct(uint16 max_outstanding_pdus); 47 void GetHdrFragment(OsclRefCounterMemFrag& frag); 48 uint16 Insert0(uint8* pPdu, int pdu_size, uint8* pRetPdu); 49 uint16 Insert0Octet(uint8 cur_byte, uint16 num_bits_from_octet, uint8* out_buffer); 50 uint16 AppendTxBits0(unsigned num_bits, int bits, uint8* pos); 51 // appends an octet to the output stream without checking for 0 bit. Flushes the current check bits 52 uint16 AppendTxOctet(uint8 octet, uint8* pos); 53 54 void SearchForHdlcFlag(uint8* bsbuf, int bsbsz); 55 unsigned Remove0(); 56 void Remove0Octet(uint8 cur_byte, int num_bits_from_octet); 57 void AppendBit(int c); 58 void AppendBits0(unsigned num_bits, int bits); 59 60 int iPmNext; 61 PVMFBufferPoolAllocator iPduFragmentAlloc; 62 PVMFBufferPoolAllocator iHdrFragmentAlloc; 63 64 uint8 iHecCrc[20]; 65 unsigned iRecvBits; 66 unsigned iNumRecvBits; 67 unsigned iRecvByte; 68 int iRecvBytePos; 69 unsigned iRecvByte0; 70 int iRecvByte0Pos; 71 int iZeroBitRemovedOutputPos; 72 unsigned iZeroBitRemovedOutput; 73 uint8* iPduPosZeroRemoved; 74 75 int iTxByte0; 76 int iTxByte0Pos; 77 int iTxCheck0; 78 int iTxCheck0Pos; 79 }; 80 81 #endif 82 83 84