INET Framework for OMNeT++/OMNEST
inet::rtp::RtpPayloadReceiver Class Reference

The class RtpPayloadReceiver acts as a base class for modules processing incoming RTP data packets. More...

#include <RtpPayloadReceiver.h>

Inheritance diagram for inet::rtp::RtpPayloadReceiver:
inet::rtp::RtpAvProfilePayload32Receiver

Public Member Functions

virtual ~RtpPayloadReceiver ()
 Destructor. More...
 

Protected Member Functions

virtual void initialize () override
 Initializes the receiver module, opens the output file and creates a queue for incoming packets. More...
 
virtual void handleMessage (cMessage *msg) override
 Method for handling incoming packets. More...
 
virtual void processRtpPacket (Packet *packet)
 Writes contents of this RtpPacket into the output file. More...
 
virtual void openOutputFile (const char *fileName)
 This method is called by initialize and opens the output file stream. More...
 
virtual void closeOutputFile ()
 Closes the output file stream. More...
 

Protected Attributes

std::ofstream _outputFileStream
 The output file stream. More...
 
std::ofstream _outputLogLoss
 The output file stream. More...
 
int _payloadType
 The payload type this RtpPayloadReceiver module processes. More...
 

Static Protected Attributes

static simsignal_t rcvdPkRtpTimestampSignal = registerSignal("rcvdPkRtpTimestamp")
 An output signal used to store arrival of rtp data packets. More...
 

Detailed Description

The class RtpPayloadReceiver acts as a base class for modules processing incoming RTP data packets.

Constructor & Destructor Documentation

◆ ~RtpPayloadReceiver()

inet::rtp::RtpPayloadReceiver::~RtpPayloadReceiver ( )
virtual

Destructor.

Disposes the queue object and closes the output file.

22 {
24 }

Member Function Documentation

◆ closeOutputFile()

void inet::rtp::RtpPayloadReceiver::closeOutputFile ( )
protectedvirtual

Closes the output file stream.

65 {
66  if (_outputFileStream.is_open())
67  _outputFileStream.close();
68  if (_outputLogLoss.is_open())
69  _outputLogLoss.close();
70 }

Referenced by ~RtpPayloadReceiver().

◆ handleMessage()

void inet::rtp::RtpPayloadReceiver::handleMessage ( cMessage *  msg)
overrideprotectedvirtual

Method for handling incoming packets.

At the moment only RTPInnerPackets containing an encapsulated RtpPacket are handled.

40 {
41  RtpInnerPacket *rinp = check_and_cast<RtpInnerPacket *>(msg);
42  if (rinp->getType() == RTP_INP_DATA_IN) {
43  auto packet = check_and_cast<Packet *>(rinp->decapsulate());
44  processRtpPacket(packet);
45  delete rinp;
46  }
47  else {
48 // delete rinp;
49  throw cRuntimeError("RtpInnerPacket of wrong type received");
50  }
51 }

◆ initialize()

void inet::rtp::RtpPayloadReceiver::initialize ( )
overrideprotectedvirtual

Initializes the receiver module, opens the output file and creates a queue for incoming packets.

Subclasses must overwrite it (but should call this method too)

Reimplemented in inet::rtp::RtpAvProfilePayload32Receiver.

27 {
28  const char *fileName = par("outputFileName");
29  const char *logFileName = par("outputLogFileName");
30  if (strcmp(fileName, ""))
31  openOutputFile(fileName);
32  if (strcmp(logFileName, "")) {
33  char logName[200];
34  sprintf(logName, logFileName, getId());
35  _outputLogLoss.open(logName);
36  }
37 }

Referenced by inet::rtp::RtpAvProfilePayload32Receiver::initialize().

◆ openOutputFile()

void inet::rtp::RtpPayloadReceiver::openOutputFile ( const char *  fileName)
protectedvirtual

This method is called by initialize and opens the output file stream.

For most payload receivers this method works well, only when using a library for a payload type which provides an own open method it must

60 {
61  _outputFileStream.open(fileName);
62 }

Referenced by initialize().

◆ processRtpPacket()

void inet::rtp::RtpPayloadReceiver::processRtpPacket ( Packet packet)
protectedvirtual

Writes contents of this RtpPacket into the output file.

Must be overwritten by subclasses.

Reimplemented in inet::rtp::RtpAvProfilePayload32Receiver.

54 {
55  const auto& rtpHeader = packet->peekAtFront<RtpHeader>();
56  emit(rcvdPkRtpTimestampSignal, (double)(rtpHeader->getTimeStamp()));
57 }

Referenced by handleMessage().

Member Data Documentation

◆ _outputFileStream

std::ofstream inet::rtp::RtpPayloadReceiver::_outputFileStream
protected

◆ _outputLogLoss

std::ofstream inet::rtp::RtpPayloadReceiver::_outputLogLoss
protected

◆ _payloadType

int inet::rtp::RtpPayloadReceiver::_payloadType
protected

The payload type this RtpPayloadReceiver module processes.

Referenced by inet::rtp::RtpAvProfilePayload32Receiver::initialize().

◆ rcvdPkRtpTimestampSignal

simsignal_t inet::rtp::RtpPayloadReceiver::rcvdPkRtpTimestampSignal = registerSignal("rcvdPkRtpTimestamp")
staticprotected

An output signal used to store arrival of rtp data packets.

Referenced by processRtpPacket().


The documentation for this class was generated from the following files:
inet::rtp::RtpPayloadReceiver::rcvdPkRtpTimestampSignal
static simsignal_t rcvdPkRtpTimestampSignal
An output signal used to store arrival of rtp data packets.
Definition: RtpPayloadReceiver.h:84
inet::rtp::RTP_INP_DATA_IN
@ RTP_INP_DATA_IN
Definition: RtpInnerPacket_m.h:102
inet::rtp::RtpPayloadReceiver::_outputFileStream
std::ofstream _outputFileStream
The output file stream.
Definition: RtpPayloadReceiver.h:69
inet::rtp::RtpPayloadReceiver::processRtpPacket
virtual void processRtpPacket(Packet *packet)
Writes contents of this RtpPacket into the output file.
Definition: RtpPayloadReceiver.cc:53
inet::rtp::RtpPayloadReceiver::openOutputFile
virtual void openOutputFile(const char *fileName)
This method is called by initialize and opens the output file stream.
Definition: RtpPayloadReceiver.cc:59
inet::rtp::RtpPayloadReceiver::closeOutputFile
virtual void closeOutputFile()
Closes the output file stream.
Definition: RtpPayloadReceiver.cc:64
inet::rtp::RtpPayloadReceiver::_outputLogLoss
std::ofstream _outputLogLoss
The output file stream.
Definition: RtpPayloadReceiver.h:74