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(PVT_PARAMS_H) 19 #define PVT_PARAMS_H 20 21 #include "oscl_stdstring.h" 22 #include "oscl_base.h" 23 #include "control_msg_hdr.h" 24 #include "pvt_common.h" 25 #include "oscl_mem.h" 26 27 class CPVChannelParam : public CPVTrackInfo 28 { 29 public: 30 CPVChannelParam(TPVDirection dir, TPVChannelId id, TPVDirectionality directionality, ErrorProtectionLevel_t epl): 31 iDirection(dir), iChannelId(id), iDirectionality(directionality), iEpl(epl), 32 iNumSduSizes(0), iSduSizes(NULL), iMediaParam(NULL) 33 { 34 } 35 CPVChannelParam(CPVChannelParam& that) : CPVTrackInfo(that), 36 iDirection(that.iDirection), iChannelId(that.iChannelId), iDirectionality(that.iDirectionality), iEpl(that.iEpl), 37 iNumSduSizes(that.iNumSduSizes), iSduSizes(NULL), iMediaParam(NULL) 38 { 39 if (iNumSduSizes) 40 { 41 iSduSizes = (int*)OSCL_DEFAULT_MALLOC(iNumSduSizes * sizeof(int)); 42 oscl_memcpy(iSduSizes, that.iSduSizes, iNumSduSizes*sizeof(int)); 43 } 44 if (that.iMediaParam) 45 { 46 iMediaParam = (CPVMediaParam*)that.iMediaParam->Copy(); 47 } 48 49 } 50 virtual ~CPVChannelParam() 51 { 52 if (iSduSizes) 53 OSCL_DEFAULT_FREE(iSduSizes); 54 if (iMediaParam) 55 OSCL_DELETE(iMediaParam); 56 } 57 58 void SetChannelParams(TPVDirection dir, TPVChannelId id, TPVDirectionality directionality, ErrorProtectionLevel_t epl) 59 { 60 iDirection = dir; 61 iChannelId = id; 62 iDirectionality = directionality; 63 iEpl = epl; 64 } 65 66 void SetMediaParam(CPVMediaParam* media_param) 67 { 68 if (iMediaParam) 69 { 70 OSCL_DELETE(iMediaParam); 71 iMediaParam = NULL; 72 } 73 if (media_param) 74 { 75 iMediaParam = (CPVMediaParam*)media_param->Copy(); 76 } 77 } 78 79 int SetSduSizes(int num_sizes, int* sizes) 80 { 81 iNumSduSizes = num_sizes; 82 if (iSduSizes) 83 { 84 OSCL_DEFAULT_FREE(iSduSizes); 85 iSduSizes = NULL; 86 } 87 if (num_sizes) 88 { 89 iSduSizes = (int*)OSCL_DEFAULT_MALLOC(iNumSduSizes * sizeof(int)); 90 91 for (int i = 0; i < num_sizes; i++) 92 { 93 iSduSizes[i] = sizes[i]; 94 } 95 } 96 return num_sizes; 97 } 98 99 void Clear() 100 { 101 SetChannelParams(OUTGOING, CHANNEL_ID_UNKNOWN, EPVT_UNI_DIRECTIONAL, E_EP_LOW); 102 SetMediaParam(NULL); 103 SetSduSizes(0, NULL); 104 } 105 106 /* Get methods */ 107 TPVDirection GetDirection() 108 { 109 return iDirection; 110 } 111 TPVChannelId GetChannelId() 112 { 113 return iChannelId; 114 } 115 116 TPVDirectionality GetDirectionality() 117 { 118 return iDirectionality; 119 } 120 121 ErrorProtectionLevel_t GetErrorProtectionLevel() 122 { 123 return iEpl; 124 } 125 126 int GetNumSduSizes() 127 { 128 return iNumSduSizes; 129 } 130 int GetSduSize(int index = 0) 131 { 132 return iSduSizes[index]; 133 } 134 int* GetSduSizes() 135 { 136 if (iNumSduSizes) 137 return iSduSizes; 138 return NULL; 139 } 140 CPVMediaParam* GetMediaParam() 141 { 142 return iMediaParam; 143 } 144 145 CPVTrackInfo* Copy() 146 { 147 return OSCL_NEW(CPVChannelParam, (*this)); 148 } 149 150 protected: 151 CPVChannelParam() : iDirection(OUTGOING), iChannelId(CHANNEL_ID_UNKNOWN), iDirectionality(EPVT_UNI_DIRECTIONAL), iEpl(E_EP_LOW), 152 iNumSduSizes(0), iSduSizes(NULL), iMediaParam(NULL) 153 { 154 } 155 156 TPVDirection iDirection; 157 TPVChannelId iChannelId; 158 TPVDirectionality iDirectionality; 159 ErrorProtectionLevel_t iEpl; 160 int iNumSduSizes; 161 int* iSduSizes; 162 CPVMediaParam* iMediaParam; 163 }; 164 165 166 class CPVDataParam : public CPVParam 167 { 168 public: 169 CPVDataParam() {} 170 }; 171 172 #define min2(a, b) ((a > b) ? b : a) 173 174 #endif 175