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

#include <RtpApplication.h>

Inheritance diagram for inet::RtpApplication:
inet::LifecycleUnsupported inet::ILifecycle

Public Member Functions

 RtpApplication ()
 
- Public Member Functions inherited from inet::LifecycleUnsupported
virtual bool handleOperationStage (LifecycleOperation *operation, IDoneCallback *doneCallback) override
 Perform one stage of a lifecycle operation. More...
 
- Public Member Functions inherited from inet::ILifecycle
virtual ~ILifecycle ()
 

Protected Member Functions

virtual void initialize (int stage) override
 
virtual int numInitStages () const override
 
virtual void handleMessage (cMessage *msg) override
 

Protected Attributes

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

Constructor & Destructor Documentation

◆ RtpApplication()

inet::RtpApplication::RtpApplication ( )
inline
43 {}

Member Function Documentation

◆ handleMessage()

void inet::RtpApplication::handleMessage ( cMessage *  msg)
overrideprotectedvirtual
81 {
82  using namespace rtp;
83 
84  if (msgIn->isSelfMessage()) {
85  switch (msgIn->getKind()) {
87  EV_INFO << "enterSession" << endl;
88  if (isActiveSession) {
89  EV_WARN << "Session already entered\n";
90  }
91  else {
92  isActiveSession = true;
93  RtpCiEnterSession *ci = new RtpCiEnterSession();
94  ci->setCommonName(commonName);
95  ci->setProfileName(profileName);
96  ci->setBandwidth(bandwidth);
97  ci->setDestinationAddress(destinationAddress);
98  ci->setPort(port);
99  cMessage *msg = new RtpControlMsg("Enter Session");
100  msg->setControlInfo(ci);
101  send(msg, "rtpOut");
102  }
103  break;
104 
106  EV_INFO << "startTransmission" << endl;
107  if (!isActiveSession) {
108  EV_WARN << "Session already left\n";
109  }
110  else {
111  RtpCiSenderControl *ci = new RtpCiSenderControl();
112  ci->setCommand(RTP_CONTROL_PLAY);
113  ci->setSsrc(ssrc);
114  cMessage *msg = new RtpControlMsg("senderModuleControl(PLAY)");
115  msg->setControlInfo(ci);
116  send(msg, "rtpOut");
117 
118  cMessage *selfMsg = new cMessage("stopTransmission", RTPAPP_STOP_TRANSMISSION);
119  scheduleAfter(transmissionStopDelay, selfMsg);
120  }
121  break;
122 
124  EV_INFO << "stopTransmission" << endl;
125  if (!isActiveSession) {
126  EV_WARN << "Session already left\n";
127  }
128  else {
129  RtpCiSenderControl *ci = new RtpCiSenderControl();
130  ci->setCommand(RTP_CONTROL_STOP);
131  ci->setSsrc(ssrc);
132  cMessage *msg = new RtpControlMsg("senderModuleControl(STOP)");
133  msg->setControlInfo(ci);
134  send(msg, "rtpOut");
135  }
136  break;
137 
139  EV_INFO << "leaveSession" << endl;
140  if (!isActiveSession) {
141  EV_WARN << "Session already left\n";
142  }
143  else {
144  RtpCiLeaveSession *ci = new RtpCiLeaveSession();
145  cMessage *msg = new RtpControlMsg("Leave Session");
146  msg->setControlInfo(ci);
147  send(msg, "rtpOut");
148  }
149  break;
150 
151  default:
152  throw cRuntimeError("Invalid msgKind value %d in message '%s'", msgIn->getKind(), msgIn->getName());
153  }
154  }
155  else if (isActiveSession) {
156  cObject *obj = msgIn->removeControlInfo();
157  RtpControlInfo *ci = dynamic_cast<RtpControlInfo *>(obj);
158  if (ci) {
159  switch (ci->getType()) {
161  EV_INFO << "Session Entered" << endl;
162  ssrc = (check_and_cast<RtpCiSessionEntered *>(ci))->getSsrc();
163  if (opp_strcmp(fileName, "")) {
164  EV_INFO << "CreateSenderModule" << endl;
165  RtpCiCreateSenderModule *ci = new RtpCiCreateSenderModule();
166  ci->setSsrc(ssrc);
167  ci->setPayloadType(payloadType);
168  ci->setFileName(fileName);
169  cMessage *msg = new RtpControlMsg("createSenderModule()");
170  msg->setControlInfo(ci);
171  send(msg, "rtpOut");
172  }
173  else {
174  cMessage *selfMsg = new cMessage("leaveSession", RTPAPP_LEAVE_SESSION);
175  EV_INFO << "Receiver Module : leaveSession" << endl;
176  scheduleAfter(sessionLeaveDelay, selfMsg);
177  }
178  }
179  break;
180 
182  EV_INFO << "Sender Module Created" << endl;
183  cMessage *selfMsg = new cMessage("startTransmission", RTPAPP_START_TRANSMISSION);
184  scheduleAfter(transmissionStartDelay, selfMsg);
185  }
186  break;
187 
188  case RTP_IFP_SENDER_STATUS: {
189  cMessage *selfMsg;
190  RtpCiSenderStatus *rsim = check_and_cast<RtpCiSenderStatus *>(ci);
191  switch (rsim->getStatus()) {
193  EV_INFO << "PLAYING" << endl;
194  break;
195 
197  EV_INFO << "FINISHED" << endl;
198  selfMsg = new cMessage("leaveSession", RTPAPP_LEAVE_SESSION);
199  scheduleAfter(sessionLeaveDelay, selfMsg);
200  break;
201 
203  EV_INFO << "STOPPED" << endl;
204  selfMsg = new cMessage("leaveSession", RTPAPP_LEAVE_SESSION);
205  scheduleAfter(sessionLeaveDelay, selfMsg);
206  break;
207 
208  default:
209  throw cRuntimeError("Invalid sender status: %d", rsim->getStatus());
210  }
211  }
212  break;
213 
215  if (!isActiveSession)
216  EV_WARN << "Session already left\n";
217  else
218  isActiveSession = false;
219  break;
220 
222  EV_INFO << "Sender Module Deleted" << endl;
223  break;
224 
225  default:
226  break;
227  }
228  }
229  delete obj;
230  }
231  delete msgIn;
232 }

◆ initialize()

virtual void inet::RtpApplication::initialize ( int  stage)
overrideprotectedvirtual

◆ numInitStages()

virtual int inet::RtpApplication::numInitStages ( ) const
inlineoverrideprotectedvirtual
39 { return NUM_INIT_STAGES; }

Member Data Documentation

◆ bandwidth

double inet::RtpApplication::bandwidth = 0
protected

◆ commonName

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

◆ destinationAddress

Ipv4Address inet::RtpApplication::destinationAddress
protected

◆ fileName

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

◆ isActiveSession

bool inet::RtpApplication::isActiveSession = false
protected

◆ payloadType

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

◆ port

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

◆ profileName

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

◆ sessionEnterDelay

simtime_t inet::RtpApplication::sessionEnterDelay
protected

Referenced by inet::Define_Module().

◆ sessionLeaveDelay

simtime_t inet::RtpApplication::sessionLeaveDelay
protected

◆ ssrc

uint32_t inet::RtpApplication::ssrc = 0
protected

◆ transmissionStartDelay

simtime_t inet::RtpApplication::transmissionStartDelay
protected

◆ transmissionStopDelay

simtime_t inet::RtpApplication::transmissionStopDelay
protected

The documentation for this class was generated from the following files:
inet::RTPAPP_STOP_TRANSMISSION
@ RTPAPP_STOP_TRANSMISSION
Definition: RtpApplication_m.h:56
inet::rtp::RTP_IFP_SESSION_ENTERED
@ RTP_IFP_SESSION_ENTERED
Definition: RtpInterfacePacket_m.h:93
inet::RtpApplication::transmissionStartDelay
simtime_t transmissionStartDelay
Definition: RtpApplication.h:28
inet::rtp::RTP_SENDER_STATUS_FINISHED
@ RTP_SENDER_STATUS_FINISHED
Definition: RtpSenderStatusMessage_m.h:67
inet::RtpApplication::profileName
const char * profileName
Definition: RtpApplication.h:23
inet::rtp::RTP_SENDER_STATUS_PLAYING
@ RTP_SENDER_STATUS_PLAYING
Definition: RtpSenderStatusMessage_m.h:66
inet::RTPAPP_START_TRANSMISSION
@ RTPAPP_START_TRANSMISSION
Definition: RtpApplication_m.h:55
inet::RtpApplication::sessionLeaveDelay
simtime_t sessionLeaveDelay
Definition: RtpApplication.h:30
inet::rtp::RTP_IFP_SENDER_STATUS
@ RTP_IFP_SENDER_STATUS
Definition: RtpInterfacePacket_m.h:99
inet::RtpApplication::transmissionStopDelay
simtime_t transmissionStopDelay
Definition: RtpApplication.h:29
inet::RtpApplication::isActiveSession
bool isActiveSession
Definition: RtpApplication.h:35
inet::RtpApplication::destinationAddress
Ipv4Address destinationAddress
Definition: RtpApplication.h:33
inet::rtp::RTP_CONTROL_PLAY
@ RTP_CONTROL_PLAY
Definition: RtpSenderControlMessage_m.h:78
inet::RtpApplication::payloadType
int payloadType
Definition: RtpApplication.h:26
inet::rtp::RTP_CONTROL_STOP
@ RTP_CONTROL_STOP
Definition: RtpSenderControlMessage_m.h:82
inet::rtp::RTP_IFP_SENDER_MODULE_CREATED
@ RTP_IFP_SENDER_MODULE_CREATED
Definition: RtpInterfacePacket_m.h:95
NUM_INIT_STAGES
#define NUM_INIT_STAGES
Definition: InitStageRegistry.h:73
inet::RtpApplication::ssrc
uint32_t ssrc
Definition: RtpApplication.h:34
inet::RTPAPP_LEAVE_SESSION
@ RTPAPP_LEAVE_SESSION
Definition: RtpApplication_m.h:57
inet::RtpApplication::commonName
const char * commonName
Definition: RtpApplication.h:22
inet::rtp::RTP_IFP_SESSION_LEFT
@ RTP_IFP_SESSION_LEFT
Definition: RtpInterfacePacket_m.h:101
inet::rtp::RTP_SENDER_STATUS_STOPPED
@ RTP_SENDER_STATUS_STOPPED
Definition: RtpSenderStatusMessage_m.h:68
inet::rtp::RTP_IFP_SENDER_MODULE_DELETED
@ RTP_IFP_SENDER_MODULE_DELETED
Definition: RtpInterfacePacket_m.h:97
inet::RtpApplication::bandwidth
double bandwidth
Definition: RtpApplication.h:24
inet::RTPAPP_ENTER_SESSION
@ RTPAPP_ENTER_SESSION
Definition: RtpApplication_m.h:54
inet::RtpApplication::port
int port
Definition: RtpApplication.h:25
inet::RtpApplication::fileName
const char * fileName
Definition: RtpApplication.h:21