#include <RTPEndsystemModule.h>
|
Called when the socket layer has connected a socket. 00339 { 00340 initializeRTCP(); 00341 00342 delete sifp; 00343 };
|
|
Requests a client socket from the socket layer. 00401 { 00402 SocketInterfacePacket *sifp = new SocketInterfacePacket("socket()"); 00403 sifp->socket(Socket::IPSuite_AF_INET, Socket::IPSuite_SOCK_DGRAM, Socket::UDP); 00404 send(sifp, "toSocketLayer"); 00405 };
|
|
Creates the profile module. 00377 { 00378 cModuleType *moduleType = findModuleType(_profileName); 00379 if (moduleType == NULL) { 00380 error("Profile type not found !"); 00381 }; 00382 RTPProfile *profile = (RTPProfile *)(moduleType->create("Profile", this)); 00383 00384 profile->setGateSize("toPayloadReceiver", 4); 00385 profile->setGateSize("fromPayloadReceiver", 4); 00386 00387 connect(this, findGate("toProfile"), NULL, profile, profile->findGate("fromRTP")); 00388 connect(profile, profile->findGate("toRTP"), NULL, this, findGate("fromProfile")); 00389 profile->initialize(); 00390 profile->scheduleStart(simTime()); 00391 };
|
|
00194 { 00195 RTPInnerPacket *rinp = new RTPInnerPacket("createSenderModule()"); 00196 rinp->createSenderModule(rifp->ssrc(), rifp->payloadType(), rifp->fileName()); 00197 send(rinp, "toProfile"); 00198 00199 delete rifp; 00200 };
|
|
Requests a server socket from the socket layer. 00394 { 00395 SocketInterfacePacket *sifp = new SocketInterfacePacket("socket()"); 00396 sifp->socket(Socket::IPSuite_AF_INET, Socket::IPSuite_SOCK_DGRAM, Socket::UDP); 00397 send(sifp, "toSocketLayer"); 00398 };
|
|
Sends a rtp data packet to the socket layer and a copy of it to the rtcp module. 00269 { 00270 00271 RTPPacket *encapsulatedMsg = (RTPPacket *)(rinp->decapsulate()); 00272 SocketInterfacePacket *sifpOut = new SocketInterfacePacket("write()"); 00273 sifpOut->write(_socketFdOut, encapsulatedMsg); 00274 send(sifpOut, "toSocketLayer"); 00275 00276 // RTCP module must be informed about sent rtp data packet 00277 00278 RTPInnerPacket *rinpOut = new RTPInnerPacket(*rinp); 00279 rinpOut->encapsulate(new RTPPacket(*encapsulatedMsg)); 00280 send(rinpOut, "toRTCP"); 00281 00282 delete rinp; 00283 };
|
|
00203 { 00204 RTPInnerPacket *rinp = new RTPInnerPacket("deleteSenderModule()"); 00205 rinp->deleteSenderModule(rifp->ssrc()); 00206 send(rinp, "toProfile"); 00207 00208 delete rifp; 00209 };
|
|
Creates the profile module and initializes it. 00164 { 00165 _profileName = rifp->profileName(); 00166 _commonName = rifp->commonName(); 00167 _bandwidth = rifp->bandwidth(); 00168 _destinationAddress = rifp->destinationAddress(); 00169 _port = rifp->port(); 00170 if (_port % 2 != 0) { 00171 _port = _port - 1; 00172 } 00173 00174 _mtu = resolveMTU(); 00175 00176 createProfile(); 00177 initializeProfile(); 00178 00179 delete rifp; 00180 };
|
|
Handles incoming messages. 00052 { 00053 00054 if (msg->arrivalGateId() == findGate("fromApp")) { 00055 handleMessageFromApp(msg); 00056 } 00057 00058 else if (msg->arrivalGateId() == findGate("fromProfile")) { 00059 handleMessageFromProfile(msg); 00060 } 00061 00062 else if (msg->arrivalGateId() == findGate("fromRTCP")) { 00063 handleMessageFromRTCP(msg); 00064 } 00065 00066 else if (msg->arrivalGateId() == findGate("fromSocketLayer")) { 00067 handleMessageFromSocketLayer(msg); 00068 } 00069 00070 else { 00071 EV << "RTPEndsystemModule: Message from unknown Gate !" << endl; 00072 } 00073 };
|
|
Handles messages received from the applicaiton. 00080 { 00081 RTPInterfacePacket *rifp = (RTPInterfacePacket *)msg; 00082 if (rifp->type() == RTPInterfacePacket::RTP_IFP_ENTER_SESSION) { 00083 enterSession(rifp); 00084 } 00085 else if (rifp->type() == RTPInterfacePacket::RTP_IFP_CREATE_SENDER_MODULE) { 00086 createSenderModule(rifp); 00087 } 00088 else if (rifp->type() == RTPInterfacePacket::RTP_IFP_DELETE_SENDER_MODULE) { 00089 deleteSenderModule(rifp); 00090 } 00091 else if (rifp->type() == RTPInterfacePacket::RTP_IFP_SENDER_CONTROL) { 00092 senderModuleControl(rifp); 00093 } 00094 else if (rifp->type() == RTPInterfacePacket::RTP_IFP_LEAVE_SESSION) { 00095 leaveSession(rifp); 00096 } 00097 else { 00098 EV << "RTPEndsystemModule: unknown RTPInterfacePacket type from application !" << endl; 00099 } 00100 };
|
|
Handles messages received from the profile module. 00103 { 00104 RTPInnerPacket *rinp = (RTPInnerPacket *)msg; 00105 if (rinp->type() == RTPInnerPacket::RTP_INP_PROFILE_INITIALIZED) { 00106 profileInitialized(rinp); 00107 } 00108 else if (rinp->type() == RTPInnerPacket::RTP_INP_SENDER_MODULE_CREATED) { 00109 senderModuleCreated(rinp); 00110 } 00111 else if (rinp->type() == RTPInnerPacket::RTP_INP_SENDER_MODULE_DELETED) { 00112 senderModuleDeleted(rinp); 00113 } 00114 else if (rinp->type() == RTPInnerPacket::RTP_INP_SENDER_MODULE_INITIALIZED) { 00115 senderModuleInitialized(rinp); 00116 } 00117 else if (rinp->type() == RTPInnerPacket::RTP_INP_SENDER_MODULE_STATUS) { 00118 senderModuleStatus(rinp); 00119 } 00120 else if (rinp->type() == RTPInnerPacket::RTP_INP_DATA_OUT) { 00121 dataOut(rinp); 00122 } 00123 else { 00124 EV << "RTPEndsystemModule: Unknown RTPInnerPacket type from profile !" << endl; 00125 } 00126 }
|
|
Handles messages received from the rtcp module. 00129 { 00130 RTPInnerPacket *rinp = (RTPInnerPacket *)msg; 00131 if (rinp->type() == RTPInnerPacket::RTP_INP_RTCP_INITIALIZED) { 00132 rtcpInitialized(rinp); 00133 } 00134 else if (rinp->type() == RTPInnerPacket::RTP_INP_SESSION_LEFT) { 00135 sessionLeft(rinp); 00136 } 00137 else { 00138 EV << "RTPEndsystemModule: Unknown RTPInnerPacket type " << rinp->type() << " from rtcp !" << endl; 00139 } 00140 };
|
|
Handles messages received from the socket layer. 00143 { 00144 SocketInterfacePacket *sifpIn = (SocketInterfacePacket *)msg; 00145 if (sifpIn->action() == SocketInterfacePacket::SA_SOCKET_RET) { 00146 socketRet(sifpIn); 00147 } 00148 else if (sifpIn->action() == SocketInterfacePacket::SA_CONNECT_RET) { 00149 connectRet(sifpIn); 00150 } 00151 else if (sifpIn->action() == SocketInterfacePacket::SA_READ_RET) { 00152 readRet(sifpIn); 00153 } 00154 else { 00155 EV << "RTPEndsystemModule: Unknown SocketInterfacePacket type " << sifpIn->action() << " !" << endl; 00156 } 00157 };
|
|
Initializes variables. 00045 { 00046 00047 _socketFdIn = Socket::FILEDESC_UNDEF; 00048 _socketFdOut = Socket::FILEDESC_UNDEF; 00049 };
|
|
Initializes the profile module. 00408 { 00409 RTPInnerPacket *rinp = new RTPInnerPacket("initializeProfile()"); 00410 rinp->initializeProfile(_mtu); 00411 send(rinp, "toProfile"); 00412 };
|
|
Initializes the rtcp module-. 00415 { 00416 RTPInnerPacket *rinp = new RTPInnerPacket("initializeRTCP()"); 00417 IN_Port rtcpPort = _port + 1; 00418 rinp->initializeRTCP(opp_strdup(_commonName), _mtu, _bandwidth, _rtcpPercentage, _destinationAddress, rtcpPort); 00419 send(rinp, "toRTCP"); 00420 };
|
|
Destroys the profile module and orders the rtcp module to send an rtcp bye packet. 00183 { 00184 cModule *profileModule = gate("toProfile")->toGate()->ownerModule(); 00185 profileModule->deleteModule(); 00186 RTPInnerPacket *rinp = new RTPInnerPacket("leaveSession()"); 00187 rinp->leaveSession(); 00188 send(rinp,"toRTCP"); 00189 00190 delete rifp; 00191 };
|
|
Called when the profile module is initialized. 00221 { 00222 _rtcpPercentage = rinp->rtcpPercentage(); 00223 if (_port == IPSuite_PORT_UNDEF) { 00224 _port = rinp->port(); 00225 if (_port % 2 != 0) { 00226 _port = _port - 1; 00227 } 00228 } 00229 00230 delete rinp; 00231 00232 createServerSocket(); 00233 };
|
|
Called when data from the socket layer has been received. 00346 { 00347 00348 cMessage *msg = sifp->decapsulate(); 00349 00350 RTPPacket *packet1 = (RTPPacket *)msg; 00351 RTPInnerPacket *rinp1 = new RTPInnerPacket("dataIn1()"); 00352 rinp1->dataIn(packet1, sifp->fAddr(), sifp->fPort()); 00353 00354 //RTPPacket *packet2 = new RTPPacket(*packet1); 00355 00356 RTPInnerPacket *rinp2 = new RTPInnerPacket(*rinp1); 00357 00358 //rinp2->dataIn(packet2, IN_Addr(sifp->fAddr()), IN_Port(sifp->fPort())); 00359 00360 send(rinp2, "toRTCP"); 00361 send(rinp1, "toProfile"); 00362 00363 delete sifp; 00364 };
|
|
Determines the maximum transmission unit that can be uses for rtp. This implementation assumes that we use an ethernet with 1500 bytes mtu. The returned value is 1500 bytes minus header sizes for ip and udp. 00367 { 00368 // this is not what it should be 00369 // do something like mtu path discovery 00370 // for the simulation we can use this example value 00371 // it's 1500 bytes (ethernet) minus ip 00372 // and udp headers 00373 return 1500 - 20 - 8; 00374 };
|
|
Informs the application that the session is entered. 00286 { 00287 RTPInterfacePacket *rifp = new RTPInterfacePacket("sessionEntered()"); 00288 rifp->sessionEntered(rinp->ssrc()); 00289 send(rifp, "toApp"); 00290 00291 delete rinp; 00292 };
|
|
00212 { 00213 RTPInnerPacket *rinp = new RTPInnerPacket("senderModuleControl()"); 00214 rinp->senderModuleControl(rinp->ssrc(), (RTPSenderControlMessage *)(rifp->decapsulate())); 00215 send(rinp, "toProfile"); 00216 00217 delete rifp; 00218 }
|
|
00236 { 00237 RTPInterfacePacket *rifp = new RTPInterfacePacket("senderModuleCreated()"); 00238 rifp->senderModuleCreated(rinp->ssrc()); 00239 send(rifp, "toApp"); 00240 00241 delete rinp; 00242 };
|
|
00245 { 00246 RTPInterfacePacket *rifp = new RTPInterfacePacket("senderModuleDeleted()"); 00247 rifp->senderModuleDeleted(rinp->ssrc()); 00248 send(rifp, "toApp"); 00249 00250 // perhaps we should send a message to rtcp module 00251 delete rinp; 00252 };
|
|
00255 {
00256 send(rinp, "toRTCP");
00257 };
|
|
00260 { 00261 RTPInterfacePacket *rifp = new RTPInterfacePacket("senderModuleStatus()"); 00262 rifp->senderModuleStatus(rinp->ssrc(), (RTPSenderStatusMessage *)(rinp->decapsulate())); 00263 send(rifp, "toApp"); 00264 00265 delete rinp; 00266 };
|
|
Informs the application that this end system has left the rtp session. 00295 { 00296 00297 RTPInterfacePacket *rifp = new RTPInterfacePacket("sessionLeft()"); 00298 rifp->sessionLeft(); 00299 send(rifp, "toApp"); 00300 00301 delete rinp; 00302 };
|
|
Called when the socket layer returns a socket. 00305 { 00306 if (_socketFdIn == Socket::FILEDESC_UNDEF) { 00307 _socketFdIn = sifp->filedesc(); 00308 00309 SocketInterfacePacket *sifpOut = new SocketInterfacePacket("bind()"); 00310 00311 IPAddress ipaddr(_destinationAddress); 00312 00313 if (ipaddr.isMulticast()) { 00314 sifpOut->bind(_socketFdIn, IN_Addr(_destinationAddress), IN_Port(_port)); 00315 } 00316 else { 00317 sifpOut->bind(_socketFdIn, IPADDRESS_UNDEF, IN_Port(_port)); 00318 } 00319 send(sifpOut, "toSocketLayer"); 00320 00321 createClientSocket(); 00322 } 00323 else if (_socketFdOut == Socket::FILEDESC_UNDEF) { 00324 _socketFdOut = sifp->filedesc(); 00325 00326 SocketInterfacePacket *sifpOut = new SocketInterfacePacket("connect()"); 00327 sifpOut->connect(_socketFdOut, _destinationAddress, _port); 00328 send(sifpOut, "toSocketLayer"); 00329 00330 } 00331 else { 00332 EV << "RTPEndsystemModule: SA_SOCKET_RET from socket layer but no socket requested !" << endl; 00333 } 00334 00335 delete sifp; 00336 };
|
|
The available bandwidth for this session. |
|
The CNAME of this end system. |
|
The destination address. |
|
The maximum size of a packet. |
|
The rtp port. |
|
The name of the profile used in this session. |
|
The percentage of the bandwidth used for rtcp. |
|
The rtp server socket file descriptor. |
|
The rtp client socket file descriptor. |