|
INET Framework for OMNeT++/OMNEST
|
The class RtpProfile is a module which handles RtpPayloadSender and RtpPayloadReceiver modules.
More...
#include <RtpProfile.h>
|
| typedef std::map< uint32_t, SsrcGate * > | SsrcGateMap |
| | Stores information to which gate rtp data packets from a ssrc must be forwarded. More...
|
| |
The class RtpProfile is a module which handles RtpPayloadSender and RtpPayloadReceiver modules.
It creates them dynamically on demand. This class offers all functionality for the above tasks, subclasses just need to set variables like profile name, rtcp percentage and preferred port in their initialize() method. The dynamically created sender and receiver modules must have have following class names: Rtp<profileName>Payload<payloadType>Sender Rtp<profileName>Payload<payloadType>Receiver
◆ SsrcGateMap
Stores information to which gate rtp data packets from a ssrc must be forwarded.
◆ RtpProfile()
| inet::rtp::RtpProfile::RtpProfile |
( |
| ) |
|
◆ ~RtpProfile()
| inet::rtp::RtpProfile::~RtpProfile |
( |
| ) |
|
|
protectedvirtual |
◆ createSenderModule()
| void inet::rtp::RtpProfile::createSenderModule |
( |
RtpInnerPacket * |
rinp | ) |
|
|
protectedvirtual |
This method is called when the application issued the creation of an rtp payload sender module to transmit data.
It creates a new sender module and connects it. The profile module informs the rtp module of having finished this task. Then it initializes the newly create sender module with a inititalizeSenderModule message.
140 EV_TRACE <<
"createSenderModule Enter" << endl;
141 int ssrc = rinp->getSsrc();
142 int payloadType = rinp->getPayloadType();
144 EV_INFO <<
"ProfileName: " <<
_profileName <<
" payloadType: " << payloadType << endl;
146 std::string moduleTypeName(std::string(
"inet.transportlayer.rtp.Rtp") +
_profileName +
"Payload" + std::to_string(payloadType) +
"Sender");
147 std::string moduleName(std::string(
"rtp") +
_profileName +
"Payload" + std::to_string(payloadType) +
"Sender");
150 if (moduleType ==
nullptr)
151 throw cRuntimeError(
"RtpProfile: payload sender module '%s' not found", moduleTypeName.c_str());
153 RtpPayloadSender *rtpPayloadSender = check_and_cast<RtpPayloadSender *>(moduleType->create(moduleName.c_str(),
this));
154 rtpPayloadSender->finalizeParameters();
156 gate(
"payloadSenderOut")->connectTo(rtpPayloadSender->gate(
"profileIn"));
157 rtpPayloadSender->gate(
"profileOut")->connectTo(gate(
"payloadSenderIn"));
159 rtpPayloadSender->callInitialize();
160 rtpPayloadSender->scheduleStart(simTime());
162 RtpInnerPacket *rinpOut1 =
new RtpInnerPacket(
"senderModuleCreated()");
163 rinpOut1->setSenderModuleCreatedPkt(ssrc);
164 send(rinpOut1,
"rtpOut");
166 RtpInnerPacket *rinpOut2 =
new RtpInnerPacket(
"initializeSenderModule()");
167 rinpOut2->setInitializeSenderModulePkt(ssrc, rinp->getFileName(),
_mtu);
168 send(rinpOut2,
"payloadSenderOut");
171 EV_TRACE <<
"createSenderModule Exit" << endl;
Referenced by handleMessageFromRTP().
◆ dataIn()
Handles incoming data packets: If there isn't a receiver module for this sender it creates one.
The data packet is forwarded to the receiver module after calling processIncomingPacket.
193 EV_TRACE <<
"dataIn(RtpInnerPacket *rinp) Enter" << endl;
196 Packet *packet = check_and_cast<Packet *>(rinp->getEncapsulatedPacket());
197 const auto& rtpHeader = packet->peekAtFront<RtpHeader>();
199 uint32_t ssrc = rtpHeader->getSsrc();
205 std::string payloadReceiverTypeName(std::string(
"inet.transportlayer.rtp.Rtp") +
_profileName +
"Payload" + std::to_string(rtpHeader->getPayloadType()) +
"Receiver");
206 std::string payloadReceiverName(std::string(
"rtp") +
_profileName +
"Payload" + std::to_string(rtpHeader->getPayloadType()) +
"Receiver" + std::to_string(ssrc));
208 if (moduleType ==
nullptr)
209 throw cRuntimeError(
"Receiver module type %s not found", payloadReceiverTypeName.c_str());
211 RtpPayloadReceiver *receiverModule =
212 check_and_cast<RtpPayloadReceiver *>(moduleType->create(payloadReceiverName.c_str(),
this));
214 char outputFileName[100];
215 sprintf(outputFileName,
"id%i.sim", receiverModule->getId());
216 receiverModule->par(
"outputFileName") = outputFileName;
218 receiverModule->finalizeParameters();
220 this->gate(ssrcGate->getGateId())->connectTo(receiverModule->gate(
"profileIn"));
221 receiverModule->gate(
"profileOut")->connectTo(this->gate(ssrcGate->getGateId()
222 - findGate(
"payloadReceiverOut", 0) + findGate(
"payloadReceiverIn", 0)));
224 for (
int i = 0; receiverModule->callInitialize(i); i++)
227 receiverModule->scheduleStart(simTime());
231 send(rinp, ssrcGate->getGateId());
232 EV_TRACE <<
"dataIn(RtpInnerPacket *rinp) Exit" << endl;
Referenced by handleMessageFromRTP().
◆ dataOut()
Handles outgoing data packets: Calls processOutgoingPacket and forwards the packet to the rtp module.
238 send(rinp,
"rtpOut");
Referenced by handleMessageFromPayloadSender().
◆ deleteSenderModule()
| void inet::rtp::RtpProfile::deleteSenderModule |
( |
RtpInnerPacket * |
rinp | ) |
|
|
protectedvirtual |
When a sender module is no longer needed it can be deleted by the profile module.
176 cModule *senderModule = gate(
"payloadSenderOut")->getNextGate()->getOwnerModule();
177 senderModule->deleteModule();
179 RtpInnerPacket *rinpOut =
new RtpInnerPacket(
"senderModuleDeleted()");
180 rinpOut->setSenderModuleDeletedPkt(rinpIn->getSsrc());
183 send(rinpOut,
"rtpOut");
Referenced by handleMessageFromRTP().
◆ findSSRCGate()
Finds the gate of the receiver module for rtp data packets from this ssrc.
266 return (objectIndex ==
_ssrcGates.end()) ? nullptr : objectIndex->second;
Referenced by dataIn().
◆ handleMessage()
| void inet::rtp::RtpProfile::handleMessage |
( |
cMessage * |
msg | ) |
|
|
overrideprotectedvirtual |
Creates and removes payload sender and receiver modules on demand.
47 if (msg->getArrivalGateId() == findGate(
"rtpIn")) {
50 else if (msg->getArrivalGateId() == findGate(
"payloadSenderIn")) {
53 else if (msg->getArrivalGateId() >= findGate(
"payloadReceiverIn")
54 && msg->getArrivalGateId() < findGate(
"payloadReceiverIn") +
_maxReceivers)
59 throw cRuntimeError(
"message coming from unknown gate");
◆ handleMessageFromPayloadReceiver()
| void inet::rtp::RtpProfile::handleMessageFromPayloadReceiver |
( |
cMessage * |
msg | ) |
|
|
protectedvirtual |
Handles messages coming from a receiver module.
Referenced by handleMessage().
◆ handleMessageFromPayloadSender()
| void inet::rtp::RtpProfile::handleMessageFromPayloadSender |
( |
cMessage * |
msg | ) |
|
|
protectedvirtual |
Handles messages coming from the sender module.
100 RtpInnerPacket *rinpIn = check_and_cast<RtpInnerPacket *>(msg);
102 switch (rinpIn->getType()) {
116 throw cRuntimeError(
"Profile received RtpInnerPacket from sender module with wrong type: %d", rinpIn->getType());
Referenced by handleMessage().
◆ handleMessageFromRTP()
| void inet::rtp::RtpProfile::handleMessageFromRTP |
( |
cMessage * |
msg | ) |
|
|
protectedvirtual |
Handles messages received from the rtp module.
65 EV_TRACE <<
"handleMessageFromRTP Enter " << endl;
67 RtpInnerPacket *rinpIn = check_and_cast<RtpInnerPacket *>(msg);
69 switch (rinpIn->getType()) {
91 throw cRuntimeError(
"RtpInnerPacket from RtpModule has wrong type: %d", rinpIn->getType());
95 EV_TRACE <<
"handleMessageFromRTP Exit " << endl;
Referenced by handleMessage().
◆ initialize()
| void inet::rtp::RtpProfile::initialize |
( |
| ) |
|
|
overrideprotectedvirtual |
Initializes variables.
Must be overwritten by subclasses.
Reimplemented in inet::rtp::RtpAvProfile.
27 EV_TRACE <<
"initialize() Enter" << endl;
36 EV_TRACE <<
"initialize() Exit" << endl;
◆ initializeProfile()
| void inet::rtp::RtpProfile::initializeProfile |
( |
RtpInnerPacket * |
rinp | ) |
|
|
protectedvirtual |
Initialization message received from rtp module.
129 EV_TRACE <<
"initializeProfile Enter" << endl;
130 _mtu = rinp->getMtu();
132 RtpInnerPacket *rinpOut =
new RtpInnerPacket(
"profileInitialized()");
134 send(rinpOut,
"rtpOut");
135 EV_TRACE <<
"initializeProfile Exit" << endl;
Referenced by handleMessageFromRTP().
◆ newSSRCGate()
Creates a new association ssrc/gateId for this ssrc.
271 SsrcGate *ssrcGate =
new SsrcGate(ssrc);
272 bool assigned =
false;
273 int receiverGateId = findGate(
"payloadReceiverOut", 0);
274 for (
int i = receiverGateId; i < receiverGateId +
_maxReceivers && !assigned; i++) {
275 if (!gate(i)->isConnected()) {
276 ssrcGate->setGateId(i);
282 throw cRuntimeError(
"Can't manage more senders");
Referenced by dataIn().
◆ processIncomingPacket()
| void inet::rtp::RtpProfile::processIncomingPacket |
( |
RtpInnerPacket * |
rinp | ) |
|
|
protectedvirtual |
Every time a rtp packet is received it it pre-processed by this method to remove profile specific extension which are not handled by the payload receiver module.
In this implementation the packet isn't changed. Important: This method works with RtpInnerPacket. So the rtp packet must be decapsulated, changed and encapsulated again.
Referenced by dataIn().
◆ processOutgoingPacket()
| void inet::rtp::RtpProfile::processOutgoingPacket |
( |
RtpInnerPacket * |
rinp | ) |
|
|
protectedvirtual |
Simular to the procedure for incoming packets, this adds profile specific extensions to outgoing rtp packets.
Referenced by dataOut().
◆ senderModuleControl()
| void inet::rtp::RtpProfile::senderModuleControl |
( |
RtpInnerPacket * |
rinp | ) |
|
|
protectedvirtual |
The profile module forwards sender control messages to the sender module.
188 send(rinp,
"payloadSenderOut");
Referenced by handleMessageFromRTP().
◆ senderModuleInitialized()
| void inet::rtp::RtpProfile::senderModuleInitialized |
( |
RtpInnerPacket * |
rinp | ) |
|
|
protectedvirtual |
The sender module returns a senderModuleInitialized message after being initialized.
The profile module forwards this message to the rtp module which delivers it to its destination, the rtcp module.
243 EV_TRACE <<
"senderModuleInitialized" << endl;
244 send(rinp,
"rtpOut");
Referenced by handleMessageFromPayloadSender().
◆ senderModuleStatus()
| void inet::rtp::RtpProfile::senderModuleStatus |
( |
RtpInnerPacket * |
rinp | ) |
|
|
protectedvirtual |
After having received a sender module control message the sender module returns a sender status message to inform the application what it's doing at the moment.
249 EV_TRACE <<
"senderModuleStatus" << endl;
250 send(rinp,
"rtpOut");
Referenced by handleMessageFromPayloadSender().
◆ _autoOutputFileNames
| bool inet::rtp::RtpProfile::_autoOutputFileNames = false |
|
protected |
If this is set true the RtpProfile automatically sets the output file name for payload receiver modules so the user is not bothered to set them manually during simulation runtime.
Referenced by dataIn(), and initialize().
◆ _maxReceivers
| int inet::rtp::RtpProfile::_maxReceivers = 0 |
|
protected |
The maximum number of incoming data streams this profile module can handle.
It is set to the gate size of "payloadReceiverOut", "payloadReceiverIn".
Referenced by handleMessage(), initialize(), and newSSRCGate().
◆ _mtu
| int inet::rtp::RtpProfile::_mtu = 0 |
|
protected |
◆ _preferredPort
| int inet::rtp::RtpProfile::_preferredPort = -1 |
|
protected |
◆ _profileName
| const char* inet::rtp::RtpProfile::_profileName = nullptr |
|
protected |
◆ _rtcpPercentage
| int inet::rtp::RtpProfile::_rtcpPercentage = 0 |
|
protected |
◆ _ssrcGates
The documentation for this class was generated from the following files:
int _mtu
The maximum size an RtpPacket can have.
Definition: RtpProfile.h:197
virtual void handleMessageFromRTP(cMessage *msg)
Handles messages received from the rtp module.
Definition: RtpProfile.cc:63
virtual void dataIn(RtpInnerPacket *rinp)
Handles incoming data packets: If there isn't a receiver module for this sender it creates one.
Definition: RtpProfile.cc:191
const short PORT_UNDEF
TCP/UDP port numbers.
Definition: Ipv4Address.h:28
int _rtcpPercentage
The percentage of the available bandwidth to be used for rtcp.
Definition: RtpProfile.h:187
const char * _profileName
The name of this profile.
Definition: RtpProfile.h:168
SsrcGateMap _ssrcGates
Definition: RtpProfile.h:182
virtual void initializeProfile(RtpInnerPacket *rinp)
Initialization message received from rtp module.
Definition: RtpProfile.cc:127
@ RTP_INP_DATA_IN
Definition: RtpInnerPacket_m.h:102
std::vector< T >::iterator find(std::vector< T > &v, const Tk &a)
Definition: stlutils.h:44
virtual SsrcGate * findSSRCGate(uint32_t ssrc)
Finds the gate of the receiver module for rtp data packets from this ssrc.
Definition: RtpProfile.cc:263
@ RTP_INP_SENDER_MODULE_CONTROL
Definition: RtpInnerPacket_m.h:97
@ RTP_INP_SENDER_MODULE_INITIALIZED
Definition: RtpInnerPacket_m.h:96
virtual void processOutgoingPacket(RtpInnerPacket *rinp)
Simular to the procedure for incoming packets, this adds profile specific extensions to outgoing rtp ...
Definition: RtpProfile.cc:258
virtual void handleMessageFromPayloadReceiver(cMessage *msg)
Handles messages coming from a receiver module.
Definition: RtpProfile.cc:121
int _maxReceivers
The maximum number of incoming data streams this profile module can handle.
Definition: RtpProfile.h:175
int _preferredPort
The rtp port this profile uses if no port is given.
Definition: RtpProfile.h:192
@ RTP_INP_INITIALIZE_PROFILE
Definition: RtpInnerPacket_m.h:87
@ RTP_INP_DATA_OUT
Definition: RtpInnerPacket_m.h:101
@ RTP_INP_CREATE_SENDER_MODULE
Definition: RtpInnerPacket_m.h:91
virtual SsrcGate * newSSRCGate(uint32_t ssrc)
Creates a new association ssrc/gateId for this ssrc.
Definition: RtpProfile.cc:269
bool _autoOutputFileNames
If this is set true the RtpProfile automatically sets the output file name for payload receiver modul...
Definition: RtpProfile.h:204
virtual void createSenderModule(RtpInnerPacket *rinp)
This method is called when the application issued the creation of an rtp payload sender module to tra...
Definition: RtpProfile.cc:138
virtual void senderModuleInitialized(RtpInnerPacket *rinp)
The sender module returns a senderModuleInitialized message after being initialized.
Definition: RtpProfile.cc:241
virtual void senderModuleStatus(RtpInnerPacket *rinp)
After having received a sender module control message the sender module returns a sender status messa...
Definition: RtpProfile.cc:247
virtual void dataOut(RtpInnerPacket *rinp)
Handles outgoing data packets: Calls processOutgoingPacket and forwards the packet to the rtp module.
Definition: RtpProfile.cc:235
virtual void processIncomingPacket(RtpInnerPacket *rinp)
Every time a rtp packet is received it it pre-processed by this method to remove profile specific ext...
Definition: RtpProfile.cc:253
virtual void deleteSenderModule(RtpInnerPacket *rinp)
When a sender module is no longer needed it can be deleted by the profile module.
Definition: RtpProfile.cc:174
@ RTP_INP_SENDER_MODULE_STATUS
Definition: RtpInnerPacket_m.h:98
@ RTP_INP_DELETE_SENDER_MODULE
Definition: RtpInnerPacket_m.h:93
virtual void handleMessageFromPayloadSender(cMessage *msg)
Handles messages coming from the sender module.
Definition: RtpProfile.cc:98
virtual void senderModuleControl(RtpInnerPacket *rinp)
The profile module forwards sender control messages to the sender module.
Definition: RtpProfile.cc:186