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

This module is used to receive getData(mpeg video) of payload 32 for rtp endsystems working under the rtp av profile. More...

#include <RTPAVProfilePayload32Receiver.h>

Inheritance diagram for inet::rtp::RTPAVProfilePayload32Receiver:
inet::rtp::RTPPayloadReceiver

Protected Member Functions

virtual ~RTPAVProfilePayload32Receiver ()
 Destructor. More...
 
virtual void initialize () override
 Calls the method of the superclass RTPPayloadReceiver and sets the payload type to 32. More...
 
virtual void processPacket (RTPPacket *packet) override
 Writes information about received frames into the output file. More...
 
- Protected Member Functions inherited from inet::rtp::RTPPayloadReceiver
virtual void handleMessage (cMessage *msg) override
 Method for handling incoming packets. 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

cQueue * _queue
 A reordering queue for incoming packets. More...
 
uint32 _lowestAllowedTimeStamp
 Stores the lowest allowed time stamp of rtp data packets. More...
 
uint32 _highestSequenceNumber
 
- Protected Attributes inherited from inet::rtp::RTPPayloadReceiver
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...
 

Additional Inherited Members

- Public Member Functions inherited from inet::rtp::RTPPayloadReceiver
virtual ~RTPPayloadReceiver ()
 Destructor. More...
 
- Static Protected Attributes inherited from inet::rtp::RTPPayloadReceiver
static simsignal_t _rcvdPkRtpTimestampSignal = registerSignal("rcvdPkRtpTimestamp")
 An output signal used to store arrival of rtp data packets. More...
 

Detailed Description

This module is used to receive getData(mpeg video) of payload 32 for rtp endsystems working under the rtp av profile.

It expects data in the format defined in rfc 2250. Its corresponding sender module is RTPAVProfilePayload32Sender. This implementation doesn't work with real mpeg data, so it doesn't write an mpeg file but a sim file, which can be played with a modified mpeg player.

Constructor & Destructor Documentation

inet::rtp::RTPAVProfilePayload32Receiver::~RTPAVProfilePayload32Receiver ( )
protectedvirtual

Destructor.

40 {
41  delete _queue;
42 }
cQueue * _queue
A reordering queue for incoming packets.
Definition: RTPAVProfilePayload32Receiver.h:60

Member Function Documentation

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

Calls the method of the superclass RTPPayloadReceiver and sets the payload type to 32.

Reimplemented from inet::rtp::RTPPayloadReceiver.

45 {
47  _payloadType = 32;
48  _queue = new cQueue("IncomingQueue", &compareRTPPacketsBySequenceNumber);
51 }
uint32 _lowestAllowedTimeStamp
Stores the lowest allowed time stamp of rtp data packets.
Definition: RTPAVProfilePayload32Receiver.h:67
int compareRTPPacketsBySequenceNumber(cObject *packet1, cObject *packet2)
Definition: RTPAVProfilePayload32Receiver.cc:34
cQueue * _queue
A reordering queue for incoming packets.
Definition: RTPAVProfilePayload32Receiver.h:60
uint32 _highestSequenceNumber
Definition: RTPAVProfilePayload32Receiver.h:69
int _payloadType
The payload type this RTPPayloadReceiver module processes.
Definition: RTPPayloadReceiver.h:90
virtual void initialize() override
Initializes the receiver module, opens the output file and creates a queue for incoming packets...
Definition: RTPPayloadReceiver.cc:38
void inet::rtp::RTPAVProfilePayload32Receiver::processPacket ( RTPPacket packet)
overrideprotectedvirtual

Writes information about received frames into the output file.

The only error correction provided is reordering packets of one frame if needed.

Reimplemented from inet::rtp::RTPPayloadReceiver.

54 {
55  // the first packet sets the lowest allowed time stamp
56  if (_lowestAllowedTimeStamp == 0) {
57  _lowestAllowedTimeStamp = rtpPacket->getTimeStamp();
58  _highestSequenceNumber = rtpPacket->getSequenceNumber();
59  if (_outputLogLoss.is_open())
60  _outputLogLoss << "sequenceNumberBase" << rtpPacket->getSequenceNumber() << endl;
61  }
62  else if (_outputLogLoss.is_open()) {
63  for (int i = _highestSequenceNumber + 1; i < rtpPacket->getSequenceNumber(); i++) {
64  //char line[100];
65  //sprintf(line, "%i", i);
66  _outputLogLoss << i << endl;
67  }
68  }
69 
70  if ((rtpPacket->getTimeStamp() < _lowestAllowedTimeStamp) ||
71  (rtpPacket->getSequenceNumber() <= _highestSequenceNumber))
72  {
73  delete rtpPacket;
74  }
75  else {
76  // is this packet from the next frame ?
77  // this can happen when the marked packet has been
78  // lost or arrives late
79  bool nextTimeStamp = rtpPacket->getTimeStamp() > _lowestAllowedTimeStamp;
80 
81  // is this packet marked, which means that it's
82  // the last packet of this frame
83  bool marked = rtpPacket->getMarker();
84 
85  // test if end of frame reached
86 
87  // check if we received the last (= marked)
88  // packet of the frame or
89  // we received a packet of the next frame
90  _highestSequenceNumber = rtpPacket->getSequenceNumber();
91 
92  if (nextTimeStamp || marked) {
93  // a marked packet belongs to this frame
94  if (marked && !nextTimeStamp) {
95  _queue->insert(rtpPacket);
96  }
97 
98  int pictureType = 0;
99  int frameSize = 0;
100 
101  // the queue contains all packets for this frame
102  // we have received
103  while (!_queue->isEmpty()) {
104  RTPPacket *readPacket = (RTPPacket *)(_queue->pop());
105  RTPMpegPacket *mpegPacket = (RTPMpegPacket *)(readPacket->decapsulate());
106  if (pictureType == 0)
107  pictureType = mpegPacket->getPictureType();
108  frameSize = frameSize + mpegPacket->getPayloadLength();
109 
110  delete mpegPacket;
111  delete readPacket;
112  }
113 
114  // we start the next frame
115  // set the allowed time stamp
116  if (nextTimeStamp) {
117  _lowestAllowedTimeStamp = rtpPacket->getTimeStamp();
118  _queue->insert(rtpPacket);
119  }
120 
121  // we have calculated a frame
122  if (frameSize > 0 && _outputFileStream.is_open()) {
123  char line[100];
124  // what picture type is it
125  char picture;
126  switch (pictureType) {
127  case 1:
128  picture = 'I';
129  break;
130 
131  case 2:
132  picture = 'P';
133  break;
134 
135  case 3:
136  picture = 'B';
137  break;
138 
139  case 4:
140  picture = 'D';
141  break;
142 
143  default:
144  picture = ' ';
145  break;
146  }
147 
148  // create sim line
149  sprintf(line, "%f %i %c-Frame", simTime().dbl(), frameSize * 8, picture);
150  // and write it to the file
151  _outputFileStream << line << endl;
152  }
153  }
154  else {
155  // we are not at the end of the frame
156  // so just insert this packet
157  _queue->insert(rtpPacket);
158  }
159  }
160 }
uint32 _lowestAllowedTimeStamp
Stores the lowest allowed time stamp of rtp data packets.
Definition: RTPAVProfilePayload32Receiver.h:67
cQueue * _queue
A reordering queue for incoming packets.
Definition: RTPAVProfilePayload32Receiver.h:60
uint32 _highestSequenceNumber
Definition: RTPAVProfilePayload32Receiver.h:69
std::ofstream _outputLogLoss
The output file stream.
Definition: RTPPayloadReceiver.h:85
std::ofstream _outputFileStream
The output file stream.
Definition: RTPPayloadReceiver.h:80

Member Data Documentation

uint32 inet::rtp::RTPAVProfilePayload32Receiver::_highestSequenceNumber
protected

Referenced by initialize(), and processPacket().

uint32 inet::rtp::RTPAVProfilePayload32Receiver::_lowestAllowedTimeStamp
protected

Stores the lowest allowed time stamp of rtp data packets.

The value is used to throw away packets from mpeg frames already stored in the data file.

Referenced by initialize(), and processPacket().

cQueue* inet::rtp::RTPAVProfilePayload32Receiver::_queue
protected

A reordering queue for incoming packets.

Referenced by initialize(), processPacket(), and ~RTPAVProfilePayload32Receiver().


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