#include <RTPApplication.h>
Public Member Functions | |
RTPApplication () | |
virtual void | initialize () |
virtual void | activity () |
Protected Attributes | |
const char * | _commonName |
const char * | _profileName |
int | _bandwidth |
IPAddress | _destinationAddress |
int | _port |
const char * | _fileName |
int | _payloadType |
simtime_t | _sessionEnterDelay |
simtime_t | _transmissionStartDelay |
simtime_t | _transmissionStopDelay |
simtime_t | _sessionLeaveDelay |
RTPApplication::RTPApplication | ( | ) | [inline] |
virtual void RTPApplication::initialize | ( | ) | [virtual] |
Reads the OMNeT++ parameters.
void RTPApplication::activity | ( | ) | [virtual] |
RTPApplication uses activity for message handling. The behaviour is controlled by omnet parameters.
00067 { 00068 00069 00070 bool sessionEntered = false; 00071 bool transmissionStarted = false; 00072 bool transmissionFinished = false; 00073 bool sessionLeft = false; 00074 00075 cMessage *msg1 = new cMessage("enterSession"); 00076 scheduleAt(simTime() + _sessionEnterDelay, msg1); 00077 00078 uint32 ssrc = 0; 00079 00080 while (!sessionLeft) { 00081 00082 cMessage *msgIn = receive(); 00083 if (msgIn->isSelfMessage()) { 00084 if (!opp_strcmp(msgIn->getName(), "enterSession")) { 00085 ev << "enterSession"<<endl; 00086 // create an RTPInterfacePacket to enter the session 00087 RTPInterfacePacket *rifpOut1 = new RTPInterfacePacket("enterSession()"); 00088 rifpOut1->enterSession(opp_strdup(_commonName), opp_strdup(_profileName), _bandwidth, _destinationAddress, _port); 00089 // and send it to the rtp layer 00090 send(rifpOut1, "toRTP"); 00091 } 00092 else if (!opp_strcmp(msgIn->getName(), "startTransmission")) { 00093 ev << "startTransmission"<<endl; 00094 RTPSenderControlMessage *rscm = new RTPSenderControlMessage(); 00095 rscm->setCommand("PLAY"); 00096 RTPInterfacePacket *rifpOut = new RTPInterfacePacket("senderModuleControl(PLAY)"); 00097 rifpOut->senderModuleControl(ssrc, rscm); 00098 send(rifpOut, "toRTP"); 00099 transmissionStarted = true; 00100 00101 cMessage *msg4 = new cMessage("stopTransmission"); 00102 scheduleAt(simTime() + _transmissionStopDelay, msg4); 00103 } 00104 else if (!opp_strcmp(msgIn->getName(), "stopTransmission")) { 00105 ev << "stopTransmission"<<endl; 00106 RTPSenderControlMessage *rscm = new RTPSenderControlMessage(); 00107 rscm->setCommand("STOP"); 00108 RTPInterfacePacket *rifpOut = new RTPInterfacePacket("senderModuleControl(STOP)"); 00109 rifpOut->senderModuleControl(ssrc, rscm); 00110 send(rifpOut, "toRTP"); 00111 } 00112 else if (!opp_strcmp(msgIn->getName(), "leaveSession")) { 00113 ev<< "leaveSession"<<endl; 00114 RTPInterfacePacket *rifpOut = new RTPInterfacePacket("leaveSession()"); 00115 rifpOut->leaveSession(); 00116 send(rifpOut, "toRTP"); 00117 } 00118 } 00119 else { 00120 RTPInterfacePacket *rifpIn = check_and_cast<RTPInterfacePacket *>(msgIn); 00121 00122 if (rifpIn->getType() == RTPInterfacePacket::RTP_IFP_SESSION_ENTERED) { 00123 ev << "Session Entered"<<endl; 00124 ssrc = rifpIn->getSSRC(); 00125 sessionEntered = true; 00126 if (opp_strcmp(_fileName, "")) { 00127 RTPInterfacePacket *rifpOut = new RTPInterfacePacket("createSenderModule()"); 00128 rifpOut->createSenderModule(ssrc, _payloadType, opp_strdup(_fileName)); 00129 ev << "CreateSenderModule"<<endl; 00130 send(rifpOut, "toRTP"); 00131 } 00132 else { 00133 cMessage *msg2 = new cMessage("leaveSession"); 00134 ev << "Receiver Module : leaveSession"<<endl; 00135 scheduleAt(simTime() + _sessionLeaveDelay, msg2); 00136 } 00137 } 00138 else if (rifpIn->getType() == RTPInterfacePacket::RTP_IFP_SENDER_MODULE_CREATED) { 00139 cMessage *msg3 = new cMessage("startTransmission"); 00140 ev << "Sender Module Created"<<endl; 00141 scheduleAt(simTime() + _transmissionStartDelay, msg3); 00142 } 00143 else if (rifpIn->getType() == RTPInterfacePacket::RTP_IFP_SENDER_STATUS) { 00144 RTPSenderStatusMessage *rsim = (RTPSenderStatusMessage *)(rifpIn->decapsulate()); 00145 if (!opp_strcmp(rsim->getStatus(), "PLAYING")) { 00146 ev << "PLAYING"<<endl; 00147 } 00148 else if (!opp_strcmp(rsim->getStatus(), "FINISHED")) { 00149 transmissionFinished = true; 00150 ev << "FINISHED"<<endl; 00151 cMessage *msg5 = new cMessage("leaveSession"); 00152 scheduleAt(simTime() + _sessionLeaveDelay, msg5); 00153 } 00154 else if (!opp_strcmp(rsim->getStatus(), "STOPPED")) { 00155 transmissionFinished = true; 00156 ev << "FINISHED"<<endl; 00157 cMessage *msg6 = new cMessage("leaveSession"); 00158 scheduleAt(simTime() + _sessionLeaveDelay, msg6); 00159 } 00160 else { 00161 delete rifpIn; 00162 } 00163 cancelAndDelete(rsim); 00164 } 00165 else if (rifpIn->getType() == RTPInterfacePacket::RTP_IFP_SESSION_LEFT) { 00166 sessionLeft = true; 00167 } 00168 } 00169 delete msgIn; 00170 00171 } 00172 }
const char* RTPApplication::_commonName [protected] |
The CNAME of this participant.
Referenced by activity().
const char* RTPApplication::_profileName [protected] |
The name of the used profile.
Referenced by activity().
int RTPApplication::_bandwidth [protected] |
The reserved bandwidth for rtp/rtcp in bytes/second.
Referenced by activity().
IPAddress RTPApplication::_destinationAddress [protected] |
The address of the unicast peer or of the multicast group.
Referenced by activity().
int RTPApplication::_port [protected] |
One of the udp port used.
Referenced by activity().
const char* RTPApplication::_fileName [protected] |
The name of the file to be transmitted.
Referenced by activity().
int RTPApplication::_payloadType [protected] |
The payload type of the data in the file.
Referenced by activity().
simtime_t RTPApplication::_sessionEnterDelay [protected] |
The delay after the application enters the session,
Referenced by activity().
simtime_t RTPApplication::_transmissionStartDelay [protected] |
The delay after the application starts the transmission.
Referenced by activity().
simtime_t RTPApplication::_transmissionStopDelay [protected] |
The delay after the application stops the transmission.
Referenced by activity().
simtime_t RTPApplication::_sessionLeaveDelay [protected] |
The delay after the application leaves the session.
Referenced by activity().