|
INET Framework for OMNeT++/OMNEST
|
An Rtp is the center of the Rtp layer of an endsystem.
More...
#include <Rtp.h>
An Rtp is the center of the Rtp layer of an endsystem.
It creates the profile module, sends and receives Rtp data packets and forwards messages. It also communicates with the application.
◆ connectRet()
| void inet::rtp::Rtp::connectRet |
( |
| ) |
|
|
protectedvirtual |
Called when the socket layer has connected a socket.
Referenced by createSocket().
◆ createProfile()
| void inet::rtp::Rtp::createProfile |
( |
const char * |
profileName | ) |
|
|
protectedvirtual |
Creates the profile module.
366 if (moduleType ==
nullptr)
367 throw cRuntimeError(
"Profile type `%s' not found", profileName);
369 RtpProfile *profile = check_and_cast<RtpProfile *>(moduleType->create(
"Profile",
this));
370 profile->finalizeParameters();
372 profile->setGateSize(
"payloadReceiverOut", 30);
373 profile->setGateSize(
"payloadReceiverIn", 30);
375 this->gate(
"profileOut")->connectTo(profile->gate(
"rtpIn"));
376 profile->gate(
"rtpOut")->connectTo(this->gate(
"profileIn"));
378 profile->callInitialize();
379 profile->scheduleStart(simTime());
Referenced by enterSession().
◆ createSenderModule()
203 RtpInnerPacket *rinp =
new RtpInnerPacket(
"createSenderModule()");
204 EV_INFO << rifp->getSsrc() << endl;
205 rinp->setCreateSenderModulePkt(rifp->getSsrc(), rifp->getPayloadType(), rifp->getFileName());
206 send(rinp,
"profileOut");
Referenced by handleMessageFromApp().
◆ createSocket()
| void inet::rtp::Rtp::createSocket |
( |
| ) |
|
|
protectedvirtual |
Requests a server socket from the UDP layer.
385 MulticastGroupList mgl = getModuleFromPar<IInterfaceTable>(par(
"interfaceTableModule"),
this)->collectMulticastGroups();
Referenced by profileInitialized().
◆ dataOut()
Sends a RTP data packet to the UDP layer and a copy of it to the rtcp module.
290 Packet *packet = check_and_cast<Packet *>(rinp->getEncapsulatedPacket()->dup());
296 send(rinp,
"rtcpOut");
Referenced by handleMessageFromProfile().
◆ deleteSenderModule()
213 RtpInnerPacket *rinp =
new RtpInnerPacket(
"deleteSenderModule()");
214 rinp->setDeleteSenderModulePkt(rifp->getSsrc());
215 send(rinp,
"profileOut");
Referenced by handleMessageFromApp().
◆ enterSession()
Creates the profile module and initializes it.
172 const char *profileName = rifp->getProfileName();
177 _port = rifp->getPort();
Referenced by handleMessageFromApp().
◆ handleMessage()
| void inet::rtp::Rtp::handleMessage |
( |
cMessage * |
msg | ) |
|
|
overrideprotectedvirtual |
Handles incoming messages.
57 if (msg->getArrivalGateId() ==
appInGate) {
63 else if (msg->getArrivalGateId() ==
rtcpInGate) {
66 else if (msg->getArrivalGateId() ==
udpInGate) {
70 throw cRuntimeError(
"Message from unknown gate");
◆ handleMessageFromApp()
| void inet::rtp::Rtp::handleMessageFromApp |
( |
cMessage * |
msg | ) |
|
|
protectedvirtual |
Handles messages received from the applicaiton.
79 RtpControlInfo *ci = check_and_cast<RtpControlInfo *>(msg->removeControlInfo());
82 switch (ci->getType()) {
104 throw cRuntimeError(
"Unknown RtpControlInfo type from application");
Referenced by handleMessage().
◆ handleMessageFromProfile()
| void inet::rtp::Rtp::handleMessageFromProfile |
( |
cMessage * |
msg | ) |
|
|
protectedvirtual |
Handles messages received from the profile module.
110 RtpInnerPacket *rinp = check_and_cast<RtpInnerPacket *>(msg);
112 switch (rinp->getType()) {
138 throw cRuntimeError(
"Unknown RtpInnerPacket type %d from profile", rinp->getType());
140 EV_DEBUG <<
"handleMessageFromProfile(cMessage *msg) Exit" << endl;
Referenced by handleMessage().
◆ handleMessageFromRTCP()
| void inet::rtp::Rtp::handleMessageFromRTCP |
( |
cMessage * |
msg | ) |
|
|
protectedvirtual |
Handles messages received from the rtcp module.
145 RtpInnerPacket *rinp = check_and_cast<RtpInnerPacket *>(msg);
147 switch (rinp->getType()) {
157 throw cRuntimeError(
"Unknown RtpInnerPacket type %d from rtcp", rinp->getType());
Referenced by handleMessage().
◆ handleMessagefromUDP()
| void inet::rtp::Rtp::handleMessagefromUDP |
( |
cMessage * |
msg | ) |
|
|
protectedvirtual |
Handles messages received from the UDP layer.
Referenced by handleMessage().
◆ initialize()
| void inet::rtp::Rtp::initialize |
( |
int |
stage | ) |
|
|
overrideprotectedvirtual |
Initializes variables.
35 cSimpleModule::initialize(stage);
48 NodeStatus *nodeStatus = node ? check_and_cast_nullable<NodeStatus *>(node->getSubmodule(
"status")) : nullptr;
49 bool isOperational = (!nodeStatus) || nodeStatus->getState() ==
NodeStatus::UP;
51 throw cRuntimeError(
"This module doesn't support starting in node DOWN state");
◆ initializeProfile()
| void inet::rtp::Rtp::initializeProfile |
( |
| ) |
|
|
protectedvirtual |
Initializes the profile module.
392 RtpInnerPacket *rinp =
new RtpInnerPacket(
"initializeProfile()");
393 rinp->setInitializeProfilePkt(
_mtu);
394 send(rinp,
"profileOut");
Referenced by enterSession().
◆ initializeRTCP()
| void inet::rtp::Rtp::initializeRTCP |
( |
| ) |
|
|
protectedvirtual |
Initializes the rtcp module-.
399 RtpInnerPacket *rinp =
new RtpInnerPacket(
"initializeRTCP()");
400 int rtcpPort =
_port + 1;
402 send(rinp,
"rtcpOut");
Referenced by connectRet().
◆ leaveSession()
Destroys the profile module and orders the rtcp module to send an rtcp bye packet.
192 cModule *profileModule = gate(
"profileOut")->getNextGate()->getOwnerModule();
193 profileModule->deleteModule();
194 RtpInnerPacket *rinp =
new RtpInnerPacket(
"leaveSession()");
195 rinp->setLeaveSessionPkt();
196 send(rinp,
"rtcpOut");
Referenced by handleMessageFromApp().
◆ numInitStages()
| virtual int inet::rtp::Rtp::numInitStages |
( |
| ) |
const |
|
inlineoverrideprotectedvirtual |
◆ profileInitialized()
◆ readRet()
| void inet::rtp::Rtp::readRet |
( |
cMessage * |
sifp | ) |
|
|
protectedvirtual |
Called when data from the socket layer has been received.
332 Packet *pk = check_and_cast<Packet *>(sifp);
333 const auto& rtpHeader = pk->peekAtFront<RtpHeader>();
338 RtpInnerPacket *rinp1 =
new RtpInnerPacket(
"dataIn1()");
340 RtpInnerPacket *rinp2 =
new RtpInnerPacket(*rinp1);
341 send(rinp2,
"rtcpOut");
342 send(rinp1,
"profileOut");
Referenced by handleMessagefromUDP().
◆ resolveMTU()
| int inet::rtp::Rtp::resolveMTU |
( |
| ) |
|
|
protectedvirtual |
Determines the maximum transmission unit that can be uses for RTP.
This implementation assumes that we use an ethernet with 1500 bytes mtu. The returned value is 1500 bytes minus header sizes for ip and udp.
353 IIpv4RoutingTable *rt = getModuleFromPar<IIpv4RoutingTable>(par(
"routingTableModule"),
this);
359 int pmtu = rtie->getMtu();
360 return pmtu - 20 - 8;
Referenced by enterSession().
◆ rtcpInitialized()
Informs the application that the session is entered.
301 RtpCiSessionEntered *ci =
new RtpCiSessionEntered();
302 ci->setSsrc(rinp->getSsrc());
303 cMessage *msg =
new RtpControlMsg(
"sessionEntered()");
304 msg->setControlInfo(ci);
Referenced by handleMessageFromRTCP().
◆ senderModuleControl()
222 RtpInnerPacket *rinp =
new RtpInnerPacket(
"senderModuleControl()");
223 RtpSenderControlMessage *scm =
new RtpSenderControlMessage();
224 scm->setCommand(rifp->getCommand());
225 scm->setCommandParameter1(rifp->getCommandParameter1());
226 scm->setCommandParameter2(rifp->getCommandParameter2());
227 rinp->setSenderModuleControlPkt(rinp->getSsrc(), scm);
228 send(rinp,
"profileOut");
Referenced by handleMessageFromApp().
◆ senderModuleCreated()
249 RtpCiSenderModuleCreated *ci =
new RtpCiSenderModuleCreated();
250 ci->setSsrc(rinp->getSsrc());
251 cMessage *msg =
new RtpControlMsg(
"senderModuleCreated()");
252 msg->setControlInfo(ci);
Referenced by handleMessageFromProfile().
◆ senderModuleDeleted()
260 RtpCiSenderModuleDeleted *ci =
new RtpCiSenderModuleDeleted();
261 ci->setSsrc(rinp->getSsrc());
262 cMessage *msg =
new RtpControlMsg(
"senderModuleDeleted()");
263 msg->setControlInfo(ci);
Referenced by handleMessageFromProfile().
◆ senderModuleInitialized()
◆ senderModuleStatus()
276 RtpSenderStatusMessage *ssm = check_and_cast<RtpSenderStatusMessage *>(rinp->decapsulate());
277 RtpCiSenderStatus *ci =
new RtpCiSenderStatus();
278 ci->setSsrc(rinp->getSsrc());
279 ci->setStatus(ssm->getStatus());
280 ci->setTimeStamp(ssm->getTimeStamp());
281 cMessage *msg =
new RtpControlMsg(
"senderModuleStatus()");
282 msg->setControlInfo(ci);
Referenced by handleMessageFromProfile().
◆ sessionLeft()
Informs the application that this end system has left the RTP session.
312 RtpCiSessionLeft *ci =
new RtpCiSessionLeft();
313 cMessage *msg =
new RtpControlMsg(
"sessionLeft()");
314 msg->setControlInfo(ci);
Referenced by handleMessageFromRTCP().
◆ socketRet()
| void inet::rtp::Rtp::socketRet |
( |
| ) |
|
|
protectedvirtual |
Called when the socket layer returns a socket.
◆ _bandwidth
| int inet::rtp::Rtp::_bandwidth |
|
protected |
◆ _commonName
| std::string inet::rtp::Rtp::_commonName |
|
protected |
◆ _destinationAddress
◆ _leaveSession
| bool inet::rtp::Rtp::_leaveSession |
|
protected |
◆ _mtu
◆ _port
| int inet::rtp::Rtp::_port |
|
protected |
◆ _rtcpPercentage
| int inet::rtp::Rtp::_rtcpPercentage |
|
protected |
◆ _udpSocket
◆ appInGate
| int inet::rtp::Rtp::appInGate |
|
protected |
◆ profileInGate
| int inet::rtp::Rtp::profileInGate |
|
protected |
◆ rtcpInGate
| int inet::rtp::Rtp::rtcpInGate |
|
protected |
◆ udpInGate
| int inet::rtp::Rtp::udpInGate |
|
protected |
The documentation for this class was generated from the following files:
virtual void initializeProfile()
Initializes the profile module.
Definition: Rtp.cc:390
void setOutputGate(cGate *toUdp)
Sets the gate on which to send to UDP.
Definition: UdpSocket.h:117
cModule * findContainingNode(const cModule *from)
Find the node containing the given module.
Definition: ModuleAccess.cc:31
virtual void enterSession(RtpCiEnterSession *rifp)
Creates the profile module and initializes it.
Definition: Rtp.cc:170
@ RTP_IFP_SENDER_CONTROL
Definition: RtpInterfacePacket_m.h:98
@ RTP_INP_SESSION_LEFT
Definition: RtpInnerPacket_m.h:100
void bind(int localPort)
Bind the socket to a local port number.
Definition: UdpSocket.cc:34
void sendTo(Packet *msg, L3Address destAddr, int destPort)
Sends a data packet to the given address and port.
Definition: UdpSocket.cc:69
const short PORT_UNDEF
TCP/UDP port numbers.
Definition: Ipv4Address.h:28
virtual void dataOut(RtpInnerPacket *rinp)
Sends a RTP data packet to the UDP layer and a copy of it to the rtcp module.
Definition: Rtp.cc:288
virtual void handleMessageFromProfile(cMessage *msg)
Handles messages received from the profile module.
Definition: Rtp.cc:108
@ RTP_INP_SENDER_MODULE_DELETED
Definition: RtpInnerPacket_m.h:94
@ RTP_INP_PROFILE_INITIALIZED
Definition: RtpInnerPacket_m.h:88
@ RTP_INP_SENDER_MODULE_CREATED
Definition: RtpInnerPacket_m.h:92
virtual int resolveMTU()
Determines the maximum transmission unit that can be uses for RTP.
Definition: Rtp.cc:348
std::vector< T >::iterator find(std::vector< T > &v, const Tk &a)
Definition: stlutils.h:44
virtual void readRet(cMessage *sifp)
Called when data from the socket layer has been received.
Definition: Rtp.cc:329
int udpInGate
Definition: Rtp.h:191
@ RTP_INP_SENDER_MODULE_INITIALIZED
Definition: RtpInnerPacket_m.h:96
virtual void senderModuleControl(RtpCiSenderControl *rifp)
Definition: Rtp.cc:220
virtual void senderModuleInitialized(RtpInnerPacket *rinp)
Definition: Rtp.cc:269
@ RTP_INP_RTCP_INITIALIZED
Definition: RtpInnerPacket_m.h:90
int appInGate
Definition: Rtp.h:191
@ RTP_INP_DATA_OUT
Definition: RtpInnerPacket_m.h:101
simsignal_t packetReceivedSignal
Definition: Simsignals.cc:97
virtual void initializeRTCP()
Initializes the rtcp module-.
Definition: Rtp.cc:397
virtual void createProfile(const char *profileName)
Creates the profile module.
Definition: Rtp.cc:363
void joinLocalMulticastGroups(MulticastGroupList mgl)
Joins the socket to each multicast group that are registered with any of the interfaces.
Definition: UdpSocket.cc:265
int _mtu
The maximum size of a packet.
Definition: Rtp.h:174
INET_API InitStage INITSTAGE_TRANSPORT_LAYER
Initialization of transport-layer protocols.
std::vector< MulticastGroup > MulticastGroupList
Definition: IInterfaceTable.h:26
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
std::string str(bool printUnspec=true) const
Returns the string representation of the address (e.g.
Definition: Ipv4Address.cc:98
@ RTP_IFP_LEAVE_SESSION
Definition: RtpInterfacePacket_m.h:100
#define NUM_INIT_STAGES
Definition: InitStageRegistry.h:73
@ RTP_IFP_ENTER_SESSION
Definition: RtpInterfacePacket_m.h:92
virtual void senderModuleCreated(RtpInnerPacket *rinp)
Definition: Rtp.cc:247
virtual void leaveSession(RtpCiLeaveSession *rifp)
Destroys the profile module and orders the rtcp module to send an rtcp bye packet.
Definition: Rtp.cc:188
virtual void createSocket()
Requests a server socket from the UDP layer.
Definition: Rtp.cc:382
virtual void senderModuleDeleted(RtpInnerPacket *rinp)
Definition: Rtp.cc:258
virtual void sessionLeft(RtpInnerPacket *rinp)
Informs the application that this end system has left the RTP session.
Definition: Rtp.cc:310
int _rtcpPercentage
The percentage of the bandwidth used for rtcp.
Definition: Rtp.h:179
virtual void handleMessageFromRTCP(cMessage *msg)
Handles messages received from the rtcp module.
Definition: Rtp.cc:143
bool _leaveSession
True when this end system is about to leave the session.
Definition: Rtp.h:189
int rtcpInGate
Definition: Rtp.h:191
int _bandwidth
The available bandwidth for this session.
Definition: Rtp.h:159
@ UP
Definition: NodeStatus.h:28
UdpSocket _udpSocket
The UDP socket.
Definition: Rtp.h:184
virtual void handleMessagefromUDP(cMessage *msg)
Handles messages received from the UDP layer.
Definition: Rtp.cc:161
int _port
The RTP port.
Definition: Rtp.h:169
virtual void profileInitialized(RtpInnerPacket *rinp)
Called when the profile module is initialized.
Definition: Rtp.cc:233
std::string _commonName
The CNAME of this end system.
Definition: Rtp.h:154
@ RTP_IFP_DELETE_SENDER_MODULE
Definition: RtpInterfacePacket_m.h:96
virtual void connectRet()
Called when the socket layer has connected a socket.
Definition: Rtp.cc:324
int profileInGate
Definition: Rtp.h:191
@ RTP_IFP_CREATE_SENDER_MODULE
Definition: RtpInterfacePacket_m.h:94
virtual void handleMessageFromApp(cMessage *msg)
Handles messages received from the applicaiton.
Definition: Rtp.cc:77
@ RTP_INP_SENDER_MODULE_STATUS
Definition: RtpInnerPacket_m.h:98
virtual void rtcpInitialized(RtpInnerPacket *rinp)
Informs the application that the session is entered.
Definition: Rtp.cc:299
virtual void senderModuleStatus(RtpInnerPacket *rinp)
Definition: Rtp.cc:274
virtual void deleteSenderModule(RtpCiDeleteSenderModule *rifp)
Definition: Rtp.cc:211
virtual void createSenderModule(RtpCiCreateSenderModule *rifp)
Definition: Rtp.cc:201
Ipv4Address _destinationAddress
The destination address.
Definition: Rtp.h:164