RTPApplication uses activity for message handling. The behaviour is controlled by omnet parameters.
00070 {
00071
00072
00073 bool sessionEntered = false;
00074 bool transmissionStarted = false;
00075 bool transmissionFinished = false;
00076 bool sessionLeft = false;
00077
00078
00079 cMessage *msg1 = new cMessage("enterSession");
00080 scheduleAt(simTime() + _sessionEnterDelay, msg1);
00081
00082 u_int32 ssrc = 0;
00083
00084 while (!sessionLeft) {
00085
00086 cMessage *msgIn = receive();
00087 if (msgIn->isSelfMessage()) {
00088 if (!opp_strcmp(msgIn->name(), "enterSession")) {
00089
00090 RTPInterfacePacket *rifpOut1 = new RTPInterfacePacket("enterSession()");
00091 rifpOut1->enterSession(opp_strdup(_commonName), opp_strdup(_profileName), _bandwidth, _destinationAddress, _port);
00092
00093 send(rifpOut1, "toRTP");
00094 }
00095 else if (!opp_strcmp(msgIn->name(), "startTransmission")) {
00096 RTPSenderControlMessage *rscm = new RTPSenderControlMessage();
00097 rscm->setCommand("PLAY");
00098 RTPInterfacePacket *rifpOut = new RTPInterfacePacket("senderModuleControl(PLAY)");
00099 rifpOut->senderModuleControl(ssrc, rscm);
00100 send(rifpOut, "toRTP");
00101 transmissionStarted = true;
00102
00103 cMessage *msg4 = new cMessage("stopTransmission");
00104 scheduleAt(simTime() + _transmissionStopDelay, msg4);
00105 }
00106 else if (!opp_strcmp(msgIn->name(), "stopTransmission")) {
00107 RTPSenderControlMessage *rscm = new RTPSenderControlMessage();
00108 rscm->setCommand("STOP");
00109 RTPInterfacePacket *rifpOut = new RTPInterfacePacket("senderModuleControl(STOP)");
00110 rifpOut->senderModuleControl(ssrc, rscm);
00111 send(rifpOut, "toRTP");
00112 }
00113 else if (!opp_strcmp(msgIn->name(), "leaveSession")) {
00114 RTPInterfacePacket *rifpOut = new RTPInterfacePacket("leaveSession()");
00115 rifpOut->leaveSession();
00116 send(rifpOut, "toRTP");
00117 }
00118 }
00119 else {
00120 if (opp_strcmp(msgIn->className(), "RTPInterfacePacket")) {
00121 opp_error("RTPApplication can only receive packets of type RTPInterfacePacket !");
00122 }
00123 RTPInterfacePacket *rifpIn = (RTPInterfacePacket *)msgIn;
00124 if (rifpIn->type() == RTPInterfacePacket::RTP_IFP_SESSION_ENTERED) {
00125 ssrc = rifpIn->ssrc();
00126 sessionEntered = true;
00127 if (opp_strcmp(_fileName, "")) {
00128 RTPInterfacePacket *rifpOut = new RTPInterfacePacket("createSenderModule()");
00129 rifpOut->createSenderModule(ssrc, _payloadType, opp_strdup(_fileName));
00130 send(rifpOut, "toRTP");
00131 }
00132 else {
00133 cMessage *msg2 = new cMessage("leaveSession");
00134 scheduleAt(simTime() + _sessionLeaveDelay, msg2);
00135 }
00136 }
00137 else if (rifpIn->type() == RTPInterfacePacket::RTP_IFP_SENDER_MODULE_CREATED) {
00138 cMessage *msg3 = new cMessage("startTransmission");
00139 scheduleAt(simTime() + _transmissionStartDelay, msg3);
00140 }
00141 else if (rifpIn->type() == RTPInterfacePacket::RTP_IFP_SENDER_STATUS) {
00142 RTPSenderStatusMessage *rsim = (RTPSenderStatusMessage *)(rifpIn->decapsulate());
00143 if (!opp_strcmp(rsim->status(), "PLAYING")) {
00144
00145 }
00146 else if (!opp_strcmp(rsim->status(), "FINISHED")) {
00147 transmissionFinished = true;
00148 cMessage *msg5 = new cMessage("leaveSession");
00149 scheduleAt(simTime() + _sessionLeaveDelay, msg5);
00150 }
00151 else if (!opp_strcmp(rsim->status(), "STOPPED")) {
00152 transmissionFinished = true;
00153 cMessage *msg6 = new cMessage("leaveSession");
00154 scheduleAt(simTime() + _sessionLeaveDelay, msg6);
00155 }
00156 else {
00157 }
00158 }
00159 else if (rifpIn->type() == RTPInterfacePacket::RTP_IFP_SESSION_LEFT) {
00160 sessionLeft = true;
00161 }
00162 }
00163 delete msgIn;
00164
00165 }
00166 }