#include <RTPApplication.h>
Protected Member Functions | |
RTPApplication () | |
virtual void | initialize () |
virtual void | activity () |
Private Attributes | |
const char * | _commonName |
const char * | _profileName |
int | _bandwidth |
IN_Addr | _destinationAddress |
IN_Port | _port |
const char * | _fileName |
int | _payloadType |
simtime_t | _sessionEnterDelay |
simtime_t | _transmissionStartDelay |
simtime_t | _transmissionStopDelay |
simtime_t | _sessionLeaveDelay |
RTPApplication::RTPApplication | ( | ) | [inline, protected] |
void RTPApplication::activity | ( | ) | [protected, virtual] |
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 // create an RTPInterfacePacket to enter the session 00090 RTPInterfacePacket *rifpOut1 = new RTPInterfacePacket("enterSession()"); 00091 rifpOut1->enterSession(opp_strdup(_commonName), opp_strdup(_profileName), _bandwidth, _destinationAddress, _port); 00092 // and send it to the rtp layer 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 }
virtual void RTPApplication::initialize | ( | ) | [protected, virtual] |
Reads the OMNeT++ parameters.
int RTPApplication::_bandwidth [private] |
The reserved bandwidth for rtp/rtcp in bytes/second.
const char* RTPApplication::_commonName [private] |
The CNAME of this participant.
IN_Addr RTPApplication::_destinationAddress [private] |
The address of the unicast peer or of the multicast group.
const char* RTPApplication::_fileName [private] |
The name of the file to be transmitted.
int RTPApplication::_payloadType [private] |
The payload type of the data in the file.
IN_Port RTPApplication::_port [private] |
One of the udp port used.
const char* RTPApplication::_profileName [private] |
The name of the used profile.
simtime_t RTPApplication::_sessionEnterDelay [private] |
The delay after the application enters the session,
simtime_t RTPApplication::_sessionLeaveDelay [private] |
The delay after the application leaves the session.
simtime_t RTPApplication::_transmissionStartDelay [private] |
The delay after the application starts the transmission.
simtime_t RTPApplication::_transmissionStopDelay [private] |
The delay after the application stops the transmission.