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 #ifndef RTP_PAYLOAD_PARSER_BASE_H 19 #define RTP_PAYLOAD_PARSER_BASE_H 20 21 #include "rtp_payload_parser_include.h" 22 #include "rtppp_media_frag_group.h" 23 24 #include "pvmf_media_data.h" 25 #include "pvmf_media_frag_group.h" 26 27 #include "oscl_mem_mempool.h" 28 #include "oscl_vector.h" 29 30 enum RTP_PAYLOAD_PARSER_RET_CODE 31 { 32 RTP_PAYLOAD_PARSER_FAILURE = 0, 33 RTP_PAYLOAD_PARSER_SUCCESS = 1, 34 RTP_PAYLOAD_PARSER_INPUT_NOT_EXHAUSTED = 2, 35 RTP_PAYLOAD_PARSER_MEMORY_ALLOC_FAILURE = 3, 36 RTP_PAYLOAD_PARSER_DATA_NOT_READY = 4, 37 RTP_PAYLOAD_PARSER_INTERNAL_QUEUE_IS_EMPTY = 5 38 }; 39 40 #define RTP_PAYLOAD_PARSER_MAX_NUM_MEDIA_DATA 64 41 42 typedef OsclMemAllocator PoolMemAlloc; 43 44 class RTPPayloadParser 45 { 46 public: 47 RTPPayloadParser(); 48 virtual ~RTPPayloadParser(); 49 50 /* single payload parse */ 51 OSCL_IMPORT_REF virtual RTP_PAYLOAD_PARSER_RET_CODE parseRTPPayload(PVMFSharedMediaDataPtr& rtpPacket, 52 PVMFSharedMediaDataPtr& accessUnit) = 0; 53 54 /* multiple payload parsing - need not be implemented in deriving class */ 55 OSCL_IMPORT_REF virtual RTP_PAYLOAD_PARSER_RET_CODE parseRTPPayload(PVMFSharedMediaDataPtr& rtpPacket, 56 Oscl_Vector<PVMFSharedMediaDataPtr, OsclMemAllocator>*& accessUnits) 57 { 58 return RTP_PAYLOAD_PARSER_FAILURE; 59 } 60 61 virtual uint numBuffersRequired(PVMFSharedMediaDataPtr& rtpPacket) 62 { 63 return 1; 64 } 65 66 67 OSCL_IMPORT_REF virtual bool IsOutputBufferAvailable(uint& available, int count = 1); 68 69 void notifyfreechunkavailable(OsclMemPoolFixedChunkAllocatorObserver& obs, int numChunks = 1) 70 { 71 if (iMediaDataGroupAlloc) 72 iMediaDataGroupAlloc->notifyfreechunkgroupavailable(obs, numChunks, NULL); 73 } 74 75 virtual void setRepositionFlag() 76 { 77 ibRepositionFlag = true; 78 } 79 virtual uint32 getMinCurrTimestamp() 80 { 81 return 0; 82 } 83 84 protected: 85 RTPPPMediaFragGroupCombinedAlloc<PoolMemAlloc>* iMediaDataGroupAlloc; 86 OsclMemPoolFixedChunkAllocator* iMediaDataImplMemPool; 87 bool ibRepositionFlag; 88 }; 89 90 91 #endif // RTP_PAYLOAD_PARSER_BASE_H 92