|
INET Framework for OMNeT++/OMNEST
|
00001 /*************************************************************************** 00002 RTPInnerPacket.cc - description 00003 ------------------- 00004 begin : Sat Oct 20 2001 00005 copyright : (C) 2001 by Matthias Oppitz 00006 email : Matthias.Oppitz@gmx.de 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 00018 00024 #include "RTPInnerPacket.h" 00025 #include "RTPPacket.h" 00026 00027 Register_Class(RTPInnerPacket); 00028 00029 00030 RTPInnerPacket::RTPInnerPacket(const char *name) : cPacket(name) 00031 { 00032 _type = RTP_INP_UNDEF; 00033 _commonName = NULL; 00034 _mtu = 0; 00035 _bandwidth = 0; 00036 _rtcpPercentage = 0; 00037 _address = IPAddress::UNSPECIFIED_ADDRESS; 00038 _port = PORT_UNDEF; 00039 _ssrc = 0; 00040 _payloadType = 0; 00041 _fileName = NULL; 00042 _clockRate = 0; 00043 _timeStampBase = 0; 00044 _sequenceNumberBase = 0; 00045 } 00046 00047 00048 RTPInnerPacket::RTPInnerPacket(const RTPInnerPacket& rinp) : cPacket() 00049 { 00050 setName(rinp.getName()); 00051 operator=(rinp); 00052 } 00053 00054 00055 RTPInnerPacket::~RTPInnerPacket() 00056 { 00057 if (opp_strcmp(_commonName, "")) 00058 delete _commonName; 00059 if (opp_strcmp(_fileName, "")) 00060 delete _fileName; 00061 } 00062 00063 00064 RTPInnerPacket& RTPInnerPacket::operator=(const RTPInnerPacket& rinp) 00065 { 00066 cPacket::operator=(rinp); 00067 _type = rinp._type; 00068 _commonName = opp_strdup(rinp._commonName); 00069 _mtu = rinp._mtu; 00070 _bandwidth = rinp._bandwidth; 00071 _rtcpPercentage = rinp._rtcpPercentage; 00072 _address = rinp._address; 00073 _port = rinp._port; 00074 _ssrc = rinp._ssrc; 00075 _payloadType = rinp._payloadType; 00076 _fileName = opp_strdup(rinp._fileName); 00077 _clockRate = rinp._clockRate; 00078 _timeStampBase = rinp._timeStampBase; 00079 _sequenceNumberBase = rinp._sequenceNumberBase; 00080 return *this; 00081 } 00082 00083 00084 RTPInnerPacket *RTPInnerPacket::dup() const 00085 { 00086 return new RTPInnerPacket(*this); 00087 } 00088 00089 00090 std::string RTPInnerPacket::info() 00091 { 00092 std::stringstream out; 00093 out << "RTPInnerPacket: type=" << _type; 00094 return out.str(); 00095 } 00096 00097 00098 void RTPInnerPacket::dump(std::ostream& os) const 00099 { 00100 os << "RTPInnerPacket:" << endl; 00101 os << " type = " << _type << endl; 00102 os << " commonName = " << _commonName << endl; 00103 os << " mtu = " << _mtu << endl; 00104 os << " bandwidth = " << _bandwidth << endl; 00105 os << " rtcpPercentage = " << _rtcpPercentage << endl; 00106 os << " address = " << _address << endl; 00107 os << " port = " << _port << endl; 00108 os << " ssrc = " << _ssrc << endl; 00109 os << " payloadType = " << _payloadType << endl; 00110 os << " fileName = " << _fileName << endl; 00111 os << " clockRate = " << _clockRate << endl; 00112 os << " timeStampBase = " << _timeStampBase << endl; 00113 os << " sequenceNumberBase = " << _sequenceNumberBase << endl; 00114 } 00115 00116 00117 void RTPInnerPacket::initializeProfile(int mtu) 00118 { 00119 _type = RTP_INP_INITIALIZE_PROFILE; 00120 _mtu = mtu; 00121 } 00122 00123 00124 void RTPInnerPacket::profileInitialized(int rtcpPercentage, int port) 00125 { 00126 _type = RTP_INP_PROFILE_INITIALIZED; 00127 _rtcpPercentage = rtcpPercentage; 00128 _port = port; 00129 } 00130 00131 00132 void RTPInnerPacket::initializeRTCP(const char *commonName, int mtu, int bandwidth, int rtcpPercentage, IPAddress address, int port) 00133 { 00134 _type = RTP_INP_INITIALIZE_RTCP; 00135 _commonName = commonName; 00136 _mtu = mtu; 00137 _bandwidth = bandwidth; 00138 _rtcpPercentage = rtcpPercentage; 00139 _address = address; 00140 _port = port; 00141 } 00142 00143 00144 void RTPInnerPacket::rtcpInitialized(uint32 ssrc) 00145 { 00146 _type = RTP_INP_RTCP_INITIALIZED; 00147 _ssrc = ssrc; 00148 } 00149 00150 00151 void RTPInnerPacket::createSenderModule(uint32 ssrc, int payloadType, const char *fileName) 00152 { 00153 _type = RTP_INP_CREATE_SENDER_MODULE; 00154 _ssrc = ssrc; 00155 _payloadType = payloadType; 00156 _fileName = fileName; 00157 } 00158 00159 00160 void RTPInnerPacket::senderModuleCreated(uint32 ssrc) 00161 { 00162 _type = RTP_INP_SENDER_MODULE_CREATED; 00163 _ssrc = ssrc; 00164 } 00165 00166 00167 void RTPInnerPacket::deleteSenderModule(uint32 ssrc) 00168 { 00169 _type = RTP_INP_DELETE_SENDER_MODULE; 00170 _ssrc = ssrc; 00171 } 00172 00173 00174 void RTPInnerPacket::senderModuleDeleted(uint32 ssrc) 00175 { 00176 _type = RTP_INP_SENDER_MODULE_DELETED; 00177 _ssrc = ssrc; 00178 } 00179 00180 00181 void RTPInnerPacket::initializeSenderModule(uint32 ssrc, const char *fileName, int mtu) 00182 { 00183 _type = RTP_INP_INITIALIZE_SENDER_MODULE; 00184 _ssrc = ssrc; 00185 _fileName = fileName; 00186 _mtu = mtu; 00187 } 00188 00189 00190 void RTPInnerPacket::senderModuleInitialized(uint32 ssrc, int payloadType, int clockRate, int timeStampBase, int sequenceNumberBase) 00191 { 00192 _type = RTP_INP_SENDER_MODULE_INITIALIZED; 00193 _ssrc = ssrc; 00194 _payloadType = payloadType; 00195 _clockRate = clockRate; 00196 _timeStampBase = timeStampBase; 00197 _sequenceNumberBase = sequenceNumberBase; 00198 } 00199 00200 void RTPInnerPacket::senderModuleControl(uint32 ssrc, RTPSenderControlMessage *msg) 00201 { 00202 _type = RTP_INP_SENDER_MODULE_CONTROL; 00203 _ssrc = ssrc; 00204 encapsulate(msg); 00205 } 00206 00207 00208 void RTPInnerPacket::senderModuleStatus(uint32 ssrc, RTPSenderStatusMessage *msg) 00209 { 00210 _type = RTP_INP_SENDER_MODULE_STATUS; 00211 _ssrc = ssrc; 00212 encapsulate(msg); 00213 } 00214 00215 00216 void RTPInnerPacket::leaveSession() 00217 { 00218 _type = RTP_INP_LEAVE_SESSION; 00219 } 00220 00221 00222 void RTPInnerPacket::sessionLeft() 00223 { 00224 _type = RTP_INP_SESSION_LEFT; 00225 } 00226 00227 00228 void RTPInnerPacket::dataOut(RTPPacket *packet) 00229 { 00230 _type = RTP_INP_DATA_OUT; 00231 encapsulate(packet); 00232 } 00233 00234 00235 void RTPInnerPacket::dataIn(RTPPacket *packet, IPAddress address, int port) 00236 { 00237 _type = RTP_INP_DATA_IN; 00238 _address = address; 00239 _port = port; 00240 encapsulate(packet); 00241 } 00242 00243 00244 RTPInnerPacket::RTP_INP_TYPE RTPInnerPacket::getType() 00245 { 00246 return _type; 00247 } 00248 00249 00250 const char *RTPInnerPacket::getCommonName() 00251 { 00252 return opp_strdup(_commonName); 00253 } 00254 00255 00256 int RTPInnerPacket::getMTU() 00257 { 00258 return _mtu; 00259 } 00260 00261 00262 int RTPInnerPacket::getBandwidth() 00263 { 00264 return _bandwidth; 00265 } 00266 00267 00268 int RTPInnerPacket::getRtcpPercentage() 00269 { 00270 return _rtcpPercentage; 00271 } 00272 00273 00274 IPAddress RTPInnerPacket::getAddress() 00275 { 00276 return _address; 00277 } 00278 00279 00280 int RTPInnerPacket::getPort() 00281 { 00282 return _port; 00283 } 00284 00285 00286 uint32 RTPInnerPacket::getSSRC() 00287 { 00288 return _ssrc; 00289 } 00290 00291 00292 const char *RTPInnerPacket::getFileName() 00293 { 00294 return opp_strdup(_fileName); 00295 } 00296 00297 00298 int RTPInnerPacket::getPayloadType() 00299 { 00300 return _payloadType; 00301 } 00302 00303 00304 int RTPInnerPacket::getClockRate() 00305 { 00306 return _clockRate; 00307 } 00308 00309 00310 int RTPInnerPacket::getTimeStampBase() 00311 { 00312 return _timeStampBase; 00313 } 00314 00315 00316 int RTPInnerPacket::getSequenceNumberBase() 00317 { 00318 return _sequenceNumberBase; 00319 }