INET Framework for OMNeT++/OMNEST
inet::RTPApplication Class Reference

#include <RTPApplication.h>

Inheritance diagram for inet::RTPApplication:
inet::ILifecycle

Public Member Functions

 RTPApplication ()
 
- Public Member Functions inherited from inet::ILifecycle
virtual ~ILifecycle ()
 

Protected Types

enum  SelfMsgKind { ENTER_SESSION, START_TRANSMISSION, STOP_TRANSMISSION, LEAVE_SESSION }
 

Protected Member Functions

virtual void initialize (int stage) override
 
virtual int numInitStages () const override
 
virtual void handleMessage (cMessage *msg) override
 
virtual bool handleOperationStage (LifecycleOperation *operation, int stage, IDoneCallback *doneCallback) override
 Perform one stage of a lifecycle operation. More...
 

Protected Attributes

const char * fileName = nullptr
 
const char * commonName = nullptr
 
const char * profileName = nullptr
 
int bandwidth = 0
 
int port = -1
 
int payloadType = -1
 
simtime_t sessionEnterDelay
 
simtime_t transmissionStartDelay
 
simtime_t transmissionStopDelay
 
simtime_t sessionLeaveDelay
 
IPv4Address destinationAddress
 
uint32 ssrc = 0
 
bool isActiveSession = false
 

Member Enumeration Documentation

Enumerator
ENTER_SESSION 
START_TRANSMISSION 
STOP_TRANSMISSION 
LEAVE_SESSION 
29  {
34  };
Definition: RTPApplication.h:32
Definition: RTPApplication.h:31
Definition: RTPApplication.h:33
Definition: RTPApplication.h:30

Constructor & Destructor Documentation

inet::RTPApplication::RTPApplication ( )
inline
60 {}

Member Function Documentation

void inet::RTPApplication::handleMessage ( cMessage *  msg)
overrideprotectedvirtual
88 {
89  using namespace rtp;
90 
91  if (msgIn->isSelfMessage()) {
92  switch (msgIn->getKind()) {
93  case ENTER_SESSION:
94  EV_INFO << "enterSession" << endl;
95  if (isActiveSession) {
96  EV_WARN << "Session already entered\n";
97  }
98  else {
99  isActiveSession = true;
100  RTPCIEnterSession *ci = new RTPCIEnterSession();
101  ci->setCommonName(commonName);
102  ci->setProfileName(profileName);
103  ci->setBandwidth(bandwidth);
104  ci->setDestinationAddress(destinationAddress);
105  ci->setPort(port);
106  cMessage *msg = new RTPControlMsg("Enter Session");
107  msg->setControlInfo(ci);
108  send(msg, "rtpOut");
109  }
110  break;
111 
112  case START_TRANSMISSION:
113  EV_INFO << "startTransmission" << endl;
114  if (!isActiveSession) {
115  EV_WARN << "Session already left\n";
116  }
117  else {
118  RTPCISenderControl *ci = new RTPCISenderControl();
119  ci->setCommand(RTP_CONTROL_PLAY);
120  ci->setSsrc(ssrc);
121  cMessage *msg = new RTPControlMsg("senderModuleControl(PLAY)");
122  msg->setControlInfo(ci);
123  send(msg, "rtpOut");
124 
125  cMessage *selfMsg = new cMessage("stopTransmission", STOP_TRANSMISSION);
126  scheduleAt(simTime() + transmissionStopDelay, selfMsg);
127  }
128  break;
129 
130  case STOP_TRANSMISSION:
131  EV_INFO << "stopTransmission" << endl;
132  if (!isActiveSession) {
133  EV_WARN << "Session already left\n";
134  }
135  else {
136  RTPCISenderControl *ci = new RTPCISenderControl();
137  ci->setCommand(RTP_CONTROL_STOP);
138  ci->setSsrc(ssrc);
139  cMessage *msg = new RTPControlMsg("senderModuleControl(STOP)");
140  msg->setControlInfo(ci);
141  send(msg, "rtpOut");
142  }
143  break;
144 
145  case LEAVE_SESSION:
146  EV_INFO << "leaveSession" << endl;
147  if (!isActiveSession) {
148  EV_WARN << "Session already left\n";
149  }
150  else {
151  RTPCILeaveSession *ci = new RTPCILeaveSession();
152  cMessage *msg = new RTPControlMsg("Leave Session");
153  msg->setControlInfo(ci);
154  send(msg, "rtpOut");
155  }
156  break;
157 
158  default:
159  throw cRuntimeError("Invalid msgKind value %d in message '%s'",
160  msgIn->getKind(), msgIn->getName());
161  }
162  }
163  else if (isActiveSession) {
164  cObject *obj = msgIn->removeControlInfo();
165  RTPControlInfo *ci = dynamic_cast<RTPControlInfo *>(obj);
166  if (ci) {
167  switch (ci->getType()) {
169  EV_INFO << "Session Entered" << endl;
170  ssrc = (check_and_cast<RTPCISessionEntered *>(ci))->getSsrc();
171  if (opp_strcmp(fileName, "")) {
172  EV_INFO << "CreateSenderModule" << endl;
173  RTPCICreateSenderModule *ci = new RTPCICreateSenderModule();
174  ci->setSsrc(ssrc);
175  ci->setPayloadType(payloadType);
176  ci->setFileName(fileName);
177  cMessage *msg = new RTPControlMsg("createSenderModule()");
178  msg->setControlInfo(ci);
179  send(msg, "rtpOut");
180  }
181  else {
182  cMessage *selfMsg = new cMessage("leaveSession", LEAVE_SESSION);
183  EV_INFO << "Receiver Module : leaveSession" << endl;
184  scheduleAt(simTime() + sessionLeaveDelay, selfMsg);
185  }
186  }
187  break;
188 
190  EV_INFO << "Sender Module Created" << endl;
191  cMessage *selfMsg = new cMessage("startTransmission", START_TRANSMISSION);
192  scheduleAt(simTime() + transmissionStartDelay, selfMsg);
193  }
194  break;
195 
196  case RTP_IFP_SENDER_STATUS: {
197  cMessage *selfMsg;
198  RTPCISenderStatus *rsim = check_and_cast<RTPCISenderStatus *>(ci);
199  switch (rsim->getStatus()) {
201  EV_INFO << "PLAYING" << endl;
202  break;
203 
205  EV_INFO << "FINISHED" << endl;
206  selfMsg = new cMessage("leaveSession", LEAVE_SESSION);
207  scheduleAt(simTime() + sessionLeaveDelay, selfMsg);
208  break;
209 
211  EV_INFO << "STOPPED" << endl;
212  selfMsg = new cMessage("leaveSession", LEAVE_SESSION);
213  scheduleAt(simTime() + sessionLeaveDelay, selfMsg);
214  break;
215 
216  default:
217  throw cRuntimeError("Invalid sender status: %d", rsim->getStatus());
218  }
219  }
220  break;
221 
223  if (!isActiveSession)
224  EV_WARN << "Session already left\n";
225  else
226  isActiveSession = false;
227  break;
228 
230  EV_INFO << "Sender Module Deleted" << endl;
231  break;
232 
233  default:
234  break;
235  }
236  }
237  delete obj;
238  }
239  delete msgIn;
240 }
Definition: RTPInterfacePacket_m.h:72
int bandwidth
Definition: RTPApplication.h:40
const char * fileName
Definition: RTPApplication.h:37
Definition: RTPInterfacePacket_m.h:78
Definition: RTPSenderControlMessage_m.h:72
Definition: RTPApplication.h:32
Definition: RTPSenderStatusMessage_m.h:62
const char * profileName
Definition: RTPApplication.h:39
simtime_t sessionLeaveDelay
Definition: RTPApplication.h:46
simtime_t transmissionStartDelay
Definition: RTPApplication.h:44
Definition: RTPInterfacePacket_m.h:80
Definition: RTPSenderStatusMessage_m.h:61
bool isActiveSession
Definition: RTPApplication.h:51
const char * commonName
Definition: RTPApplication.h:38
Definition: RTPApplication.h:31
int payloadType
Definition: RTPApplication.h:42
simtime_t transmissionStopDelay
Definition: RTPApplication.h:45
Definition: RTPApplication.h:33
Definition: RTPInterfacePacket_m.h:76
Definition: RTPInterfacePacket_m.h:74
Definition: RTPApplication.h:30
Definition: RTPSenderStatusMessage_m.h:60
IPv4Address destinationAddress
Definition: RTPApplication.h:49
Definition: RTPSenderControlMessage_m.h:76
int port
Definition: RTPApplication.h:41
uint32 ssrc
Definition: RTPApplication.h:50
bool inet::RTPApplication::handleOperationStage ( LifecycleOperation operation,
int  stage,
IDoneCallback doneCallback 
)
overrideprotectedvirtual

Perform one stage of a lifecycle operation.

Processing may be done entirely within this method, or may be a longer process that involves nonzero simulation time or several events, and is triggered by this method call.

Return value: true = "done"; false = "not yet done, will invoke doneCallback when done"

Implements inet::ILifecycle.

243 {
244  Enter_Method_Silent();
245 
246  throw cRuntimeError("Unsupported lifecycle operation '%s'", operation->getClassName());
247  return true;
248 }
virtual void inet::RTPApplication::initialize ( int  stage)
overrideprotectedvirtual
virtual int inet::RTPApplication::numInitStages ( ) const
inlineoverrideprotectedvirtual
55 { return NUM_INIT_STAGES; }
The number of initialization stages.
Definition: InitStages.h:116

Member Data Documentation

int inet::RTPApplication::bandwidth = 0
protected

Referenced by handleMessage().

const char* inet::RTPApplication::commonName = nullptr
protected

Referenced by handleMessage().

IPv4Address inet::RTPApplication::destinationAddress
protected

Referenced by handleMessage().

const char* inet::RTPApplication::fileName = nullptr
protected

Referenced by handleMessage().

bool inet::RTPApplication::isActiveSession = false
protected

Referenced by handleMessage().

int inet::RTPApplication::payloadType = -1
protected

Referenced by handleMessage().

int inet::RTPApplication::port = -1
protected

Referenced by handleMessage().

const char* inet::RTPApplication::profileName = nullptr
protected

Referenced by handleMessage().

simtime_t inet::RTPApplication::sessionEnterDelay
protected
simtime_t inet::RTPApplication::sessionLeaveDelay
protected

Referenced by handleMessage().

uint32 inet::RTPApplication::ssrc = 0
protected

Referenced by handleMessage().

simtime_t inet::RTPApplication::transmissionStartDelay
protected

Referenced by handleMessage().

simtime_t inet::RTPApplication::transmissionStopDelay
protected

Referenced by handleMessage().


The documentation for this class was generated from the following files: